diff --git a/bun.lockb b/bun.lockb index 4b88a23..8939e69 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index fc0578e..73944a9 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "vitest": "^2.0.4" }, "dependencies": { + "@pothos/core": "^4.3.0", "@tailwindcss/typography": "^0.5.15", "graphql": "^16.9.0", "graphql-yoga": "^5.10.4", diff --git a/src/lib/pothos/index.ts b/src/lib/pothos/index.ts new file mode 100644 index 0000000..f1fa65a --- /dev/null +++ b/src/lib/pothos/index.ts @@ -0,0 +1,14 @@ +import SchemaBuilder from '@pothos/core'; + +export const builder = new SchemaBuilder({}); + +builder.queryType({ + fields: (t) => ({ + version: t.string({ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + resolve: (parent, args, context) => '1.0.0-alpha' + }) + }) +}); + +export const Schema = builder.toSchema(); \ No newline at end of file diff --git a/src/lib/yoga/index.ts b/src/lib/yoga/index.ts index 65e9322..835252e 100644 --- a/src/lib/yoga/index.ts +++ b/src/lib/yoga/index.ts @@ -1,22 +1,10 @@ +import { Schema } from '$lib/pothos'; import type { RequestEvent } from '@sveltejs/kit'; -import { createSchema, createYoga } from 'graphql-yoga'; +import { createYoga } from 'graphql-yoga'; export const Yoga = 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` + schema: Schema, graphqlEndpoint: '/api/graphql', - - // Needed to let Yoga use sveltekit's Response object + // Let Yoga use sveltekit's Response object fetchAPI: { Response } }); \ No newline at end of file