ExecutedMutationWithRenamedInputField(
            IQueryRequestBuilder requestBuilder)
        {
            IHttpClientFactory clientFactory = CreateRemoteSchemas();

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton(clientFactory);
            serviceCollection.AddStitchedSchema(builder =>
                                                builder.AddSchemaFromHttp("contract")
                                                .AddSchemaFromHttp("customer")
                                                .RenameField(
                                                    new FieldReference("CreateCustomerInput", "name"),
                                                    "foo")
                                                .AddExtensionsFromString(
                                                    FileResource.Open("StitchingExtensions.graphql"))
                                                .AddSchemaConfiguration(c =>
            {
                c.RegisterType <PaginationAmountType>();
                c.RegisterExtendedScalarTypes();
            }));

            IServiceProvider services =
                serviceCollection.BuildServiceProvider();

            IQueryExecutor executor = services
                                      .GetRequiredService <IQueryExecutor>();

            using (IServiceScope scope = services.CreateScope())
            {
                requestBuilder.SetServices(scope.ServiceProvider);
                return(await executor.ExecuteAsync(requestBuilder.Create()));
            }
        }
Ejemplo n.º 2
0
        protected async Task <IReadOnlyQueryRequest> BuildRequestAsync(
            HttpContext context,
            IServiceProvider services,
            IQueryRequestBuilder builder)
        {
            if (!_interceptorInitialized)
            {
                _interceptor = services
                               .GetService <IQueryRequestInterceptor <HttpContext> >();
                _interceptorInitialized = true;
            }

            if (_interceptor != null)
            {
                await _interceptor.OnCreateAsync(
                    context,
                    builder,
                    context.GetCancellationToken())
                .ConfigureAwait(false);
            }

            builder.SetServices(services);
            builder.TryAddProperty(nameof(HttpContext), context);
            builder.TryAddProperty(nameof(ClaimsPrincipal), context.GetUser());

            if (context.IsTracingEnabled())
            {
                builder.TryAddProperty(ContextDataKeys.EnableTracing, true);
            }

            return(builder.Create());
        }
Ejemplo n.º 3
0
            CreateQueryRequestInternalAsync(
                HttpContext context,
                IServiceProvider services)
        {
            IQueryRequestBuilder builder =
                await CreateQueryRequestAsync(context)
                    .ConfigureAwait(false);

            OnCreateRequestAsync onCreateRequest = Options.OnCreateRequest
                ?? GetService<OnCreateRequestAsync>(context);

            builder.AddProperty(nameof(HttpContext), context);
            builder.AddProperty(nameof(ClaimsPrincipal), context.GetUser());
            builder.SetServices(services);

            if (context.IsTracingEnabled())
            {
                builder.AddProperty(ContextDataKeys.EnableTracing, true);
            }

            if (onCreateRequest != null)
            {
                CancellationToken requestAborted =
                    context.GetCancellationToken();

                await onCreateRequest(context, builder, requestAborted)
                    .ConfigureAwait(false);
            }

            return builder.Create();
        }