Sending enum-arguments as variables (with Relay) mostly results in VariableTypeMismatch
See original GitHub issueThis issue is a bit related to the question and answer on http://stackoverflow.com/questions/35946313/how-to-set-a-relay-variable-as-an-enum-value/35987582#35987582, however my issue is specifically server-side.
I have these relevant parts of the schema for Users
:
Users(orderBy: [UserOrdering]): UserConnection
input UserOrdering {
sort: UserSortField!
direction: SortDirection!
}
enum UserSortField {
FIRSTNAME
LASTNAME
FULLNAME
}
enum SortDirection {
ASC
DESC
}
When sending the query with orderBy
specified as a variable:
query($orderBy: [UserOrdering]!) {
viewer {
...on LoggedInViewer {
Users(orderBy:$orderBy) {
edges {
node {
fullName
}
}
}
}
}
}
variables:
{
"orderBy": [{"sort": "FULLNAME", "direction": "ASC"}]
}
Most of the times I get back: Validation error of type VariableTypeMismatch: Variable type doesn't match
.
When sending orderBy
hardcoded, the query always works:
query {
viewer {
...on LoggedInViewer {
Users(orderBy: [{sort:FULLNAME, direction:ASC}]) {
edges {
node {
fullName
}
}
}
}
}
}
Now, the strange thing is that sometimes querying with orderBy
as a variable works (when sending the query with GraphiQL a couple of times). I suspect it has something to do with the order of execution on the server-side, but I’m not sure what to look for exactly.
Can you help me making this query work consistently?
NB: I’m using version 2016-09-02T14-27-54
of graphql-java
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (2 by maintainers)
Ahhh thank you @TomerSabags. This makes sense… so we can add
VariableTypeMismatch
to the list of rules that depend on==
for validation (#85).After debugging this a bit futher, I now see when the error is thrown.
Some debugging notes about the variables when evaluating
VariableTypesMatchRule.checkVariable
:Now, let’s find out why
variableType.wrappedType
sometimes refers to a different object thaninputType
(which causesVariablesTypesMatcher
to error).