Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure Federation annotations are in the index, add a test #30143

Merged
merged 1 commit into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;

}

}