dgs-framework

GraphQL for Java with Spring Boot made easy.

APACHE-2.0 License

Stars
3.1K

Bot releases are visible (Hide)

dgs-framework - v4.9.11

Published by github-actions[bot] almost 3 years ago

What’s Changed

This version has an important CVE-2021-44228 vulnerability fix present in Log4J < 2.15.

Fixes

  • Recommending Log4J versions >= 2.15 (#779) @berngp
  • Pin graphiql to the latest known working version to avoid unexpected new issues. (#771) @srinivasankavitha
  • Websocket client use websocket subprotocol header during handshake (#691) @amondnet
  • Support for Input Arguments with Nest Map, Like JSON scalar (#769) @xuchuanqiu

Other

  • Update Gradle Wrapper from 7.3 to 7.3.1 (#766) @github-actions
  • Refactor DgsFederationResolverTest to improve readability (#772) @berngp
  • CI Distinct step to execute a Check (#764) @berngp
  • Add more IDE project specific files into gitignore (#754) @hantsy
dgs-framework - v4.9.10

Published by github-actions[bot] almost 3 years ago

What’s Changed

  • Add graphql-dgs-extended-validation module (#659) @hantsy
  • refactor: Added util function jsonTypeRef for simplification of TypeRef creation (#741) @npwork
  • bugfix : graphiql/index.html does not replace fetch path (#737) @heoYH

Other Changes

  • Moving GRAPHQL Versions to the Platform BOM (#759) @berngp
  • BOM now requires graphql-java-extended-validation:17.0-hibernate-validator-6.2.0.Final (#752) @berngp
  • Bump nebula.netflixoss from 10.3.0 to 10.4.0 (#747) @dependabot
  • Bump mockk from 1.12.0 to 1.12.1 (#748) @dependabot
dgs-framework - v4.9.7

Published by berngp almost 3 years ago

What’s Changed

Fixes

  • Missing the typename in a federated query should return a BadRequest (#732) @berngp
  • The DefaultDgsFederationResolver now properly handle exceptions thrown by failed completable futures. (#730) @victorlevasseur
  • Setting the dgs.graphql.graphiql.path now works in webflux (#725) @heoYH

Other

  • Update Gradle Wrapper from 7.2 to 7.3 (#729) @github-actions
  • Tune Gradle to make our builds much faster (#733) @berngp

Note: Builds v4.9.5 and v4.9.6 failed to be deployed in Artifactory.

dgs-framework - v4.9.3

Published by berngp almost 3 years ago

What’s Changed

  • Override equals method for TypedGraphQLError (#702) @clandry94
  • Update log level for parsing errors to avoid unnecessary alerts. (#703) @srinivasankavitha
  • Fix SSE Subscriptions (#716, #722, #721) @berngp
dgs-framework - v4.9.2

Published by github-actions[bot] about 3 years ago

What’s Changed

  • Introduce a CONFLICT error detail catered for mutations. (#696) @berngp
  • Moving the private JacksonObjectMapper into companion object to establish compatibility with CGLIB proxying (#694) @mwftapi
dgs-framework - v4.9.1

Published by github-actions[bot] about 3 years ago

What’s Changed

  • Update compile only dependency on webclient to implementation. (#690) @srinivasankavitha
  • added tests for client (#678) @paulbakker
  • fix: convert runtime to ResponseStatusException to get status (#674) @rachanamamillapalli
dgs-framework - 4.9.0

Published by github-actions[bot] about 3 years ago

What’s Changed

Highlights

  • Upgrade to graphql-java:17.3, which has many improvements.
  • A WebClient based GraphQL client implementation.
  • Refactored existing GraphQL client implementation for better ergonomics.

Full list of changes

  • Add ParameterNamesModule and Jdk8Module to the GraphQLResponse object mapper. (#670) @srinivasankavitha
  • Added createWithWebClient factory method that takes header consumer (#669) @paulbakker
  • refactored dgs client, and new Webclient based client. (#658) @paulbakker
  • Update contributing doc (#662) @hantsy
  • Upgrade to graphql-java 17.0 (#518) @berngp
  • Adopt kotlinter-gradle instead of org.jlleitschuh.gradle:ktlint-gradle (#393) @berngp

Migrating to the new GraphQLClient

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:

  • A brand new 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!
  • If you do have a strong opinion about what HTTP client to use, you can continue to use the 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.

dgs-framework -

Published by paulbakker about 3 years ago

What’s Changed

  • added subscription integration test (#654) @paulbakker
dgs-framework - v4.8.2

Published by github-actions[bot] about 3 years ago

What’s Changed

  • Avoid dependency ranges in platform to prevent SNAPSHOT versions. (#646) @berngp
dgs-framework - v4.8.1

Published by github-actions[bot] about 3 years ago

What’s Changed

  • Support List of enums as ArgumentInput types. (#645) @berngp
  • Sse subscription client (#643) @paulbakker
dgs-framework - v4.8.0

Published by github-actions[bot] about 3 years ago

What’s Changed

  • An @InputArgument representing a complex type can be empty (#641) @berngp
  • Move spring-security to Compile Only since its not a requirement. (#632) @berngp
  • Prevent the creation of Loggers in the Hotpath. (#638) @berngp
  • Fix bug in handling Optional Enum input arguments (#639) @paulbakker
  • Bump nebula.dependency-recommender from 10.0.1 to 11.0.0 (#636) @dependabot
  • Bump nebula.netflixoss from 10.2.1 to 10.3.0 (#637) @dependabot
  • Websocket Subscription Client using Webflux (#522) @callumforrester
  • Allow input arguments or fields of input objects as Set for list values (#635) @paulbakker
  • Bump nebula.netflixoss from 10.2.0 to 10.2.1 (#634) @dependabot
  • Compile javac with -parameters (#633) @berngp
  • Bump spectator-api from 0.134.+ to 1.0.0 (#629) @dependabot
dgs-framework - v4.7.6

Published by github-actions[bot] about 3 years ago

What’s Changed

  • Input Arguments can be serialized to Kotlin List of Lists (#623) @berngp
  • Allow the endpoint path to be configured to / (#622) @paulbakker
  • Improve how we resolve generic types for List of Lists in InputArgs (#619) @berngp
dgs-framework - v4.7.5

Published by github-actions[bot] about 3 years ago

What’s Changed

  • Addressing InputArgument Serialization with nested lists. (#612) @berngp
  • Added more tests for InputObjectMapper (#613) @paulbakker
  • Add framework specific DgsNoOpPreparsedDocumentProvider (#599) @jord1e
  • Only look for generic type if the field is generic (#611) @paulbakker
dgs-framework - v4.7.4

Published by github-actions[bot] about 3 years ago

What’s Changed

  • Account for multiple type parameters of generic classes (#609) @paulbakker
  • Fix serialization of List of Enums as Input Arguments (#604) @berngp
  • Fix nullable enums in input arugments (#603) @jbaxleyiii
  • Added support for input arguments of type Any/Object. (#596) @paulbakker
dgs-framework -

Published by paulbakker about 3 years ago

dgs-framework - v4.7.2

Published by berngp about 3 years ago

What’s Changed

  • Convert fix (#595) @paulbakker
dgs-framework - 4.7.0

Published by paulbakker about 3 years ago

New Features

Support for providing a bean of type PreparsedDocumentProvider (#583) @paulbakker

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);
			};
		}
	}
}

Bug fixes

Fix lists nested in input types for input arguments (#591) @paulbakker

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.

Other changes

  • Added test with null value for scalar in input argument (#590) @paulbakker
  • Added test using Object scalar (#589) @paulbakker
  • Upgrade to nebula netflixoss 10.2.0 (#581) @berngp
dgs-framework -

Published by paulbakker about 3 years ago

dgs-framework - v4.6.0

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.

What’s Changed

  • Custom implementation of convertValue for input types (#549) @paulbakker.
  • DataFetchers can have an input argument annotated with@CookieValue to express that such value should be fetch from the cookie inside the web request. (#542) @paulbakker.
  • In your server you can now declare a GraphQL Directive via the @DgsDirective annotation. (#536) @hantsy
  • Metrics should skip instrumenting data fetchers annotated with @DgsEnableDataFetcherInstrumentation(false) (#577) @berngp
  • Support methods that have multiple @DgsData annotations. (#574) @berngp
  • Add the @connection directive automatically when pagination module is used. (#568) @srinivasankavitha

⚠️ WARNING
Due the changes on #549 there are implicit modification on how GraphQL ID are serialized to input arguments.
The serialization of a GraphQL ID input argument to a Java java.util.Long will not happen out of the box now.
In principal this is not correct since an ID should be treated as a String, 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.

Performance Improvements

  • Avoid calculating the stacktrace when calling ExecutionStrategyInstrumentationContext (#562 & #567) @berngp
  • Call the ListableBeanFactory only once when fetching the MeterRegistry (#551) @berngp

Other

  • chore: Add @JsonCreator to TypedGraphQLError (#556) @hantsy
  • Added a test for working with a custom scalar for an input variable in the client (#572) @paulbakker
  • Added test for input arguments without annotation. (#564) @paulbakker
  • Bump spectator-api from 0.133.+ to 0.134.0 (#563) @dependabot
dgs-framework - v4.6.0-rc.5

Published by github-actions[bot] about 3 years ago

What’s Changed

  • Avoid unnecessarily calculating the stacktrace when calling ExecutionStrategyInstrumentationContext (#562) @berngp