graphql-go-tools icon indicating copy to clipboard operation
graphql-go-tools copied to clipboard

Mutation / Query + Subscription Split link?

Open maaft opened this issue 3 years ago • 1 comments

Hey, would it be possible to use these tools to host a simple gateway that splits mutations and queries + subscriptions and forward them to different servers?

Mutation -> forward to mutation.gql.example.com

Query or Subscription -> forward to query.gql.example.com

Only caveat is, that due to some limitations on our graphql server both endpoints offer the same API (mutations + queries). So simple federation is not possible in my usecase.

maaft avatar Oct 07 '22 13:10 maaft

Hey, yes absolutely. Everything is possible. Here's an example of how this could be implemented: https://docs.wundergraph.com/docs/wundergraph-server-ts-reference/on-origin-request-hook

We could write an onOriginRequest hook that checks for "mutation" in the body, and rewrites the host.

If you'd like to build this on your own, all you have to do is wire everything up and create a custom transport that does the same thing as the onOriginRequest hook.

jensneuse avatar Oct 17 '22 21:10 jensneuse