Skip to content

Preserve result order #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jbttn opened this issue Jul 2, 2020 · 3 comments · Fixed by #84
Closed

Preserve result order #60

jbttn opened this issue Jul 2, 2020 · 3 comments · Fixed by #84

Comments

@jbttn
Copy link
Contributor

jbttn commented Jul 2, 2020

7.2.2 Serialized Map Ordering

Since the result of evaluating a selection set is ordered, the serialized Map of results should preserve this order by writing the map entries in the same order as those fields were requested as defined by query execution. Producing a serialized response where fields are represented in the same order in which they appear in the request improves human readability during debugging and enables more efficient parsing of responses if the order of properties can be anticipated.

For example, if the request was { name, age }, a GraphQL service responding in JSON should respond with { "name": "Mark", "age": 30 } and should not respond with { "age": 30, "name": "Mark" }.

@paulofaria
Copy link
Member

Thank you @jbttn! I'll take a stab at it this week.

NeedleInAJayStack added a commit to NeedleInAJayStack/GraphQL that referenced this issue Jun 16, 2021
NeedleInAJayStack added a commit to NeedleInAJayStack/GraphQL that referenced this issue Jun 16, 2021
NeedleInAJayStack added a commit to NeedleInAJayStack/GraphQL that referenced this issue Jun 16, 2021
NeedleInAJayStack added a commit to NeedleInAJayStack/GraphQL that referenced this issue Jun 16, 2021
@NeedleInAJayStack
Copy link
Member

This was resolved for Map and GraphQLResult in the linked merge request. However, when encoding with an ordinary JSONEncoder, order is not preserved due to the internals of JSONEncoder.

@NeedleInAJayStack
Copy link
Member

This was actually fixed in #94 by providing a GraphQLJSONEncoder that preserves result ordering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants