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
I'm currently working with an architecture that uses custom schema stitching and subscription notification mechanisms, and I'm hoping to get some guidance on a couple of challenges we're facing.
Current Setup:
We have a federated service that hosts the supergraph. When a client requests a subscription, the federated service forwards the request to our backend service (running as a Lambda), which handles storing the subscription-related data. The federated service manages the WebSocket connection, so after the subscription is stored, we need to return a successful terminated response to the federated service.
To address this, we've been using an HttpResponseInterceptor to prevent the default behavior of subscriptions returning server-sent events over HTTP. The interceptor does the following:
When we perform a mutation and need to send a notification to the federated service, we’re facing an issue in retrieving the GraphQL-formatted response. We can access the Result object from middleware, but it doesn't seem to expose the actual formatted response payload that the federated service is expecting, eg:
Our current solution involves using the ToJson() method on the IExecutionResult/IOperationResult and sending the notification from within in the interceptor, but this feels a bit hacky and doesn’t seem to align with the intended use of the library.
Question:
Is there a more 'proper' or cleaner way to achieve this? Specifically, we’re looking for a way to access the actual formatted GraphQL response in a more integrated manner, perhaps through middleware or another approach, that avoids the need for the workaround we’re currently using.
I’d appreciate any insights or recommendations on how to approach this problem within the spirit of the library.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I'm currently working with an architecture that uses custom schema stitching and subscription notification mechanisms, and I'm hoping to get some guidance on a couple of challenges we're facing.
Current Setup:
We have a federated service that hosts the supergraph. When a client requests a subscription, the federated service forwards the request to our backend service (running as a Lambda), which handles storing the subscription-related data. The federated service manages the WebSocket connection, so after the subscription is stored, we need to return a successful terminated response to the federated service.
To address this, we've been using an HttpResponseInterceptor to prevent the default behavior of subscriptions returning server-sent events over HTTP. The interceptor does the following:
Problem:
When we perform a mutation and need to send a notification to the federated service, we’re facing an issue in retrieving the GraphQL-formatted response. We can access the Result object from middleware, but it doesn't seem to expose the actual formatted response payload that the federated service is expecting, eg:
Our current solution involves using the
ToJson()
method on the IExecutionResult/IOperationResult and sending the notification from within in the interceptor, but this feels a bit hacky and doesn’t seem to align with the intended use of the library.Question:
Is there a more 'proper' or cleaner way to achieve this? Specifically, we’re looking for a way to access the actual formatted GraphQL response in a more integrated manner, perhaps through middleware or another approach, that avoids the need for the workaround we’re currently using.
I’d appreciate any insights or recommendations on how to approach this problem within the spirit of the library.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions