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
Based on the subscription field name “newComments” and a mapping from subscription names to channels, the server subscribes to one or more pub/sub channels. When something is published to one of these channels, the server runs the GraphQL query specified in the subscription and sends a full new result to the client.
My API surface idea for this is:
Add a net.Context argument to the resolve parameters. Use a context for each request. Similar to how go-grpc does it.
When a streaming call starts, create a context, and call the resolver functions. If a resolver function needs to return a stream of objects, instead of an array, it can return a chan interface{} channel.
The call continues to execute and finishes when one of (Context ended/closed, Result channel closed) occurs.
It's a little tough to work around the current pattern of Execute -> return result. I think the best way to handle this is to change the Execute function OR add another function that returns an object instead of a map[string]interface{}, and also accepts a root Context. In this object we can define how the result is shown. If it's a single map[string]interface{} result, set the result field of that object. Otherwise, set the resultChan fields on that object.
The text was updated successfully, but these errors were encountered:
@paralin we're ourselves looking to add subscriptions in the near future. We'll keep this issue open, and post updates when we get around to it. @atrniv would be better placed to discuss the technical details of the design.
I'm using the library now in my code and quite like how robust it is.
Can we add subscriptions? They are supported in the GraphQL spec and Apollo client.
https://dev-blog.apollodata.com/graphql-subscriptions-in-apollo-client-9a2457f015fb#.lkud9zs7b
From the article:
My API surface idea for this is:
net.Context
argument to the resolve parameters. Use a context for each request. Similar to howgo-grpc
does it.chan interface{}
channel.It's a little tough to work around the current pattern of
Execute
-> return result. I think the best way to handle this is to change theExecute
function OR add another function that returns an object instead of amap[string]interface{}
, and also accepts a rootContext
. In this object we can define how the result is shown. If it's a singlemap[string]interface{}
result, set theresult
field of that object. Otherwise, set theresultChan
fields on that object.The text was updated successfully, but these errors were encountered: