diff --git a/bun.lockb b/bun.lockb index 4841c93..4b88a23 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index e7b9a73..fc0578e 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,8 @@ }, "dependencies": { "@tailwindcss/typography": "^0.5.15", + "graphql": "^16.9.0", + "graphql-yoga": "^5.10.4", "storybook-dark-mode": "^4.0.2" } } diff --git a/src/routes/api/graphql/+server.ts b/src/routes/api/graphql/+server.ts new file mode 100644 index 0000000..6722a21 --- /dev/null +++ b/src/routes/api/graphql/+server.ts @@ -0,0 +1,24 @@ +import { createSchema, createYoga } from 'graphql-yoga'; +import type { RequestEvent } from '@sveltejs/kit'; + +const yogaApp = createYoga({ + 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 }; \ No newline at end of file