Skip to content

Commit

Permalink
Remove deprecated code from Vert.x Web GraphQL
Browse files Browse the repository at this point in the history
Removed in Vert.x 5:

- ApolloWS transport
- Vert.x Data Fetchers (including Property Data Fetcher) and Batch Loaders
- Query Context / Data Loader Registry / Locale callbacks in GraphQLHandler

This commit also udpates code that use deprecated GraphQL Java code.

Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
  • Loading branch information
tsegismont committed Jun 9, 2023
1 parent 7e2a9aa commit e826941
Show file tree
Hide file tree
Showing 43 changed files with 33 additions and 3,494 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,6 @@ on:
default: 8
type: string
jobs:
Apollo-Link-Tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: [18.13.0]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ inputs.branch }}
- name: Install JDK
uses: actions/setup-java@v2
with:
java-version: ${{ inputs.jdk }}
distribution: temurin
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: sh vertx-web-graphql/start-apollo-tests-server.sh
- run: npm install
working-directory: vertx-web-graphql/tests/apollo
- run: npm run test
working-directory: vertx-web-graphql/tests/apollo
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: ApolloTestsServer.log
path: ~/ApolloTestsServer.log
- run: sh stop-apollo-tests-server.sh
working-directory: vertx-web-graphql
if: ${{ always() }}
GraphQLWS-Tests:
runs-on: ubuntu-latest
strategy:
Expand Down
9 changes: 0 additions & 9 deletions vertx-web-graphql/src/main/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,6 @@ Configure GraphQL-Java with the {@link io.vertx.ext.web.handler.graphql.instrume
{@link examples.GraphQLExamples#jsonObjectAdapter}
----

==== GraphQL-Java 19 and before

Configure GraphQL-Java to use {@link io.vertx.ext.web.handler.graphql.schema.VertxPropertyDataFetcher} instead:

[source,$lang]
----
{@link examples.GraphQLExamples#jsonData}
----

=== Batch loading

Dataloaders help you to load data efficiently by batching fetch requests and caching results.
Expand Down

This file was deleted.

51 changes: 2 additions & 49 deletions vertx-web-graphql/src/main/java/examples/GraphQLExamples.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
import graphql.execution.preparsed.persisted.PersistedQueryCache;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import graphql.schema.idl.FieldWiringEnvironment;
import graphql.schema.idl.RuntimeWiring;
import graphql.schema.idl.WiringFactory;
import io.vertx.core.Future;
import io.vertx.core.MultiMap;
import io.vertx.core.Vertx;
Expand All @@ -32,21 +30,11 @@
import io.vertx.ext.web.Router;
import io.vertx.ext.web.RoutingContext;
import io.vertx.ext.web.handler.BodyHandler;
import io.vertx.ext.web.handler.graphql.ApolloWSHandler;
import io.vertx.ext.web.handler.graphql.GraphQLHandler;
import io.vertx.ext.web.handler.graphql.GraphQLHandlerOptions;
import io.vertx.ext.web.handler.graphql.GraphiQLHandler;
import io.vertx.ext.web.handler.graphql.GraphiQLHandlerOptions;
import io.vertx.ext.web.handler.graphql.UploadScalar;
import io.vertx.ext.web.handler.graphql.*;
import io.vertx.ext.web.handler.graphql.instrumentation.JsonObjectAdapter;
import io.vertx.ext.web.handler.graphql.instrumentation.VertxFutureAdapter;
import io.vertx.ext.web.handler.graphql.schema.VertxPropertyDataFetcher;
import io.vertx.ext.web.handler.graphql.ws.GraphQLWSHandler;
import org.dataloader.BatchLoaderEnvironment;
import org.dataloader.BatchLoaderWithContext;
import org.dataloader.DataLoader;
import org.dataloader.DataLoaderFactory;
import org.dataloader.DataLoaderRegistry;
import org.dataloader.*;

import java.util.List;
import java.util.concurrent.CompletionStage;
Expand Down Expand Up @@ -169,20 +157,6 @@ private Future<List<Link>> retrieveLinksPostedBy(User user) {
return null;
}

public void jsonData() {
RuntimeWiring.Builder builder = RuntimeWiring.newRuntimeWiring();

builder.wiringFactory(new WiringFactory() {

@Override
public DataFetcher<Object> getDefaultDataFetcher(FieldWiringEnvironment environment) {

return VertxPropertyDataFetcher.create(environment.getFieldDefinition().getName());

}
});
}

public void jsonObjectAdapter(GraphQL.Builder graphQLBuilder) {
graphQLBuilder.instrumentation(new JsonObjectAdapter());
}
Expand Down Expand Up @@ -214,27 +188,6 @@ private Future<List<String>> findComments(List<Long> ids, BatchLoaderEnvironment
return null;
}

public void addApolloWsHandlerToRouter(Router router) {
GraphQL graphQL = setupGraphQLJava();

router.route("/graphql").handler(ApolloWSHandler.create(graphQL));
}

public void configureServerForApolloWs(Vertx vertx, Router router) {
HttpServerOptions httpServerOptions = new HttpServerOptions()
.addWebSocketSubProtocol("graphql-ws");
vertx.createHttpServer(httpServerOptions)
.requestHandler(router)
.listen(8080);
}

public void configureWebSocketLinkAndHttpLinkSamePath(Router router) {
GraphQL graphQL = setupGraphQLJava();

router.route("/graphql").handler(ApolloWSHandler.create(graphQL));
router.route("/graphql").handler(GraphQLHandler.create(graphQL));
}

public void addGraphQLWSHandlerToRouter(Router router, GraphQL graphQL) {
router.route("/graphql").handler(GraphQLWSHandler.create(graphQL));
}
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit e826941

Please sign in to comment.