Introduce GraphQL media type static final

See gh-45487
See gh-45494
This commit is contained in:
Stéphane Nicoll 2025-05-08 21:44:43 -07:00 committed by Phillip Webb
parent 36fb1e9b4b
commit 564bfeef95
2 changed files with 6 additions and 4 deletions

View File

@ -224,8 +224,8 @@ class GraphQlWebMvcAutoConfigurationTests {
.content("{\"query\": \"" + query + "\"}"))
.satisfies((result) -> assertThat(result).hasStatusOk()
.headers()
.containsEntry(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, List.of("https://example.com"))
.containsEntry(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, List.of("true")));
.hasValue(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "https://example.com")
.hasValue(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS, "true"));
});
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -44,6 +44,8 @@ import org.springframework.http.codec.json.Jackson2JsonEncoder;
@ConditionalOnClass({ GraphQL.class, GraphQlTester.class })
public class GraphQlTesterAutoConfiguration {
private static final MediaType APPLICATION_GRAPHQL = new MediaType("application", "graphql+json");
@Bean
@ConditionalOnBean(ExecutionGraphQlService.class)
@ConditionalOnMissingBean
@ -53,7 +55,7 @@ public class GraphQlTesterAutoConfiguration {
ExecutionGraphQlServiceTester.Builder<?> builder = ExecutionGraphQlServiceTester.builder(graphQlService);
objectMapperProvider.ifAvailable((objectMapper) -> {
builder.encoder(new Jackson2JsonEncoder(objectMapper, MediaType.APPLICATION_GRAPHQL_RESPONSE,
MediaType.APPLICATION_JSON, MediaType.APPLICATION_GRAPHQL));
MediaType.APPLICATION_JSON, APPLICATION_GRAPHQL));
builder.decoder(new Jackson2JsonDecoder(objectMapper, MediaType.APPLICATION_JSON));
});
return builder.build();