-
Notifications
You must be signed in to change notification settings - Fork 61
Description
Module version(s) affected
v4, v5
Description
Currently sort arguments are passed as an object:
{
"created": "asc",
"name": "asc"
}
According to the GraphQL spec, there’s no guarantee about the order that these will be interpreted, so the sort order might be interpreted as either Created ASC, Name ASC or Name ASC, Created ASC. It appears that webonyx/graphql-php will interpret them in the order they’re defined in the schema, not in the query or inputs.
We’ve managed to work around this by manually parsing the query in #563, but that only works if the sort order is baked into the query itself. When the sort order is passed as an argument to the query, the original order is lost as soon as the query is parsed (more info: #571 (comment)). That aside, manually inspecting the query AST to try to “fix” the sort order is probably an indication we’re approaching this the wrong way.
One alternative approach suggested is to use an array instead (a “list” in GraphQL speak). That might look something like:
[
{"created": "asc"},
{"name": "asc"}
]
If we could use that approach, I think it’d be important to preserve backward compatibility if at all possible. I haven’t looked at how that might be possible yet - perhaps interfaces or union types could help.
How to reproduce
Possible Solution
No response
Additional Context
No response
Validations
- Check that there isn't already an issue that reports the same bug
- Double check that your reproduction steps work in a fresh installation of
silverstripe/installer(with any code examples you've provided)