StepZen's Custom Scalars

The additional scalar types built into StepZen's system.

According to GraphQL.org, scalar types represent the leaves of a GraphQL query. They allow the query fields to resolve to concrete data.

There's a list of scalar types built in to GraphQL:

  • Int: A signed 32‐bit integer.
  • Float: A signed double-precision floating-point value.
  • String: A UTF‐8 character sequence.
  • Boolean: true or false.
  • ID: The ID scalar type represents a unique identifier, often 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.

StepZen provides the following custom scalar types: Date, DateTime & JSON.

Date scalar type

The Date scalar type represents a date. Date is serialized as an RFC 3339 section 5.6 full-date quoted string.

DateTime scalar type

The DateTime scalar type represents a date and time. DateTime is serialized as an RFC 3339 quoted string.

It differs from Date in that its format is full-date "T" full-time

JSON scalar type

The JSON scalar type represents an arbitrary JSON value. That means it can be a simple value, array, or object.

Secret scalar type

Secret is used as an argument type representing a secret such as an API key or token. Any value is always serialized as ******** in any GraphQL response to avoid any leakage of secrets. Values are Strings.

Using StepZen's custom scalar types

You can implement these types just as you would GraphQL's built-in types, inside your type definition like so:

type Tracking {
  origin: String!
  weight_lbs: Int
  dateDelivered: DateTime
  dateReceived: Date
  finalAddress: JSON
}

Now the fields dateDelivered, dateReceived, and finalAddress, which use StepZen's DateTime, Date, and JSON types, are available for you to use in your queries.

This site uses cookies: By using this website, you consent to our use of cookies in accordance with our Website Terms of Use and Cookie Policy.