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 trying to make the batching network layer work together with apollo-server-express. I'm using apollo-server instead of graphql-express + the middleware from this module, because it supports query and field tracing.
The batch middleware depends on an id for each batched query to connect requests and responses. However, apollo-server does not pass this id back. This actually turns out to be in line with the graphql spec:
To ensure future changes to the protocol do not break existing servers and clients, the top level response map must not contain any entries other than the three described above. [data, errors, and extensions] http://facebook.github.io/graphql/draft/#sec-Response-Format
However, the spec also defines that JSON serialization is ordered:
Since the result of evaluating a selection set is ordered, the JSON object serialized should preserve this order by writing the object properties in the same order as those fields were requested as defined by query execution. http://facebook.github.io/graphql/draft/#sec-JSON-Serialization
So it should be possible to correlate responses to requests without relying on ids. A solution could be to make the ID optional, and fall back to query index when there is no id.
I can implement this change if you think it sounds good, but I would like to get some feedback first.
The text was updated successfully, but these errors were encountered:
janmeier
changed the title
Batching: make request id optional
Batching: make query id optional
Nov 24, 2017
I'm trying to make the batching network layer work together with apollo-server-express. I'm using apollo-server instead of graphql-express + the middleware from this module, because it supports query and field tracing.
The batch middleware depends on an id for each batched query to connect requests and responses. However, apollo-server does not pass this id back. This actually turns out to be in line with the graphql spec:
However, the spec also defines that JSON serialization is ordered:
So it should be possible to correlate responses to requests without relying on ids. A solution could be to make the ID optional, and fall back to query index when there is no id.
I can implement this change if you think it sounds good, but I would like to get some feedback first.
The text was updated successfully, but these errors were encountered: