Skip to content

Commit 3960bdd

Browse files
author
Wesley Ellis
committed
fix fieldNameSeen and add test to catch mistakes in future
1 parent d0d8895 commit 3960bdd

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

codegen/lib/graphql_java_gen/templates/APISchema.java.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public class <%= schema_name %> {
295295

296296
public <%= type.name %> set<%= field.classify_name %>(<%= java_annotations(field, in_argument: true) %><%= java_input_type(field.type) %> <%= escape_reserved_word(field.camelize_name) %>) {
297297
this.<%= escape_reserved_word(field.camelize_name) %> = <%= escape_reserved_word(field.camelize_name) %>;
298-
this.<%= escape_reserved_word(field.name) %>Seen = true;
298+
this.<%= field.camelize_name %>Seen = true;
299299
return this;
300300
}
301301
<% end %>
@@ -310,7 +310,7 @@ public class <%= schema_name %> {
310310
<%= generate_build_input_code(escape_reserved_word(field.camelize_name), field.type) %>
311311
<% end %>
312312
<% type.optional_input_fields.each do |field| %>
313-
if (this.<%= escape_reserved_word(field.name) %>Seen) {
313+
if (this.<%= field.camelize_name %>Seen) {
314314
_queryBuilder.append(separator);
315315
separator = ",";
316316
_queryBuilder.append("<%= field.name %>:");

codegen/test/support/schema.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ module Schema
9191
argument :value, !types.Int
9292
argument :ttl, TimeType
9393
argument :negate, types.Boolean, default_value: false
94+
argument :api_client, types.String
9495
end
9596

9697
MutationType = GraphQL::ObjectType.define do

support/src/test/java/com/shopify/graphql/support/Generated.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,9 @@ public static class SetIntegerInput implements Serializable {
10821082
private Boolean negate;
10831083
private boolean negateSeen = false;
10841084

1085+
private String apiClient;
1086+
private boolean apiClientSeen = false;
1087+
10851088
public SetIntegerInput(String key, int value) {
10861089
this.key = key;
10871090

@@ -1128,6 +1131,17 @@ public SetIntegerInput setNegate(@Nullable Boolean negate) {
11281131
return this;
11291132
}
11301133

1134+
@Nullable
1135+
public String getApiClient() {
1136+
return apiClient;
1137+
}
1138+
1139+
public SetIntegerInput setApiClient(@Nullable String apiClient) {
1140+
this.apiClient = apiClient;
1141+
this.apiClientSeen = true;
1142+
return this;
1143+
}
1144+
11311145
public void appendTo(StringBuilder _queryBuilder) {
11321146
String separator = "";
11331147
_queryBuilder.append('{');
@@ -1164,6 +1178,17 @@ public void appendTo(StringBuilder _queryBuilder) {
11641178
}
11651179
}
11661180

1181+
if (this.apiClientSeen) {
1182+
_queryBuilder.append(separator);
1183+
separator = ",";
1184+
_queryBuilder.append("api_client:");
1185+
if (apiClient != null) {
1186+
Query.appendQuotedString(_queryBuilder, apiClient.toString());
1187+
} else {
1188+
_queryBuilder.append("null");
1189+
}
1190+
}
1191+
11671192
_queryBuilder.append('}');
11681193
}
11691194
}

0 commit comments

Comments
 (0)