-
Notifications
You must be signed in to change notification settings - Fork 842
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
Subscription execution #495
Subscription execution #495
Conversation
Is the done channel necessary? Can’t you just close the channel or cancel the context? |
Probably not. I should probably revisit the strategy on the iterator here. |
I looked at the other graphql go libraries implementations and i found out a few things:
|
Thanks for the research on this. One of the goals of this project is to follow the official reference implementation. That is the motivation behind some of the existing design choices. I will review these. Using the context to cancel seems straightforward enough and I was originally using the context to cancel but ran into issues that I cant recall so I will revisit that. |
Please see graphql spec https://spec.graphql.org/June2018/#sec-Source-Stream and https://spec.graphql.org/June2018/#sec-Response-Stream. In a subscription the purpose of subscribe is to generate the source stream who's messages are used as the source in the resolve function to generate the response.
probably fine, I'd like to re-work the iterator anyway. |
@remorses I have changed the following
|
I made some changes to your fork, i opened a pull request on your branch here What i changed
I still have to check if it works ok with the handler |
I made an example usage repo with playground: https://github.com/remorses/graphql-go-subscription-example |
This feature looks great indeed. It solves one of the problems with subscription. Do you guys feel comfortable merging this PR? |
I believe so, just waiting for one of the project owners to review and merge. I don't believe there are any breaking changes in any of the code here. Adding a subscribe field is the only modification to object types and the subscription code is all self contained/new code. |
I agree that I would love to see this on master. Has anyone reached out directly to @chris-ramon (seems to be the only active maintainer) to see if he is aware of this PR. At this point, the most helpful thing would be reasons from him why it isn't being merged / reviewed. |
@pckilgore I have reached out and he has seen the PR. |
Any progress here? I have one question to @bhoriuchi If I have defined schema like:
Will it work?
I have troubles with last two examples. |
I found an issue with field selections returning nil. Working on a fix. Please do not merge yet. TY |
Never mind. This is working as designed. see apollographql/graphql-subscriptions#51 . The event message needs to be nested in the subscription field name for it to resolve correctly. Merging can proceed here is an example of a subscribe resolver using a theoretical event emitter that publishes events func SubscribeFoo(p graphql.ResolveParams) (interface{}, error) {
topic := "foo"
c := make(chan interface{})
off := DefaultEmitter.On(topic, func(msg ...interface{}) {
data := map[string]interface{}{
p.Info.FieldName: msg[0],
}
c <- data
})
go func() {
for {
select {
case <-p.Context.Done():
off()
close(c)
return
}
}
}()
return c, nil
} |
Any updates? I constantly see re-sync with master, but I dont see it ever actually merging with master. This has been going on like from 2019 :P What is going on? :D |
@chris-ramon Is there anything still blocking this PR from merging? I see it has been kept alive but it's unclear what the status is at this time. |
For those of you following this thread, if you want to use this feature and don't mind using the replace feature in go mod, this is how i have been using it
|
@chris-ramon Will this get merged? What is the status here? |
Happy belated 2 year anniversary PR! |
still waiting for the glorious day when this will be merged :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 🚢 — Thanks a lot for the great work & feedback everybody! All kudos to: @bhoriuchi & @remorses.
Confirmed this graphql.Subscribe
implementation follows the implementation from graphql-js
and works as expected.
Also just for reference, I've put together a small working example integrating this graphql.Subscribe
implementation and GraphQL Playground: https://github.com/graphql-go/subscription-example
Thanks for getting this in @chris-ramon can we possibly get a version (v0.7.10) tag applied? |
@bhoriuchi great call! — Just created v0.8.0, released as minor version since we're adding a new end-user API: |
Maybe someone needs this ping example |
Adds subscription execution support and a Subscribe resolver to Field and FieldDefinition types
Resolves #242