GraphQL
support below scalar data types.
Type
|
Description
|
Int
|
Represent
a signed 32‐bit
integer.
|
Float
|
Represent
a signed double-precision floating-point value.
|
String
|
Represent
a UTF‐8
character sequence.
|
Boolean
|
Represent
true or false
|
ID
|
Represent
a unique identifier. It is used to refetch an object or as the key for a
cache. The ID type is serialized in the same way as a String; however,
defining it as an ID signifies that it is not intended to be human‐readable.
|
You can
even define custom type using ‘type’ keyword.
type Address { id: Int city: String state: String country: String }
You can
refer custom types in other types definition.
type Query { employees: [Employee] } type Employee { id: Int firstName: String lastName: String email: String permanentAddress: Address temporaryAddress: Address department: Department } type Address { id: Int city: String state: String country: String } type Department{ id: Int departmentName: String }
For
example, Employee type refer Address and Department types.
Support
of enum types
GraphQL
also support enums. Enums are special kind of scalar that is restricted to a
particular set of allowed values.
enum day { MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY SUNDAY }
No comments:
Post a Comment