Search in sources :

Example 1 with ExecutionGraphQlService

use of org.springframework.graphql.execution.ExecutionGraphQlService in project spring-graphql by spring-projects.

the class SchemaMappingPrincipalMethodArgumentResolverTests method executeAsync.

private Mono<RequestOutput> executeAsync(String schema, String document, Function<Context, Context> contextWriter) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.registerBean(GreetingController.class, () -> greetingController);
    context.refresh();
    ExecutionGraphQlService graphQlService = GraphQlSetup.schemaContent(schema).runtimeWiringForAnnotatedControllers(context).toGraphQlService();
    return Mono.delay(Duration.ofMillis(10)).flatMap(aLong -> graphQlService.execute(TestRequestInput.forDocument(document))).contextWrite(contextWriter);
}
Also used : StepVerifier(reactor.test.StepVerifier) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ExecutionGraphQlService(org.springframework.graphql.execution.ExecutionGraphQlService) GraphQlSetup(org.springframework.graphql.GraphQlSetup) SecurityContextThreadLocalAccessor(org.springframework.graphql.execution.SecurityContextThreadLocalAccessor) Controller(org.springframework.stereotype.Controller) Function(java.util.function.Function) Nested(org.junit.jupiter.api.Nested) ReactorContextManager(org.springframework.graphql.execution.ReactorContextManager) ReactiveSecurityContextHolder(org.springframework.security.core.context.ReactiveSecurityContextHolder) Duration(java.time.Duration) MethodParameter(org.springframework.core.MethodParameter) SubscriptionMapping(org.springframework.graphql.data.method.annotation.SubscriptionMapping) Nullable(org.springframework.lang.Nullable) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) Method(java.lang.reflect.Method) TestRequestInput(org.springframework.graphql.TestRequestInput) ValueSource(org.junit.jupiter.params.provider.ValueSource) GraphQlResponse(org.springframework.graphql.GraphQlResponse) ClassUtils(org.springframework.util.ClassUtils) QueryMapping(org.springframework.graphql.data.method.annotation.QueryMapping) SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) Context(reactor.util.context.Context) Mono(reactor.core.publisher.Mono) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.jupiter.api.Test) Flux(reactor.core.publisher.Flux) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Principal(java.security.Principal) Authentication(org.springframework.security.core.Authentication) RequestOutput(org.springframework.graphql.RequestOutput) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) ExecutionGraphQlService(org.springframework.graphql.execution.ExecutionGraphQlService)

Example 2 with ExecutionGraphQlService

use of org.springframework.graphql.execution.ExecutionGraphQlService in project spring-graphql by spring-projects.

the class GraphQlSetup method toGraphQlService.

public ExecutionGraphQlService toGraphQlService() {
    GraphQlSource source = graphQlSourceBuilder.build();
    ExecutionGraphQlService service = new ExecutionGraphQlService(source);
    this.dataLoaderRegistrars.forEach(service::addDataLoaderRegistrar);
    return service;
}
Also used : GraphQlSource(org.springframework.graphql.execution.GraphQlSource) ExecutionGraphQlService(org.springframework.graphql.execution.ExecutionGraphQlService)

Aggregations

ExecutionGraphQlService (org.springframework.graphql.execution.ExecutionGraphQlService)2 Method (java.lang.reflect.Method)1 Principal (java.security.Principal)1 Duration (java.time.Duration)1 Function (java.util.function.Function)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Nested (org.junit.jupiter.api.Nested)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 ValueSource (org.junit.jupiter.params.provider.ValueSource)1 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)1 MethodParameter (org.springframework.core.MethodParameter)1 GraphQlResponse (org.springframework.graphql.GraphQlResponse)1 GraphQlSetup (org.springframework.graphql.GraphQlSetup)1 RequestOutput (org.springframework.graphql.RequestOutput)1 TestRequestInput (org.springframework.graphql.TestRequestInput)1 QueryMapping (org.springframework.graphql.data.method.annotation.QueryMapping)1 SubscriptionMapping (org.springframework.graphql.data.method.annotation.SubscriptionMapping)1 GraphQlSource (org.springframework.graphql.execution.GraphQlSource)1 ReactorContextManager (org.springframework.graphql.execution.ReactorContextManager)1