Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel
panelIconId9f7d7d2d-b063-45cf-874b-3bd8f5df69a8
panelIcon:graphql-emoji:
panelIconText:graphql-emoji:
bgColor#F4F5F7

The Fraud Data API is developed using GraphQL technology. GraphQL is a new API standard that provides a more efficient, powerful and flexible alternative to REST (Representational State Transfer)*.

Introduction

What is GraphQL?

GraphQL is a data query language for APIs that can be used with any language and framework. It can be used anywhere a client communicates with an API and makes API communications more efficient. GraphQL was developed to meet the need for more flexibility and efficiency in client/server communications. 

...

  1. Popular way for client’s to retrieve data using HTTP

  2. Introduced ideas like stateless server and structured resource access

  3. Has a strict specification for how servers will make data available, but in practice has been widely interpreted/implemented

GraphQL Schema

...

...

The

...

The schema is one of the most important concepts when working with a GraphQL API. It specifies the capabilities of the API , the shape of the available data, and the specific queries and mutation functions that can be used to read, write and make web requests from a GraphQL server. GraphQL enables users to specify exactly what data they get back in their response—nothing more, and nothing less, and it allows querying for multiple fields in a single request.

GraphQL Schema

The GraphQL schema specifies the API’s capabilities and defines how clients can fetch and update data.  

  • Often seen as a contract between the server and the client

  • In general, a schema is simply a collection of GraphQL types

  • Each schema will have some root types that define the entry points for the API: the

    • Query

    , the Mutation, and the Subscription types
    • Mutation

    • Subscription.

GraphQL is organized in terms of schema and type system versus Rest API endpoints.

(blue star) GraphQL has its own type system that’s used to define the schema of an API. The syntax for writing schemas is called Schema Definition Language (SDL).

Examples of how we would have to define these types in the schema to enable the examples above.

Query Types in the GraphQL Schema

To enable the allPersons query...

...

We need to add a corresponding field to the query type. 

...

title: String!

author: Person!

GraphQL SDL

Simple types example below: Person and Post. 

...