use of org.springframework.graphql.RequestInput in project spring-graphql by spring-projects.
the class SchemaMappingInvocationTests method queryWithArgumentViaDataFetchingEnvironment.
@Test
void queryWithArgumentViaDataFetchingEnvironment() {
String document = "{ " + " authorById(id:\"101\") { " + " id" + " firstName" + " lastName" + " }" + "}";
AtomicReference<GraphQLContext> contextRef = new AtomicReference<>();
RequestInput requestInput = TestRequestInput.forDocument(document);
requestInput.configureExecutionInput((executionInput, builder) -> {
contextRef.set(executionInput.getGraphQLContext());
return executionInput;
});
Mono<RequestOutput> resultMono = graphQlService().execute(requestInput);
Author author = GraphQlResponse.from(resultMono).toEntity("authorById", Author.class);
assertThat(author.getId()).isEqualTo(101);
assertThat(author.getFirstName()).isEqualTo("George");
assertThat(author.getLastName()).isEqualTo("Orwell");
assertThat(contextRef.get().<String>get("key")).isEqualTo("value");
}
Aggregations