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
{{ message }}
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.
When you pass enum values as argument in your GraphQL queries, the validation fails. To reproduce this bug, let's use the super simple SortEnum that contains only 2 attributes, ASC and DESC :
enum SortEnum @doc(description: "This enumeration indicates whether to return results in ascending or descending order") {
ASC
DESC
}
We'll use it on the products query to sort the paginated result.
Type these variables in the "Query Variables" block on the bottom left :
{
"sort": "ASC",
"price": "1"
}
...and hit the big upper button to perform the request.
Expected result (*)
Normally in GraphQL, you are able to pass enum types as variables. The result should be a paginated list of products sorted by name ASC.
Actual result (*)
The request doesn't perform well :
{
"errors": [
{
"message": "Variable \"$sort\" of type \"SortEnum\" used in position expecting type \"SortEnum\".",
"category": "graphql",
"locations": [
{
"line": 3,
"column": 3
},
{
"line": 12,
"column": 17
}
]
}
]
}
I don't know if it's a Magento or a graphql-php related error. The error seems to be caused by the graphql-php validation process, the class GraphQL\Validator\Rules\VariablesInAllowedPosition is causing the error.
I tested with custom enums and the issue is the same. The only way to succeed is to change the type SortEnum to String and pass value as a string, but it's not a proper solution at all.
Actually this is very annoying because you can't use enum types as arguments for queries.
The text was updated successfully, but these errors were encountered:
Hello there,
When you pass enum values as argument in your GraphQL queries, the validation fails. To reproduce this bug, let's use the super simple
SortEnum
that contains only 2 attributes,ASC
andDESC
:We'll use it on the
products
query to sort the paginated result.Preconditions (*)
Steps to reproduce (*)
https://yoursite.com/graphql
Type these variables in the "Query Variables" block on the bottom left :
...and hit the big upper button to perform the request.
Expected result (*)
Actual result (*)
I don't know if it's a Magento or a graphql-php related error. The error seems to be caused by the graphql-php validation process, the class
GraphQL\Validator\Rules\VariablesInAllowedPosition
is causing the error.I tested with custom enums and the issue is the same. The only way to succeed is to change the type
SortEnum
toString
and pass value as a string, but it's not a proper solution at all.Actually this is very annoying because you can't use enum types as arguments for queries.
The text was updated successfully, but these errors were encountered: