Skip to content

Instantly share code, notes, and snippets.

@paulruescher
Created February 8, 2023 06:33
Show Gist options
  • Save paulruescher/2c632dd1417152b29f46d7f526c16a34 to your computer and use it in GitHub Desktop.
Save paulruescher/2c632dd1417152b29f46d7f526c16a34 to your computer and use it in GitHub Desktop.
import Fastify from "fastify";
import mercurius from "mercurius";
const app = Fastify();
const schema = `
type Query {
add(x: Int, y: Int): Int
}
`;
const resolvers = {
Query: {
add: async (_, { x, y }) => x + y,
},
};
app.register(mercurius, {
schema,
resolvers,
});
app.get("/", async function (req, reply) {
const query = "{ add(x: 2, y: 2) }";
return reply.graphql(query);
});
app.listen({ port: 3000 });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment