public async Task InvokeAsync(IQueryContext context)
        {
            Activity activity = ParsingDiagnosticEvents.BeginParsing(context);

            context.Document = _queryCache.GetOrCreate(
                context.Request.Query,
                () => ParseDocument(context.Request.Query));

            await _next(context).ConfigureAwait(false);

            ParsingDiagnosticEvents.EndParsing(activity, context);
        }
Example #2
0
        public async Task InvokeAsync(IQueryContext context)
        {
            Activity activity = ParsingDiagnosticEvents.BeginParsing(context);

            if (IsContextIncomplete(context))
            {
                context.Result = QueryResult.CreateError(new QueryError(
                                                             "The parse query middleware expects " +
                                                             "a valid query request."));
            }
            else
            {
                context.Document = _queryCache.GetOrCreate(
                    context.Request.Query,
                    () => ParseDocument(context.Request.Query));

                await _next(context).ConfigureAwait(false);
            }

            ParsingDiagnosticEvents.EndParsing(activity, context);
        }