-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Clients are receiving a subscription response even with context.skip #3189
Comments
Removing the method doesn't work either. This still results in the same issue: field :notification, Types::NotificationType, "Sent a notification", null: true, subscription_scope: :current_user
# def notification
# context.skip
# end |
Thanks for those details. I misunderstood what you meant by empty response. I think Were you previously using
I'm not sure I want to change the empty response from If it turns out it's a compatibility issue from switching to result = MySchema.execute(...)
if result.query.subscription? && !result.query.subscription_update?
# don't transmit anything, the client expects no response
else
transmit(result)
end Does that help at all? |
Thanks for the reply! We were not previously using the interpreter. The only change we made to result in this was upgrading to 1.11.5 from 1.9.10, and then adding the two lines for the AST and the new Interpreter: + use GraphQL::Execution::Interpreter
+ use GraphQL::Analysis::AST If I can make the argument, I think that returning an empty object for For example, If I remember correctly from the spec, For example, your graphql-ruby/javascript_client/src/subscriptions/ActionCableLink.ts Lines 44 to 47 in af617b9
That code could be the part of our issue here, since we're using While we could hack it, I think this is actually a design issue from #2536. |
We have faced the same issue with the initial response is being returned as |
Agree. I also thought Take our case, for example, we are following the client setup Apollo 2 – ActionCable and the current behavior will be like below: const Example = () => {
const { loading, error, data } = useSubscription(THE_NUMBER)
console.log(JSON.stringify(loading, error, data))
// { loading: true, data: null } // 1st render, UI shows 'Loading...' 👍
// { loading: false, data: {} } // 2nd render, UI shows nothing 😳
// { loading: false, data: { theNumber: 42 } // 3rd render, UI shows 42 👍
return loading ? <div>Loading...</div> : <pre{data.theNumber}</pre>;
} I'm guessing this is a real-world example for the above-mentioned problem of
|
I believe the underlying issue, "when skip/NO_UPDATE is used don't send any message over ActionCable" is fixed by #3713. If I have it right, the skip behavior that |
Describe the bug
Client callbacks for subscriptions are being called for non-returning subscription methods, even when
context.skip
is used.Versions
graphql
version: 1.11.5rails
: 6.0.3.2graphql-batch
: 0.4.3graphql-fragment_cache
: 1.0.3actioncable
: 5.2.4-4GraphQL schema
Include relevant types and fields (in Ruby is best, in GraphQL IDL is ok).
Are you using interpreter? Any custom instrumentation, etc?
GraphQL query
The ActionCable websocket request:
The query from
data
(no variables):The ActionCable websocket response
Steps to reproduce
Not sure other than the provided code.
Expected behavior
The
context.skip
should prevent the client from receiving and acting on a message.Actual behavior
The client is receiving the message and running code that it should not be running. For example, the
notification
subscription tries to run the code for when a notification subscription is received, but no data arrives:Console output,
data
is empty here. Previously, this would not be called when the subscription was first active.Additional context
This seems to be the same issue as #3180, but the fix there didn't work. I believe it's related to the breaking change in #2536.
The text was updated successfully, but these errors were encountered: