public async Task Invoke( HttpContext context, Schema schema, OperationExecuter operationExecuter) { bool handled = false; if (context.Request.Method.Equals(_post, StringComparison.OrdinalIgnoreCase)) { string path = context.Request.Path.ToUriComponent(); if (_route == null || _route.Equals(path)) { await HandleRequestAsync(context, schema, operationExecuter, context.RequestAborted) .ConfigureAwait(false); handled = true; } } if (!handled) { await _next(context); } }
public async Task TypeNameIntrospectionNotOnQuery() { // arrange Schema schema = CreateSchema(); DocumentNode query = Parser.Default.Parse("{ b { __typename } }"); // act OperationExecuter operationExecuter = new OperationExecuter(); QueryResult result = await operationExecuter.ExecuteRequestAsync( schema, query, null, null, null, CancellationToken.None); // assert Assert.Null(result.Errors); Assert.Equal(Snapshot.Current(), Snapshot.New(result)); }
public async Task ExecuteGraphiQLIntrospectionQuery() { // arrange Schema schema = CreateSchema(); DocumentNode query = Parser.Default.Parse( FileResource.Open("IntrospectionQuery.graphql")); // act OperationExecuter operationExecuter = new OperationExecuter(); Stopwatch sw = Stopwatch.StartNew(); QueryResult result = await operationExecuter.ExecuteRequestAsync( schema, query, null, null, null, CancellationToken.None); // assert Assert.Null(result.Errors); Assert.Equal(Snapshot.Current(), Snapshot.New(result)); }
private async Task HandleRequestAsync( HttpContext context, Schema schema, OperationExecuter operationExecuter, CancellationToken cancellationToken) { QueryRequest request = await ReadRequestAsync(context.Request) .ConfigureAwait(false); DocumentNode queryDocument = _parser.Parse(request.Query); QueryResult result = await operationExecuter.ExecuteRequestAsync( schema, queryDocument, request.OperationName, DeserializeVariables(request.Variables), null, CancellationToken.None).ConfigureAwait(false); await WriteResponseAsync(context.Response, result) .ConfigureAwait(false); }