From 4c5f2abf84d7831eaa4585c418be306a83f49b58 Mon Sep 17 00:00:00 2001 From: Marek Skacelik Date: Wed, 2 Aug 2023 14:41:46 +0200 Subject: [PATCH] Added directive filtration for SchemaDirectives (TypeSystemDirectiveLocation) --- .../smallrye/graphql/schema/SchemaBuilder.java | 2 +- .../graphql/schema/creator/ArgumentCreator.java | 5 +++++ .../schema/creator/DirectiveTypeCreator.java | 6 ++++++ .../graphql/schema/creator/FieldCreator.java | 5 +++++ .../graphql/schema/creator/ModelCreator.java | 14 ++++++++++++-- .../graphql/schema/creator/OperationCreator.java | 5 +++++ .../schema/creator/type/AbstractCreator.java | 7 +++---- .../graphql/schema/creator/type/Creator.java | 2 ++ .../graphql/schema/creator/type/EnumCreator.java | 7 ++++++- .../schema/creator/type/InputTypeCreator.java | 8 ++++++-- .../schema/creator/type/InterfaceCreator.java | 5 +++++ .../graphql/schema/creator/type/TypeCreator.java | 4 ++++ .../schema/creator/type/UnionCreator.java | 7 +++++++ .../graphql/schema/helper/Directives.java | 3 ++- .../graphql/index/SchemaBuilderTest.java | 2 +- .../graphql/index/app/SomeDirective.java | 4 ++-- .../smallrye/graphql/api/DirectiveLocation.java | 2 +- .../graphql/api/federation/InterfaceObject.java | 2 +- .../smallrye/graphql/schema/FieldDirective.java | 4 ++-- .../io/smallrye/graphql/schema/InputTestApi.java | 16 ++++++++++++++++ .../graphql/schema/OperationDirective.java | 4 ++-- .../io/smallrye/graphql/schema/SchemaTest.java | 9 +++++++-- .../schema/schemadirectives/OutputDirective.java | 13 +++++++++++++ .../src/test/resources/schemaTest.graphql | 4 ++-- 24 files changed, 116 insertions(+), 24 deletions(-) create mode 100644 server/implementation/src/test/java/io/smallrye/graphql/schema/schemadirectives/OutputDirective.java diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/SchemaBuilder.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/SchemaBuilder.java index e952a61c8..b3e2184d0 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/SchemaBuilder.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/SchemaBuilder.java @@ -128,7 +128,7 @@ private Schema generateSchema() { Annotations annotations = Annotations.getAnnotationsForClass(graphQLApiAnnotation.target().asClass()); schema.getDirectiveInstances() .addAll(directivesHelper - .buildDirectiveInstances(annotations) + .buildDirectiveInstances(annotations, "SCHEMA") .stream() .map(directiveInstance -> { String directiveClassName = directiveInstance.getType().getClassName(); diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ArgumentCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ArgumentCreator.java index 39adb695a..63834b371 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ArgumentCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ArgumentCreator.java @@ -39,6 +39,11 @@ public ArgumentCreator(ReferenceCreator referenceCreator) { deprecatedHelper = new DeprecatedDirectivesHelper(); } + @Override + public String getDirectiveLocation() { + return "ARGUMENT_DEFINITION"; + } + /** * Create an argument model. Arguments exist on Operations as input parameters * diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/DirectiveTypeCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/DirectiveTypeCreator.java index f28b35891..e199caacf 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/DirectiveTypeCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/DirectiveTypeCreator.java @@ -26,6 +26,12 @@ public DirectiveTypeCreator(ReferenceCreator referenceCreator) { super(referenceCreator); } + @Override + public String getDirectiveLocation() { + throw new IllegalArgumentException( + "This method should never be called since 'DirectiveType' cannot have another directives"); + } + private static DotName NON_NULL = DotName.createSimple("org.eclipse.microprofile.graphql.NonNull"); public DirectiveType create(ClassInfo classInfo) { diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/FieldCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/FieldCreator.java index 21593d12a..a0be34b60 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/FieldCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/FieldCreator.java @@ -40,6 +40,11 @@ public FieldCreator(ReferenceCreator referenceCreator) { deprecatedHelper = new DeprecatedDirectivesHelper(); } + @Override + public String getDirectiveLocation() { + return "FIELD_DEFINITION"; + } + /** * Creates a field from a method only.This is used in the case of an interface * diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ModelCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ModelCreator.java index 354f90d5e..1b53f997b 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ModelCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/ModelCreator.java @@ -43,7 +43,7 @@ public TypeAutoNameStrategy getTypeAutoNameStrategy() { } /** - * The the return type.This is usually the method return type, but can also be adapted to something else + * The return type.This is usually the method return type, but can also be adapted to something else * * @param methodInfo method * @return the return type @@ -60,6 +60,8 @@ protected static Type getReturnType(FieldInfo fieldInfo) { } + public abstract String getDirectiveLocation(); + protected void populateField(Direction direction, Field field, Type type, Annotations annotations) { // Wrapper field.setWrapper(WrapperCreator.createWrapper(type).orElse(null)); @@ -97,7 +99,15 @@ private void doPopulateField(Direction direction, Field field, Type type, Annota // Directives if (directives != null) { // this happens while scanning for the directive types - field.addDirectiveInstances(directives.buildDirectiveInstances(annotations)); + field.addDirectiveInstances(directives.buildDirectiveInstances(annotations, getDirectiveLocation(direction))); + } + } + + private String getDirectiveLocation(Direction direction) { + String directiveLocation = getDirectiveLocation(); + if (direction.equals(Direction.IN) && directiveLocation.equals("FIELD_DEFINITION")) { + return "INPUT_FIELD_DEFINITION"; } + return directiveLocation; } } diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/OperationCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/OperationCreator.java index b946d6c63..9e1dc5845 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/OperationCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/OperationCreator.java @@ -255,4 +255,9 @@ private void addDirectivesForRolesAllowed(Annotations annotationsForPojo, Annota operation.addDirectiveInstance(rolesAllowedDirectives); } } + + @Override + public String getDirectiveLocation() { + return "FIELD_DEFINITION"; + } } diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/AbstractCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/AbstractCreator.java index 4d6e662b8..47bc237b8 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/AbstractCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/AbstractCreator.java @@ -74,15 +74,14 @@ public Type create(ClassInfo classInfo, Reference reference) { addOperations(type, classInfo); // Directives - addDirectives(type, annotations); - + addDirectives(type, annotations, getDirectiveLocation()); return type; } protected abstract void addFields(Type type, ClassInfo classInfo, Reference reference); - private void addDirectives(Type type, Annotations annotations) { - type.setDirectiveInstances(directives.buildDirectiveInstances(annotations)); + private void addDirectives(Type type, Annotations annotations, String directiveLocation) { + type.setDirectiveInstances(directives.buildDirectiveInstances(annotations, directiveLocation)); } private void addPolymorphicTypes(Type type, ClassInfo classInfo, Reference reference) { diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/Creator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/Creator.java index 6b6cafa56..c860bbeb1 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/Creator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/Creator.java @@ -13,4 +13,6 @@ public interface Creator { T create(ClassInfo classInfo, Reference reference); + + String getDirectiveLocation(); } diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/EnumCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/EnumCreator.java index 177374a12..c74a060ca 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/EnumCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/EnumCreator.java @@ -77,8 +77,13 @@ public EnumType create(ClassInfo classInfo, Reference reference) { return enumType; } + @Override + public String getDirectiveLocation() { + return "ENUM"; + } + private List getDirectiveInstances(Annotations annotations) { - return directives.buildDirectiveInstances(annotations); + return directives.buildDirectiveInstances(annotations, getDirectiveLocation()); } } diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/InputTypeCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/InputTypeCreator.java index 613bf1004..8f27c9d9b 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/InputTypeCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/InputTypeCreator.java @@ -37,7 +37,6 @@ */ public class InputTypeCreator implements Creator { private static final Logger LOG = Logger.getLogger(InputTypeCreator.class.getName()); - private final FieldCreator fieldCreator; private Directives directives; @@ -78,6 +77,11 @@ public InputType create(ClassInfo classInfo, Reference reference) { return inputType; } + @Override + public String getDirectiveLocation() { + return "INPUT_OBJECT"; + } + public boolean hasUseableConstructor(ClassInfo classInfo) { MethodInfo constructor = findCreator(classInfo); return constructor != null; @@ -138,7 +142,7 @@ public void setDirectives(Directives directives) { } private List getDirectiveInstances(Annotations annotations) { - return directives.buildDirectiveInstances(annotations); + return directives.buildDirectiveInstances(annotations, getDirectiveLocation()); } private void addFields(InputType inputType, ClassInfo classInfo, Reference reference) { diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/InterfaceCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/InterfaceCreator.java index b88c31ea5..8a21bca0b 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/InterfaceCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/InterfaceCreator.java @@ -57,6 +57,11 @@ protected void addFields(Type interfaceType, ClassInfo classInfo, Reference refe } } + @Override + public String getDirectiveLocation() { + return "INTERFACE"; + } + private static final String JAVA_DOT = "java."; /** diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/TypeCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/TypeCreator.java index 3bf2fd724..b9de3fee2 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/TypeCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/TypeCreator.java @@ -112,4 +112,8 @@ private boolean isNotGenericType(MethodInfo method) { type.kind() != org.jboss.jandex.Type.Kind.PARAMETERIZED_TYPE); } + @Override + public String getDirectiveLocation() { + return "OBJECT"; + } } diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/UnionCreator.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/UnionCreator.java index 0df64f3af..85667e91e 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/UnionCreator.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/creator/type/UnionCreator.java @@ -41,4 +41,11 @@ public UnionType create(ClassInfo classInfo, Reference reference) { return new UnionType(classInfo.name().toString(), name, maybeDescription.orElse(null)); } + + // TODO: create feature that allows adding UNION directives (graphql.schema) + @Override + public String getDirectiveLocation() { + return "UNION"; + } + } diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/Directives.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/Directives.java index 06ddcd9fd..cf4dfb44d 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/Directives.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/helper/Directives.java @@ -38,12 +38,13 @@ public Directives(List directiveTypes) { } } - public List buildDirectiveInstances(Annotations annotations) { + public List buildDirectiveInstances(Annotations annotations, String directiveLocation) { // only build directive instances from `@Directive` annotations here (that means the `directiveTypes` map), // because `directiveTypesOther` directives get their instances added on-the-go by classes that extend `ModelCreator` return directiveTypes.keySet().stream() .flatMap(annotations::resolve) .map(this::toDirectiveInstance) + .filter(directiveInstance -> directiveInstance.getType().getLocations().contains(directiveLocation)) .collect(toList()); } diff --git a/common/schema-builder/src/test/java/io/smallrye/graphql/index/SchemaBuilderTest.java b/common/schema-builder/src/test/java/io/smallrye/graphql/index/SchemaBuilderTest.java index d538812e1..0552ca470 100644 --- a/common/schema-builder/src/test/java/io/smallrye/graphql/index/SchemaBuilderTest.java +++ b/common/schema-builder/src/test/java/io/smallrye/graphql/index/SchemaBuilderTest.java @@ -153,7 +153,7 @@ public void testSchemaWithDirectives() throws IOException { assertEquals("someDirective", someDirective.getName()); assertEquals(SomeDirective.class.getName(), someDirective.getClassName()); assertEquals(singleton("value"), someDirective.argumentNames()); - assertEquals(new HashSet<>(asList("INTERFACE", "FIELD", "OBJECT")), someDirective.getLocations()); + assertEquals(new HashSet<>(asList("INTERFACE", "FIELD_DEFINITION", "OBJECT")), someDirective.getLocations()); // check directive instances on type Type movie = schema.getTypes().get("Movie"); diff --git a/common/schema-builder/src/test/java/io/smallrye/graphql/index/app/SomeDirective.java b/common/schema-builder/src/test/java/io/smallrye/graphql/index/app/SomeDirective.java index f6011f26b..e25826c0a 100644 --- a/common/schema-builder/src/test/java/io/smallrye/graphql/index/app/SomeDirective.java +++ b/common/schema-builder/src/test/java/io/smallrye/graphql/index/app/SomeDirective.java @@ -1,6 +1,6 @@ package io.smallrye.graphql.index.app; -import static io.smallrye.graphql.api.DirectiveLocation.FIELD; +import static io.smallrye.graphql.api.DirectiveLocation.FIELD_DEFINITION; import static io.smallrye.graphql.api.DirectiveLocation.INTERFACE; import static io.smallrye.graphql.api.DirectiveLocation.OBJECT; import static java.lang.annotation.RetentionPolicy.RUNTIME; @@ -9,7 +9,7 @@ import io.smallrye.graphql.api.Directive; -@Directive(on = { OBJECT, INTERFACE, FIELD }) +@Directive(on = { OBJECT, INTERFACE, FIELD_DEFINITION }) @Retention(RUNTIME) public @interface SomeDirective { String[] value(); diff --git a/server/api/src/main/java/io/smallrye/graphql/api/DirectiveLocation.java b/server/api/src/main/java/io/smallrye/graphql/api/DirectiveLocation.java index 4f457d948..83ebf57ea 100644 --- a/server/api/src/main/java/io/smallrye/graphql/api/DirectiveLocation.java +++ b/server/api/src/main/java/io/smallrye/graphql/api/DirectiveLocation.java @@ -32,7 +32,7 @@ public enum DirectiveLocation { INLINE_FRAGMENT, VARIABLE_DEFINITION, - // TypeSystemDirectiveLocation + // TypeSystemDirectiveLocation: SCHEMA, SCALAR, OBJECT, diff --git a/server/api/src/main/java/io/smallrye/graphql/api/federation/InterfaceObject.java b/server/api/src/main/java/io/smallrye/graphql/api/federation/InterfaceObject.java index a294f1914..6d13b8986 100644 --- a/server/api/src/main/java/io/smallrye/graphql/api/federation/InterfaceObject.java +++ b/server/api/src/main/java/io/smallrye/graphql/api/federation/InterfaceObject.java @@ -1,6 +1,6 @@ package io.smallrye.graphql.api.federation; -import static io.smallrye.graphql.api.DirectiveLocation.*; +import static io.smallrye.graphql.api.DirectiveLocation.OBJECT; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Retention; diff --git a/server/implementation/src/test/java/io/smallrye/graphql/schema/FieldDirective.java b/server/implementation/src/test/java/io/smallrye/graphql/schema/FieldDirective.java index 5f3aaea3d..97456b9cf 100644 --- a/server/implementation/src/test/java/io/smallrye/graphql/schema/FieldDirective.java +++ b/server/implementation/src/test/java/io/smallrye/graphql/schema/FieldDirective.java @@ -1,6 +1,6 @@ package io.smallrye.graphql.schema; -import static io.smallrye.graphql.api.DirectiveLocation.FIELD; +import static io.smallrye.graphql.api.DirectiveLocation.FIELD_DEFINITION; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Retention; @@ -8,6 +8,6 @@ import io.smallrye.graphql.api.Directive; @Retention(RUNTIME) -@Directive(on = FIELD) +@Directive(on = FIELD_DEFINITION) public @interface FieldDirective { } diff --git a/server/implementation/src/test/java/io/smallrye/graphql/schema/InputTestApi.java b/server/implementation/src/test/java/io/smallrye/graphql/schema/InputTestApi.java index 2a515d9dc..721970614 100644 --- a/server/implementation/src/test/java/io/smallrye/graphql/schema/InputTestApi.java +++ b/server/implementation/src/test/java/io/smallrye/graphql/schema/InputTestApi.java @@ -3,6 +3,8 @@ import org.eclipse.microprofile.graphql.GraphQLApi; import org.eclipse.microprofile.graphql.Query; +import io.smallrye.graphql.schema.schemadirectives.OutputDirective; + @GraphQLApi public class InputTestApi { @@ -11,6 +13,11 @@ public int query(InputWithDirectives input) { return 0; } + @Query + public int someQuery(SomeObject someObject) { + return 1; + } + @InputDirective public static class InputWithDirectives { @InputDirective @@ -21,4 +28,13 @@ public void setBar(int bar) { } } + @OutputDirective + public static class SomeObject { + int boo; + + public void setBoo(int boo) { + this.boo = boo; + } + } + } diff --git a/server/implementation/src/test/java/io/smallrye/graphql/schema/OperationDirective.java b/server/implementation/src/test/java/io/smallrye/graphql/schema/OperationDirective.java index 703f52a1d..ff066dc9f 100644 --- a/server/implementation/src/test/java/io/smallrye/graphql/schema/OperationDirective.java +++ b/server/implementation/src/test/java/io/smallrye/graphql/schema/OperationDirective.java @@ -1,6 +1,6 @@ package io.smallrye.graphql.schema; -import static io.smallrye.graphql.api.DirectiveLocation.*; +import static io.smallrye.graphql.api.DirectiveLocation.FIELD_DEFINITION; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Retention; @@ -8,6 +8,6 @@ import io.smallrye.graphql.api.Directive; @Retention(RUNTIME) -@Directive(on = { QUERY, MUTATION, SUBSCRIPTION }) +@Directive(on = { FIELD_DEFINITION }) public @interface OperationDirective { } diff --git a/server/implementation/src/test/java/io/smallrye/graphql/schema/SchemaTest.java b/server/implementation/src/test/java/io/smallrye/graphql/schema/SchemaTest.java index 33506d955..dbff14f39 100644 --- a/server/implementation/src/test/java/io/smallrye/graphql/schema/SchemaTest.java +++ b/server/implementation/src/test/java/io/smallrye/graphql/schema/SchemaTest.java @@ -55,6 +55,7 @@ import io.smallrye.graphql.schema.rolesallowedschemas.RolesSchema2; import io.smallrye.graphql.schema.rolesallowedschemas.RolesSchema3; import io.smallrye.graphql.schema.schemadirectives.NonRepeatableSchemaDirective; +import io.smallrye.graphql.schema.schemadirectives.OutputDirective; import io.smallrye.graphql.schema.schemadirectives.RepeatableSchemaDirective; import io.smallrye.graphql.schema.schemadirectives.Schema1; import io.smallrye.graphql.schema.schemadirectives.Schema2; @@ -125,8 +126,8 @@ void schemaWithEnumDirectives() { @Test void schemaWithInputDirectives() { - GraphQLSchema graphQLSchema = createGraphQLSchema(InputDirective.class, InputTestApi.class, - InputTestApi.InputWithDirectives.class); + GraphQLSchema graphQLSchema = createGraphQLSchema(InputDirective.class, OutputDirective.class, InputTestApi.class, + InputTestApi.InputWithDirectives.class, InputTestApi.SomeObject.class); GraphQLInputObjectType inputWithDirectives = graphQLSchema.getTypeAs("InputWithDirectivesInput"); assertNotNull(inputWithDirectives.getDirective("inputDirective"), @@ -135,6 +136,10 @@ void schemaWithInputDirectives() { "Input type field InputWithDirectivesInput.foo should have directive @inputDirective"); assertNotNull(inputWithDirectives.getField("bar").getDirective("inputDirective"), "Input type field InputWithDirectivesInput.bar should have directive @inputDirective"); + + GraphQLInputObjectType outputAsInputWithDirectives = graphQLSchema.getTypeAs("SomeObjectInput"); + assertNull(outputAsInputWithDirectives.getDirective("outputDirective"), + "Input type SomeObject should not have directive @outputDirective"); } @Test diff --git a/server/implementation/src/test/java/io/smallrye/graphql/schema/schemadirectives/OutputDirective.java b/server/implementation/src/test/java/io/smallrye/graphql/schema/schemadirectives/OutputDirective.java new file mode 100644 index 000000000..7fe1248a6 --- /dev/null +++ b/server/implementation/src/test/java/io/smallrye/graphql/schema/schemadirectives/OutputDirective.java @@ -0,0 +1,13 @@ +package io.smallrye.graphql.schema.schemadirectives; + +import static io.smallrye.graphql.api.DirectiveLocation.OBJECT; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Retention; + +import io.smallrye.graphql.api.Directive; + +@Retention(RUNTIME) +@Directive(on = { OBJECT }) +public @interface OutputDirective { +} diff --git a/server/implementation/src/test/resources/schemaTest.graphql b/server/implementation/src/test/resources/schemaTest.graphql index 8247f9173..62d402354 100644 --- a/server/implementation/src/test/resources/schemaTest.graphql +++ b/server/implementation/src/test/resources/schemaTest.graphql @@ -9,7 +9,7 @@ directive @deprecated( reason: String = "No longer supported" ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | ENUM_VALUE | INPUT_FIELD_DEFINITION -directive @fieldDirective on FIELD +directive @fieldDirective on FIELD_DEFINITION "Directs the executor to include this field or fragment only when the `if` argument is true" directive @include( @@ -20,7 +20,7 @@ directive @include( "test-description" directive @intArrayTestDirective(value: [Int]) on OBJECT | INTERFACE -directive @operationDirective on QUERY | MUTATION | SUBSCRIPTION +directive @operationDirective on FIELD_DEFINITION "Used to specify the role required to execute a given field or operation." directive @rolesAllowed(value: String) on FIELD_DEFINITION