Allow configuring an input prefix with annotations starter #505
Description
Is your feature request related to a problem? Please describe.
Using the annotations starter I do not have full control over input type names. Input type names are always prefixed “Input”. Using the annotations starter it is impossible to exactly implement a schema with this mutation:
type Mutation {
createReview(episode: Episode, review: ReviewInput): Review
}
type Review {
id: ID!
stars: Int!
commentary: String
}
input ReviewInput {
stars: Int!
commentary: String
}
No matter if a @GraphQLName
annotation is used on a ReviewInput
class or not, the input type name will be prefixed with “Input” in the generated schema:
type Mutation {
createReview(episode: Episode, review: InputReviewInput): Review
}
type Review {
id: ID!
stars: Int!
commentary: String
}
input InputReviewInput {
stars: Int!
commentary: String
}
“Input” is the GraphQL-Java Annotations library's default input prefix. The library allows configuring the input prefix. It also supports configuring an input suffix which defaults to the empty string.
Describe the solution you'd like
The annotations starter should expose configuration properties for the input type name prefix and suffix.
Describe alternatives you've considered
The alternative is configuring the AnnotationsSchemaCreator
with the desired prefix and creating a GraphQLSchema
bean from it:
@Bean
public GraphQLSchema graphQLSchema() {
// Clearing the input prefix is required in order to avoid generating names like “InputReviewInput”.
GraphQLAnnotations graphQLAnnotations = new GraphQLAnnotations();
graphQLAnnotations.getContainer().setInputPrefix("");
return newAnnotationsSchema()
.setAnnotationsProcessor(graphQLAnnotations)
.query(Query.class)
.mutation(Mutation.class)
.setAlwaysPrettify(true)
.build();
}
But this pretty much obsoletes using the annotations starter.