Created
December 31, 2020 12:49
-
-
Save mr-pascal/71b3240ee1d6115a7dee1a1773f9c278 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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