GraphQL: Type System Cheat Sheet

Scalar Type

The default Scalar types:

  • Int − Signed 32-bit Integer
  • Float − Signed double-precision floating-point value
  • String − UTF – 8-character sequence
  • Boolean − True or false
  • ID − A unique identifier, often used as a unique identifier to fetch an object or as the key for a cache.

The syntax for defining a Scalar type:

field: data_type

Object Type

The syntax for defining an Object type

type object_type_name
{
   field1: data_type
   field2:data_type 
   ....
   fieldn:data_type
}

Query Type

The syntax for defining a Query Type

type Query {
   field1: data_type
   field2:data_type
   field2(param1:data_type,param2:data_type,...paramN:data_type):data_type
}

Mutation Type

The syntax for defining a Mutation type

type Mutation {
   field1: data_type
   field2(param1:data_type,param2:data_type,...paramN:data_type):data_type 
}

Enum Type

The syntax for defining an Enum type

type enum_name{
   value1
   value2
}

Leave a Reply

Your email address will not be published. Required fields are marked *