Skip to content

Instantly share code, notes, and snippets.

@mr-pascal
Created December 31, 2020 12:49
Show Gist options
  • Save mr-pascal/71b3240ee1d6115a7dee1a1773f9c278 to your computer and use it in GitHub Desktop.
Save mr-pascal/71b3240ee1d6115a7dee1a1773f9c278 to your computer and use it in GitHub Desktop.
// src/index.ts
import fastify, {FastifyInstance} from 'fastify';
import {Server, IncomingMessage, ServerResponse} from 'http';
/**
* Create instance of our Fastify server
*/
export const app: FastifyInstance<Server, IncomingMessage, ServerResponse> = fastify({logger: false});
// ---------------------------------------------------
import mercurius from 'mercurius';
import {makeExecutableSchema} from '@graphql-tools/schema';
import {mergeTypeDefs, mergeResolvers} from '@graphql-tools/merge';
/**
* Add 'mercurius' to our fastify server
*/
app.register(mercurius, {
schema: makeExecutableSchema({
// Merge type definitions from different sources
typeDefs: mergeTypeDefs([typeDefs, typeDefs2]),
// Merge resolvers from different sources
resolvers: mergeResolvers([resolvers, resolvers2]),
}),
// Enable the GraphQL Playground
graphiql: 'playground',
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment