コード例 #1
0
 public Task <IOperationResult <IFarmList> > FarmListAsync(
     CancellationToken cancellationToken = default)
 {
     return(_executor.ExecuteAsync(
                new FarmListOperation(),
                cancellationToken));
 }
コード例 #2
0
        public async Task RunAsync()
        {
            // Commands
            var decoratedCommand = new FooCommand {
                Name = "Decorated command"
            };
            await _executor.ExecuteAsync(decoratedCommand);

            await _writer.WriteLineAsync("----------------");

            var regularCommand = new BarCommand {
                Name = "Regular command"
            };
            var regularCommandResult = await _executor.ExecuteAsync(regularCommand);

            await _writer.WriteLineAsync("----------------");

            var syncCommand       = new BazCommand();
            var syncCommandResult = await _executor.ExecuteAsync(syncCommand);

            await _writer.WriteLineAsync($"Sync command result is `{syncCommandResult}`");

            await _writer.WriteLineAsync("----------------");

            // Queries
            var regularQuery = new FooQuery {
                Number1 = 3, Number2 = 4
            };
            var regularQueryResult = await _executor.ExecuteAsync(regularQuery);

            await _writer.WriteLineAsync("----------------");
        }
コード例 #3
0
 public Task <IOperationResult <IGetHero> > GetHeroAsync(
     CancellationToken cancellationToken = default)
 {
     return(_executor.ExecuteAsync(
                new GetHeroOperation(),
                cancellationToken));
 }
コード例 #4
0
        public Task <IOperationResult <IPublishSchema> > PublishSchemaAsync(
            Optional <string> schemaName              = default,
            Optional <string> environmentName         = default,
            Optional <string> sourceText              = default,
            Optional <IReadOnlyList <TagInput>?> tags = default,
            CancellationToken cancellationToken       = default)
        {
            if (schemaName.HasValue && schemaName.Value is null)
            {
                throw new ArgumentNullException(nameof(schemaName));
            }

            if (environmentName.HasValue && environmentName.Value is null)
            {
                throw new ArgumentNullException(nameof(environmentName));
            }

            if (sourceText.HasValue && sourceText.Value is null)
            {
                throw new ArgumentNullException(nameof(sourceText));
            }

            return(_executor.ExecuteAsync(
                       new PublishSchemaOperation
            {
                SchemaName = schemaName,
                EnvironmentName = environmentName,
                SourceText = sourceText,
                Tags = tags
            },
                       cancellationToken));
        }
コード例 #5
0
 public Task <IOperationResult <IGetHero> > GetHeroAsync(
     Episode?episode,
     CancellationToken cancellationToken)
 {
     return(_executor.ExecuteAsync(
                new GetHeroOperation {
         Episode = episode
     },
                cancellationToken));
 }
コード例 #6
0
 public Task <IOperationResult <IGetHero> > GetHeroAsync(
     Optional <Episode> episode          = default,
     CancellationToken cancellationToken = default)
 {
     return(_executor.ExecuteAsync(
                new GetHeroOperation {
         Episode = episode
     },
                cancellationToken));
 }
コード例 #7
0
 public Task <IOperationResult <IMediaDetails> > MediaDetailsAsync(
     Optional <System.Guid> id           = default,
     CancellationToken cancellationToken = default)
 {
     return(_executor.ExecuteAsync(
                new MediaDetailsOperation {
         Id = id
     },
                cancellationToken));
 }
コード例 #8
0
 public Task <IOperationResult <IGetProducts> > GetProductsAsync(
     Optional <int> currentPage          = default,
     Optional <double> highPrice         = default,
     CancellationToken cancellationToken = default)
 {
     return(_executor.ExecuteAsync(
                new GetProductsOperation
     {
         CurrentPage = currentPage,
         HighPrice = highPrice
     },
                cancellationToken));
 }
コード例 #9
0
        public Task <IOperationResult <IGetHuman> > GetHumanAsync(
            Optional <string> id = default,
            CancellationToken cancellationToken = default)
        {
            if (id.HasValue && id.Value is null)
            {
                throw new ArgumentNullException(nameof(id));
            }

            return(_executor.ExecuteAsync(
                       new GetHumanOperation {
                Id = id
            },
                       cancellationToken));
        }
コード例 #10
0
        public Task <IOperationResult <IGetUser> > GetUserAsync(
            Optional <string> login             = default,
            CancellationToken cancellationToken = default)
        {
            if (login.HasValue && login.Value is null)
            {
                throw new ArgumentNullException(nameof(login));
            }

            return(_executor.ExecuteAsync(
                       new GetUserOperation {
                Login = login
            },
                       cancellationToken));
        }
コード例 #11
0
 public Task <IOperationResult <IMyQuery> > MyQueryAsync(
     CancellationToken cancellationToken)
 {
     return(_executor.ExecuteAsync(
                new MyQueryOperation(),
                cancellationToken));
 }
コード例 #12
0
 public Task <IOperationResult <IGetValues> > GetValuesAsync(
     CancellationToken cancellationToken)
 {
     return(_executor.ExecuteAsync(
                new GetValuesOperation(),
                cancellationToken));
 }
コード例 #13
0
ファイル: GetHeroQuery.cs プロジェクト: zmarty/hotchocolate
        public async Task <IOperationResult <GetHeroResult> > ExecuteAsync(
            CancellationToken cancellationToken = default)
        {
            OperationRequest request = CreateRequest();

            return(await _operationExecutor
                   .ExecuteAsync(request, cancellationToken)
                   .ConfigureAwait(false));
        }
コード例 #14
0
 public Task <IOperationResult <IGetCustomers> > GetCustomersAsync(
     CancellationToken cancellationToken = default)
 {
     return(_executor.ExecuteAsync(
                new GetCustomersOperation(),
                cancellationToken));
 }
コード例 #15
0
 private async Task <TResult> ExecuteAsync <TResult>(IOperation <TResult> operation)
 {
     try
     {
         return(await _executor.ExecuteAsync(operation));
     }
     catch (ValidationException ex)
     {
         var commandType = operation.GetType().Name;
         foreach (var failure in ex.ValidationResult)
         {
             await _writer.WriteLineAsync($"Validation {failure.Level} ({commandType}): {failure.Message}");
         }
         return(default);
コード例 #16
0
ファイル: GitHubClient.cs プロジェクト: yuriypts/hotchocolate
        public Task <IOperationResult <IGetUser> > GetUserAsync(
            string login,
            CancellationToken cancellationToken)
        {
            if (login is null)
            {
                throw new ArgumentNullException(nameof(login));
            }

            return(_executor.ExecuteAsync(
                       new GetUserOperation {
                Login = login
            },
                       cancellationToken));
        }
コード例 #17
0
        public Task <IOperationResult <IPeople> > GetPeopleAsync(
            Optional <string> userId            = default,
            CancellationToken cancellationToken = default)
        {
            if (userId.HasValue && userId.Value is null)
            {
                throw new ArgumentNullException(nameof(userId));
            }

            return(_executor.ExecuteAsync(
                       new GetPeopleOperation {
                UserId = userId
            },
                       cancellationToken));
        }