Search in sources :

Example 36 with SchemaParser

use of graphql.schema.idl.SchemaParser in project vertx-web by vert-x3.

the class ApolloTestsServer method setupGraphQL.

private GraphQL setupGraphQL() {
    String schema = vertx.fileSystem().readFileBlocking("links.graphqls").toString();
    String uploadSchema = vertx.fileSystem().readFileBlocking("upload.graphqls").toString();
    SchemaParser schemaParser = new SchemaParser();
    TypeDefinitionRegistry typeDefinitionRegistry = schemaParser.parse(schema).merge(schemaParser.parse(uploadSchema));
    RuntimeWiring runtimeWiring = newRuntimeWiring().scalar(UploadScalar.build()).type("Query", builder -> builder.dataFetcher("allLinks", this::getAllLinks)).type("Mutation", builder -> builder.dataFetcher("singleUpload", this::singleUpload)).build();
    SchemaGenerator schemaGenerator = new SchemaGenerator();
    GraphQLSchema graphQLSchema = schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring);
    return GraphQL.newGraphQL(graphQLSchema).build();
}
Also used : DataFetchingEnvironment(graphql.schema.DataFetchingEnvironment) GraphQL(graphql.GraphQL) RuntimeWiring.newRuntimeWiring(graphql.schema.idl.RuntimeWiring.newRuntimeWiring) Promise(io.vertx.core.Promise) Publisher(org.reactivestreams.Publisher) POST(io.vertx.core.http.HttpMethod.POST) Vertx(io.vertx.core.Vertx) TypeDefinitionRegistry(graphql.schema.idl.TypeDefinitionRegistry) Router(io.vertx.ext.web.Router) HashMap(java.util.HashMap) BodyHandler(io.vertx.ext.web.handler.BodyHandler) FileUpload(io.vertx.ext.web.FileUpload) Collectors.toList(java.util.stream.Collectors.toList) RuntimeWiring(graphql.schema.idl.RuntimeWiring) SchemaParser(graphql.schema.idl.SchemaParser) AbstractVerticle(io.vertx.core.AbstractVerticle) Map(java.util.Map) GraphQLSchema(graphql.schema.GraphQLSchema) HttpServerOptions(io.vertx.core.http.HttpServerOptions) JsonObject(io.vertx.core.json.JsonObject) SchemaGenerator(graphql.schema.idl.SchemaGenerator) CorsHandler(io.vertx.ext.web.handler.CorsHandler) GET(io.vertx.core.http.HttpMethod.GET) RuntimeWiring.newRuntimeWiring(graphql.schema.idl.RuntimeWiring.newRuntimeWiring) RuntimeWiring(graphql.schema.idl.RuntimeWiring) TypeDefinitionRegistry(graphql.schema.idl.TypeDefinitionRegistry) SchemaGenerator(graphql.schema.idl.SchemaGenerator) SchemaParser(graphql.schema.idl.SchemaParser) GraphQLSchema(graphql.schema.GraphQLSchema)

Aggregations

SchemaParser (graphql.schema.idl.SchemaParser)36 TypeDefinitionRegistry (graphql.schema.idl.TypeDefinitionRegistry)35 GraphQLSchema (graphql.schema.GraphQLSchema)27 SchemaGenerator (graphql.schema.idl.SchemaGenerator)21 RuntimeWiring (graphql.schema.idl.RuntimeWiring)20 GraphQL (graphql.GraphQL)16 RuntimeWiring.newRuntimeWiring (graphql.schema.idl.RuntimeWiring.newRuntimeWiring)14 Test (org.junit.Test)14 DataFetchingEnvironment (graphql.schema.DataFetchingEnvironment)11 GraphQLSchemaDTO (org.wso2.carbon.apimgt.api.gateway.GraphQLSchemaDTO)8 HashMap (java.util.HashMap)7 Map (java.util.Map)7 GET (io.vertx.core.http.HttpMethod.GET)6 ArrayList (java.util.ArrayList)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 InboundMessageContext (org.wso2.carbon.apimgt.gateway.inbound.InboundMessageContext)6 InboundProcessorResponseDTO (org.wso2.carbon.apimgt.gateway.inbound.websocket.InboundProcessorResponseDTO)6 AbstractVerticle (io.vertx.core.AbstractVerticle)5 Router (io.vertx.ext.web.Router)5 VerbInfoDTO (org.wso2.carbon.apimgt.impl.dto.VerbInfoDTO)5