Documentation
Integrations and Guides
GraphQL-Yoga

GraphQL-Yoga

Installation

Terminal
yarn add @graphql-hive/client

We recommend installing Hive Client package as a direct dependency of your project, because it includes a runtime to send usage reports and schemas to Hive registry.

The @graphql-hive/client package exports an Envelop plugin (opens in a new tab), that can be used directly with GraphQL-Yoga (opens in a new tab).

Publishing Schemas

You can report schemas to Hive registry by using the reporting section of the configuration:

import { createServer } from 'node:http'
import { createYoga } from 'graphql-yoga'
import { useHive } from '@graphql-hive/client'
import { schema } from './schema'
 
const yoga = createYoga({
  schema,
  plugins: [
    useHive({
      enabled: true, // Enable/Disable Hive Client
      debug: true, // Debugging mode
      token: 'YOUR-TOKEN',
      // Schema reporting
      reporting: {
        // feel free to set dummy values here
        author: 'Author of the schema version',
        commit: 'git sha or any identifier'
      }
    })
  ]
})
 
const server = createServer(yoga)
 
server.listen(4000, () => {
  console.info('Server is running on http://localhost:4000/graphql')
})

Usage Reporting

You can send usage reporting to Hive registry by using the usage section of the configuration:

import { createServer } from 'node:http'
import { createYoga } from 'graphql-yoga'
import { schema } from './schema'
 
const yoga = createYoga({
  schema,
  plugins: [
    useHive({
      enabled: true, // Enable/Disable Hive Client
      token: 'YOUR-TOKEN',
      reporting: {
        // feel free to set dummy values here, or real runtime values if you have them
        author: 'Author of the schema version',
        commit: 'git sha or any identifier'
      },
      // Collects and send usage reporting based on executed operations
      usage: true
    })
  ]
})
 
const server = createServer(yoga)
 
server.listen(4000, () => {
  console.info('Server is running on http://localhost:4000/graphql')
})

Additional Resources