GraphQL Yoga v4 documentation (superseded by v5): GraphQL Yoga provides you a cross-platform GraphQL Server. So you can easily integrate it into any platform besides Node.js.
GraphQL Yoga provides you a cross-platform GraphQL Server. So you can easily integrate it into any
platform besides Node.js. Bun is a modern JavaScript runtime like Node or Deno,
and it supports Fetch API as a first class citizen. So the configuration is really simple like any
other JS runtime with Yoga;
Installation
npm i graphql-yoga graphql
yarn add graphql-yoga graphql
pnpm add graphql-yoga graphql
bun add graphql-yoga graphql
Usage
The following code is a simple example of how to use GraphQL Yoga with Bun.
import { createSchema, createYoga } from 'graphql-yoga'const yoga = createYoga({ schema: createSchema({ typeDefs: /* GraphQL */ ` type Query { greetings: String } `, resolvers: { Query: { greetings: () => 'Hello from Yoga in a Bun app!' } } })})const server = Bun.serve(yoga)console.info( `Server is running on ${new URL( yoga.graphqlEndpoint, `http://${server.hostname}:${server.port}` )}`)
This site uses cookies for analytics and improving your experience.