Skip to content

Conversation

@rahulsom
Copy link
Contributor

Prior to this change, the generated code would have the right name for the parameter but wrong name in the creation of InputArgument.

InputArgument packageArg = new InputArgument("package", package, false, null);

Now we have a test for generated code being compilable, and we handle this case correctly.

@rahulsom
Copy link
Contributor Author

See the failure on pulpogato/pulpogato#841 for example

"""
|InputArgument ${input.name}Arg = new InputArgument("${input.name}", ${input.name}, false, null);
|getInputArguments().get("${it.name}").add(${input.name}Arg);
|InputArgument ${javaReservedKeywordSanitizer.sanitize(input.name)}Arg = new InputArgument(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: consider extracting into a local var and reusing in all 3 places in the modified block

|InputArgument ${input.name}Arg = new InputArgument("${input.name}", ${input.name}Reference, true, ${getVariableDefinitionType(
|InputArgument ${javaReservedKeywordSanitizer.sanitize(
input.name,
)}Arg = new InputArgument("${input.name}", ${input.name}Reference, true, ${getVariableDefinitionType(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall it be sanitized it here as well (${input.name}Reference)?

| ${javaReservedKeywordSanitizer.sanitize(input.name)},
| false,
| null);
|getInputArguments().get("${fieldDefinition.name}").add(${input.name}Arg);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question: why is it sanitized on line 603 but not here?

Copy link
Contributor

@sjohnr sjohnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @rahulsom, thanks for the PR! I added a comment for your review below.

|InputArgument ${input.name}Arg = new InputArgument("${input.name}", ${input.name}Reference, true, ${getVariableDefinitionType(
|InputArgument ${javaReservedKeywordSanitizer.sanitize(
input.name,
)}Arg = new InputArgument("${input.name}", ${input.name}Reference, true, ${getVariableDefinitionType(
Copy link
Contributor

@sjohnr sjohnr Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think *Reference param name should be sanitized as well? I'm not sure if this would also be a problem and perhaps we're missing a test case, or this param doesn't need to be sanitized?

Edit: Looks like @iuliiasobolevska beat me to it here. 😄

@rahulsom rahulsom force-pushed the handle-java-keywords branch 2 times, most recently from 7745ac2 to f19b2ec Compare January 6, 2026 19:02
@rahulsom
Copy link
Contributor Author

rahulsom commented Jan 6, 2026

Thanks @iuliiasobolevska & @sjohnr for the review! Changes are in.

.addCode(
"""
|this.variableReferences.put("${javaReservedKeywordSanitizer.sanitize(inputValue.name)}", variableRef);
|this.variableReferences.put("$sanitizedInputName", variableRef);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding might be off but would we want to instead keep the unsanitized input name here to match the GraphQL input so the query is serialized correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. That makes sense. Updated that. Thanks!

Prior to this change, the generated code would have the right name for the parameter but wrong name in the creation of InputArgument.

```java
InputArgument packageArg = new InputArgument("package", package, false, null);
```

Now we have a test for generated code being compilable, and we handle this case correctly.
@rahulsom rahulsom force-pushed the handle-java-keywords branch from f19b2ec to a1c7ba8 Compare January 9, 2026 23:02
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

Successfully merging this pull request may close these issues.

4 participants