Commit Graph

1521 Commits

Author SHA1 Message Date
Brian Clozel
4c70199993 Merge branch '1.3.x' 2025-04-15 11:54:27 +02:00
Brian Clozel
9228631596 Upgrade to github-changelog-generator 0.0.12 2025-04-15 11:54:11 +02:00
Brian Clozel
70f16c1158 Configure JSON GraphQlModule in client support
The various GraphQL clients supported in this project automatically detect
JSON codecs for reading/writing GraphQL requests as JSON payloads.
If there is none detected, clients provide a default codec instance.

This commit configures automatically the `GraphQlModule` from gh-1174 in
default codecs and add integration tests for `FieldValue<T>` usage on the
client side.

This also improves the documentation around `FieldValue<T>` for both
server and client side support.

Closes gh-1190
2025-04-15 11:44:05 +02:00
James Bodkin
1ec45c68f5 Add Jackson module to serialize/deserialize FieldValue
This commit adds a new `GraphQlModule` Jackson module that supports:

* serialization/deserialization of `FieldValue<T>`
* the upgrade of `FieldValue<T>` as reference types

This enables `FieldValue<T>` to be read/written from/to JSON with
Jackson on the client side. Note, on the server side this module is not
involved as the payload is deserialized as a `Map<String,Object>` and
values are bound as `FieldValue<T>` types directly.

Closes gh-1174

Signed-off-by: James Bodkin <james.bodkin@amphora.net>
[brian.clozel@broadcom.com: apply code conventions, use FieldValue type]
Signed-off-by: Brian Clozel <brian.clozel@broadcom.com>
2025-04-15 11:44:03 +02:00
Brian Clozel
9b9761f424 Rename ArgumentValue to FieldValue
Prior to this commit, `ArgumentValue<T>` would mainly focus on the
server-side support with the binding of arguments on Controller methods.

With the introduction of this feature on the client in gh-1174, this
commit reconsiders both the `ArgumentValue<T>` name and its package
location to reflect the broader support.

This commit deprecates `ArgumentValue<T>` in favor of `FieldValue<T>`
with similar support.

Closes gh-1187
2025-04-15 11:44:01 +02:00
Brian Clozel
b1e2e9a486 Merge branch '1.3.x' 2025-04-09 20:55:22 +02:00
Patrick Grosslicht
8ff287bec8 Use correct logger name in QuerydslDataFetcher
Closes gh-1185

Signed-off-by: Patrick Grosslicht <1881000+pgrosslicht@users.noreply.github.com>
2025-04-09 20:54:57 +02:00
Brian Clozel
578b04d226 Merge branch '1.3.x' 2025-04-08 17:06:37 +02:00
James Bodkin
d8381e6cf3 Allow non-nullable types in GraphQL Relay
Closes gh-1173

Signed-off-by: James Bodkin <james.bodkin@amphora.net>
[brian.clozel@broadcom.com: remove unrelated test]
Signed-off-by: Brian Clozel <brian.clozel@broadcom.com>
2025-04-08 17:02:37 +02:00
Brian Clozel
a43f3036c5 Fix data.method<->data.federation package tangle
Closes gh-1184
2025-04-08 15:29:53 +02:00
Brian Clozel
626687ae33 Add ArchUnit automated architecture checks
See gh-1184
2025-04-08 15:29:22 +02:00
Brian Clozel
6de47bd2d3 Make test classes package private
See gh-1184
2025-04-08 15:27:26 +02:00
Brian Clozel
aa59d4bf9c Upgrade to Spring Java Format 0.0.41
See gh-1184
2025-04-08 15:24:52 +02:00
Brian Clozel
ecc88f7a41 Ensure that DataLoader are retrieved from DataFetchingEnvironment
Closes gh-1177
2025-04-08 10:46:48 +02:00
Brian Clozel
04fa5e1e0f Polishing 2025-04-07 15:36:03 +02:00
Brian Clozel
594c9dfc4f Add DataLoader observability support
Prior to this commit, the `GraphQlObservationInstrumentation` would
instrument the following operations:

* GraphQL requests
* GraphQL data fetching operations

In the case of batch loading operations, the instrumentation would
consider each load call as a separate data fetching operation. This
would significantly clutter recorded traces and would make it look like
"N+1 problems" would still be present.

This commit adds a new "graphql.dataloader" observation for such
operations and avoids recording data fetching observations when
`SelfDescribingDataFetcher` declare that they call batch loading
operations.

Closes gh-1034
2025-04-07 15:30:13 +02:00
Brian Clozel
19a935fc18 Add batch loading info to SelfDescribingDataFetcher
Prior to this commit, the `SelfDescribingDataFetcher` would augment the
`DataFetcher` contract and provide more information about the data
fetcher itself.

This commit adds a new `isBatchLoading` method to indicate whether the
current data fetcher is using a `DataLoader` for fetching elements.
In Spring for GraphQL, this can typically happen if the method is
annotated with `@BatchMapping` or if the `@SchemaMapping` method as a
`DataLoader` parameter.

This change is required for instrumentation purposes: such data fetchers
should not be instrumented as data fetching operations, but instead
delegate to the `DataLoaderRegistry` being itself instrumented.

Closes gh-1176
2025-04-07 15:29:57 +02:00
Brian Clozel
462e73ede6 Upgrade to GraphQL Java 23.0
This commit upgrades to GraphQL Java 23.0.

Because this new version brings in java-dataloader 4.0.0, this commit
also adapts to a breaking change there. `DataLoaderOptions` is now
immutable and calling setters on it will return a new instance.
As a result, this commit also changes the `BatchLoaderRegistry` to
customize the dataloader by consuming a `DataLoaderOptions.Builder`
instead of a `DataLoaderOptions` directly. This only breaks binary
compatibility as both `DataLoaderOptions` and `DataLoaderOptions.Builder`
have identical APIs.

Closes gh-1169
2025-04-07 10:48:58 +02:00
James Bodkin
eb5a83ab6a Reduce allocations for empty ArgumentValue
Closes gh-1175

Signed-off-by: James Bodkin <james.bodkin@amphora.net>
[brian.clozel@broadcom.com: apply code conventions]
Signed-off-by: Brian Clozel <brian.clozel@broadcom.com>
2025-04-04 10:11:47 +02:00
Brian Clozel
e2f954a2cf Document DataFetcherResult usage in Controllers
This commit polishes the new "Local Context" section and the existing
"Return Values" section to also mention `DataFetcherResult`.

Closes gh-1167
2025-04-03 18:05:17 +02:00
Brian Clozel
48c8885041 Polishing
See gh-1172
2025-04-03 15:10:34 +02:00
James Bodkin
015058b7b5 Add isEmpty and ifPresent methods in ArgumentValue
Closes gh-1172

Signed-off-by: James Bodkin <james.bodkin@amphora.net>
[brian.clozel@broadcom.com: add tests and reduce scope]
Signed-off-by: Brian Clozel <brian.clozel@broadcom.com>
2025-04-03 15:05:23 +02:00
rstoyanchev
9180a7e4dc Allow creation of custom GraphQlSource instance
Closes gh-1086
2025-04-01 19:01:53 +01:00
Brian Clozel
4ce9ca71c2 Polishing 2025-04-01 17:27:04 +02:00
Brian Clozel
3c97533725 Document use of local context in Controllers
See gh-1167
2025-04-01 17:24:18 +02:00
Brian Clozel
acb182844b Avoid further processing when GraphQL request is cancelled
As of gh-1149, CANCEL signals are propagated from the transport request
up to reactive `DataFetcher`s. This efficiently cancels processing and
avoids spending resources when execution results won't be sent to the
client.
Prior to this commit, this would have no effect on non-reactive
`DataFetcher`s because they would still be executed. While we cannot
consistently cancel ongoing blocking operations, we can avoid further
processing and other `DataFetcher`s from being called by returning an
error result instead of the original result.

This commit updates the `ContextDataFetcherDecorator` to detect if the
request has been cancelled and return early a data fetcher result with a
`AbortExecutionException` error instead of the original result.

Closes gh-1153
2025-03-28 15:06:13 +01:00
Tran Ngoc Nhan
53980216ea Fix typo
Closes gh-1165
Signed-off-by: Tran Ngoc Nhan <ngocnhan.tran1996@gmail.com>
2025-03-28 09:34:23 +01:00
Brian Clozel
afd481c7e9 Fix milestone release workflow 2025-03-18 14:08:31 +01:00
Brian Clozel
45319f9888 Upgrade test dependencies 2025-03-18 11:45:03 +01:00
Brian Clozel
82895f2fdc Upgrade to Netflix GraphQL CodeGen 7.0.3
Closes gh-1162
2025-03-18 11:44:34 +01:00
Brian Clozel
6b0fb4e7c5 Upgrade to Apollo GraphQL Federation 5.3.0
Closes gh-1161
2025-03-18 11:43:54 +01:00
Brian Clozel
bcb7c32629 Upgrade to Spring Security 6.5.0-M3
Closes gh-1160
2025-03-18 11:43:03 +01:00
Brian Clozel
ec3b103c7d Upgrade to Spring Data 2025.0.0-M2
Closes gh-1159
2025-03-18 11:42:27 +01:00
Brian Clozel
d072fac6c6 Upgrade to Micrometer 1.15.0-M3
Closes gh-1158
2025-03-18 11:41:37 +01:00
Brian Clozel
c33912994c Upgrade to Reactor 2024.0.4
Closes gh-1157
2025-03-18 11:40:03 +01:00
Brian Clozel
262c077262 Upgrade to Spring Framework 6.2.3
Closes gh-1156
2025-03-18 11:35:56 +01:00
rstoyanchev
0d672c1383 SSE handlers support keep-alive
Closes gh-1048
2025-03-17 18:14:07 +00:00
rstoyanchev
44ca9b0da0 SSE handlers support keep-alive
Closes gh-1048
2025-03-17 18:14:07 +00:00
Brian Clozel
a5ec819748 Merge branch '1.3.x' 2025-03-14 09:40:35 +01:00
Brian Clozel
a6c69eb7ac Polishing
See gh-1149
2025-03-14 09:38:56 +01:00
rstoyanchev
cf1c99f489 Support DataLoader in EntityMapping methods
Closes gh-1095
2025-03-13 12:06:52 +00:00
rstoyanchev
d51dbfb937 Remove Future checks in GraphQlHttpHandler
Closes gh-1152
2025-03-13 11:08:12 +00:00
Brian Clozel
285dcda3f5 Remove deprecated code
Closes gh-1151
2025-03-12 21:13:14 +01:00
Brian Clozel
0d4fe150aa Remove test log reporting in build output 2025-03-12 17:28:55 +01:00
Brian Clozel
6d471cd7b8 Add TimeoutWebGraphQlInterceptor
This commit adds a new web interceptor that can be configured with a
specific duration. If the response is not produced within this timeline,
the interceptor sends a HTTP error status to the client (by default,
"REQUEST TIMEOUT" but this can be configured) and sends a CANCEL signal
upstream.
This CANCEL signal flows up to controller methods and maually registered
data fetchers, if they have a reactive return type. Processing will be
automatically aborted.
For other types of date fetchers, applications can retrieve a publisher
from the GraphQL context and get notified of cancellations.

Closes gh-450
2025-03-12 17:00:18 +01:00
rstoyanchev
0df247fa38 Merge branch '1.3.x' 2025-03-11 18:23:17 +00:00
rstoyanchev
f3f5516b8a ContextDataFetcherDecorator support for DataFetcherResult
Closes gh-1143
2025-03-11 18:21:06 +00:00
rstoyanchev
008a78d1c5 Handle invalid media types as client errors
Closes gh-1145
2025-03-11 18:14:26 +00:00
rstoyanchev
bd8a633eac AbstractGraphQlTesterBuilder copies extensions/attributes
Closes gh-1135
2025-03-11 18:14:26 +00:00
rstoyanchev
5682740dee GraphQlTester provides access to underlying response
Closes gh-1131
2025-03-11 18:14:26 +00:00