Пример #1
0
        public async Task <IActionResult> Post([FromBody] GraphQLQuery query)
        {
            var inputs = query.Variables.ToInputs();

            var result = await new DocumentExecuter().ExecuteAsync(_ =>
            {
                _.Schema        = _schema;
                _.Query         = query.Query;
                _.OperationName = query.OperationName;
                _.Inputs        = inputs;
            });

            if (result.Errors?.Count > 0)
            {
                return(BadRequest());
            }

            return(Ok(result));
        }
Пример #2
0
        public async Task <ActionResult <string> > Post([FromBody] GraphQLQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }
            var inputs           = query.Variables.ToInputs();
            var executionOptions = new ExecutionOptions
            {
                Schema = _schema,
                Query  = query.Query,
                Inputs = inputs
            };

            var result = await _documentExecuter.ExecuteAsync(executionOptions).ConfigureAwait(false);

            if (result.Errors?.Count > 0)
            {
                return(BadRequest(result));
            }

            return(Ok(result));
        }