コード例 #1
0
        public async Task <GraphQLOutput> Query(GraphQLQuery query)
        {
            GraphQLOutput output = null;

            try
            {
                var executionOptions = new ExecutionOptions()
                {
                    Schema = Schema,
                    Query  = query.Query,
                    Inputs = query.GetInputs()
                };
                var executionResult = await Executer.ExecuteAsync(executionOptions);

                output = new GraphQLOutput(executionResult.Data, executionResult.Errors?.ToArray());
            }
            catch (Exception ex)
            {
                output = new GraphQLOutput(null, new[] { new ExecutionError("Controller exception", ex), });
            }
            if (!DisplayStackTrace && output.Errors != null)
            {
                foreach (var error in output.Errors)
                {
                    error.StackTrace = null;
                }
            }
            return(output);
        }
コード例 #2
0
        private string RunOperation(string query, Inputs inputs)
        {
            var executionResult = Executer.ExecuteAsync(Schema, null, query, null, inputs: inputs).Result;
            var output          = new GraphQLOutput(executionResult.Data, executionResult.Errors?.ToArray());

            return(JsonConvert.SerializeObject(output, SerializerSettings));
        }