'use strict' const Fastify = require('fastify') const mercurius = require('mercurius') const { makeExecutableSchema } = require('@graphql-tools/schema') const app = Fastify() const typeDefs = ` type Query { add(x: Int, y: Int): Int } ` const resolvers = { Query: { add: async (_, { x, y }) => x + y } } app.register(mercurius, { schema: makeExecutableSchema({ typeDefs, resolvers }) }) app.get('/', async function (req, reply) { const query = '{ add(x: 2, y: 2) }' return reply.graphql(query) }) app.listen({ port: 3000 })