• Docs
  • Usage
  • GraphQL-Yoga

Usage with GraphQL-Yoga

To use graphql-scalars with GraphQL-Yoga, just add the scalars you need to the GraphQL schema, and provide that schema to Yoga. No additional setup is needed.

import { createSchema, createYoga } from 'graphql-yoga'
import { DateTimeResolver, DateTimeTypeDefinition } from "graphql-scalars"
 
export const schema = createSchema({
  typeDefs: /* GraphQL */ `
    ${DateTimeTypeDefinition}
    type Query {
      time: DateTime
    }
  `,
  resolvers: {
    DateTime: DateTimeResolver
  }
})
 
// Create a Yoga instance with a GraphQL schema.
const yoga = createYoga({ schema })

You can find more information about GraphQL-Yoga in the documentation.

Last updated on October 3, 2022