graphql icon indicating copy to clipboard operation
graphql copied to clipboard

Enum in Default value in query arguments

Open hsequeda opened this issue 4 years ago • 3 comments

I cannot find a way to use a enum type as a default value in the arguments of a query.

hsequeda avatar Apr 09 '20 04:04 hsequeda

@stdevHsequeda Are you trying to define something like this:

type Query {
  someField(val: MyEnum = A_ENUM_VALUE): Something
}

enum MyEnum {
  A_ENUM_VALUE
  ANOTHER_ENUM_VALUE
}

If so, then when you define the args for someField, you need to set DefaultValue to A_ENUM_VALUE in quotes.

"val": &graphql.ArgumentConfig{
  Type: MyEnumType,
  DefaultValue: "A_ENUM_VALUE",
}

Zaba505 avatar Apr 24 '20 05:04 Zaba505

Yes, but nothing.

hsequeda avatar Apr 24 '20 07:04 hsequeda

@Zaba505 this does not reflect default value on GraphQL schema docs, any idea why?

alishagupta007 avatar Jul 22 '22 10:07 alishagupta007