About the GraphQL API

About GraphQL

The GraphQL data query language is:

  • A specification. The spec determines the validity of the schema on the API server. The schema determines the validity of client calls.

  • Strongly typed. The schema defines an API's type system and all object relationships.

  • Introspective. A client can query the schema for details about the schema.

  • Hierarchical. The shape of a GraphQL call mirrors the shape of the JSON data it returns. Nested fields let you query for and receive only the data you specify in a single round trip.

  • An application layer. GraphQL is not a storage model or a database query language. The graph refers to graph structures defined in the schema, where nodes define objects and edges define relationships between objects. The API traverses and returns application data based on the schema definitions, independent of how the data is stored.

Queries

In this section

About queries

Every GraphQL schema has a root type for both queries and mutations. The query type defines GraphQL operations that retrieve data from the server.

sums

Type: [SumType]


Mutations

In this section

About mutations

Every GraphQL schema has a root type for both queries and mutations. The mutation type defines GraphQL operations that change data on the server. It is analogous to performing HTTP verbs such as POST, PATCH, and DELETE.

createSum

Type: CreateSum

Create a sum mutation.

Arguments

Name Description

values (SumInput!)

Return fields

Name Description

sum (SumType)


Arguments

Name Description

token (String)

Return fields

Name Description

payload (GenericScalar!)

refreshExpiresIn (Int!)

token (String!)


tokenAuth

Type: ObtainJSONWebToken

Obtain JSON Web Token mutation

Arguments

Name Description

username (String!)

password (String!)

Return fields

Name Description

payload (GenericScalar!)

refreshExpiresIn (Int!)

token (String!)


Arguments

Name Description

token (String)

Return fields

Name Description

payload (GenericScalar!)


Objects

In this section

About objects

Objects in GraphQL represent the resources you can access. An object can contain a list of fields, which are specifically typed.

CreateSum

Create a sum mutation.

Fields

Name Description

sum (SumType)


ObtainJSONWebToken

Obtain JSON Web Token mutation

Fields

Name Description

payload (GenericScalar!)

refreshExpiresIn (Int!)

token (String!)


Fields

Name Description

payload (GenericScalar!)

refreshExpiresIn (Int!)

token (String!)


SumType

Is all the fields of the sum model.

Fields

Name Description

id (ID!)

firstNumber (Int!)

first number

secondNumber (Int!)

second number

result (Int!)

result of sum


Fields

Name Description

payload (GenericScalar!)


Input objects

In this section

About input objects

Input objects can be described as "composable objects" because they include a set of input fields that define the object.

SumInput

Input object for the sum service.

Input fields

Name Description

firstNumber (Int!)

First number to sum.

secondNumber (Int!)

Second number to sum.


Scalars

In this section

About scalars

Scalars are primitive values: Int, Float, String, Boolean, or ID.

When calling the GraphQL API, you must specify nested subfields until you return only scalars.

Boolean

The Boolean scalar type represents true or false.


GenericScalar

The GenericScalar scalar type represents a generic GraphQL scalar value that could be: String, Boolean, Int, Float, List or Object.


ID

The ID scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as "4") or integer (such as 4) input value will be accepted as an ID.


Int

The Int scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.


String

The String scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.