use of io.vertx.ext.web.handler.graphql.schema.VertxDataFetcher in project vertx-web by vert-x3.
the class VertxDataFetcherTest method graphQL.
@Override
protected GraphQL graphQL() {
String schema = vertx.fileSystem().readFileBlocking("links.graphqls").toString();
SchemaParser schemaParser = new SchemaParser();
TypeDefinitionRegistry typeDefinitionRegistry = schemaParser.parse(schema);
RuntimeWiring runtimeWiring = newRuntimeWiring().type("Query", builder -> {
VertxDataFetcher<Object> dataFetcher = VertxDataFetcher.create((env, fut) -> fut.complete(getAllLinks(env)));
return builder.dataFetcher("allLinks", dataFetcher);
}).build();
SchemaGenerator schemaGenerator = new SchemaGenerator();
GraphQLSchema graphQLSchema = schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring);
return GraphQL.newGraphQL(graphQLSchema).build();
}
use of io.vertx.ext.web.handler.graphql.schema.VertxDataFetcher in project vertx-web by vert-x3.
the class GraphQLExamples method futureDataFetcher.
public void futureDataFetcher() {
VertxDataFetcher<List<Link>> dataFetcher = VertxDataFetcher.create(environment -> {
Future<List<Link>> future = retrieveLinksFromBackend(environment);
return future;
});
RuntimeWiring runtimeWiring = RuntimeWiring.newRuntimeWiring().type("Query", builder -> builder.dataFetcher("allLinks", dataFetcher)).build();
}
use of io.vertx.ext.web.handler.graphql.schema.VertxDataFetcher in project vertx-web by vert-x3.
the class GraphQLExamples method callbackDataFetcher.
public void callbackDataFetcher() {
VertxDataFetcher<List<Link>> dataFetcher = VertxDataFetcher.create((env, promise) -> {
retrieveLinksFromBackend(env, promise);
});
RuntimeWiring runtimeWiring = RuntimeWiring.newRuntimeWiring().type("Query", builder -> builder.dataFetcher("allLinks", dataFetcher)).build();
}
Aggregations