graphql-spqr-spring-boot-starter icon indicating copy to clipboard operation
graphql-spqr-spring-boot-starter copied to clipboard

Lombok + SPQR

Open nautilor opened this issue 4 years ago • 1 comments

Hello,

I am trying to achieve something like this

 @Builder
 @NoArgsConstructor
 @AllArgsConstructor
 @EqualsAndHashCode
 @Data
 public class User {

     private String username;

     private String firstName;

     private String lastName;

     @GraphQLQuery(name = "emailAddress", description = "The user email")
     private String email;

 }

I know spqr cannot access private fields and I would have to generate getters to acheive this but I was wondering if there was a way to do this and still benefit of lombok @Data

I have found

 @Getter(onMethod = @__(@GraphQLQuery(name = "emailAddress", description = "The user email")))
 private String email;

this does work still not quite clean In my opinion

nautilor avatar Jul 15 '20 12:07 nautilor

@nautilor add @Setter @Getter

like this :

@Data
@Setter
@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Person {

    @Id
    @GeneratedValue
    @Type(type = "uuid-char")
    private UUID id;

    private String name;

    @GraphQLQuery(name = "years", description = "The person age")
    private Integer age;

}

image

pnboot avatar Jul 22 '20 02:07 pnboot