-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subscriptions with elysia graphql yoga don't work #12
Comments
???? |
you can do this instead as a workaround (don't forget to import { Elysia } from "elysia";
import { yoga } from "@elysiajs/graphql-yoga";
import { createSchema } from "graphql-yoga";
const schema = createSchema({
typeDefs: `
type Query {
hello: String
}
type Subscription {
countdown(from: Int!): Int!
}
`,
resolvers: {
Query: {
hello: () => "yay",
},
Subscription: {
countdown: {
subscribe: async function* (_, { from }) {
for (let i = from; i >= 0; i--) {
await Bun.sleep(1000);
yield { countdown: i };
}
},
},
},
},
});
new Elysia()
.use(
yoga({
// @ts-ignore
schema,
})
)
.listen(5000); http://localhost:5000/graphql?query=subscription+%7B%0A++countdown%28from%3A+5%29%0A%7D |
@bogeychan that not working
|
@kamalkech works for me, use latest versions: ├── @elysiajs/[email protected]
├── [email protected]
├── [email protected] curl -N -H "accept:text/event-stream" http://localhost:5000/graphql?query=subscription%20%7B%0A%20%20countdown%28from%3A%205%29%0A%7D |
yoga({
// @ts-ignore
schema,
graphiql: {
// Use WebSockets in GraphiQL
subscriptionsProtocol: "WS",
},
}) |
nvm, |
@bogeychan how use sse with yoga on elysiajs server instead of yoga server |
Even SSE doesn't work, I tried to use it with EventSource, as mentioned in the example here: But no events are sent. All the examples use a elysia-graphql-yoga/src/index.ts Line 195 in a4fe2d5
|
@snigdha920 any piste ? |
I needed subscriptions in my project and in the end had to make a different server for graphql yoga because graphql-ws subscriptions wouldn't work with Elysia.
The main issues are:
Because of all these limitations, I had to literally create a separate server and then handle metrics collection, logs collection, etc. for that server again.
I think this is something important, and shouldn't be too hard to add? I'm going to attempt a PR for this @SaltyAom I will try to make the websocket handlers work first, then expose the /graphql/stream url and make it work
Related to: #11
The text was updated successfully, but these errors were encountered: