An Apollo GraphQL Server integration for SvelteKit 🥳.
Note: Major and minor releases are equivalent to apollo-server-core.
In a new project, install the apollo-server-svelte-kit
and graphql
dependencies using:
npm install apollo-server-svelte-kit graphql
or
yarn add apollo-server-svelte-kit graphql
Then create an SvelteKit Endpoint (e.g. src/routes/graphql/+server.js
) and add the following content:
import { getDefaultHandler, gql } from 'apollo-server-svelte-kit';
const handler = getDefaultHandler(
gql`
type Query {
ping: String!
}
`,
{
Query: {
ping: () => 'pong'
}
}
);
export const GET = handler;
export const HEAD = handler;
export const POST = handler;
For more details take a look at the Apollo Documentation.