Usage
Usage — GraphQL Scalars documentation.
graphql-scalars provides generic scalar definition for JavaScript/TypeScript, that means you can
use it with any GraphQL server implementation.
To use your scalars, start by importing the scalar the you wish to use, and add it to your GraphQL schema.
Each scalar provides a separate implementation (based on GraphQLScalar class of graphql-js), so
you can use it with both schema-first and code-first approaches.
Schema-first approach
Start by adding the scalar to your GraphQL SDL:
Note that you can also import ready-to-use type definitions for scalars like below:
Then, you can import the specific scalar’s resolver:
And add it to your resolver map:
Code-first
With most code-first implementation, you can just import the scalar directly and add it to your schema as type.