You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
We are trying to generate the code of the Shopify API from an introspection schema.
Waht we come across is the problem that when generating the code, if an enum is directly used in a field, the pre and suffix are ignored during this generation:
the following definintions in the schema lead to the following code which fails to compile since the class cannot be found. Leaving out the pre/suffix is no option since there is a class named Collection which will clash with the java one, since the includes use java.util.* and you will get ambiguity.
What you can see in the examples below is that the row
httpMethod: StagedUploadHttpMethodType = PUT
generates the following field in the class, where the suffix Graphql is missing
the specific fields that show the problem and the generated code:
"""Possible HTTP method of a staged upload target."""
enum StagedUploadHttpMethodType {
"""The POST HTTP method."""
POST
"""The PUT HTTP method."""
PUT
}
"""
Specifies the fields required to generate the URL and parameters needed to upload an asset to Shopify.
"""
input StagedUploadTargetGenerateInput {
"""The resource type being uploaded."""
resource: StagedUploadTargetGenerateUploadResource!
"""The filename of the asset being uploaded."""
filename: String!
"""The MIME type of the asset being uploaded."""
mimeType: String!
"""The HTTP method to be used by the staged upload."""
httpMethod: StagedUploadHttpMethodType = PUT
}
which leads to the following generated code:
package nl.minc.shopify.graphql.model.client;
import java.util.*;
public class StagedUploadTargetGenerateInputGraphql {
@javax.validation.constraints.NotNull
private StagedUploadTargetGenerateUploadResourceGraphql resource;
@javax.validation.constraints.NotNull
private String filename;
@javax.validation.constraints.NotNull
private String mimeType;
private StagedUploadHttpMethodTypeGraphql httpMethod = StagedUploadHttpMethodType.PUT;
public StagedUploadTargetGenerateInputGraphql() {
}
public StagedUploadTargetGenerateInputGraphql(StagedUploadTargetGenerateUploadResourceGraphql resource, String filename, String mimeType, StagedUploadHttpMethodTypeGraphql httpMethod) {
this.resource = resource;
this.filename = filename;
this.mimeType = mimeType;
this.httpMethod = httpMethod;
}
public StagedUploadTargetGenerateUploadResourceGraphql getResource() {
return resource;
}
public void setResource(StagedUploadTargetGenerateUploadResourceGraphql resource) {
this.resource = resource;
}
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public String getMimeType() {
return mimeType;
}
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
public StagedUploadHttpMethodTypeGraphql getHttpMethod() {
return httpMethod;
}
public void setHttpMethod(StagedUploadHttpMethodTypeGraphql httpMethod) {
this.httpMethod = httpMethod;
}
@Override
public String toString() {
StringJoiner joiner = new StringJoiner(", ", "{ ", " }");
if (resource != null) {
joiner.add("resource: " + resource);
}
if (filename != null) {
joiner.add("filename: \"" + com.kobylynskyi.graphql.codegen.model.graphql.GraphQLRequestSerializer.escapeJsonString(filename) + "\"");
}
if (mimeType != null) {
joiner.add("mimeType: \"" + com.kobylynskyi.graphql.codegen.model.graphql.GraphQLRequestSerializer.escapeJsonString(mimeType) + "\"");
}
if (httpMethod != null) {
joiner.add("httpMethod: " + httpMethod);
}
return joiner.toString();
}
public static class Builder {
private StagedUploadTargetGenerateUploadResourceGraphql resource;
private String filename;
private String mimeType;
private StagedUploadHttpMethodTypeGraphql httpMethod = StagedUploadHttpMethodType.PUT;
public Builder() {
}
public Builder setResource(StagedUploadTargetGenerateUploadResourceGraphql resource) {
this.resource = resource;
return this;
}
public Builder setFilename(String filename) {
this.filename = filename;
return this;
}
public Builder setMimeType(String mimeType) {
this.mimeType = mimeType;
return this;
}
public Builder setHttpMethod(StagedUploadHttpMethodTypeGraphql httpMethod) {
this.httpMethod = httpMethod;
return this;
}
public StagedUploadTargetGenerateInputGraphql build() {
return new StagedUploadTargetGenerateInputGraphql(resource, filename, mimeType, httpMethod);
}
}
}
The text was updated successfully, but these errors were encountered:
Hi,
We are trying to generate the code of the Shopify API from an introspection schema.
Waht we come across is the problem that when generating the code, if an enum is directly used in a field, the pre and suffix are ignored during this generation:
the following definintions in the schema lead to the following code which fails to compile since the class cannot be found. Leaving out the pre/suffix is no option since there is a class named Collection which will clash with the java one, since the includes use java.util.* and you will get ambiguity.
What you can see in the examples below is that the row
httpMethod: StagedUploadHttpMethodType = PUT
generates the following field in the class, where the suffix Graphql is missing
private StagedUploadHttpMethodTypeGraphql httpMethod = StagedUploadHttpMethodType.PUT;
the specific fields that show the problem and the generated code:
which leads to the following generated code:
The text was updated successfully, but these errors were encountered: