Annotation Interface GraphQLRepository
This annotation marks an Interface as being a GraphQL Repository. That is: its methods are all marked with either the
A GraphQL Repository may be used either in a Spring app or a non-Spring app.
When used in a Spring app, a GraphQL Repository must respect these rules:
The
The value or basePackages parameter of the annotation must give the package where to search for
GraphQL Repositories.
The
In all cases, a GraphQL Repository must respect these rules:
The GraphQL repository is an interface: the runtime code will dynamically create a proxy
No implementation would be provided for this interface
Each of its methods must be marked either by the
Queries, Mutations and Subscriptions may be mixed in the same GraphQL Repository
The method parameters must respect these rules:
For Partial Requests:
The first parameters must be the parameters of the query/mutation/subscription as defined in the GraphQL schema.
Theses parameters, if any, are the parameters that follow the GraphQLRequest in the executor's matching method (see
the samples below, for more clarity)
There first parameters may not be marked with the
Then the method may add the Bind Parameter or GraphQL Variable values. These values must be marked with the
All the Bind Parameters and GraphQL Variables must have a matching parameter, in the GraphQL repository
method.
Every method of this interface must throw the
For queries or mutations, the return type of each method must be the POJO generated by the plugin, that maps the
GraphQL requests return type
For subscriptions, the return type of each method must be
For Full Requests:
Each parameter (if any) must be Bind Parameter or GraphQL Variable values. They must be marked with the
All the Bind Parameters and GraphQL Variables must have a matching parameter, in the GraphQL repository
method.
A Full Request may have no parameter. This occurs only if the given GraphQL query contains no Bind Parameter, nor
GraphQL variable.
Every method of this interface must throw the
For queries or mutations, the return type of each method must be the POJO generated by the plugin for the GraphQL
query or mutation object
For subscriptions, the return type of each method must be the POJO generated by the plugin for the GraphQL
subscription object
FullRequest or the PartialRequest annotation. A Java runtime proxy is created at runtime, that will
execute the relevant GraphQL request, when one of its methods is executed.A GraphQL Repository may be used either in a Spring app or a non-Spring app.
When used in a Spring app, a GraphQL Repository must respect these rules:
EnableGraphQLRepositories annotation must be specified in a spring Configuration classGraphQLRepository must annotate each GraphQL repository interfaceInvocationHandler that will execute the GraphQL requestPartialRequest or the FullRequest annotation: it
is not allowed that a GraphQL repository's method is not a GraphQL request.BindParameter annotationBindParameter annotationGraphQLRequestExecutionExceptionSubscriptionClientBindParameter annotationGraphQLRequestExecutionException- Author:
- etienne-sf
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionClass<? extends GraphQLQueryExecutor>When more than one GraphQL schema are used, a GraphQL Repository requests may be relative to only one GraphQL schema.The name of the Spring bean to build.
-
Element Details
-
value
String valueThe name of the Spring bean to build. Default is to use the interface name as the bean name- Default:
- ""
-
queryExecutor
Class<? extends GraphQLQueryExecutor> queryExecutorWhen more than one GraphQL schema are used, a GraphQL Repository requests may be relative to only one GraphQL schema. In this case, the queryExecutor value is mandatory: it must provide the queryExecutor of this GraphQL schema.- Default:
- com.graphql_java_generator.client.GraphQLQueryExecutor.class
-