add pothos

This commit is contained in:
Benjamin Palko 2024-12-10 10:06:44 -05:00
parent 7954843448
commit e06dc1ec94
4 changed files with 19 additions and 16 deletions

BIN
bun.lockb

Binary file not shown.

View file

@ -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",

14
src/lib/pothos/index.ts Normal file
View file

@ -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();

View file

@ -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<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`
schema: Schema,
graphqlEndpoint: '/api/graphql',
// Needed to let Yoga use sveltekit's Response object
// Let Yoga use sveltekit's Response object
fetchAPI: { Response }
});