You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{createSchema,createYoga}from"graphql-yoga";constyoga=createYoga({schema: createSchema<{}>({typeDefs: /* GraphQL */` type Query { greetings: String } `,resolvers: {Query: {greetings: ()=>"Hello from Yoga in a Bun app!",},},}),});constserver=Bun.serve(yoga);console.info(`Server is running on ${newURL(yoga.graphqlEndpoint,`http://${server.hostname}:${server.port}`)}`);
However, I'm encountering this type error when performing typescript type checking:
index.ts:18:26 - error TS2345: Argument of type 'YogaServerInstance<{}, {}>' is not assignable to parameter of type 'Serve<unknown>'.
Type 'YogaServerInstance<{}, {}>' is not assignable to type 'UnixTLSWebSocketServeOptions<unknown>'.
18 const server = Bun.serve(yoga);
~~~~
Found 1 error in index.ts:18
It seems the types has changed on 1.0.0 release.
A workaround is to give an option object to Bun.serve instead of the yoga instance directly. This also allows you to give other options like development or tls if this is something you need.
Describe the bug
I'm following the instruction to create a minimum GraphQL server locally https://the-guild.dev/graphql/yoga-server/docs/integrations/integration-with-bun
It runs successfully and I can see graphiql UI at http://localhost:3000/graphql
However, I'm encountering this type error when performing typescript type checking:
Your Example Website or App
https://the-guild.dev/graphql/yoga-server/docs/integrations/integration-with-bun
Steps to Reproduce the Bug or Issue
bun init
bun add graphql-yoga graphql typescript
index.ts
bun run index.ts
should work just finetsc
will show the error.Expected behavior
I expect there is no TS errors.
Screenshots or Videos
No response
Platform
Additional context
Thanks!
The text was updated successfully, but these errors were encountered: