Graphql-tools: delegateToSchema should return the full result with the extensions field for subscriptions

Created on 14 Jan 2019  Â·  2Comments  Â·  Source: ardatan/graphql-tools

When returning a response to a subscription document, only the transformed data from the remote schema is returned.

https://github.com/apollographql/graphql-tools/blob/dacfd83566b6d8a9bee61ee1b5cda373b2b531a7/src/stitching/delegateToSchema.ts#L132-L134

This is a problem when the remote schema populates the websocket connection and channel subscription information in the extensions field of the response. I ran into this when attempting to merge a remote AWS AppSync schema into my Apollo Server lambda implementation. The way AWS AppSync implements subscriptions is via their IoT MQTT services. That is, when a request for a subscription comes in, as part of the response, it includes all the information _(such as the wss url, credentials, and channel metadata) in the extensions field in the response. AWS then provides a [SubscriptionHandshakeLink]( https://github.com/awslabs/aws-mobile-appsync-sdk-js/blob/master/packages/aws-appsync/src/link/subscription-handshake-link.ts) in their AppSync SDK that uses this information to extablish the websocket connection.

Without the extensions field being passed back up in the response, the client never receives the connection information.

Most helpful comment

This issue affects not only subscriptions, but also things like errors

https://github.com/graphql-binding/graphql-binding/issues/173

extensions field is missing when executing GraphQL operations like in https://github.com/graphql-binding/graphql-binding package which also uses delegateToSchema. As a result some sensitive information like Apollo error codes and other parameters stored in extensions are not retrieved when the operation is executed.

All 2 comments

This issue affects not only subscriptions, but also things like errors

https://github.com/graphql-binding/graphql-binding/issues/173

extensions field is missing when executing GraphQL operations like in https://github.com/graphql-binding/graphql-binding package which also uses delegateToSchema. As a result some sensitive information like Apollo error codes and other parameters stored in extensions are not retrieved when the operation is executed.

See implementation in #969 using a link.

Was this page helpful?
0 / 5 - 0 ratings