-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
The GraphQL spec has for some time supported required arguments with default values, however graphql-ruby (1.9) appears not to support this
argument :id, ID, required: true, default_value: "123"results in the schema compilation error:
Query is invalid: field "account" argument "id" Variable id of type "ID!" is required and will not use the default value. Perhaps you meant to use type "ID".
This seems like a very legitimate use case to me, a less contrived example:
argument :hideDisabledAccounts, Boolean, required: true, default_value: false
# vs
argument :hideDisabledAccounts, Boolean, required: falseAs Rubyists we understand that nil is false-y, so the behaviour here is roughly the same, but from the outside (and the inside) the 1st definition's behaviour seems to me much clearer than the 2nd, in the case where no value is provided.
References:
This behaviour being requested in GraphQL reference implementation, and delivered
Merged spec change which adds "Non-null arguments and input object fields are no longer required to be provided a value/variable if that argument also supplies a default value."