move to lib
This commit is contained in:
parent
b10cb37549
commit
7954843448
2 changed files with 24 additions and 23 deletions
22
src/lib/yoga/index.ts
Normal file
22
src/lib/yoga/index.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import type { RequestEvent } from '@sveltejs/kit';
|
||||
import { createSchema, 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`
|
||||
graphqlEndpoint: '/api/graphql',
|
||||
|
||||
// Needed to let Yoga use sveltekit's Response object
|
||||
fetchAPI: { Response }
|
||||
});
|
||||
|
|
@ -1,24 +1,3 @@
|
|||
import { createSchema, createYoga } from 'graphql-yoga';
|
||||
import type { RequestEvent } from '@sveltejs/kit';
|
||||
import { Yoga } from '$lib/yoga';
|
||||
|
||||
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 };
|
||||
export { Yoga as GET, Yoga as POST };
|
||||
Loading…
Add table
Reference in a new issue