use of io.vertx.ext.web.handler.graphql.VertxDataFetcher in project vertx-examples by vert-x3.
the class Server method createGraphQL.
private GraphQL createGraphQL() {
String schema = vertx.fileSystem().readFileBlocking("links.graphqls").toString();
SchemaParser schemaParser = new SchemaParser();
TypeDefinitionRegistry typeDefinitionRegistry = schemaParser.parse(schema);
RuntimeWiring runtimeWiring = newRuntimeWiring().type("Query", builder -> {
VertxDataFetcher<List<Link>> getAllLinks = new VertxDataFetcher<>(this::getAllLinks);
return builder.dataFetcher("allLinks", getAllLinks);
}).build();
SchemaGenerator schemaGenerator = new SchemaGenerator();
GraphQLSchema graphQLSchema = schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring);
return GraphQL.newGraphQL(graphQLSchema).build();
}
Aggregations