diff --git a/server/api/src/main/java/io/smallrye/graphql/api/federation/FederatedSource.java b/server/api/src/main/java/io/smallrye/graphql/api/federation/FederatedSource.java deleted file mode 100644 index 191936064..000000000 --- a/server/api/src/main/java/io/smallrye/graphql/api/federation/FederatedSource.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.smallrye.graphql.api.federation; - -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import io.smallrye.common.annotation.Experimental; - -/** - * A federated resolver method is the federated equivalent to a 'local' resolver method (with a parameter annotated as - * {@link org.eclipse.microprofile.graphql.Source @Source}), i.e. it adds a field with the name of the method - * and the type of the method return type to the source object. - * The class of the source parameter must be annotated as {@link Extends @Extends} - * and have at least one field annotated as {@link External @External}. - */ -@Retention(RUNTIME) -@Target(PARAMETER) -@Experimental("SmallRye GraphQL Federation is still subject to change.") -public @interface FederatedSource { -} diff --git a/server/implementation/src/main/java/io/smallrye/graphql/execution/ExecutionResponse.java b/server/implementation/src/main/java/io/smallrye/graphql/execution/ExecutionResponse.java index e623cf41b..5c955fb27 100644 --- a/server/implementation/src/main/java/io/smallrye/graphql/execution/ExecutionResponse.java +++ b/server/implementation/src/main/java/io/smallrye/graphql/execution/ExecutionResponse.java @@ -36,6 +36,10 @@ public ExecutionResponse(ExecutionResult executionResult) { this.executionResult = executionResult; } + public String toString() { + return "ExecutionResponse->" + executionResult; + } + public ExecutionResult getExecutionResult() { return this.executionResult; } diff --git a/server/tck/src/test/java/io/smallrye/graphql/SmallRyeGraphQLArchiveProcessor.java b/server/tck/src/test/java/io/smallrye/graphql/SmallRyeGraphQLArchiveProcessor.java index 9e814efe6..bc51216e3 100644 --- a/server/tck/src/test/java/io/smallrye/graphql/SmallRyeGraphQLArchiveProcessor.java +++ b/server/tck/src/test/java/io/smallrye/graphql/SmallRyeGraphQLArchiveProcessor.java @@ -12,6 +12,7 @@ import org.jboss.shrinkwrap.resolver.api.maven.Maven; import io.smallrye.graphql.api.Entry; +import io.smallrye.graphql.api.federation.Key; import io.smallrye.graphql.test.apps.adapt.to.api.AdaptToResource; import io.smallrye.graphql.test.apps.adapt.with.api.AdapterResource; import io.smallrye.graphql.test.apps.async.api.AsyncApi; @@ -23,6 +24,7 @@ import io.smallrye.graphql.test.apps.enumlist.api.EnumListApi; import io.smallrye.graphql.test.apps.error.api.ErrorApi; import io.smallrye.graphql.test.apps.exceptionlist.ExceptionListApi; +import io.smallrye.graphql.test.apps.federation.ProductApi; import io.smallrye.graphql.test.apps.fieldexistence.api.FieldExistenceApi; import io.smallrye.graphql.test.apps.generics.api.ControllerWithGenerics; import io.smallrye.graphql.test.apps.grouping.api.BookGraphQLApi; @@ -90,6 +92,8 @@ public void process(Archive applicationArchive, TestClass testClass) { // For our auto Map adaption war.addPackage(Entry.class.getPackage()); + // For the federation directives + war.addPackage(Key.class.getPackage()); // Add our own test app war.addPackage(ProfileGraphQLApi.class.getPackage()); war.addPackage(AdditionalScalarsApi.class.getPackage()); @@ -116,6 +120,7 @@ public void process(Archive applicationArchive, TestClass testClass) { war.addPackage(NonNullClass.class.getPackage()); war.addPackage(NonNullPackageClass.class.getPackage()); war.addPackage(StocksApi.class.getPackage()); + war.addPackage(ProductApi.class.getPackage()); } } } diff --git a/server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/product/api/Product.java b/server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/Product.java similarity index 90% rename from server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/product/api/Product.java rename to server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/Product.java index aa6ee7de6..65666661b 100644 --- a/server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/product/api/Product.java +++ b/server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/Product.java @@ -1,4 +1,4 @@ -package io.smallrye.graphql.test.apps.federation.product.api; +package io.smallrye.graphql.test.apps.federation; import org.eclipse.microprofile.graphql.Id; diff --git a/server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/product/api/Products.java b/server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/ProductApi.java similarity index 87% rename from server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/product/api/Products.java rename to server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/ProductApi.java index 5b91aedb6..7fae5144f 100644 --- a/server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/product/api/Products.java +++ b/server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/ProductApi.java @@ -1,4 +1,4 @@ -package io.smallrye.graphql.test.apps.federation.product.api; +package io.smallrye.graphql.test.apps.federation; import static java.util.Arrays.asList; @@ -9,7 +9,7 @@ import org.eclipse.microprofile.graphql.Query; @GraphQLApi -public class Products { +public class ProductApi { private static final List PRODUCTS = asList( Product.product("1", "Armchair"), Product.product("2", "Table")); diff --git a/server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/price/api/Prices.java b/server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/price/api/Prices.java deleted file mode 100644 index 11bf7d028..000000000 --- a/server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/price/api/Prices.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.smallrye.graphql.test.apps.federation.price.api; - -import static java.util.Arrays.asList; - -import java.util.List; - -import org.eclipse.microprofile.graphql.GraphQLApi; -import org.eclipse.microprofile.graphql.Id; -import org.eclipse.microprofile.graphql.Query; - -@GraphQLApi -public class Prices { - private static final List PRICES = asList( - ProductWithPrice.product("1", 100), - ProductWithPrice.product("2", 400)); - - @Query - public ProductWithPrice product(@Id String id) { - return PRICES.stream() - .filter(productWithPrice -> productWithPrice.getId().equals(id)) - .findFirst().orElseThrow(() -> new RuntimeException("product not find")); - } -} diff --git a/server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/price/api/ProductWithPrice.java b/server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/price/api/ProductWithPrice.java deleted file mode 100644 index 19131afb6..000000000 --- a/server/tck/src/test/java/io/smallrye/graphql/test/apps/federation/price/api/ProductWithPrice.java +++ /dev/null @@ -1,40 +0,0 @@ -package io.smallrye.graphql.test.apps.federation.price.api; - -import org.eclipse.microprofile.graphql.Id; - -import io.smallrye.graphql.api.federation.Extends; -import io.smallrye.graphql.api.federation.Key; - -/** - * In a real federated service, this would also be a {@code Price}, but we can't have the same type twice within one service. - */ -@Key(fields = "id") -@Extends -public class ProductWithPrice { - public static ProductWithPrice product(String id, int price) { - ProductWithPrice product = new ProductWithPrice(); - product.setId(id); - product.setPrice(price); - return product; - } - - @Id - private String id; - private int price; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public int getPrice() { - return price; - } - - public void setPrice(int price) { - this.price = price; - } -} diff --git a/server/tck/src/test/resources/META-INF/microprofile-config.properties b/server/tck/src/test/resources/META-INF/microprofile-config.properties index ad7b91b3f..a36a79132 100644 --- a/server/tck/src/test/resources/META-INF/microprofile-config.properties +++ b/server/tck/src/test/resources/META-INF/microprofile-config.properties @@ -6,4 +6,5 @@ smallrye.graphql.logPayload=true mp.graphql.showErrorMessage=java.security.AccessControlException,io.smallrye.graphql.test.apps.exceptionlist.* mp.graphql.hideErrorMessage=java.io.IOException,io.smallrye.graphql.test.apps.exceptionlist.* smallrye.graphql.errorExtensionFields=exception,classification,code,description,validationErrorType,queryPath -smallrye.graphql.parser.capture.sourceLocation=false \ No newline at end of file +smallrye.graphql.parser.capture.sourceLocation=false +smallrye.graphql.federation.enabled=true diff --git a/server/tck/src/test/resources/tests/federation/input.graphql b/server/tck/src/test/resources/tests/federation/input.graphql index a1b066fae..d2b130d63 100644 --- a/server/tck/src/test/resources/tests/federation/input.graphql +++ b/server/tck/src/test/resources/tests/federation/input.graphql @@ -1,8 +1,12 @@ -{ - deepList{ - names +query product { + _entities(representations: [{ + __typename: "Product", + id: "1" + }]) { + ... on Product { + __typename + name + id + } } - deepListFoo{ - bar - } -} \ No newline at end of file +} diff --git a/server/tck/src/test/resources/tests/federation/output.json b/server/tck/src/test/resources/tests/federation/output.json index a95b4f97f..57764221a 100644 --- a/server/tck/src/test/resources/tests/federation/output.json +++ b/server/tck/src/test/resources/tests/federation/output.json @@ -1,24 +1,11 @@ { "data": { - "deepList": [ - [ - [ - { - "names": [ - "Phillip" - ] - } - ] - ] - ], - "deepListFoo": [ - [ - [ - { - "bar": "bar" - } - ] - ] + "_entities": [ + { + "__typename": "Product", + "name": "Armchair", + "id": "1" + } ] } -} \ No newline at end of file +}