cksrc
cksrc

Reputation: 2347

Use enum as query argument in Graphql

What is the graphql syntax in SDL to use an enum as a query argument?

schema {
  query: Query
}
type Query {
    getWordsCountByLanguage (language: LanguageIso): [WordCount]
}
enum LanguageIso {
    AA
    AB
}

Parsing the above schema will throw an error that Expected type 'language' to be a GraphQLInputType, but it wasn't!

Defining an input type that includes an enum will result on a similar error.

It looks like there is no way of using an enum as a query argument in SDL.

Upvotes: 2

Views: 2535

Answers (1)

cksrc
cksrc

Reputation: 2347

There is a bug already reported here The issue is with nested inputs (i.e., you have an input argument that contains an enum). If you directly pass the enum as argument as in my question should work.

Upvotes: 1

Related Questions