Apollo-Server
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 a
Apollo-Server plugin (opens in a new tab), that can be used
directly.
Publishing Schemas
Import the hiveApollo
plugin and add it to ApolloServer
instance:
import { ApolloServer } from 'apollo-server'
import { hiveApollo } from '@graphql-hive/client'
const server = new ApolloServer({
typeDefs,
resolvers,
plugins: [
hiveApollo({
enabled: true,
debug: true, // or false
token: 'YOUR-TOKEN',
reporting: {
// feel free to set dummy values here
author: 'Author of the latest change',
commit: 'git sha or any identifier',
// Federation and Stitching
serviceUrl: '...',
serviceName: '...'
}
})
]
})
Usage Reporting
You can send usage reporting to Hive registry by using the usage
section of the configuration:
import { ApolloServer } from 'apollo-server'
import { hiveApollo } from '@graphql-hive/client'
const server = new ApolloServer({
typeDefs,
resolvers,
plugins: [
hiveApollo({
enabled: true,
token: 'YOUR-TOKEN',
reporting: { ... },
usage: true, // add this one
})
]
})