Fix for #114 - NPE when coercing null enum value in BatchedExecutionStrategy#115
Conversation
|
I don't think null is a valid value in GraphQL (see http://facebook.github.io/graphql/#sec-Types.Non-Null). What do you think? Thanks |
|
Yes, The test I added tried to follow the The Does that make sense? |
|
It does make some amount of sense but is still confusing. Can you rewrite your test to make a clearer separation between input coercion and result coercion? I do think that However, your change to handlePrimitives has the side effect of now all primitives return null without coercion. The spec says in 3.1.8 that
So really we should be allowing the result coercion to attempt to take place if null, and fix the NPE someplace else. You either need a null check in getNameByValue or someplace else. |
|
And for easy reference here is Enum Values Spec |
|
And now..I'm confused. What does the following mean? From the spec: If yes, If not we are back to our original issue and I also simplified the test method to only showcase the enum Either way, we need to make the strategies consistent. |
|
At this time, I see the issue is only when trying to give back a result that is null. Null is a valid thing to return from a DataFetcher, even a DF for an enum. The NPE happens when attempting to coerce this null value into some some name as in So Can you please limit your changes to a null check in |
|
@danielkwinsor Made the changes per your comment. I added additional tests in |
Fix for https://github.com/andimarek/graphql-java/issues/114 NPE when coercing null enum value in BatchedExecutionStrategy