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

[java] generated enum arguments lack validation #637

Closed
optionsome opened this issue Feb 23, 2024 · 2 comments
Closed

[java] generated enum arguments lack validation #637

optionsome opened this issue Feb 23, 2024 · 2 comments

Comments

@optionsome
Copy link
Contributor

Which packages are impacted by your issue?

@graphql-codegen/java

Describe the bug

Reading in arguments with generated types crashes due to enum arguments lacking null validation.

Your Example Website or App

https://stackblitz.com/edit/github-val3pw

Steps to Reproduce the Bug or Issue

  1. Create an input type with with an enum field and some other field(s)
  2. Generate types for the query
  3. Create query where the enum field is not provided but some other fields are
  4. Try creating a new instance of query arguments with the graphql-java DataFetchingEnvironment from the query

Expected behavior

Creating a new instance of query arguments should not crash if some field is not defined in the arguments provided in an incoming query.

Screenshots or Videos

No response

Platform

  • OS: Linux
  • NodeJS: v16.20.2
  • graphql version: 16.8.1
  • @graphql-codegen/java version(s): 4.0.0

Codegen Config File

No response

Additional context

The code crashes because it tries to call enum's valueOf method with a null value.

@saihaj
Copy link
Collaborator

saihaj commented Feb 23, 2024

@saihaj saihaj closed this as completed Feb 23, 2024
@optionsome
Copy link
Contributor Author

Thanks for the really fast review @saihaj !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants