-
-
Save paulruescher/2c632dd1417152b29f46d7f526c16a34 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
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