Skip to content

Commit

Permalink
Make sure Federation annotations are in the index, add a test
Browse files Browse the repository at this point in the history
(cherry picked from commit 7d129dd)
  • Loading branch information
jmartisk authored and gsmet committed Jan 4, 2023
1 parent 1499d1c commit b6eeaa0
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
import io.smallrye.graphql.api.AdaptWith;
import io.smallrye.graphql.api.Entry;
import io.smallrye.graphql.api.ErrorExtensionProvider;
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.Provides;
import io.smallrye.graphql.api.federation.Requires;
import io.smallrye.graphql.cdi.config.ConfigKey;
import io.smallrye.graphql.cdi.config.MicroProfileConfig;
import io.smallrye.graphql.cdi.producer.GraphQLProducer;
Expand Down Expand Up @@ -244,6 +249,11 @@ void buildFinalIndex(
try {
indexer.indexClass(Map.class);
indexer.indexClass(Entry.class);
indexer.indexClass(Extends.class);
indexer.indexClass(External.class);
indexer.indexClass(Key.class);
indexer.indexClass(Provides.class);
indexer.indexClass(Requires.class);
} catch (IOException ex) {
LOG.warn("Failure while creating index", ex);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package io.quarkus.smallrye.graphql.deployment;

import static org.hamcrest.Matchers.containsString;

import org.eclipse.microprofile.graphql.GraphQLApi;
import org.eclipse.microprofile.graphql.Query;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;
import io.restassured.RestAssured;
import io.smallrye.graphql.api.federation.Extends;

public class GraphQLFederationTest extends AbstractGraphQLTest {

@RegisterExtension
static QuarkusUnitTest test = new QuarkusUnitTest()
.withApplicationRoot((jar) -> jar
.addClasses(FooApi.class, Foo.class)
.addAsResource(new StringAsset("quarkus.smallrye-graphql.schema-include-directives=true"),
"application.properties")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"));

@Test
public void checkServiceDeclarationInSchema() {
RestAssured.given()
.get("/graphql/schema.graphql")
.then()
.body(containsString("type _Service {"));
}

@Test
public void checkFederationDirectivesInSchema() {
RestAssured.given()
.get("/graphql/schema.graphql")
.then()
.body(containsString("name: String @extends"));
}

@GraphQLApi
static class FooApi {

@Query
public Foo foo() {
return new Foo();
}

}

static class Foo {

@Extends
public String name;

}

}

0 comments on commit b6eeaa0

Please sign in to comment.