-
Notifications
You must be signed in to change notification settings - Fork 583
Open
Description
Describe the bug
Using the provided, basic example of using graphql-yoga with Bun + graphiql to create a "countdown" subscription, the data data doesnt return until the subscription has ended (as opposed to a streaming countdown you just get the final result)
Your Example Website or App
Please see attached code (couldn't find an online playground for bun)
Steps to Reproduce the Bug or Issue
- Go to http://0.0.0.0:3000/graphql?query=subscription+%7B%0A++countdown%28from%3A+3%29%0A%7D
- Click the "Execute Query" button
- Wait for result
Expected behavior
Expected to see streaming results, but I'm only seeing results upon completion.
Screenshots or Videos
No response
Platform
- OS: macOS
- Bun: 0.5.8
@graphql-yoga/*version(s): 3.7.0
Additional context
import { createYoga, createSchema } from 'graphql-yoga';
const yoga = createYoga({
schema: createSchema({
typeDefs: /* GraphQL */ `
type Query {
greetings: String
}
type Subscription {
countdown(from: Int!): Int!
}
`,
resolvers: {
Query: {
greetings: () => 'Hello from Yoga in a Bun app!',
},
Subscription: {
countdown: {
// This will return the value on every 1 sec until it reaches 0
subscribe: async function* (_, { from }) {
for (let i = from; i >= 0; i--) {
await new Promise((resolve) => setTimeout(resolve, 1000));
yield { countdown: i };
}
},
},
},
},
}),
});
const server = Bun.serve(yoga);
console.info(
`Server is running on ${new URL(
yoga.graphqlEndpoint,
`http://${server.hostname}:${server.port}`
)}`
);Metadata
Metadata
Assignees
Labels
No labels