This commit is contained in:
Benjamin Palko 2024-12-10 09:49:59 -05:00
parent 05faa76d7d
commit b10cb37549
3 changed files with 26 additions and 0 deletions

View file

@ -0,0 +1,24 @@
import { createSchema, createYoga } from 'graphql-yoga';
import type { RequestEvent } from '@sveltejs/kit';
const yogaApp = createYoga<RequestEvent>({
schema: createSchema({
typeDefs: `
type Query {
hello: String
}
`,
resolvers: {
Query: {
hello: () => 'SvelteKit - GraphQL Yoga'
}
}
}),
// Needed to be defined explicitly because our endpoint lives at a different path other than `/graphql`
graphqlEndpoint: '/api/graphql',
// Needed to let Yoga use sveltekit's Response object
fetchAPI: { Response }
});
export { yogaApp as GET, yogaApp as POST };