add yoga
This commit is contained in:
parent
05faa76d7d
commit
b10cb37549
3 changed files with 26 additions and 0 deletions
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
|
@ -49,6 +49,8 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tailwindcss/typography": "^0.5.15",
|
"@tailwindcss/typography": "^0.5.15",
|
||||||
|
"graphql": "^16.9.0",
|
||||||
|
"graphql-yoga": "^5.10.4",
|
||||||
"storybook-dark-mode": "^4.0.2"
|
"storybook-dark-mode": "^4.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
24
src/routes/api/graphql/+server.ts
Normal file
24
src/routes/api/graphql/+server.ts
Normal 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 };
|
||||||
Loading…
Add table
Reference in a new issue