ExecuteAsync() public method

public ExecuteAsync ( Action configure ) : Task
configure Action
return Task
 public async Task<ExecutionResult> Execute(
   Schema schema,
   object rootObject,
   string query,
   string operationName = null,
   Inputs inputs = null)
 {
     var executer = new DocumentExecuter();
     return await executer.ExecuteAsync(schema, rootObject, query, operationName);
 }
Example #2
0
        public static async Task <string> ExecuteAsync(this ISchema schema, Action <ExecutionOptions> configure)
        {
            var executor = new DocumentExecuter();
            var result   = await executor.ExecuteAsync(options =>
            {
                options.Schema = schema;
                configure(options);
            }).ConfigureAwait(false);

            return(await new DocumentWriter(indent: true).WriteToStringAsync(result).ConfigureAwait(false));
        }
        public static string Execute(this ISchema schema, Action <ExecutionOptions> configure)
        {
            var executor = new DocumentExecuter();
            var result   = executor.ExecuteAsync(options =>
            {
                options.Schema = schema;
                configure(options);
            }).GetAwaiter().GetResult();

            return(new DocumentWriter(indent: true).Write(result));
        }
Example #4
0
        public static async Task <string> ExecuteAsync(this ISchema schema, Action <ExecutionOptions> configure)
        {
            var executor = new DocumentExecuter();
            var result   = await executor.ExecuteAsync(_ =>
            {
                _.Schema = schema;
                configure(_);
            });

            return(new DocumentWriter(indent: true).Write(result));
        }
Example #5
0
        /// <summary>
        /// Executes a GraphQL request with the default <see cref="DocumentExecuter"/>, serializes the result using the specified <see cref="IDocumentWriter"/>, and returns the result
        /// </summary>
        /// <param name="schema">An instance of <see cref="ISchema"/> to use to execute the query</param>
        /// <param name="documentWriter">An instance of <see cref="IDocumentExecuter"/> to use to serialize the result</param>
        /// <param name="configure">A delegate which configures the execution options</param>
        public static async Task <string> ExecuteAsync(this ISchema schema, IDocumentWriter documentWriter, Action <ExecutionOptions> configure)
        {
            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            var executor = new DocumentExecuter();
            var result   = await executor.ExecuteAsync(options =>
            {
                options.Schema = schema;
                configure(options);
            }).ConfigureAwait(false);

            return(await documentWriter.WriteToStringAsync(result).ConfigureAwait(false));
        }
Example #6
0
        /// <summary>
        /// Executes a GraphQL request with the default <see cref="DocumentExecuter"/>, serializes the result using the specified <see cref="IGraphQLTextSerializer"/>, and returns the result
        /// </summary>
        /// <param name="schema">An instance of <see cref="ISchema"/> to use to execute the query</param>
        /// <param name="serializer">An instance of <see cref="IGraphQLTextSerializer"/> to use to serialize the result</param>
        /// <param name="configure">A delegate which configures the execution options</param>
        public static async Task <string> ExecuteAsync(this ISchema schema, IGraphQLTextSerializer serializer, Action <ExecutionOptions> configure)
        {
            if (configure == null)
            {
                throw new ArgumentNullException(nameof(configure));
            }

            var executor = new DocumentExecuter();
            var result   = await executor.ExecuteAsync(options =>
            {
                options.Schema = schema;
                configure(options);
            }).ConfigureAwait(false);

            return(serializer.Serialize(result));
        }