A plugin for Fastify that adds GraphQL and GraphiQL support.
This project was forked from fastify-apollo as it is no longer being maintained fast enough to keep pace with the rapid changes happening in the GraphQL ecosystem.
npm install --save fastify-graphql graphql
or
yarn add fastify-graphql graphql
const Fastify = require('fastify');
const app = Fastify();
const {graphiqlFastify, graphqlFastify} = require('fastify-graphql');
app.register(graphqlFastify, {
prefix: '/graphql',
graphql: {
schema: your_graphql_schema,
},
});
app.register(graphiqlFastify, {
prefix: '/graphiql',
graphiql: {
endpointURL: '/graphql',
}
});
Both plugins need to be given a prefix, under which they will mount.
GraphQL settings extends GraphQLServerOptions
GraphiQL settings extends GraphiQLData