GraphQL for Java with Spring Boot made easy.
APACHE-2.0 License
Bot releases are visible (Hide)
Published by github-actions[bot] almost 3 years ago
This version has an important CVE-2021-44228 vulnerability fix present in Log4J < 2.15.
Published by github-actions[bot] almost 3 years ago
Published by berngp almost 3 years ago
DefaultDgsFederationResolver
now properly handle exceptions thrown by failed completable futures. (#730) @victorlevasseurdgs.graphql.graphiql.path
now works in webflux (#725) @heoYHNote: Builds v4.9.5 and v4.9.6 failed to be deployed in Artifactory.
Published by berngp almost 3 years ago
Published by github-actions[bot] about 3 years ago
private JacksonObjectMapper
into companion object to establish compatibility with CGLIB proxying (#694) @mwftapiPublished by github-actions[bot] about 3 years ago
Published by github-actions[bot] about 3 years ago
graphql-java:17.3
, which has many improvements.In this release we deprecated the DefaultGraphQLClient
class and the existing executeQuery
methods on the GraphQLClient
and MonoGraphQLClient
interfaces.
The deprecated methods required a RequestExecutor
to be passed in that takes care of the actual HTTP request. Requiring a RequestExecutor
makes it possible to plug-in any HTTP client, but requires quite a bit of plumbing.
The deprecated class/methods are replaced by the following:
WebClientGraphQLClient
. If you don't have a strong opinion about what HTTP client to use, this is the easiest way to use the client. The user just provides a WebClient instance, and the framework takes care of the rest. This should be the preferred method for most users!RequestExecutor
approach using the new CustomGraphQLClient
or CustomMonoGraphQLClient
classes. The RequestExecutor
is now defined as a constructor argument instead of at each execute*
method for better ergonomics. You can use your existing RequestExecutor
implementation however!Below are two examples of how to migrate an existing usage of DefaultGraphQLClient
to either of the new approaches.
A DefaultGraphQLClient
that we'll migrate.
RestTemplate restTemplate = new RestTemplate();
String url = "http://localhost:8080/graphql";
DefaultGraphQLClient client = new DefaultGraphQLClient(url);
RequestExecutor requestExecutor = (url, headers, body) -> {
HttpHeaders httpHeaders = new HttpHeaders();
headers.forEach(httpHeaders::addAll);
ResponseEntity<String> exchange = restTemplate.exchange(url, HttpMethod.POST, new HttpEntity<>(body, httpHeaders),String.class);
return new HttpResponse(exchange.getStatusCodeValue(), exchange.getBody());
};
client.executeQuery(query, variables, requestExecutor);
Using WebClient
WebClient webClient = WebClient.create("http://localhost:8080/graphql");
WebClientGraphQLClient client = MonoGraphQLClient.createWithWebClient(webClient);
client.reactiveExecuteQuery(query);
Optionally, you can provide a Consumer<HttpHeader>
to the WebClientGraphQLClient
to provide additional headers.
WebClient webClient = WebClient.create("http://localhost:8080/graphql");
WebClientGraphQLClient client = MonoGraphQLClient.createWithWebClient(WebClient.create("http://localhost:$port/graphql" , headers ->
headers.add("myheader", "test")
);
client.reactiveExecuteQuery(query);
Using CustomGraphQLClient
RequestExecutor requestExecutor = (url, headers, body) -> {
HttpHeaders httpHeaders = new HttpHeaders();
headers.forEach(httpHeaders::addAll);
ResponseEntity<String> exchange = restTemplate.exchange(url, HttpMethod.POST, new HttpEntity<>(body, httpHeaders),String.class);
return new HttpResponse(exchange.getStatusCodeValue(), exchange.getBody());
};
CustomGraphQLClient client = GraphQLClient.createCustom(url, requestExecutor);
client.executeQuery(query); //the RequestExecutor was already passed in to the constructor
Updated docs for the new client.
Published by github-actions[bot] about 3 years ago
Published by github-actions[bot] about 3 years ago
Published by github-actions[bot] about 3 years ago
Published by github-actions[bot] about 3 years ago
Published by github-actions[bot] about 3 years ago
Published by github-actions[bot] about 3 years ago
Published by berngp about 3 years ago
Published by paulbakker about 3 years ago
It is now possible to register a bean of type PreparsedDocumentProvider
, which the framework uses during query execution.
A PreparsedDocumentProvider
can be used to build a cache of queries that were previously parsed, which can improve query execution performance.
The developer is responsible for choosing and configuring a cache implementation. The following is an example using Caffeine
.
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Configuration
static class PreparsedDocumentProviderConfig {
private final Cache<String, PreparsedDocumentEntry> cache = Caffeine.newBuilder().maximumSize(250)
.expireAfterAccess(5, TimeUnit.MINUTES).recordStats().build();
@Bean
public PreparsedDocumentProvider preparsedDocumentProvider() {
return (executionInput, parseAndValidateFunction) -> {
Function<String, PreparsedDocumentEntry> mapCompute = key -> parseAndValidateFunction.apply(executionInput);
return cache.get(executionInput.getQuery(), mapCompute);
};
}
}
}
This fixes a bug that was introduced in 4.6.0
that caused lists of input objects nested inside an input object to not be deserialized correctly for @InputArgument
values.
Published by github-actions[bot] about 3 years ago
🔴 ALERT
We recommend developers to wait for 4.7.0, when available, since it has important fixes for Input Arguments serialization.
The serialization of an input argument into a collection fails in this version.
convertValue
for input types (#549) @paulbakker.@CookieValue
to express that such value should be fetch from the cookie inside the web request. (#542) @paulbakker.@DgsDirective
annotation. (#536) @hantsy@DgsEnableDataFetcherInstrumentation(false)
(#577) @berngp@DgsData
annotations. (#574) @berngp⚠️ WARNING
Due the changes on #549 there are implicit modification on how GraphQL ID are serialized to input arguments.
The serialization of a GraphQLID
input argument to a Javajava.util.Long
will not happen out of the box now.
In principal this is not correct since anID
should be treated as aString
, GraphQL defines it as follows... "the ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache. The ID type is serialized in the same way as a String; however, defining it as an ID signifies that it is not intended to be human‐readable." ref.
Published by github-actions[bot] about 3 years ago