★ wanayoo — archive 1999 https://github.com/graphql-java-kickstart/graphql-java-tools/issues/444Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum not converted to Enum type when fetched from DataFetchingEvironment arguments when Query Default Value is used #444

Open
jcromp opened this issue Oct 1, 2020 · 0 comments
Labels
bug

Comments

@jcromp
Copy link

@jcromp jcromp commented Oct 1, 2020

I'd like to preface this by saying I am new to GraphQL and this could easily be an issue in my Query.

I have recreated the issue with unit tests here: https://github.com/jcromp/graphql-enum-error-example
mvn test should do the trick.

The query should take a list of Enum's and if no values are provided it should default to a list of ALL the possible enum values:

type Query {
     foos(fooStatus: [StatusEnum!] = [GOOD, BAD, UGLY]): [Foo]
}

enum StatusEnum {
    GOOD,
    BAD,
    UGLY
}

This works perfectly fine if I am providing the values to the query. However, when I don't provide value(s) and the default value is used, when the resolver gets the arguments from the DataFetchingEnvironment they come out as Strings and not their Enum type, this causes a ClassCastException: class java.lang.String cannot be cast to class com.example.enumerrorexample.StatusEnum

If this is me not understanding something could someone please let me know what I am doing wrong.

Thanks.

@vojtapol vojtapol added the bug label Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.