add pothos
This commit is contained in:
parent
7954843448
commit
e06dc1ec94
4 changed files with 19 additions and 16 deletions
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
|
@ -48,6 +48,7 @@
|
||||||
"vitest": "^2.0.4"
|
"vitest": "^2.0.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@pothos/core": "^4.3.0",
|
||||||
"@tailwindcss/typography": "^0.5.15",
|
"@tailwindcss/typography": "^0.5.15",
|
||||||
"graphql": "^16.9.0",
|
"graphql": "^16.9.0",
|
||||||
"graphql-yoga": "^5.10.4",
|
"graphql-yoga": "^5.10.4",
|
||||||
|
|
|
||||||
14
src/lib/pothos/index.ts
Normal file
14
src/lib/pothos/index.ts
Normal 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();
|
||||||
|
|
@ -1,22 +1,10 @@
|
||||||
|
import { Schema } from '$lib/pothos';
|
||||||
import type { RequestEvent } from '@sveltejs/kit';
|
import type { RequestEvent } from '@sveltejs/kit';
|
||||||
import { createSchema, createYoga } from 'graphql-yoga';
|
import { createYoga } from 'graphql-yoga';
|
||||||
|
|
||||||
export const Yoga = createYoga<RequestEvent>({
|
export const Yoga = createYoga<RequestEvent>({
|
||||||
schema: createSchema({
|
schema: Schema,
|
||||||
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',
|
graphqlEndpoint: '/api/graphql',
|
||||||
|
// Let Yoga use sveltekit's Response object
|
||||||
// Needed to let Yoga use sveltekit's Response object
|
|
||||||
fetchAPI: { Response }
|
fetchAPI: { Response }
|
||||||
});
|
});
|
||||||
Loading…
Add table
Reference in a new issue