Annotation Interface Ignore


@Retention(RUNTIME) @Target({FIELD,METHOD}) @Documented public @interface Ignore
Excludes an otherwise mapped element. Mostly useful to e.g. mark a field as excluded in the GraphQL input type only.

The behavior is different depending on where @Ignore annotation is placed:
  • On field: Field is ignored in both graphql type and input type.
  • On getter: Field is ignored in the graphql type.
  • On setter: Field is ignored in the graphql input type.


For example, a user might annotate a class' properties and/or getters/setters as such:
 @Type("Starship")
 @Input("StarshipInput")
 @Description("A starship in Star Wars")
 public class Starship {
     private String id;
     private String name;
     private float length;
     @Ignore
     private String color;
     private float mass;

     @Ignore
     public void setLength(float length) {
         this.length = length;
     }

     @Ignore
     public float getMass() {
         return mass;
     }

     // other getters/setters...
 }
 
Schema generation of this would result in a stanza such as:
 "A starship in Star Wars"
 type Starship {
   id: String
   length: Float
   name: String
 }

 "A starship in Star Wars"
 input StarshipInput {
   id: String
   mass: Float
   name: String
 }