Types
At the heart of any GraphQL implementation is a description of what types of objects it can return, described in a GraphQL type system and returned in the GraphQL Schema.
The Alambic type system extends the GraphQL initial format by adding information about data validation and relations between objects.
Internal Object Types
Alambic provides 5 internal types that can be used to compose your own custom type definition:
- String
- Int
- Float
- Boolean
- ID
Custom Object Types
Every object field that compose your custom Type must belongs to one of internal or custom types:
{
"Product": {
"fields": {
"productId": {
"type": "ID",
...
},
"Name": {
"type": "String",
...
},
"Price": {
"type": "Float",
...
},
"Weight": {
"type": "Int",
...
},
"InStock": {
"type": "Boolean",
...
},
"Stores": {
"type": "Store",
...
}
}
}
}
Fields
Fields are part of Object Types definitions.
They are described by the following options:
Property | Type | Required | Description |
---|---|---|---|
name | String | No | Name of the field. If not set GraphQL will use the key of fields array |
type | Type | Yes | Must be an Internal Type or an existing foreign object Type |
description | String | No | Field description for clients |
required | Boolean | No | Is this field required? default to false |
multivalued | Boolean | No | Is this field multivalued? default to false |
args | Array | No | The args array is usually used to describe the fields that can be retrieved from a foreign object Type |
relation | Key:Value | No | Describes the relation between the current and the foreign object Type. Key = foreign key name; Value = local key Name. |