From a87737b9a7369974693b056db56d226e2987ee90 Mon Sep 17 00:00:00 2001 From: Roman Lovakov Date: Wed, 4 Sep 2024 18:57:20 +0300 Subject: [PATCH 01/10] Added resolver for federation queries --- .../smallrye/graphql/schema/Annotations.java | 1 + .../graphql/schema/SchemaBuilder.java | 3 ++ .../schema/creator/OperationCreator.java | 2 + .../graphql/schema/model/OperationType.java | 3 +- .../smallrye/graphql/schema/model/Schema.java | 17 ++++++ .../graphql/api/federation/Resolver.java | 15 ++++++ .../graphql/entry/http/IndexInitializer.java | 2 + .../smallrye/graphql/bootstrap/Bootstrap.java | 54 +++++++++++++++++-- .../bootstrap/FederationDataFetcher.java | 16 +++++- 9 files changed, 106 insertions(+), 7 deletions(-) create mode 100644 server/api/src/main/java/io/smallrye/graphql/api/federation/Resolver.java diff --git a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Annotations.java b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Annotations.java index 3123a0d64..971dd5525 100644 --- a/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Annotations.java +++ b/common/schema-builder/src/main/java/io/smallrye/graphql/schema/Annotations.java @@ -590,6 +590,7 @@ private static Map getAnnotationsWithFilter(org.jbo public static final DotName ERROR_CODE = DotName.createSimple("io.smallrye.graphql.api.ErrorCode"); public static final DotName DATAFETCHER = DotName.createSimple("io.smallrye.graphql.api.DataFetcher"); public static final DotName SUBCRIPTION = DotName.createSimple("io.smallrye.graphql.api.Subscription"); + public static final DotName RESOLVER = DotName.createSimple("io.smallrye.graphql.api.federation.Resolver"); public static final DotName DIRECTIVE = DotName.createSimple("io.smallrye.graphql.api.Directive"); public static final DotName DEFAULT_NON_NULL = DotName.createSimple("io.smallrye.graphql.api.DefaultNonNull"); public static final DotName NULLABLE = DotName.createSimple("io.smallrye.graphql.api.Nullable"); 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 0d819a3f1..39566d1a4 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 @@ -386,6 +386,9 @@ private void addOperations(Optional group, Schema schema, List queries = new HashSet<>(); private Set mutations = new HashSet<>(); private Set subscriptions = new HashSet<>(); + private Set resolvers = new HashSet<>(); private Map> groupedQueries = new HashMap<>(); private Map> groupedMutations = new HashMap<>(); @@ -95,6 +96,22 @@ public boolean hasSubscriptions() { return !this.subscriptions.isEmpty(); } + public Set getResolvers() { + return resolvers; + } + + public void setResolvers(Set resolvers) { + this.resolvers = resolvers; + } + + public void addResolver(Operation resolver) { + this.resolvers.add(resolver); + } + + public boolean hasResolvers() { + return !this.resolvers.isEmpty(); + } + public Map> getGroupedQueries() { return groupedQueries; } diff --git a/server/api/src/main/java/io/smallrye/graphql/api/federation/Resolver.java b/server/api/src/main/java/io/smallrye/graphql/api/federation/Resolver.java new file mode 100644 index 000000000..98e617a14 --- /dev/null +++ b/server/api/src/main/java/io/smallrye/graphql/api/federation/Resolver.java @@ -0,0 +1,15 @@ +package io.smallrye.graphql.api.federation; + +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import io.smallrye.common.annotation.Experimental; + +@Target(ElementType.METHOD) +@Retention(RUNTIME) +@Experimental("Resolver method without creating query method") +public @interface Resolver { +} diff --git a/server/implementation-servlet/src/main/java/io/smallrye/graphql/entry/http/IndexInitializer.java b/server/implementation-servlet/src/main/java/io/smallrye/graphql/entry/http/IndexInitializer.java index 92610c307..6a4a189ce 100644 --- a/server/implementation-servlet/src/main/java/io/smallrye/graphql/entry/http/IndexInitializer.java +++ b/server/implementation-servlet/src/main/java/io/smallrye/graphql/entry/http/IndexInitializer.java @@ -41,6 +41,7 @@ import io.smallrye.graphql.api.federation.Override; import io.smallrye.graphql.api.federation.Provides; import io.smallrye.graphql.api.federation.Requires; +import io.smallrye.graphql.api.federation.Resolver; import io.smallrye.graphql.api.federation.Shareable; import io.smallrye.graphql.api.federation.Tag; import io.smallrye.graphql.api.federation.link.Import; @@ -126,6 +127,7 @@ private IndexView createCustomIndex() { indexer.index(convertClassToInputStream(Shareable.class)); indexer.index(convertClassToInputStream(Tag.class)); indexer.index(convertClassToInputStream(OneOf.class)); + indexer.index(convertClassToInputStream(Resolver.class)); } catch (IOException ex) { throw new RuntimeException(ex); } diff --git a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java index 1eaf74ff6..45225b7b1 100644 --- a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java +++ b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java @@ -30,6 +30,7 @@ import com.apollographql.federation.graphqljava.Federation; +import graphql.Scalars; import graphql.introspection.Introspection.DirectiveLocation; import graphql.schema.Coercing; import graphql.schema.DataFetcher; @@ -124,7 +125,7 @@ public static GraphQLSchema bootstrap(Schema schema) { } public static GraphQLSchema bootstrap(Schema schema, boolean skipInjectionValidation) { - if (schema != null && (schema.hasOperations())) { + if (schema != null && (schema.hasOperations()) || Config.get().isFederationEnabled()) { Bootstrap bootstrap = new Bootstrap(schema, skipInjectionValidation); bootstrap.generateGraphQLSchema(); return bootstrap.graphQLSchema; @@ -185,7 +186,11 @@ private void generateGraphQLSchema() { createGraphQLObjectTypes(); createGraphQLInputObjectTypes(); - addQueries(schemaBuilder); + GraphQLObjectType resolversType = Config.get().isFederationEnabled() + ? buildResolvers() + : GraphQLObjectType.newObject().name("Resolver").build(); + + GraphQLObjectType queryRootType = addQueries(schemaBuilder); addMutations(schemaBuilder); addSubscriptions(schemaBuilder); schemaBuilder.withSchemaAppliedDirectives(Arrays.stream( @@ -214,9 +219,20 @@ private void generateGraphQLSchema() { if (Config.get().isFederationEnabled()) { log.enableFederation(); + + if (!(schema.hasQueries() || schema.hasResolvers() || schema.hasMutations() || schema.hasSubscriptions())) { + throw new RuntimeException("You must define at least one method marked with one of the annotations - " + + "@Query, @Mutation, @Subscription, @Resolver. An empty diagram has no meaning"); + } + + // hack! For schema build success if queries are empty. + // It will be overrides in Federation transformation + addSdlQueryToSchema(schemaBuilder, queryRootType); + GraphQLSchema rawSchema = schemaBuilder.build(); this.graphQLSchema = Federation.transform(rawSchema) - .fetchEntities(new FederationDataFetcher(rawSchema.getQueryType(), rawSchema.getCodeRegistry())) + .fetchEntities( + new FederationDataFetcher(resolversType, rawSchema.getQueryType(), rawSchema.getCodeRegistry())) .resolveEntityType(fetchEntityType()) .setFederation2(true) .build(); @@ -225,6 +241,35 @@ private void generateGraphQLSchema() { } } + private void addSdlQueryToSchema(GraphQLSchema.Builder schemaBuilder, GraphQLObjectType queryRootType) { + GraphQLObjectType type = GraphQLObjectType.newObject() + .name("_Service") + .field(GraphQLFieldDefinition + .newFieldDefinition().name("sdl") + .type(new GraphQLNonNull(Scalars.GraphQLString)) + .build()) + .build(); + + GraphQLFieldDefinition field = GraphQLFieldDefinition.newFieldDefinition() + .name("_service") + .type(GraphQLNonNull.nonNull(type)) + .build(); + + GraphQLObjectType.Builder newQueryType = GraphQLObjectType.newObject(queryRootType); + + newQueryType.field(field); + schemaBuilder.query(newQueryType.build()); + } + + private GraphQLObjectType buildResolvers() { + GraphQLObjectType.Builder queryBuilder = GraphQLObjectType.newObject() + .name("Resolver"); + if (schema.hasResolvers()) { + addRootObject(queryBuilder, schema.getResolvers(), "Resolver"); + } + return queryBuilder.build(); + } + private TypeResolver fetchEntityType() { return env -> { Object src = env.getObject(); @@ -326,7 +371,7 @@ private void createGraphQLDirectiveType(DirectiveType directiveType) { directiveTypes.add(directiveBuilder.build()); } - private void addQueries(GraphQLSchema.Builder schemaBuilder) { + private GraphQLObjectType addQueries(GraphQLSchema.Builder schemaBuilder) { GraphQLObjectType.Builder queryBuilder = GraphQLObjectType.newObject() .name(QUERY) .description(QUERY_DESCRIPTION); @@ -340,6 +385,7 @@ private void addQueries(GraphQLSchema.Builder schemaBuilder) { GraphQLObjectType query = queryBuilder.build(); schemaBuilder.query(query); + return query; } private void addMutations(GraphQLSchema.Builder schemaBuilder) { diff --git a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/FederationDataFetcher.java b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/FederationDataFetcher.java index 43d14724a..03db934e5 100644 --- a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/FederationDataFetcher.java +++ b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/FederationDataFetcher.java @@ -38,10 +38,13 @@ public class FederationDataFetcher implements DataFetcher cache = new HashMap<>(); - public FederationDataFetcher(GraphQLObjectType queryType, GraphQLCodeRegistry codeRegistry) { + public FederationDataFetcher(GraphQLObjectType resolversType, GraphQLObjectType queryType, + GraphQLCodeRegistry codeRegistry) { + this.resolversType = resolversType; this.queryType = queryType; this.codeRegistry = codeRegistry; } @@ -115,6 +118,11 @@ private TypeFieldWrapper findBatchFieldDefinition(TypeAndArgumentNames typeAndAr return typeFieldWrapper; } } + for (GraphQLFieldDefinition field : resolversType.getFields()) { + if (matchesReturnTypeList(field, typeAndArgumentNames.type) && matchesArguments(typeAndArgumentNames, field)) { + return new TypeFieldWrapper(resolversType, field); + } + } return null; } @@ -131,7 +139,11 @@ private TypeFieldWrapper findFieldDefinition(TypeAndArgumentNames typeAndArgumen return typeFieldWrapper; } } - + for (GraphQLFieldDefinition field : resolversType.getFields()) { + if (matchesReturnType(field, typeAndArgumentNames.type) && matchesArguments(typeAndArgumentNames, field)) { + return new TypeFieldWrapper(resolversType, field); + } + } throw new RuntimeException( "no query found for " + typeAndArgumentNames.type + " by " + typeAndArgumentNames.argumentNames); } From 4948ed5974f1e1db3323df8b652d2306ba44f25b Mon Sep 17 00:00:00 2001 From: Marek Skacelik Date: Mon, 2 Sep 2024 15:08:56 +0200 Subject: [PATCH 02/10] added second execution of surefire pluginu (for tck client model suite execution) --- client/implementation-vertx/pom.xml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/client/implementation-vertx/pom.xml b/client/implementation-vertx/pom.xml index ad76f0e1c..760630248 100644 --- a/client/implementation-vertx/pom.xml +++ b/client/implementation-vertx/pom.xml @@ -71,4 +71,33 @@ test + + + + org.apache.maven.plugins + maven-surefire-plugin + + + + default-test + + TypesafeTckClientModelSuite + + + + separate-execution-for-client-model-tests + test + + test + + + TypesafeTckClientModelSuite + + + + + + From f1a8dc52775e755c821852a4496d8cf1eff9f364 Mon Sep 17 00:00:00 2001 From: Marek Skacelik Date: Mon, 2 Sep 2024 15:09:17 +0200 Subject: [PATCH 03/10] Added Union/Interface implementation for client model --- .../test/tck/TypesafeTckClientModelSuite.java | 1 - .../graphql/client/model/Annotations.java | 1 + .../graphql/client/model/Classes.java | 8 ++++ .../client/model/helper/OperationModel.java | 12 +++++ .../client/model/helper/TypeModel.java | 47 +++++++++++++++++++ 5 files changed, 68 insertions(+), 1 deletion(-) diff --git a/client/implementation-vertx/src/test/java/test/tck/TypesafeTckClientModelSuite.java b/client/implementation-vertx/src/test/java/test/tck/TypesafeTckClientModelSuite.java index 937ed103a..97e8e5386 100644 --- a/client/implementation-vertx/src/test/java/test/tck/TypesafeTckClientModelSuite.java +++ b/client/implementation-vertx/src/test/java/test/tck/TypesafeTckClientModelSuite.java @@ -45,7 +45,6 @@ class TypesafeTckClientModelSuite extends TypesafeTCK { static void beforeAll() { // These properties are for the ‘TypesafeGraphQLClientBuilder#builder’ to differentiate between the typesafe-client // using the client model and the one that does not. - System.clearProperty("clientModelCase"); System.setProperty("clientModelCase", "true"); } diff --git a/client/model-builder/src/main/java/io/smallrye/graphql/client/model/Annotations.java b/client/model-builder/src/main/java/io/smallrye/graphql/client/model/Annotations.java index 9fe7aff72..ef0af9910 100644 --- a/client/model-builder/src/main/java/io/smallrye/graphql/client/model/Annotations.java +++ b/client/model-builder/src/main/java/io/smallrye/graphql/client/model/Annotations.java @@ -578,6 +578,7 @@ private static Map getAnnotationsWithFilter(Type ty public static final DotName JAKARTA_JSONB_TRANSIENT = DotName.createSimple(JAKARTA_JSONB + "JsonbTransient"); public static final DotName JAKARTA_JSONB_CREATOR = DotName.createSimple(JAKARTA_JSONB + "JsonbCreator"); public static final DotName JAKARTA_JSONB_TYPE_ADAPTER = DotName.createSimple(JAKARTA_JSONB + "JsonbTypeAdapter"); + public static final DotName JAKARTA_JSONB_TYPE_INFO = DotName.createSimple(JAKARTA_JSONB + "JsonbTypeInfo"); // Jackson Annotations public static final DotName JACKSON_IGNORE = DotName.createSimple("com.fasterxml.jackson.annotation.JsonIgnore"); diff --git a/client/model-builder/src/main/java/io/smallrye/graphql/client/model/Classes.java b/client/model-builder/src/main/java/io/smallrye/graphql/client/model/Classes.java index 7825262f3..be7b48f93 100644 --- a/client/model-builder/src/main/java/io/smallrye/graphql/client/model/Classes.java +++ b/client/model-builder/src/main/java/io/smallrye/graphql/client/model/Classes.java @@ -72,6 +72,14 @@ public static boolean isAsync(Type type) { || isMulti(type); } + public static boolean isInterface(Type type) { + if (Classes.isClass(type)) { + ClassInfo clazz = getIndex().getClassByName(type.asClassType().name()); + return clazz != null && clazz.isInterface(); + } + return false; + } + public static boolean isUni(Type type) { return type.name().equals(UNI); } diff --git a/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/OperationModel.java b/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/OperationModel.java index cbfc70218..f42266801 100644 --- a/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/OperationModel.java +++ b/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/OperationModel.java @@ -9,6 +9,7 @@ import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; +import java.util.Comparator; import java.util.List; import java.util.Optional; import java.util.Stack; @@ -100,6 +101,13 @@ public String recursionCheckedFields(TypeModel type) { String valueFields = fields(type.getMapValueType()); return " {key" + keyFields + " value" + valueFields + "}"; } + if (type.isUnion() || type.isInterface()) { + return "{__typename " + type.subtypes() + .sorted(Comparator.comparing(TypeModel::getGraphQlTypeName)) // for deterministic order + .map(this::fieldsFragment) + .collect(joining(" ")) + + "}"; + } if (isRawParametrizedType(type)) { rawParametrizedTypes.push(type.getFirstRawType()); } @@ -409,4 +417,8 @@ private String readGroupName(MethodInfo method) { } return null; } + private String fieldsFragment(TypeModel type) { + return "... on " + type.getGraphQlTypeName() + fields(type); + } + } diff --git a/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/TypeModel.java b/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/TypeModel.java index 93bdd0c80..619106feb 100644 --- a/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/TypeModel.java +++ b/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/TypeModel.java @@ -3,6 +3,9 @@ import static io.smallrye.graphql.client.model.Annotations.IGNORE; import static io.smallrye.graphql.client.model.Annotations.JACKSON_IGNORE; import static io.smallrye.graphql.client.model.Annotations.JAKARTA_JSONB_TRANSIENT; +import static io.smallrye.graphql.client.model.Annotations.JAKARTA_JSONB_TYPE_INFO; +import static io.smallrye.graphql.client.model.Annotations.TYPE; +import static io.smallrye.graphql.client.model.Annotations.UNION; import static io.smallrye.graphql.client.model.Classes.ERROR_OR; import static io.smallrye.graphql.client.model.Classes.OBJECT; import static io.smallrye.graphql.client.model.Classes.OPTIONAL; @@ -20,6 +23,7 @@ import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationTarget; +import org.jboss.jandex.AnnotationValue; import org.jboss.jandex.ClassInfo; import org.jboss.jandex.DotName; import org.jboss.jandex.FieldInfo; @@ -361,6 +365,21 @@ public boolean isTypeVariable() { return Classes.isTypeVariable(type); } + /** + * @see GraphQL Union + */ + public boolean isUnion() { + return type.hasAnnotation(UNION); + } + + /** + * Is this a GraphQL Interface, i.e. a Java interface without a @Union annotation. + * + */ + public boolean isInterface() { + return Classes.isInterface(type) && !isUnion(); + } + /** * Retrieves a stream of FieldModel instances representing the fields of the type. * @@ -477,4 +496,32 @@ public boolean isCustomParametrizedType() { && !isMap() && !isCollection(); } + + public String getGraphQlTypeName() { + Optional annotationInstance = getClassAnnotation(TYPE); + if (annotationInstance.isPresent()) { + AnnotationValue value = annotationInstance.get().value(); + if (value != null) { + return value.asString(); + } + } + return getSimpleName(); + } + + /** + * Retrieves the subtypes of the current class based on the `JsonbTypeInfo` annotation. + * + * @return A stream of subtype models. + */ + public Stream subtypes() { + Optional jsonbTypeInfoAnnotation = getClassAnnotation(JAKARTA_JSONB_TYPE_INFO); + if (jsonbTypeInfoAnnotation.isEmpty()) { + return Stream.empty(); + } + + return Stream.of(jsonbTypeInfoAnnotation.get().value().asNestedArray()) + .map(annotationInstance -> annotationInstance.value("type")) + .map(AnnotationValue::asClass) + .map(TypeModel::of); + } } From 57d7c414ef132d74caaf72d74b746f0527447aed Mon Sep 17 00:00:00 2001 From: Jan Martiska Date: Fri, 6 Sep 2024 11:59:58 +0200 Subject: [PATCH 04/10] Formatting --- .../io/smallrye/graphql/client/model/helper/OperationModel.java | 1 + 1 file changed, 1 insertion(+) diff --git a/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/OperationModel.java b/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/OperationModel.java index f42266801..ba3844152 100644 --- a/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/OperationModel.java +++ b/client/model-builder/src/main/java/io/smallrye/graphql/client/model/helper/OperationModel.java @@ -417,6 +417,7 @@ private String readGroupName(MethodInfo method) { } return null; } + private String fieldsFragment(TypeModel type) { return "... on " + type.getGraphQlTypeName() + fields(type); } From 40731b0078be9b8a744d6a57d8206d133fe61234 Mon Sep 17 00:00:00 2001 From: Jan Martiska Date: Fri, 6 Sep 2024 11:40:56 +0200 Subject: [PATCH 05/10] Release 2.10.0 --- .github/project.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/project.yml b/.github/project.yml index 5dd491938..03e3dd1e5 100644 --- a/.github/project.yml +++ b/.github/project.yml @@ -1,4 +1,4 @@ name: SmallRye GraphQL release: - current-version: 2.9.2 - next-version: 2.9.3-SNAPSHOT + current-version: 2.10.0 + next-version: 2.10.1-SNAPSHOT From 590eff0cb752a6de211c71aafb7f3af2df11a3ec Mon Sep 17 00:00:00 2001 From: SmallRye CI Date: Fri, 6 Sep 2024 10:52:07 +0000 Subject: [PATCH 06/10] Update Gradle plugin version --- tools/gradle-plugin/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gradle-plugin/gradle.properties b/tools/gradle-plugin/gradle.properties index 101122f45..4a35443f0 100644 --- a/tools/gradle-plugin/gradle.properties +++ b/tools/gradle-plugin/gradle.properties @@ -1 +1 @@ -version=2.9.2 +version=2.10.0 From 039a8528315a57e5ae509964ccc9de312e295887 Mon Sep 17 00:00:00 2001 From: SmallRye CI Date: Fri, 6 Sep 2024 10:56:25 +0000 Subject: [PATCH 07/10] [maven-release-plugin] prepare release 2.10.0 --- client/api/pom.xml | 2 +- client/generator-test/pom.xml | 2 +- client/generator/pom.xml | 2 +- client/implementation-vertx/pom.xml | 2 +- client/implementation/pom.xml | 2 +- client/model-builder/pom.xml | 2 +- client/model/pom.xml | 2 +- client/pom.xml | 2 +- client/tck/pom.xml | 2 +- common/pom.xml | 2 +- common/schema-builder/pom.xml | 2 +- common/schema-model/pom.xml | 2 +- docs/pom.xml | 2 +- pom.xml | 4 ++-- release/pom.xml | 2 +- server/api/pom.xml | 2 +- server/implementation-cdi/pom.xml | 2 +- server/implementation-servlet/pom.xml | 2 +- server/implementation/pom.xml | 2 +- server/integration-tests-jdk16/pom.xml | 2 +- server/integration-tests/pom.xml | 2 +- server/pom.xml | 2 +- server/runner/pom.xml | 2 +- server/tck/pom.xml | 2 +- tools/gradle-plugin/pom.xml | 2 +- tools/maven-plugin-tests/pom.xml | 2 +- tools/maven-plugin/pom.xml | 2 +- tools/pom.xml | 2 +- ui/graphiql/pom.xml | 2 +- ui/pom.xml | 2 +- 30 files changed, 31 insertions(+), 31 deletions(-) diff --git a/client/api/pom.xml b/client/api/pom.xml index b6e7c4e4b..becd848e5 100644 --- a/client/api/pom.xml +++ b/client/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-client-api diff --git a/client/generator-test/pom.xml b/client/generator-test/pom.xml index a41d3db4a..dcb6cd0c8 100644 --- a/client/generator-test/pom.xml +++ b/client/generator-test/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-client-generator-test diff --git a/client/generator/pom.xml b/client/generator/pom.xml index a3fb183c7..e06c9ba13 100644 --- a/client/generator/pom.xml +++ b/client/generator/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-client-generator diff --git a/client/implementation-vertx/pom.xml b/client/implementation-vertx/pom.xml index 760630248..efcf823a0 100644 --- a/client/implementation-vertx/pom.xml +++ b/client/implementation-vertx/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-client-implementation-vertx diff --git a/client/implementation/pom.xml b/client/implementation/pom.xml index 792cf6310..dd0ac6fdf 100644 --- a/client/implementation/pom.xml +++ b/client/implementation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-client diff --git a/client/model-builder/pom.xml b/client/model-builder/pom.xml index a4859ccfd..9739bdb85 100644 --- a/client/model-builder/pom.xml +++ b/client/model-builder/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-client-model-builder diff --git a/client/model/pom.xml b/client/model/pom.xml index c9930f4ca..8a8268c74 100644 --- a/client/model/pom.xml +++ b/client/model/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-client-model diff --git a/client/pom.xml b/client/pom.xml index 8945b7829..cc7b11ba9 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-client-parent diff --git a/client/tck/pom.xml b/client/tck/pom.xml index a56d92da0..6b98543ce 100644 --- a/client/tck/pom.xml +++ b/client/tck/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-client-tck diff --git a/common/pom.xml b/common/pom.xml index 590b584d9..6514f8b37 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-common-parent diff --git a/common/schema-builder/pom.xml b/common/schema-builder/pom.xml index e852890be..e3980ed7d 100644 --- a/common/schema-builder/pom.xml +++ b/common/schema-builder/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-common-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-schema-builder diff --git a/common/schema-model/pom.xml b/common/schema-model/pom.xml index 8a20dc961..492d3ead6 100644 --- a/common/schema-model/pom.xml +++ b/common/schema-model/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-common-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-schema-model diff --git a/docs/pom.xml b/docs/pom.xml index c2f513c6f..cf8b860b3 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-documentation diff --git a/pom.xml b/pom.xml index 3176ec841..ffb9856c3 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ smallrye-graphql-parent - 2.9.3-SNAPSHOT + 2.10.0 pom SmallRye: GraphQL Parent @@ -87,7 +87,7 @@ scm:git:git@github.com:smallrye/smallrye-graphql.git scm:git:git@github.com:smallrye/smallrye-graphql.git https://github.com/smallrye/smallrye-graphql/ - HEAD + 2.10.0 diff --git a/release/pom.xml b/release/pom.xml index 0ea0ed1c6..4d061821b 100644 --- a/release/pom.xml +++ b/release/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-release diff --git a/server/api/pom.xml b/server/api/pom.xml index 81fa6c0c7..c2661eeaf 100644 --- a/server/api/pom.xml +++ b/server/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-api diff --git a/server/implementation-cdi/pom.xml b/server/implementation-cdi/pom.xml index d4cf0ff14..b1abf5950 100644 --- a/server/implementation-cdi/pom.xml +++ b/server/implementation-cdi/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-cdi diff --git a/server/implementation-servlet/pom.xml b/server/implementation-servlet/pom.xml index a1c0b4f15..6f94333e7 100644 --- a/server/implementation-servlet/pom.xml +++ b/server/implementation-servlet/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-servlet diff --git a/server/implementation/pom.xml b/server/implementation/pom.xml index d8679a983..296a763d9 100644 --- a/server/implementation/pom.xml +++ b/server/implementation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql diff --git a/server/integration-tests-jdk16/pom.xml b/server/integration-tests-jdk16/pom.xml index 1644d0bf9..cee135204 100644 --- a/server/integration-tests-jdk16/pom.xml +++ b/server/integration-tests-jdk16/pom.xml @@ -3,7 +3,7 @@ smallrye-graphql-server-parent io.smallrye - 2.9.3-SNAPSHOT + 2.10.0 4.0.0 diff --git a/server/integration-tests/pom.xml b/server/integration-tests/pom.xml index 7de929b42..745812a77 100644 --- a/server/integration-tests/pom.xml +++ b/server/integration-tests/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-server-parent - 2.9.3-SNAPSHOT + 2.10.0 4.0.0 diff --git a/server/pom.xml b/server/pom.xml index b66281a42..955424c60 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-server-parent diff --git a/server/runner/pom.xml b/server/runner/pom.xml index 0bc54d8be..610430476 100644 --- a/server/runner/pom.xml +++ b/server/runner/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-runner diff --git a/server/tck/pom.xml b/server/tck/pom.xml index a6506f9ca..a565723ce 100644 --- a/server/tck/pom.xml +++ b/server/tck/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-server-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-tck diff --git a/tools/gradle-plugin/pom.xml b/tools/gradle-plugin/pom.xml index b1bc2be3e..60a2f28b2 100644 --- a/tools/gradle-plugin/pom.xml +++ b/tools/gradle-plugin/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.9.3-SNAPSHOT + 2.10.0 4.0.0 diff --git a/tools/maven-plugin-tests/pom.xml b/tools/maven-plugin-tests/pom.xml index d1e973137..f43130927 100644 --- a/tools/maven-plugin-tests/pom.xml +++ b/tools/maven-plugin-tests/pom.xml @@ -3,7 +3,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.9.3-SNAPSHOT + 2.10.0 4.0.0 diff --git a/tools/maven-plugin/pom.xml b/tools/maven-plugin/pom.xml index 6239867d6..cdbbc1d8a 100644 --- a/tools/maven-plugin/pom.xml +++ b/tools/maven-plugin/pom.xml @@ -3,7 +3,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.9.3-SNAPSHOT + 2.10.0 4.0.0 diff --git a/tools/pom.xml b/tools/pom.xml index ba152f629..160565b10 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-tools-parent diff --git a/ui/graphiql/pom.xml b/ui/graphiql/pom.xml index 4ecff753e..e5236e468 100644 --- a/ui/graphiql/pom.xml +++ b/ui/graphiql/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-ui-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-ui-graphiql diff --git a/ui/pom.xml b/ui/pom.xml index 9a9835a42..73a8ff5e3 100644 --- a/ui/pom.xml +++ b/ui/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.9.3-SNAPSHOT + 2.10.0 smallrye-graphql-ui-parent From 9b2861f2cfd8c8cbf30807c926146f98b1f95dd1 Mon Sep 17 00:00:00 2001 From: SmallRye CI Date: Fri, 6 Sep 2024 10:56:26 +0000 Subject: [PATCH 08/10] [maven-release-plugin] prepare for next development iteration --- client/api/pom.xml | 2 +- client/generator-test/pom.xml | 2 +- client/generator/pom.xml | 2 +- client/implementation-vertx/pom.xml | 2 +- client/implementation/pom.xml | 2 +- client/model-builder/pom.xml | 2 +- client/model/pom.xml | 2 +- client/pom.xml | 2 +- client/tck/pom.xml | 2 +- common/pom.xml | 2 +- common/schema-builder/pom.xml | 2 +- common/schema-model/pom.xml | 2 +- docs/pom.xml | 2 +- pom.xml | 4 ++-- release/pom.xml | 2 +- server/api/pom.xml | 2 +- server/implementation-cdi/pom.xml | 2 +- server/implementation-servlet/pom.xml | 2 +- server/implementation/pom.xml | 2 +- server/integration-tests-jdk16/pom.xml | 2 +- server/integration-tests/pom.xml | 2 +- server/pom.xml | 2 +- server/runner/pom.xml | 2 +- server/tck/pom.xml | 2 +- tools/gradle-plugin/pom.xml | 2 +- tools/maven-plugin-tests/pom.xml | 2 +- tools/maven-plugin/pom.xml | 2 +- tools/pom.xml | 2 +- ui/graphiql/pom.xml | 2 +- ui/pom.xml | 2 +- 30 files changed, 31 insertions(+), 31 deletions(-) diff --git a/client/api/pom.xml b/client/api/pom.xml index becd848e5..98b9fdab8 100644 --- a/client/api/pom.xml +++ b/client/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-client-api diff --git a/client/generator-test/pom.xml b/client/generator-test/pom.xml index dcb6cd0c8..e3a27779c 100644 --- a/client/generator-test/pom.xml +++ b/client/generator-test/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-client-generator-test diff --git a/client/generator/pom.xml b/client/generator/pom.xml index e06c9ba13..69cd69ee4 100644 --- a/client/generator/pom.xml +++ b/client/generator/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-client-generator diff --git a/client/implementation-vertx/pom.xml b/client/implementation-vertx/pom.xml index efcf823a0..990b526ce 100644 --- a/client/implementation-vertx/pom.xml +++ b/client/implementation-vertx/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-client-implementation-vertx diff --git a/client/implementation/pom.xml b/client/implementation/pom.xml index dd0ac6fdf..992b246ad 100644 --- a/client/implementation/pom.xml +++ b/client/implementation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-client diff --git a/client/model-builder/pom.xml b/client/model-builder/pom.xml index 9739bdb85..5c5ef0171 100644 --- a/client/model-builder/pom.xml +++ b/client/model-builder/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-client-model-builder diff --git a/client/model/pom.xml b/client/model/pom.xml index 8a8268c74..8bbeaecdb 100644 --- a/client/model/pom.xml +++ b/client/model/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-client-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-client-model diff --git a/client/pom.xml b/client/pom.xml index cc7b11ba9..35e6e7e93 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-client-parent diff --git a/client/tck/pom.xml b/client/tck/pom.xml index 6b98543ce..49cce2dee 100644 --- a/client/tck/pom.xml +++ b/client/tck/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-client-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-client-tck diff --git a/common/pom.xml b/common/pom.xml index 6514f8b37..bace4a416 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-common-parent diff --git a/common/schema-builder/pom.xml b/common/schema-builder/pom.xml index e3980ed7d..ea0425d1e 100644 --- a/common/schema-builder/pom.xml +++ b/common/schema-builder/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-common-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-schema-builder diff --git a/common/schema-model/pom.xml b/common/schema-model/pom.xml index 492d3ead6..273c2d120 100644 --- a/common/schema-model/pom.xml +++ b/common/schema-model/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-common-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-schema-model diff --git a/docs/pom.xml b/docs/pom.xml index cf8b860b3..535a1ae5b 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-documentation diff --git a/pom.xml b/pom.xml index ffb9856c3..e0372429c 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ smallrye-graphql-parent - 2.10.0 + 2.10.1-SNAPSHOT pom SmallRye: GraphQL Parent @@ -87,7 +87,7 @@ scm:git:git@github.com:smallrye/smallrye-graphql.git scm:git:git@github.com:smallrye/smallrye-graphql.git https://github.com/smallrye/smallrye-graphql/ - 2.10.0 + HEAD diff --git a/release/pom.xml b/release/pom.xml index 4d061821b..704609442 100644 --- a/release/pom.xml +++ b/release/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-release diff --git a/server/api/pom.xml b/server/api/pom.xml index c2661eeaf..a07dff0b1 100644 --- a/server/api/pom.xml +++ b/server/api/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-api diff --git a/server/implementation-cdi/pom.xml b/server/implementation-cdi/pom.xml index b1abf5950..78e3b5cba 100644 --- a/server/implementation-cdi/pom.xml +++ b/server/implementation-cdi/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-cdi diff --git a/server/implementation-servlet/pom.xml b/server/implementation-servlet/pom.xml index 6f94333e7..258e4f448 100644 --- a/server/implementation-servlet/pom.xml +++ b/server/implementation-servlet/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-servlet diff --git a/server/implementation/pom.xml b/server/implementation/pom.xml index 296a763d9..9e68e0227 100644 --- a/server/implementation/pom.xml +++ b/server/implementation/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql diff --git a/server/integration-tests-jdk16/pom.xml b/server/integration-tests-jdk16/pom.xml index cee135204..e99987b4b 100644 --- a/server/integration-tests-jdk16/pom.xml +++ b/server/integration-tests-jdk16/pom.xml @@ -3,7 +3,7 @@ smallrye-graphql-server-parent io.smallrye - 2.10.0 + 2.10.1-SNAPSHOT 4.0.0 diff --git a/server/integration-tests/pom.xml b/server/integration-tests/pom.xml index 745812a77..111827718 100644 --- a/server/integration-tests/pom.xml +++ b/server/integration-tests/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-server-parent - 2.10.0 + 2.10.1-SNAPSHOT 4.0.0 diff --git a/server/pom.xml b/server/pom.xml index 955424c60..fec6d8c88 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-server-parent diff --git a/server/runner/pom.xml b/server/runner/pom.xml index 610430476..5b3f708f3 100644 --- a/server/runner/pom.xml +++ b/server/runner/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-server-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-runner diff --git a/server/tck/pom.xml b/server/tck/pom.xml index a565723ce..b3be60fec 100644 --- a/server/tck/pom.xml +++ b/server/tck/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-server-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-tck diff --git a/tools/gradle-plugin/pom.xml b/tools/gradle-plugin/pom.xml index 60a2f28b2..e7810abc7 100644 --- a/tools/gradle-plugin/pom.xml +++ b/tools/gradle-plugin/pom.xml @@ -4,7 +4,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.10.0 + 2.10.1-SNAPSHOT 4.0.0 diff --git a/tools/maven-plugin-tests/pom.xml b/tools/maven-plugin-tests/pom.xml index f43130927..a373a85bc 100644 --- a/tools/maven-plugin-tests/pom.xml +++ b/tools/maven-plugin-tests/pom.xml @@ -3,7 +3,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.10.0 + 2.10.1-SNAPSHOT 4.0.0 diff --git a/tools/maven-plugin/pom.xml b/tools/maven-plugin/pom.xml index cdbbc1d8a..73b708ea5 100644 --- a/tools/maven-plugin/pom.xml +++ b/tools/maven-plugin/pom.xml @@ -3,7 +3,7 @@ io.smallrye smallrye-graphql-tools-parent - 2.10.0 + 2.10.1-SNAPSHOT 4.0.0 diff --git a/tools/pom.xml b/tools/pom.xml index 160565b10..7471e60d0 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-tools-parent diff --git a/ui/graphiql/pom.xml b/ui/graphiql/pom.xml index e5236e468..d220213ff 100644 --- a/ui/graphiql/pom.xml +++ b/ui/graphiql/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-ui-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-ui-graphiql diff --git a/ui/pom.xml b/ui/pom.xml index 73a8ff5e3..cef207c19 100644 --- a/ui/pom.xml +++ b/ui/pom.xml @@ -5,7 +5,7 @@ io.smallrye smallrye-graphql-parent - 2.10.0 + 2.10.1-SNAPSHOT smallrye-graphql-ui-parent From 7cbe942524fab320a49d57c0ae1c69b7f3186cae Mon Sep 17 00:00:00 2001 From: Roman Lovakov Date: Mon, 9 Sep 2024 13:05:48 +0300 Subject: [PATCH 09/10] Refactoring, add simple tests --- .../smallrye/graphql/bootstrap/Bootstrap.java | 13 +- .../graphql/execution/ResolverTest.java | 155 ++++++++++++++++++ .../graphql/test/resolver/ExtendedApi.java | 25 +++ .../graphql/test/resolver/ExtendedType.java | 55 +++++++ .../mavenplugin/GenerateSchemaMojo.java | 4 +- 5 files changed, 244 insertions(+), 8 deletions(-) create mode 100644 server/implementation/src/test/java/io/smallrye/graphql/execution/ResolverTest.java create mode 100644 server/implementation/src/test/java/io/smallrye/graphql/test/resolver/ExtendedApi.java create mode 100644 server/implementation/src/test/java/io/smallrye/graphql/test/resolver/ExtendedType.java diff --git a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java index 45225b7b1..0b55347dd 100644 --- a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java +++ b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/Bootstrap.java @@ -125,7 +125,7 @@ public static GraphQLSchema bootstrap(Schema schema) { } public static GraphQLSchema bootstrap(Schema schema, boolean skipInjectionValidation) { - if (schema != null && (schema.hasOperations()) || Config.get().isFederationEnabled()) { + if (schema != null && (schema.hasOperations() || Config.get().isFederationEnabled())) { Bootstrap bootstrap = new Bootstrap(schema, skipInjectionValidation); bootstrap.generateGraphQLSchema(); return bootstrap.graphQLSchema; @@ -186,10 +186,6 @@ private void generateGraphQLSchema() { createGraphQLObjectTypes(); createGraphQLInputObjectTypes(); - GraphQLObjectType resolversType = Config.get().isFederationEnabled() - ? buildResolvers() - : GraphQLObjectType.newObject().name("Resolver").build(); - GraphQLObjectType queryRootType = addQueries(schemaBuilder); addMutations(schemaBuilder); addSubscriptions(schemaBuilder); @@ -227,7 +223,10 @@ private void generateGraphQLSchema() { // hack! For schema build success if queries are empty. // It will be overrides in Federation transformation - addSdlQueryToSchema(schemaBuilder, queryRootType); + addDummySdlQuery(schemaBuilder, queryRootType); + + // Build reference resolvers type, without adding to schema (just for federation) + GraphQLObjectType resolversType = buildResolvers(); GraphQLSchema rawSchema = schemaBuilder.build(); this.graphQLSchema = Federation.transform(rawSchema) @@ -241,7 +240,7 @@ private void generateGraphQLSchema() { } } - private void addSdlQueryToSchema(GraphQLSchema.Builder schemaBuilder, GraphQLObjectType queryRootType) { + private void addDummySdlQuery(GraphQLSchema.Builder schemaBuilder, GraphQLObjectType queryRootType) { GraphQLObjectType type = GraphQLObjectType.newObject() .name("_Service") .field(GraphQLFieldDefinition diff --git a/server/implementation/src/test/java/io/smallrye/graphql/execution/ResolverTest.java b/server/implementation/src/test/java/io/smallrye/graphql/execution/ResolverTest.java new file mode 100644 index 000000000..278f0585f --- /dev/null +++ b/server/implementation/src/test/java/io/smallrye/graphql/execution/ResolverTest.java @@ -0,0 +1,155 @@ +package io.smallrye.graphql.execution; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; + +import java.io.IOException; +import java.io.InputStream; +import java.util.stream.Stream; + +import jakarta.json.JsonObject; +import jakarta.json.JsonString; +import jakarta.json.JsonValue; + +import org.jboss.jandex.IndexView; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import graphql.schema.GraphQLSchema; +import io.smallrye.graphql.api.Directive; +import io.smallrye.graphql.api.federation.Extends; +import io.smallrye.graphql.api.federation.External; +import io.smallrye.graphql.api.federation.Key; +import io.smallrye.graphql.api.federation.Requires; +import io.smallrye.graphql.bootstrap.Bootstrap; +import io.smallrye.graphql.schema.SchemaBuilder; +import io.smallrye.graphql.schema.model.Schema; +import io.smallrye.graphql.spi.config.Config; +import io.smallrye.graphql.test.resolver.ExtendedApi; +import io.smallrye.graphql.test.resolver.ExtendedType; + +/** + * Test for Federated namespaces + */ +public class ResolverTest { + private static final TestConfig config = (TestConfig) Config.get(); + private static ExecutionService executionService; + + @AfterAll + static void afterAll() { + config.reset(); + config.federationEnabled = false; + System.setProperty("smallrye.graphql.federation.enabled", "false"); + } + + @BeforeAll + static void beforeAll() { + config.federationEnabled = true; + System.setProperty("smallrye.graphql.federation.enabled", "true"); + + IndexView index = buildIndex(Directive.class, Key.class, External.class, Key.Keys.class, + Extends.class, Requires.class, ExtendedType.class, ExtendedApi.class); + + GraphQLSchema graphQLSchema = createGraphQLSchema(index); + Schema schema = SchemaBuilder.build(index); + executionService = new ExecutionService(graphQLSchema, schema); + } + + private static IndexView buildIndex(Class... classes) { + org.jboss.jandex.Indexer indexer = new org.jboss.jandex.Indexer(); + Stream.of(classes).forEach(cls -> index(indexer, cls)); + return indexer.complete(); + } + + private static InputStream getResourceStream(Class type) { + String name = type.getName().replace(".", "/") + ".class"; + return Thread.currentThread().getContextClassLoader().getResourceAsStream(name); + } + + private static void index(org.jboss.jandex.Indexer indexer, Class cls) { + try { + indexer.index(getResourceStream(cls)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private static GraphQLSchema createGraphQLSchema(IndexView index) { + Schema schema = SchemaBuilder.build(index); + assertNotNull(schema, "Schema should not be null"); + GraphQLSchema graphQLSchema = Bootstrap.bootstrap(schema, true); + assertNotNull(graphQLSchema, "GraphQLSchema should not be null"); + return graphQLSchema; + } + + private static JsonObject executeAndGetResult(String graphQL) { + JsonObjectResponseWriter jsonObjectResponseWriter = new JsonObjectResponseWriter(graphQL); + jsonObjectResponseWriter.logInput(); + executionService.executeSync(jsonObjectResponseWriter.getInput(), jsonObjectResponseWriter); + jsonObjectResponseWriter.logOutput(); + return jsonObjectResponseWriter.getOutput(); + } + + @Test + public void findByIdTest() { + JsonObject jsonObject = executeAndGetResult(TEST_ID_QUERY); + assertNotNull(jsonObject); + + JsonValue jsonValue = jsonObject.getJsonObject("data") + .getJsonArray("_entities") + .getJsonObject(0) + .get("id"); + assertEquals(((JsonString) jsonValue).getString(), "id"); + + jsonValue = jsonObject.getJsonObject("data") + .getJsonArray("_entities") + .getJsonObject(0) + .get("value"); + assertNull(jsonValue); + } + + @Test + public void extendsTest() { + JsonObject jsonObject = executeAndGetResult(TEST_ID_NAME_KEY_QUERY); + assertNotNull(jsonObject); + + JsonValue jsonValue = jsonObject.getJsonObject("data") + .getJsonArray("_entities") + .getJsonObject(0) + .get("id"); + assertEquals(((JsonString) jsonValue).getString(), "id"); + + jsonValue = jsonObject.getJsonObject("data") + .getJsonArray("_entities") + .getJsonObject(0) + .get("value"); + assertEquals(((JsonString) jsonValue).getString(), "idnamekey"); + } + + private static final String TEST_ID_QUERY = "query {\n" + + "_entities(\n" + + " representations: { id: \"id\", __typename: \"ExtendedType\" }\n" + + ") {\n" + + " __typename\n" + + " ... on ExtendedType {\n" + + " id\n" + + " }\n" + + " }\n" + + "}"; + + private static final String TEST_ID_NAME_KEY_QUERY = "query {\n" + + "_entities(\n" + + " representations: { id: \"id\", name: \"name\", key: \"key\", __typename: \"ExtendedType\" }\n" + + ") {\n" + + " __typename\n" + + " ... on ExtendedType {\n" + + " id\n" + + " name\n" + + " key\n" + + " value\n" + + " }\n" + + " }\n" + + "}"; +} diff --git a/server/implementation/src/test/java/io/smallrye/graphql/test/resolver/ExtendedApi.java b/server/implementation/src/test/java/io/smallrye/graphql/test/resolver/ExtendedApi.java new file mode 100644 index 000000000..e224c570e --- /dev/null +++ b/server/implementation/src/test/java/io/smallrye/graphql/test/resolver/ExtendedApi.java @@ -0,0 +1,25 @@ +package io.smallrye.graphql.test.resolver; + +import org.eclipse.microprofile.graphql.GraphQLApi; + +import io.smallrye.graphql.api.federation.Resolver; + +@GraphQLApi +public class ExtendedApi { + @Resolver + public ExtendedType extendedTypeById(String id) { + ExtendedType extendedType = new ExtendedType(); + extendedType.setId(id); + return extendedType; + } + + @Resolver + public ExtendedType extendedTypeByIdNameKey(String id, String name, String key) { + ExtendedType extendedType = new ExtendedType(); + extendedType.setId(id); + extendedType.setName(name); + extendedType.setKey(key); + extendedType.setValue(id + name + key); + return extendedType; + } +} diff --git a/server/implementation/src/test/java/io/smallrye/graphql/test/resolver/ExtendedType.java b/server/implementation/src/test/java/io/smallrye/graphql/test/resolver/ExtendedType.java new file mode 100644 index 000000000..0d183f209 --- /dev/null +++ b/server/implementation/src/test/java/io/smallrye/graphql/test/resolver/ExtendedType.java @@ -0,0 +1,55 @@ +package io.smallrye.graphql.test.resolver; + +import io.smallrye.graphql.api.federation.Extends; +import io.smallrye.graphql.api.federation.External; +import io.smallrye.graphql.api.federation.FieldSet; +import io.smallrye.graphql.api.federation.Key; +import io.smallrye.graphql.api.federation.Requires; + +@Extends +@Key(fields = @FieldSet("id")) +public class ExtendedType { + @External + private String id; + + @External + private String name; + + @External + private String key; + + @Requires(fields = @FieldSet("name key")) + private String value; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/tools/maven-plugin/src/main/java/io/smallrye/graphql/mavenplugin/GenerateSchemaMojo.java b/tools/maven-plugin/src/main/java/io/smallrye/graphql/mavenplugin/GenerateSchemaMojo.java index f6fb2633a..90d2ad4de 100644 --- a/tools/maven-plugin/src/main/java/io/smallrye/graphql/mavenplugin/GenerateSchemaMojo.java +++ b/tools/maven-plugin/src/main/java/io/smallrye/graphql/mavenplugin/GenerateSchemaMojo.java @@ -254,7 +254,9 @@ private String generateSchema(IndexView index, boolean enableFederation) { GraphQLSchema graphQLSchema = Bootstrap.bootstrap(internalSchema, true); if (graphQLSchema != null && enableFederation) { graphQLSchema = Federation.transform(graphQLSchema) - .fetchEntities(new FederationDataFetcher(graphQLSchema.getQueryType(), graphQLSchema.getCodeRegistry())) + .fetchEntities(new FederationDataFetcher( + GraphQLObjectType.newObject().name("Resolver").build(), + graphQLSchema.getQueryType(), graphQLSchema.getCodeRegistry())) .resolveEntityType(fetchEntityType()) .setFederation2(true) .build(); From 4550ff2e286ea1cf61c906ffced4cdbbe3f896d5 Mon Sep 17 00:00:00 2001 From: Roman Lovakov Date: Thu, 12 Sep 2024 14:35:38 +0300 Subject: [PATCH 10/10] Resolvers have higher priority, update documentation --- docs/federation.md | 119 ++++++++++++++++++ .../bootstrap/FederationDataFetcher.java | 20 +-- 2 files changed, 129 insertions(+), 10 deletions(-) diff --git a/docs/federation.md b/docs/federation.md index 7f09c763f..3ed10fcf7 100644 --- a/docs/federation.md +++ b/docs/federation.md @@ -84,3 +84,122 @@ public class Prices { It is crucial that the sequence of argument list matches with the order of result list. Currently, the name of the Argument `id` must match with the property name in the type. +## Federation Reference Resolver + +In federation you also may want extend external type by some fields, without publishing queries into schema. You can do it using @Resolver + +```java +@Extends +@Key(fields = @FieldSet("upc")) +public final class Product { + @External + @NonNull + private String upc; + @External + private Integer weight; + @External + private Integer price; + private Boolean inStock; + @Requires(fields = @FieldSet("price weight")) + private Integer shippingPrice; +} + +@GraphQLApi +public class Api { + @Query // 0 query, that will be added into schema + public Product findByUPC(String upc) { + return new Product(upc , ...etc); + } + + @Resolver // 1 You dont receive external fields price weight here, just key + public Product resolveByUPC(String upc) { + return new Product(upc , ...etc); + } + + @Resolver // 2 The order of variables doesn't matter + public Product resolveByUPCForShipping(int price, String upc, @Name("weight") int someWeight) { + return new Product(upc , someWeight, price, (price * someWeight) /*calculate shippingPrice */, ...etc); + } + + @Resolver // 3 + public Product resolveByUPCForSource(int price, String upc) { + return new Product(upc, price, ...etc); + } + + @Requires(fields = @FieldSet("price")) + public int anotherWeight(@Source Product product) { + return product.price() * 2; + } +} +``` + +Will be generated next schema +``` +type Product @extends @key(fields : "upc") { + anotherWeight: Int! @requires(fields : "price") + inStock: Boolean + price: Int @external + shippingPrice: Int @requires(fields : "price weight") + upc: String! @external + weight: Int @external +} + +type Query { + _entities(representations: [_Any!]!): [_Entity]! + _service: _Service! +} +``` + +These methods will only be available to the federation router, which send next request +``` +// request 1 +query { + _entities(representations: [{ + "__typename": "Product", + "upc": "1" // just id key + }]) { + __typename + ... on Product { + inStock + } + } +} + +// request 2 +query { + _entities(representations: [{ + "__typename": "Product", + "upc": "1", // id key + "price": 100, // shippingPrice requires this field + "weight": 100 // shippingPrice requires this field + }]) { + __typename + ... on Product { + inStock + shippingPrice + } + } +} + +// request 3 +query { + _entities(representations: [{ + "__typename": "Product", + "upc": "2", + "price": 1299 // anotherWeight requires this field + } + ]) { + __typename + ... on Product { + anotherWeight + } + } +} +``` + +Unfortunately, you will have to make separate methods with different `@External` parameters. + +It is not currently possible to combine them into one separate type. + +You also can using @Query (if you want add queries into schema) or @Resolver (requests 0 and 1). +And if it was request `_entities` - @Resolvers methods are checked first (they have higher priority). diff --git a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/FederationDataFetcher.java b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/FederationDataFetcher.java index 03db934e5..279da5937 100644 --- a/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/FederationDataFetcher.java +++ b/server/implementation/src/main/java/io/smallrye/graphql/bootstrap/FederationDataFetcher.java @@ -106,6 +106,11 @@ && matchesArguments(typeAndArgumentNames, definition)) { } private TypeFieldWrapper findBatchFieldDefinition(TypeAndArgumentNames typeAndArgumentNames) { + for (GraphQLFieldDefinition field : resolversType.getFields()) { + if (matchesReturnTypeList(field, typeAndArgumentNames.type) && matchesArguments(typeAndArgumentNames, field)) { + return new TypeFieldWrapper(resolversType, field); + } + } for (GraphQLFieldDefinition field : queryType.getFields()) { if (matchesReturnTypeList(field, typeAndArgumentNames.type) && matchesArguments(typeAndArgumentNames, field)) { return new TypeFieldWrapper(queryType, field); @@ -118,15 +123,15 @@ private TypeFieldWrapper findBatchFieldDefinition(TypeAndArgumentNames typeAndAr return typeFieldWrapper; } } - for (GraphQLFieldDefinition field : resolversType.getFields()) { - if (matchesReturnTypeList(field, typeAndArgumentNames.type) && matchesArguments(typeAndArgumentNames, field)) { - return new TypeFieldWrapper(resolversType, field); - } - } return null; } private TypeFieldWrapper findFieldDefinition(TypeAndArgumentNames typeAndArgumentNames) { + for (GraphQLFieldDefinition field : resolversType.getFields()) { + if (matchesReturnType(field, typeAndArgumentNames.type) && matchesArguments(typeAndArgumentNames, field)) { + return new TypeFieldWrapper(resolversType, field); + } + } for (GraphQLFieldDefinition field : queryType.getFields()) { if (matchesReturnType(field, typeAndArgumentNames.type) && matchesArguments(typeAndArgumentNames, field)) { return new TypeFieldWrapper(queryType, field); @@ -139,11 +144,6 @@ private TypeFieldWrapper findFieldDefinition(TypeAndArgumentNames typeAndArgumen return typeFieldWrapper; } } - for (GraphQLFieldDefinition field : resolversType.getFields()) { - if (matchesReturnType(field, typeAndArgumentNames.type) && matchesArguments(typeAndArgumentNames, field)) { - return new TypeFieldWrapper(resolversType, field); - } - } throw new RuntimeException( "no query found for " + typeAndArgumentNames.type + " by " + typeAndArgumentNames.argumentNames); }