With this schema:
type Query {
myQuery (status: [MyStatusEnum!] = [FIRST, SECOND]): [MyStatusEnum!]
}
And this resolver:
resolvers: {
MyStatusEnum: {
FIRST: '1st',
SECOND: '2nd'
},
Query: {
myQuery: (_, { status }) => {
console.log(status)
}
}
}
Doing the query:
query {
myQuery
}
Will print:
{ status: [ 'FIRST', 'SECOND' ] }
I think the result should be the same as mentioned in the docs:
{ status: [ '1st', '2nd' ] }
when the argument is provided explicitly or has no default value:
query {
myQuery (status: [FIRST, SECOND])
}
+1 I am having the same problem.
It was mentioned over in graphql-js - https://github.com/graphql/graphql-js/issues/1604
I don't like their answer though. For now I am not using default values, instead I am using undefined and setting the default in my resolver
has there been any progress on this or did you guys figure out how to solve it? setting a default value for an enum input is helpful for documentation. for now i am using @will-fagerstrom suggestion and setting the default in the resolver but now it is not documented.
As noted in https://github.com/graphql/graphql-js/issues/1604#issuecomment-455145018, the current behavior (which is driven by graphql-js's execution, not by Apollo Server) is to be expected.
Is it also expected that if I pass the default value to a query in the internal representation, e.g. 0, the resolver receives undefined?
Most helpful comment
+1 I am having the same problem.
It was mentioned over in
graphql-js- https://github.com/graphql/graphql-js/issues/1604I don't like their answer though. For now I am not using default values, instead I am using undefined and setting the default in my resolver