The type system

GraphQL is a strongly-typed language, and a GraphQL schema should have types for all objects that it uses. This includes properties on objects, arguments, and variables. The type system allows a GraphQL server to determine whether a query is valid at runtime.

Scalars and object types

The GraphQLFieldConfig object defines a field's type property to be GraphQLOutputType. An output type in GraphQL can be one of the following three things:

  • A custom type, like the EmployeeType which we defined in a previous example.
  • A GraphQLScalarType, which represents a scalar value that cannot have fields of its own. This could be one of the following:
    • GraphQLInt to represent an integer value
    • GraphQLFloat to represent a float value
    • GraphQLSting to represent ...

Get Learning GraphQL and Relay now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.