-
-
Notifications
You must be signed in to change notification settings - Fork 114
Closed
Description
Issue Description
Using reserved java words as enum names results in capitalization which is then used in the query. This results in a rejected request (by AWS Appsync) because the enum is not defined in the schema.
Steps to Reproduce
Let's assume the following graphql schema:
type Mutation {
updateTest(message: TestEnum): String
}
enum TestEnum {
long,
short,
high,
low
}and generate the model and client from it. We use it like this:
public static void main(String[] args) {
UpdateTestMutationRequest mutReq = new UpdateTestMutationRequest();
mutReq.setMessage(TestEnumTO.Long);
GraphQLRequest req = new GraphQLRequest(mutReq);
String json = GraphQLRequestSerializer.toHttpJsonBody(req);
System.out.println(json);
}The printed line is the query later sent to the server.
Expected Result
{"query":"mutation { updateTest(message: long) }"}
Actual Result
{"query":"mutation { updateTest(message: Long) }"}
Since the query is generated by the serializer using #toString() the capitalized name is used.
Your Environment and Setup
-
graphql-java-codegen: 2.4.0
-
Build tool: Maven
-
Java tool: openjdk version "1.8.0_252"; OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1ubuntu1-b09)
-
Mapping Config:
<configuration>
<graphqlSchemas>
<rootDir>${project.basedir}/schema</rootDir>
</graphqlSchemas>
<outputDir>${project.build.directory}/generated-sources/graphql</outputDir>
<packageName>test.model</packageName>
<modelNameSuffix>TO</modelNameSuffix>
<generateClient>true</generateClient>
</configuration>Additional context
- The problem seems similar to ResponseProjection fields with reserved names have uppercase initial letter in final JSON #237.
- I only looked at the client side when building the query. There might be a problem when receiving a response as well.
- I temporarily worked around this problem using Nithanim@b8f5c00 which seemed to work flawlessly.
- Thank you for the awesome generator!
- Minimal maven test project
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working