You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This sounds like a good use case input unions in GraphQL to support schema level enforcement of this contract. See graphql/graphql-spec#395 for more on that.
In the meantime the best you can do is a runtime validation check:
field:car,Types::CarType,null: falsedoargument:id,ID,required: falseargument:external_id,ID,required: falseenddefcar(id: :unspecified,external_id: :unspecified)if(id == :unspecified && external_id == :unspecified) || (id != :unspecified && external_id != :unspecified)raiseGraphQL::ExecutionError.new('Must specify exactly one of id or externalId')end# ...end
I have a field that I want to filter in one of two ways.
Is there anyway to indicate that one of the two values must be required, but not both?
I tried overriding GraphQL::Schema::Argument, but it doesn't seem like 'context' is available where 'required' is used.
The text was updated successfully, but these errors were encountered: