Skip to content

An integration to use Cloudflare Workers as a hosting service with Apollo Server

Notifications You must be signed in to change notification settings

dnalborczyk/apollo-server-integrations-cloudflare-workers

Repository files navigation

NPM version NPM downloads

Apollo Server Integration for Cloudflare Workers

Installation

npm install apollo-server-integrations-cloudflare-workers

Usage

import { ApolloServer } from '@apollo/server'
import { startServerAndCreateCloudflareWorkersHandler } from 'apollo-server-integrations-cloudflare-workers'

interface Context {
  // ....
}

interface Environment {
  // ...
}

const resolvers = {
  Query: {
    hello: () => 'world',
  },
}

const typeDefs = `
  type Query {
    hello: String
  }
`

const apolloServer = new ApolloServer<Context>({
  resolvers,
  typeDefs,
})

export default {
  fetch: startServerAndCreateCloudflareWorkersHandler<Environment, Context>(
    apolloServer,
    {
      async context() {
        return {
          // ...
        }
      },
      path: '/graphql',
    },
  ),
}

Example projects

Apollo Server v4

https://github.com/dnalborczyk/apollo-server-cloudflare-workers

Apollo Federation v2 with Apollo Server v4, Apollo Gateway v2, Apollo Subgraph v2

https://github.com/dnalborczyk/apollo-federation-cloudflare-workers

About

An integration to use Cloudflare Workers as a hosting service with Apollo Server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published