Reputation: 1
I'm using the SPQR Spring Boot for GraphQL. My requirement is that if I have JSR-303/380 annotations in the POJO classes, it should be added as comments in the generated schema. Is there any mechanism to achieve this? My expectation is similar to what springdoc(OpenApi) does with the JSR annotation in POJOs while generating the API schema.
Suppose I have an attribute as shown below which is annotated with @Size.
@Size(
min = 1,
max = 8,
message = "Test Item length should be between 1 and 8"
)
private String testItem;
The generated schema should have something like below.
# Size should be minimum 1 and maximum 8
testItem: String
I could find that the @NotNull resulted in the schema getting updated correctly with exclamation mark (!) which is the graphql way of representing non-null fields/types. So definitively the annotation is having an effect but not for all annotations in JSR spec. I understand there may not be any specification in graphql for other annotations like @Pattern, @Size etc. which is why having them as comments in the schema would really help. Otherwise the consumer of the schema wouldn't have an idea of the supported patterns/format for the graphql fields unless they perform an operation.
I have gone through this link here but I don't want to repeat the information which is already available in the JSR annotation.
Upvotes: 0
Views: 36