@Documented @Retention(RUNTIME) @Target(TYPE) public @interface GraphQLReactiveRepository
This annotation marks an Interface as being a GraphQL Reactive Repository. That is: its methods are all marked with either the 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. All these methods are reactive methods: they return either a Mono (for queries and mutations) or a Flux (for subscriptions).
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 EnableGraphQLRepositories annotation must be specified in a spring Configuration class
  • The value or basePackages parameter of the annotation must give the package where to search for GraphQL Repositories.
  • The GraphQLReactiveRepository must annotate each GraphQL repository interface
  • In all cases, a GraphQL Repository must respect these rules:
  • The GraphQL repository is an interface: the runtime code will dynamically create a proxy InvocationHandler that will execute the GraphQL request
  • No implementation would be provided for this interface
  • Each of its methods must be marked either by the PartialRequest or the FullRequest annotation: it is not allowed that a GraphQL repository's method is not a GraphQL request.
  • 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 BindParameter annotation
  • Then the method may add the Bind Parameter or GraphQL Variable values. These values must be marked with the BindParameter annotation
  • 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 GraphQLRequestExecutionException
  • For queries or mutations, the return type of each method must be a Mono of the POJO generated by the plugin, that maps the GraphQL requests return type
  • For subscriptions, the return type of each method must be a Flux of the POJO generated by the plugin, that maps the GraphQL requests return type
  • For Full Requests:
  • Each parameter (if any) must be Bind Parameter or GraphQL Variable values. They must be marked with the BindParameter annotation
  • 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 GraphQLRequestExecutionException
  • For queries or mutations, the return type of each method must be a Mono of the POJO generated by the plugin for the GraphQL query or mutation object
  • For subscriptions, the return type of each method must be a Flux of the POJO generated by the plugin for the GraphQL subscription object
  • Author:
    etienne-sf
    • Optional Element Summary

      Optional Elements
      Modifier and Type
      Optional Element
      Description
      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 value
        The name of the Spring bean to build. Default is to use the interface name as the bean name
        Default:
        ""
      • queryExecutor

        Class<? extends GraphQLQueryReactiveExecutor> queryExecutor
        When 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.GraphQLQueryReactiveExecutor.class