ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.26k stars 745 forks source link

Subscription Stitching #562

Closed michaelstaib closed 2 years ago

michaelstaib commented 5 years ago

We want to enable support for stitching subscriptions.

Basics

First we should be able to add the subscription fields of the remote schemas and basically do a simple root-field stitching. Basically what we described with the auto-stitching issue #561.

Query Merging

Furthermore we want to enable merging of query parts into the subscription response. So, basically a subscription result from schema a will be enhanced by querying schema b and integrating those results in the subscription response.

leonardochaia commented 3 years ago

Hey guys. I'm interested in this feature, particularly the "simple root-field stitching".

Is this being worked on? is there anything I can do to help? Thank you. Leo.

observant2 commented 3 years ago

Hey, I can't really wait for HC13. Is there a workaround for this? I need to stitch a few servers together, but I also need working subscriptions.

matt-psaltis commented 3 years ago

We currently create the subscriptions on the stitching server. Using redis, the source service can still use the topic sender to send to the subscription.

observant2 commented 3 years ago

Thank you for the quick answer! Can you expand on this? Because creating the subscription on the stitching server would mean for us that the stitching server needs knowledge of the datastructures etc. instead of being just a dumbed down gateway.

michaelstaib commented 2 years ago

This is now implemented.

    services
            .AddSingleton(httpClientFactory)
            .AddSingleton(socketClientFactory)
            .AddGraphQL()
            .AddRemoteSchema(Context.ContractSchema)
            .AddRemoteSchema(Context.CustomerSchema,
                capabilities: new EndpointCapabilities
                {
                    Batching = BatchingSupport.RequestBatching,
                    Subscriptions = SubscriptionSupport.WebSocket
                })
            .ModifyRequestOptions(o => o.IncludeExceptionDetails = true)
            .BuildRequestExecutorAsync();
CurMa7 commented 2 years ago

Hi @michaelstaib. I've recently started using hotchocolate for our microservice-based architecture. We have several backend services with one GraphQL gateway using the RemoteRedisSchemas for its schema federation. The mutations and queries are working like a charm but I am stuck on getting the subscriptions to work with the remote schemas.

Nevertheless, I have done some digging online which led me to this post. Is it at all possible to implement federated subscriptions now? If yes can you perhaps point me towards documentation or an example of how I can achieve this.

example (1)

Above is an example of how we would like to use the schema federation.