americanexpress / nodes

A GraphQL JVM Client - Java, Kotlin, Scala, etc.
Apache License 2.0
307 stars 70 forks source link

Static fields in model class #73

Open futzl opened 5 years ago

futzl commented 5 years ago

I reuse custom types in my model class, for example a class called CreditCardNumber. Static fields in this class are also send with the request. On server side, the validation failed because of that static field is not defined in the schema.

public class CreditCardNumber {
    private static final Pattern REGEX = Pattern.compile("\\d{12;19}");
    private String number;
    ...
}

Because I share my custom types across different projects, I'm not able to annote the static field with @GraphQLIgnore.

How should I handle this? Is it a bug, that static fields are in included? May Mixins as used by Jackson be a possible solution?

guptaavi commented 5 years ago

I have the same issue. Most of the model classes are reused across projects and they are all Serializable, thus causing the serialVersionUID to be included in the generated query. This fails validation because the serialVersionUID is not part of the schema. I have no control over the generated models and cannot put a @GraphQLIgnore annotation on this field.