31
loading...
This website collects cookies to deliver better user experience
type Tracking {
origin: String!
destination: String
weight_lbs: Int
}
String
and Int
are two of GraphQL's built-in scalar types. We'll talk about what that means and how you can add your own scalars to your GraphQL schemas.A GraphQL object type has a name and fields, but at some point those fields have to resolve to some concrete data. That's where the scalar types come in: they represent the leaves of the query.
Breed
query tree are its leaves. That is, they are nodes with vertex degree 1. Vertex degrees are the number of edges (in this illustration, the arrows) connected to a vertex. These leaves will resolve to a scalar type, which can be one of GraphQL's built in scalar types or a custom type defined in the schema.DateTime
, you can create your own scalar type-- or, just use one of StepZen's if it fits your needs.Date
, DateTime
& JSON
scalar types so you can use them without having to implement your own (goodbye, extensive resolver logic!).DateTime
scalar in a StepZen GraphQL API is as simple as adding it to your schema:type Tracking {
origin: String!
destination: String
weight_lbs: Int
dateDelivered: DateTime
}
query MyQuery {
deliveryByOrigin(origin: "London") {
destination
origin
weight_lbs
dateDelivered
}
dateDelivered
:"data": {
"deliveryByOrigin": {
"destination": "Cairo",
"origin": "London",
"weight_lbs": 12,
"dateDelivered": "02-10-2020"
}