This configuration, express with graphql yoga should work right out of the box. When trying to access the graphiql playground on route '/graphql' internal server error is thrown without any logs inside the console. The same configuration works when running with node.
import express, { Request, Response, Router } from "express";
import { createYoga } from 'graphql-yoga'
import cors from 'cors';
import { makeExecutableSchema } from "@graphql-tools/schema";
const port = process.env.PORT || 4000;
class Application {
private host: express.Application;
constructor() {
this.host = express();
this.setup();
}
private setup() {
this.host.use(cors());
this.host.get("/hi", (req: Request, res: Response) => { res.send("Hello World!") })
this.host.use(this.buildYoga());
this.host.use((error: Error, req: express.Request, res: express.Response, next: express.NextFunction): void => {
console.error('π Something went wrong', error);
res.status(400).send(error);
});
}
private buildYoga(): Router {
const yoga = createYoga({
schema: makeExecutableSchema({
typeDefs: "
type Query {
greetings: String
}
",
resolvers: {
Query: {
greetings: () => 'Hello from Yoga in a Bun app!'
}
}
}),
graphiql: true,
})
return express.Router().use("/graphql", yoga);
}
public start() {
this.host.listen(port, () => {
console.log(`π Started listening on port:${port}`);
});
}
}
const application = new Application();
try {
application.start();
} catch (e) {
console.error(e);
}
What version of Bun is running?
1.0.6+969da088f5db3258a803ec186012e30f992829b4
What platform is your computer?
Darwin 22.6.0 arm64 arm
What steps can reproduce the bug?
This configuration, express with graphql yoga should work right out of the box. When trying to access the graphiql playground on route '/graphql' internal server error is thrown without any logs inside the console. The same configuration works when running with node.
What is the expected behavior?
We should enter the playground without an error.
What do you see instead?
Internal server error (500) is thrown.
Additional information
No response