Overview of advanced GraphQL concepts
Out of the box, GraphQL comes with a set of scalar types:
Int
: A signed 32-bit integerFloat
: A signed double-precision floating-point valueString
: A UTF-8 encoded character sequenceBoolean
: Can be true or falseID
: A unique identifier, serialized as aString
, but meant to signify that it is not human readable
GraphQL also allows the definition of enums, which are a special kind of scalar. They are restricted to certain values. For example, we could have the following enum to distinguish different types of posts:
enum PostType { UNPUBLISHED, UNLISTED, PUBLIC }
In Apollo, enums will be handled as strings that can only have certain values, but this may be different in other GraphQL implementations.
Many GraphQL implementations also allow defining custom scalar types. Apollo, for example, supports the definition of custom scalar types.
Fragments
When the same kind of...