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

Compilation error when field is non-null in type and nullable in interface [Version 4.1.0] #556

Closed
nnbbz opened this issue Feb 24, 2021 · 1 comment · Fixed by #557
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@nnbbz
Copy link

nnbbz commented Feb 24, 2021

Issue Description

If you have an interface that defines an Int (optional)
and you have a type that implements the interface but turns it to Required (Int!)

the resultant class that gets generated uses the primitive type int instead of the Object Integer. All other int is Integer. This seems like a bug?

The workaround currently is to add this in the customTypesMapping

mapping.put("Int!", "java.lang.Integer") <-- notice that you HAVE to specify Int! with the exclamation mark. This could be another bug?

Steps to Reproduce

Have your graphqls schema as follows:

type First implements Second {
test: Int!
}

interface Second {
test: Int
}

Run code generator with Java.

Expected Result

First.java should be Integer test.

Actual Result

Explain in detail what behavior actually happened.
First.java is primitive type int.

Environment and Setup

  • graphql-java-codegen: 4.1.0
  • Build tool: E.g.: SBT
@kobylynskyi
Copy link
Owner

@nnbbz
I will soon release a new version (4.1.4) with this fix.

Thanks for reporting this issue!


Meanwhile, you can use a workaround in your config to replace all non-null types (Int) with nullable types (Integer):

mapping.put("Int!", "java.lang.Integer")

@kobylynskyi kobylynskyi changed the title [Auto Generated POJO not working for Integers defined in interface.] (Version: 4.1.0) Compilation error when field is non-null in type and nullable in interface [Version 4.1.0] Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants