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
Perhaps I am holding it wrong, but I was caught by surprise by the documentation mentioning that queries parsed with gql from graphql-tagcan be passed to useQuery, while this seems to work a bit different for useSubscription.
While the API reference states a DocumentNode can be passed as well, I received that exact DocumentNode within the subscriptionForwarder by setting it up as described by the guide. It looks like that will result in an error for graphql-ws's client as it takes a string and no normalization is performed, unlike useQuery.
Is this intended behavior or would it be possible to apply the normalization to query for useSubscription as well and/or expose the normalizeQuery function so it can be easily used within the subscriptionForwarder as well?
I'd gladly open a pull request, if so.
Thanks!
The text was updated successfully, but these errors were encountered:
This is indeed a bug. I think it could be fixed inside handleSubscription.ts
something like this:
constnormalizedQuery=normalizeQuery(operation.query);if(!normalizedQuery){thrownewError('A query must be provided.');}useResult(forward({ ...operation,query: normalizedQuery})asany,true);
Feel free to PR, otherwise, I will PR it tomorrow since it looks like a serious bug for non apollo-server users and breaks compact with other protocol libs.
EDIT: Really wanted you to have a go at this but I think this is a bug that needs to be fixed ASAP, many thanks for pointing it out and love the way you explained it. Thanks again!
Hey, great library!
Perhaps I am holding it wrong, but I was caught by surprise by the documentation mentioning that queries parsed with
gql
fromgraphql-tag
can be passed touseQuery
, while this seems to work a bit different foruseSubscription
.While the API reference states a
DocumentNode
can be passed as well, I received that exactDocumentNode
within thesubscriptionForwarder
by setting it up as described by the guide. It looks like that will result in an error forgraphql-ws
's client as it takes astring
and no normalization is performed, unlikeuseQuery
.Is this intended behavior or would it be possible to apply the normalization to
query
foruseSubscription
as well and/or expose thenormalizeQuery
function so it can be easily used within thesubscriptionForwarder
as well?I'd gladly open a pull request, if so.
Thanks!
The text was updated successfully, but these errors were encountered: