Skip to content

Commit 6324fd4

Browse files
committed
Document allow_all_hidden: true, xref #5474
1 parent fc272ef commit 6324fd4

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/graphql/schema/validator/required_validator.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ class Validator
88
#
99
# (This is for specifying mutually exclusive sets of arguments.)
1010
#
11+
# If you use {GraphQL::Schema::Visibility} to hide all the arguments in a `one_of: [..]` set,
12+
# then a developer-facing {GraphQL::Error} will be raised during execution. Pass `allow_all_hidden: true` to
13+
# skip validation in this case instead.
14+
#
15+
# This validator also implements `argument ... required: :nullable`. If an argument has `required: :nullable`
16+
# but it's hidden with {GraphQL::Schema::Visibility}, then this validator doesn't run.
17+
#
1118
# @example Require exactly one of these arguments
1219
#
1320
# field :update_amount, IngredientAmount, null: false do
@@ -37,6 +44,7 @@ class Validator
3744
class RequiredValidator < Validator
3845
# @param one_of [Array<Symbol>] A list of arguments, exactly one of which is required for this field
3946
# @param argument [Symbol] An argument that is required for this field
47+
# @param allow_all_hidden [Boolean] If `true`, then this validator won't run if all the `one_of: ...` arguments have been hidden
4048
# @param message [String]
4149
def initialize(one_of: nil, argument: nil, allow_all_hidden: nil, message: nil, **default_options)
4250
@one_of = if one_of

0 commit comments

Comments
 (0)