Esempio n. 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);
        }
Esempio n. 2
0
        private Task <SubscriptionExecutionResult> SubscribeAsync(GraphQLQuery query, OperationMessageContext op)
        {
            var options = op.Connection.Options;

            return(_subscriptionExecuter.SubscribeAsync(new ExecutionOptions
            {
                Schema = _schema,
                OperationName = query.OperationName,
                Inputs = query.GetInputs(),
                Query = query.Query,
                UserContext = options?.BuildUserContext?.Invoke(op)
            }));
        }