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 have a system where I have 2 identical gqlgen GQL servers running with 2 independent data stores (with different data).
I'd like to proxy a client's GQL request from one server to the other and collect the response in order to reply to the client.
When a client makes a GQL request (one request) to any one of the 2 servers, the request would need to be processed by both the servers and they would each return a response of the same schema with contents based on the data they have access to.
The client needs just one response, so there needs to be an aggregation of the results to form a single response for the client.
For example if:
ServerA has data entries X1, X2
ServerB has data entries Y1, Y2
A GQL request from the client to list all entries should return [X1, X2, Y1, Y2]
If the request hits ServerA, ServerA needs to locally resolve the query in addition to passing on the query to ServerB and aggregating all the responses to respond to the client.
To go about achieving this, I tried out implementing a "proxy" which runs on each server and does the following:
Receive the request with headers (auth tokens) and GQL query
Pass the query to the local resolver for local data
Collect data from the local resolver
Forward the client's HTTP request to the other server
Receive the query response from the other server and aggregate both manually (array concatenation)
So far, aggregating the results and responding to the client have been a rather painful task as the request processing and the pagination which were otherwise handled by the GQL server need to be handled manually now.
I'd like to ask if there's a better way that I could use gqlgen's GQL server in this case?
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
-
I have a system where I have 2 identical gqlgen GQL servers running with 2 independent data stores (with different data).
I'd like to proxy a client's GQL request from one server to the other and collect the response in order to reply to the client.
When a client makes a GQL request (one request) to any one of the 2 servers, the request would need to be processed by both the servers and they would each return a response of the same schema with contents based on the data they have access to.
The client needs just one response, so there needs to be an aggregation of the results to form a single response for the client.
For example if:
ServerA has data entries X1, X2
ServerB has data entries Y1, Y2
A GQL request from the client to list all entries should return [X1, X2, Y1, Y2]
If the request hits ServerA, ServerA needs to locally resolve the query in addition to passing on the query to ServerB and aggregating all the responses to respond to the client.
To go about achieving this, I tried out implementing a "proxy" which runs on each server and does the following:
So far, aggregating the results and responding to the client have been a rather painful task as the request processing and the pagination which were otherwise handled by the GQL server need to be handled manually now.
I'd like to ask if there's a better way that I could use gqlgen's GQL server in this case?
Beta Was this translation helpful? Give feedback.
All reactions