GraphQL Yoga 3 with Cloudflare Workers

Build and deploy GraphQL Yoga to the Edge with Cloudflare Workers.

import { createYoga, createSchema } from "graphql-yoga";

export interface Env {}

const yoga = createYoga<Env & ExecutionContext>({
  schema: createSchema({
    typeDefs: /* GraphQL */ `
      type Query {
        hello: String!
      }
    `,
    resolvers: {
      Query: {
        hello: () => "Cloudflare Workers!",
      },
    },
  }),
  landingPage: false,
  graphqlEndpoint: "/",
});

export default {
  fetch: yoga.fetch,
};
Jamie Barton

Published on 9 Jan 2023 by Jamie Barton