diff --git a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/MutationMapping.java b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/MutationMapping.java index a681d83e..70f674c1 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/MutationMapping.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/MutationMapping.java @@ -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 composed annotation that acts as a + * shortcut for {@link SchemaMapping @SchemaMapping} with + * {@code typeName="Mutation"}. * - *

Specifically, {@code @MutationMapping} is a composed annotation that - * acts as a shortcut for {@code @SchemaMapping(typeName = "Mutation")}. + *

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") diff --git a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/QueryMapping.java b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/QueryMapping.java index ef806c86..d9400f0a 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/QueryMapping.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/QueryMapping.java @@ -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 composed annotation that acts as a + * shortcut for {@link SchemaMapping @SchemaMapping} with + * {@code typeName="Query"}. * - *

Specifically, {@code @QueryMapping} is a composed annotation that - * acts as a shortcut for {@code @SchemaMapping(typeName = "Query")}. + *

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") diff --git a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/SchemaMapping.java b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/SchemaMapping.java index 9f1042cf..dff610ec 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/SchemaMapping.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/SchemaMapping.java @@ -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. + * + *

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 diff --git a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/SubscriptionMapping.java b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/SubscriptionMapping.java index 46dbf05e..a2515847 100644 --- a/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/SubscriptionMapping.java +++ b/spring-graphql/src/main/java/org/springframework/graphql/data/method/annotation/SubscriptionMapping.java @@ -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 composed annotation that acts as a + * shortcut for {@link SchemaMapping @SchemaMapping} with + * {@code typeName="Subscription"}. * - *

Specifically, {@code @QueryMapping} is a composed annotation that - * acts as a shortcut for {@code @SchemaMapping(typeName = "Subscription")}. + *

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")