This repository was archived by the owner on May 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 84
Type System
Paweł Gutkowski edited this page Jul 28, 2017
·
4 revisions
Type System is a fundament of GraphQL schema. It is based on Kotlin type system and type definitions provided via DSL.
KGraphQL is able to inspect operations and partially infer schema type system, so schema creator does not have to explicitly declare every type (but it may if needed). Unions, Enums and Scalars require explicit definition in Schema DSL. Inferred classes are interpreted as GraphQL Object or Interface type.
KGraphQL maps found types (implicit and explicit) to GraphQL simple inheritance model, where every type with fields is either Object or Interface. Rules are following:
- if Class in schema is superclass of another Class in schema, it is interpreted as GraphQL Interface type.
- if Class in schema is NOT superclass of any another Class in schema, it is interpreted as GraphQL Object type.
- if Interface in schema is implemented by any Class in schema, it is interpreted as GraphQL Interface type.
- if Interface in schema is NOT implemented by any Class in schema, it is interpreted as GraphQL Object type.
By default, every schema has following built in types:
- String - represents textual data, represented as UTF‐8 character sequences
- Int - represents a signed 32‐bit numeric non‐fractional value
- Long - represents a signed 64‐bit numeric non‐fractional value. Long type is not part of GraphQL specification, but it is built in primitive type in Kotlin language.
- Float - represents signed double‐precision fractional values as specified by IEEE 754. KGraphQL represents Kotlin primitive Double and Float values as GraphQL Float.
- Boolean - represents true or false
Introspection interface aligns to GraphQL specification.