Description
Adding a default value for a condition (e.g. fields.includeArchived = { type: GraphQLBoolean, defaultValue: false}
) doesn't apply unless you pass an empty condition object (e.g. {myCollection { ... } }
doesn't respect it, but {myCollection(condition: {}) { ... } }
does). However this cannot be solved by setting the defaultValue
of the condition
argument to be {}
; though this gets correctly exposed in GraphiQL:
The results of running a query show that this condition wasn't actually applied, since the two queries above would produce different results when they should not.
I don't know why this is, but at the moment I'm leaning towards it being a bug in the way that Graphile Engine processes arguments (perhaps not applying defaults recursively?). It might actually be a GraphQL thing, but that has yet to be determined.
Interestingly, if you set the default value for the condition
argument to defaultValue: {includeArchived: false}
then it works as it should, but it should not be necessary to do this additional lookup.
Warrants further investigation. Also, once solved, we should give condition
a default value of {}
so these default conditions can apply automatically.