Allow mapping annotations at the class level

Closes gh-195
This commit is contained in:
Rossen Stoyanchev
2021-11-25 11:08:55 +00:00
parent 7543120006
commit 9ce4b6801e
4 changed files with 27 additions and 15 deletions

View File

@@ -24,15 +24,18 @@ import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
/**
* Annotation to express a mapping to a GraphQL Mutation operation.
* {@code @MutationMapping} is a <em>composed annotation</em> that acts as a
* shortcut for {@link SchemaMapping @SchemaMapping} with
* {@code typeName="Mutation"}.
*
* <p>Specifically, {@code @MutationMapping} is a <em>composed annotation</em> that
* acts as a shortcut for {@code @SchemaMapping(typeName = "Mutation")}.
* <p>You can use this annotation both at the method and at the class level, in
* which case all handlers methods in the controller are mutations, unless the
* typeName is overridden.
*
* @author Rossen Stoyanchev
* @since 1.0.0
*/
@Target(ElementType.METHOD)
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@SchemaMapping(typeName = "Mutation")

View File

@@ -24,15 +24,18 @@ import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
/**
* Annotation to express a mapping to a GraphQL Query operation.
* {@code @QueryMapping} is a <em>composed annotation</em> that acts as a
* shortcut for {@link SchemaMapping @SchemaMapping} with
* {@code typeName="Query"}.
*
* <p>Specifically, {@code @QueryMapping} is a <em>composed annotation</em> that
* acts as a shortcut for {@code @SchemaMapping(typeName = "Query")}.
* <p>You can use this annotation both at the method and at the class level, in
* which case all handlers methods in the controller are queries, unless the
* typeName is overridden.
*
* @author Rossen Stoyanchev
* @since 1.0.0
*/
@Target(ElementType.METHOD)
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@SchemaMapping(typeName = "Query")

View File

@@ -26,9 +26,12 @@ import graphql.schema.DataFetchingEnvironment;
import org.springframework.core.annotation.AliasFor;
/**
* Annotation to express a mapping to a GraphQL type and field pair. Typically
* used on methods, but also possible to use at the class level to specify a
* default type name for all handler methods.
* Annotation to express the mapping of a handler method to a GraphQL type and
* field pair.
*
* <p>You can use this annotation both at the method and at the class level, in
* which case all handlers methods inherit the class-level typeName by default
* unless overridden at the method level.
*
* @author Rossen Stoyanchev
* @since 1.0.0

View File

@@ -24,15 +24,18 @@ import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
/**
* Annotation to express a mapping to a GraphQL Subscription operation.
* {@code @SubscriptionMapping} is a <em>composed annotation</em> that acts as a
* shortcut for {@link SchemaMapping @SchemaMapping} with
* {@code typeName="Subscription"}.
*
* <p>Specifically, {@code @QueryMapping} is a <em>composed annotation</em> that
* acts as a shortcut for {@code @SchemaMapping(typeName = "Subscription")}.
* <p>You can use this annotation both at the method and at the class level, in
* which case all handlers methods in the controller are subscriptions, unless the
* typeName is overridden.
*
* @author Rossen Stoyanchev
* @since 1.0.0
*/
@Target(ElementType.METHOD)
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@SchemaMapping(typeName = "Subscription")