public async Task <IActionResult> Post([FromBody] GraphQlQuery query)
        {
            var schema = new Schema {
                Query = new AuthorQuery(blogService)
            };
            var result = await new DocumentExecuter().ExecuteAsync(x =>
            {
                x.Schema = schema;
                x.Query  = query.Query;
                x.Inputs = query.Variables;
            });

            if (result.Errors?.Count > 0)
            {
                return(BadRequest());
            }
            return(Ok(result));
        }
Esempio n. 2
0
        public async Task <IActionResult> Post([FromBody] GraphQlQuery query)
        {
            var inputs = query.Variables.ToInputs();

            var schema = new Schema()
            {
                Query = new GraphQL.GraphQueryType(_companyContext)
            };

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

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

            return(Ok(result));
        }