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

Mulitple cleanups in prep for non blocking #1331

Merged
merged 12 commits into from
Apr 3, 2022
Merged
12 changes: 8 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ jobs:
- uses: actions/checkout@v2
name: checkout

- uses: actions/setup-java@v1.4.3
- uses: actions/setup-java@v3.0.0
name: set up jdk ${{matrix.java}}
with:
java-version: ${{matrix.java}}
distribution: 'temurin'

- name: Install graphviz
run: sudo apt install graphviz
Expand Down Expand Up @@ -65,10 +66,11 @@ jobs:
restore-keys: |
${{ runner.os }}-maven-

- uses: actions/setup-java@v1.4.3
- uses: actions/setup-java@v3.0.0
name: set up jdk ${{matrix.java}}
with:
java-version: ${{matrix.java}}
distribution: 'temurin'

- name: build with maven
run: mvn -B install -DskipTests --file pom.xml
Expand Down Expand Up @@ -110,10 +112,11 @@ jobs:
restore-keys: |
${{ runner.os }}-maven-

- uses: actions/setup-java@v1.4.3
- uses: actions/setup-java@v3.0.0
name: set up jdk ${{matrix.java}}
with:
java-version: ${{matrix.java}}
distribution: 'temurin'

- name: build with maven
run: mvn -B install -DskipTests --file smallrye-graphql/pom.xml
Expand All @@ -138,9 +141,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1.4.3
- uses: actions/setup-java@v3.0.0
with:
java-version: 11
distribution: 'temurin'

- name: sonar
env:
Expand Down
Binary file modified client/implementation-vertx/src/test/resources/ssl/client.cert
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Empty file modified client/implementation-vertx/src/test/resources/ssl/generate.sh
100644 → 100755
Empty file.
Binary file modified client/implementation-vertx/src/test/resources/ssl/server.cert
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.jboss.jandex.Indexer;
import org.jboss.logging.Logger;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

Expand All @@ -48,15 +47,13 @@
* @author Phillip Kruger ([email protected])
*/
public class SchemaBuilderTest {
private static final Logger LOG = Logger.getLogger(SchemaBuilderTest.class.getName());
private static final Jsonb JSONB = JsonbBuilder.create(new JsonbConfig().withFormatting(true));

@Test
public void testSchemaModelCreation() {

IndexView index = getTCKIndex();
Schema schema = SchemaBuilder.build(index);
LOG.info(JSONB.toJson(schema));
assertNotNull(schema);
}

Expand Down Expand Up @@ -90,7 +87,6 @@ public void testConcurrentSchemaBuilding() throws Exception {
assertNotNull(movieSchema);

String basicSchemaString = JSONB.toJson(basicSchema);
LOG.info(basicSchemaString);
assertTrue(basicSchemaString.contains("org.eclipse.microprofile.graphql.tck.apps.basic.api.BasicType"));
assertTrue(basicSchemaString.contains("org.eclipse.microprofile.graphql.tck.apps.basic.api.BasicInput"));
assertTrue(basicSchemaString.contains("org.eclipse.microprofile.graphql.tck.apps.basic.api.BasicInterface"));
Expand All @@ -99,7 +95,6 @@ public void testConcurrentSchemaBuilding() throws Exception {
assertFalse(basicSchemaString.contains("io.smallrye.graphql"));

String heroSchemaString = JSONB.toJson(heroSchema);
LOG.info(heroSchemaString);
assertTrue(heroSchemaString.contains("org.eclipse.microprofile.graphql.tck.apps.superhero.model.SuperHero"));
assertTrue(heroSchemaString.contains("org.eclipse.microprofile.graphql.tck.apps.superhero.model.Sidekick"));
assertTrue(heroSchemaString.contains("org.eclipse.microprofile.graphql.tck.apps.superhero.model.Team"));
Expand All @@ -108,7 +103,6 @@ public void testConcurrentSchemaBuilding() throws Exception {
assertFalse(heroSchemaString.contains("io.smallrye.graphql"));

String movieSchemaString = JSONB.toJson(movieSchema);
LOG.info(movieSchemaString);
assertTrue(movieSchemaString.contains("io.smallrye.graphql.index.app.Movie"));
assertTrue(movieSchemaString.contains("io.smallrye.graphql.index.app.Person"));
assertFalse(movieSchemaString.contains("org.eclipse.microprofile.graphql.tck.apps.basic"));
Expand Down Expand Up @@ -146,14 +140,12 @@ public void testSchemaWithDirectives() throws IOException {
Index index = indexer.complete();

Schema schema = SchemaBuilder.build(index);
LOG.info(JSONB.toJson(schema));

// check directive types
assertTrue(schema.hasDirectiveTypes());
DirectiveType someDirective = schema.getDirectiveTypes().stream()
.filter(d -> d.getName().equals("someDirective"))
.findFirst().orElseThrow(NoSuchElementException::new);
LOG.info(JSONB.toJson(someDirective));
assertNotNull(someDirective);
assertEquals("someDirective", someDirective.getName());
assertEquals(SomeDirective.class.getName(), someDirective.getClassName());
Expand Down
19 changes: 19 additions & 0 deletions server/implementation-cdi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@
</property>
</activation>

<dependencies>
<dependency>
<groupId>org.eclipse.microprofile.graphql</groupId>
<artifactId>microprofile-graphql-tck</artifactId>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -173,6 +182,16 @@
<value>1.1-SNAPSHOT</value>
</property>
</activation>

<dependencies>
<dependency>
<groupId>org.eclipse.microprofile.graphql</groupId>
<artifactId>microprofile-graphql-server-tck</artifactId>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,53 +6,44 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.HashMap;
import java.util.Map;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.json.stream.JsonGenerator;

import org.jboss.jandex.IndexView;
import org.jboss.logging.Logger;
import org.jboss.weld.junit5.WeldInitiator;
import org.jboss.weld.junit5.WeldJunit5Extension;
import org.jboss.weld.junit5.WeldSetup;
import org.jboss.weld.junit5.auto.ActivateScopes;
import org.jboss.weld.junit5.auto.EnableAutoWeld;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import graphql.schema.GraphQLSchema;
import io.smallrye.graphql.bootstrap.Bootstrap;
import io.smallrye.graphql.cdi.CdiLookupService;
import io.smallrye.graphql.cdi.event.EventsService;
import io.smallrye.graphql.cdi.producer.GraphQLProducer;
import io.smallrye.graphql.schema.SchemaBuilder;
import io.smallrye.graphql.schema.model.Schema;
import io.smallrye.graphql.spi.LookupService;

/**
* Test a basic query
*
* @author Phillip Kruger ([email protected])
*/
@ExtendWith(WeldJunit5Extension.class)
@EnableAutoWeld
@ActivateScopes({ RequestScoped.class, ApplicationScoped.class })
public class CdiExecutionTest {
private static final Logger LOG = Logger.getLogger(CdiExecutionTest.class.getName());

private ExecutionService executionService;

@WeldSetup
public WeldInitiator weld = WeldInitiator.of(heroFinder, heroDatabase, sidekickDatabase, heroLocator, scalarTestApi,
EventsService.class, CdiLookupService.class);
@Inject
GraphQLProducer graphQLProducer;

@BeforeEach
public void init() {
IndexView index = Indexer.getTCKIndex();
Schema schema = SchemaBuilder.build(index);
GraphQLSchema graphQLSchema = Bootstrap.bootstrap(schema);
this.executionService = new ExecutionService(graphQLSchema, schema.getBatchOperations(),
schema.hasSubscriptions());
graphQLProducer.initialize(schema);
}

@Test
Expand Down Expand Up @@ -330,6 +321,7 @@ public void testInputWithDifferentNameOnInputAndType() {

private JsonObject executeAndGetData(String graphQL) {
JsonObjectResponseWriter jor = new JsonObjectResponseWriter(graphQL);
ExecutionService executionService = LookupService.get().getInstance(ExecutionService.class).get();
executionService.executeSync(toJsonObject(graphQL), jor);

ExecutionResponse result = jor.getExecutionResponse();
Expand All @@ -342,6 +334,7 @@ private JsonObject executeAndGetData(String graphQL) {

private JsonArray executeAndGetError(String graphQL) {
JsonObjectResponseWriter jor = new JsonObjectResponseWriter(graphQL);
ExecutionService executionService = LookupService.get().getInstance(ExecutionService.class).get();
executionService.executeSync(toJsonObject(graphQL), jor);
ExecutionResponse result = jor.getExecutionResponse();

Expand Down Expand Up @@ -581,27 +574,4 @@ private JsonObject toJsonObject(String graphQL) {
" }\n" +
"}";

// Create the CDI Beans in the TCK Tests app
private static final Class<?> heroFinder;
private static final Class<?> heroDatabase;
private static final Class<?> sidekickDatabase;
private static final Class<?> heroLocator;
private static final Class<?> scalarTestApi;

private static final Map<String, Object> JSON_PROPERTIES = new HashMap<>(1);

static {
try {
heroFinder = Class.forName("org.eclipse.microprofile.graphql.tck.apps.superhero.api.HeroFinder");
heroDatabase = Class.forName("org.eclipse.microprofile.graphql.tck.apps.superhero.db.HeroDatabase");
sidekickDatabase = Class.forName("org.eclipse.microprofile.graphql.tck.apps.superhero.db.SidekickDatabase");
heroLocator = Class.forName("org.eclipse.microprofile.graphql.tck.apps.superhero.db.HeroLocator");
scalarTestApi = Class.forName("org.eclipse.microprofile.graphql.tck.apps.basic.api.ScalarTestApi");
} catch (ClassNotFoundException ex) {
throw new RuntimeException(ex);
}

JSON_PROPERTIES.put(JsonGenerator.PRETTY_PRINTING, true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import javax.inject.Inject;
import javax.websocket.CloseReason;
import javax.websocket.OnClose;
import javax.websocket.OnError;
Expand All @@ -15,7 +14,6 @@

import org.jboss.logging.Logger;

import io.smallrye.graphql.execution.ExecutionService;
import io.smallrye.graphql.websocket.GraphQLWebSocketSession;
import io.smallrye.graphql.websocket.GraphQLWebsocketHandler;
import io.smallrye.graphql.websocket.graphqltransportws.GraphQLTransportWSSubprotocolHandler;
Expand All @@ -31,23 +29,18 @@ public class GraphQLServerWebSocket {

private final Logger log = Logger.getLogger(GraphQLServerWebSocket.class.getName());

private Map<Session, GraphQLWebsocketHandler> sessionsToHandlers = new ConcurrentHashMap<>();

@Inject
ExecutionService executionService;
private final Map<Session, GraphQLWebsocketHandler> sessionsToHandlers = new ConcurrentHashMap<>();

@OnOpen
public void onOpen(Session session) {
GraphQLWebsocketHandler handler = null;
String subprotocol = session.getNegotiatedSubprotocol();
switch (subprotocol) {
case "graphql-transport-ws":
handler = new GraphQLTransportWSSubprotocolHandler(new SmallRyeWebSocketSession(session),
executionService);
handler = new GraphQLTransportWSSubprotocolHandler(new SmallRyeWebSocketSession(session));
break;
case "graphql-ws":
handler = new GraphQLWSSubprotocolHandler(new SmallRyeWebSocketSession(session),
executionService);
handler = new GraphQLWSSubprotocolHandler(new SmallRyeWebSocketSession(session));
break;
default:
log.warn("Unknown subprotocol: " + subprotocol);
Expand Down
9 changes: 1 addition & 8 deletions server/implementation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
<artifactId>jakarta.json-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.context-propagation</groupId>
<artifactId>microprofile-context-propagation-api</artifactId>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
Expand All @@ -59,8 +54,6 @@
<dependency>
<groupId>io.smallrye.reactive</groupId>
<artifactId>mutiny</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>

<!-- Logging -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.dataloader.BatchLoaderWithContext;
import org.dataloader.DataLoader;
import org.dataloader.DataLoaderFactory;
import org.dataloader.DataLoaderOptions;
import org.dataloader.DataLoaderRegistry;

import graphql.ExecutionInput;
Expand All @@ -26,7 +25,6 @@
import graphql.execution.SubscriptionExecutionStrategy;
import graphql.schema.GraphQLSchema;
import io.smallrye.graphql.bootstrap.DataFetcherFactory;
import io.smallrye.graphql.execution.context.SmallRyeBatchLoaderContextProvider;
import io.smallrye.graphql.execution.context.SmallRyeContext;
import io.smallrye.graphql.execution.datafetcher.helper.BatchLoaderHelper;
import io.smallrye.graphql.execution.datafetcher.helper.ContextHelper;
Expand Down Expand Up @@ -245,11 +243,8 @@ private <K, T> DataLoaderRegistry getDataLoaderRegistry(List<Operation> operatio
DataLoaderRegistry dataLoaderRegistry = new DataLoaderRegistry();
for (Operation operation : operations) {
BatchLoaderWithContext<K, T> batchLoader = dataFetcherFactory.getSourceBatchLoader(operation);
SmallRyeBatchLoaderContextProvider ctxProvider = new SmallRyeBatchLoaderContextProvider();
DataLoaderOptions options = DataLoaderOptions.newOptions()
.setBatchLoaderContextProvider(ctxProvider);
DataLoader<K, T> dataLoader = DataLoaderFactory.newDataLoader(batchLoader, options);
ctxProvider.setDataLoader(dataLoader);

DataLoader<K, T> dataLoader = DataLoaderFactory.newDataLoader(batchLoader);
dataLoaderRegistry.register(batchLoaderHelper.getName(operation), dataLoader);
}
return dataLoaderRegistry;
Expand All @@ -268,7 +263,7 @@ private GraphQL getGraphQL() {
}

if (mutationExecutionStrategy != null) {
graphqlBuilder = graphqlBuilder.queryExecutionStrategy(mutationExecutionStrategy);
graphqlBuilder = graphqlBuilder.mutationExecutionStrategy(mutationExecutionStrategy);
}
if (hasSubscription) {
graphqlBuilder = graphqlBuilder
Expand Down
Loading