Hello,
Thanks for much for building this library! I have an enum like:
class AcceptedChallengesSortParamType < Types::BaseEnum
value 'acceptedAt_ASC', value: { accepted_at: :asc }
value 'acceptedAt_DESC', value: { accepted_at: :desc }
end
and it works great, except I can't figure out how to specify default_value other than nil. If I try:
argument :sort_by, [AcceptedChallengesSortParamType], required: false, default_value: ['acceptedAt_ASC']
I get:
F, [2019-05-09T10:02:20.694440 #1237] FATAL -- : GraphQL::Schema::InvalidTypeError (Query is invalid: field "acceptedChallenges" argument "sortBy" default value ["acceptedAt_ASC"] is not valid for type [AcceptedChallengesSortParam!] (Can't resolve enum AcceptedChallengesSortParam for "acceptedAt_ASC")):
What is the correct way to specify default_value?
graphql-ruby version: 1.9.3
rails version: 5.2.2.1
Hi,
The default_value has to match the value in your enum.
value: { accepted_at: :asc } --> default_value: { accepted_at: :asc }
Best,
Balint
To clarify further, since the argument accepts a list type, the default value should be an array, so you probably want:
argument :sort_by, [AcceptedChallengesSortParamType], required: false, default_value: [{accepted_at: :asc}]
It seems awkward because GraphQL-Ruby's assumption is that you'd be using _application values_ as enum value: overrides, not complex data structures. Anyways, let me know if it works for you!
Most helpful comment
To clarify further, since the argument accepts a list type, the default value should be an array, so you probably want:
It seems awkward because GraphQL-Ruby's assumption is that you'd be using _application values_ as enum
value:overrides, not complex data structures. Anyways, let me know if it works for you!