Skip to content

Adding default condition doesn't work as expected (requires change to GraphQL Spec) #691

Closed
@benjie

Description

@benjie

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:

Screenshot_20201112_132612

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions