🧘 Rewrite of a fully-featured GraphQL Server with focus on easy setup, performance & great developer experience. The core of Yoga implements WHATWG Fetch API and can run/deploy on any JS environment.
Most likely it's an issue with Bun. It happens when integrating GraphQL Yoga with Express and using express.json() middleware. Also the bug occurs when integrating Yoga with Fastify
import { createYoga } from 'graphql-yoga'
import express from 'express';
import { createSchema } from 'graphql-yoga'
export const schema = createSchema({
typeDefs: `
type Query {
hello: String
}
`,
resolvers: {
Query: {
hello: () => 'world'
}
}
})
const app = express()
// The Request.url getter can only be used on instances of Request
app.use(express.json({ limit: '1mb' }));
const yoga = createYoga({ schema })
app.use(yoga.graphqlEndpoint, yoga)
app.listen(4000, () => {
console.log('Running a GraphQL API server at http://localhost:4000/graphql')
})
Call stack:
Unexpected response: "TypeError: The Request.url getter can only be used on instances of Request
at get (:1:11)
at onRequest (node_modules/graphql-yoga/esm/plugins/use-health-check.js:4:17)
at iterate (node_modules/@whatwg-node/server/esm/utils.js:380:25)
at handleRequest (node_modules/@whatwg-node/server/esm/createServerAdapter.js:51:46)
at requestListener (node_modules/@whatwg-node/server/esm/createServerAdapter.js:127:25)
at <anonymous> (native)
at handle (node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (node_modules/express/lib/router/index.js:328:13)
at <anonymous> (node_modules/express/lib/router/index.js:286:9)
at next (node_modules/express/lib/router/index.js:280:10)
at <anonymous> (node_modules/body-parser/lib/read.js:137:5)
at runInAsyncScope (node:async_hooks:159:18)
at invokeCallback (node_modules/raw-body/index.js:238:16)
at done (node_modules/raw-body/index.js:227:7)
at onEnd (node_modules/raw-body/index.js:287:7)
at emit (node:events:183:48)
at endReadableNT (node:stream:2392:27)
at processTicksAndRejections (:7:39)
Describe the bug
Most likely it's an issue with Bun. It happens when integrating GraphQL Yoga with Express and using express.json() middleware. Also the bug occurs when integrating Yoga with Fastify
Your Example Website or App
https://codesandbox.io/p/devbox/bun-yoga-crckwv
Steps to Reproduce the Bug or Issue
Call stack:
Expected behavior
No error occurs
Screenshots or Videos
No response
Platform
@graphql-yoga/*
version(s): 5.7.0Additional context
No response