Commit Graph

1509 Commits

Author SHA1 Message Date
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
Brian Clozel
6956523892 Merge branch '1.3.x' 2025-03-11 10:37:02 +01:00
Brian Clozel
5c2164c5f2 Propagate cancel signal from transport to data fetchers
Prior to this commit, a WebSocket/SSE client disconnecting from the data
stream would cause a CANCEL signal to be sent to upstream publishers.
This signal would flow from the transport layer up to the
`ExecutionGraphQlService`. Because the `GraphQL` engine itself relies on
`CompletableFuture`, the CANCEL signal would not flow through and
reactive data fetchers would not receive it. This means that costly
reactive operations would not be cancelled and this could cause write
failures as publishers would still produce values.

This commit adds at the service level a Reactor `Sink` to the
`GraphQLContext` that can be picked up by the
`ContextDataFetcherDecorator` when decorating reactive data fetchers.
This allows us to manually cancel publishers when the CANCEL signal is
received at the transport level.

Fixes gh-1149
2025-03-11 10:31:53 +01:00
Brian Clozel
f1f352b07c Add project icon for IntelliJ IDEA 2025-02-28 18:36:59 +01:00
Brian Clozel
4f0a72ddcb Merge branch '1.3.x' 2025-02-28 14:24:56 +01:00
Brian Clozel
929430065c Upgrade to Gradle 8.13 2025-02-28 14:24:39 +01:00
rstoyanchev
b0862fbaf4 Polishing in FederationSchemaFactory
See gh-1088
2025-02-20 11:52:51 +00:00
rstoyanchev
2f1c4b1b99 FederationSchemaFactory checks for unmapped entities
Closes gh-1088
2025-02-20 11:25:24 +00:00
rstoyanchev
310424e793 SchemaMappingInspector checks public fields
Closes gh-1101
2025-02-20 11:25:24 +00:00
Brian Clozel
4a5aaf182d Merge branch '1.3.x' 2025-02-18 11:29:12 +01:00
Brian Clozel
c3de464dc9 Next development version (v1.3.5-SNAPSHOT) 2025-02-18 11:28:15 +01:00
Brian Clozel
5b999680ab Merge branch '1.3.x' 2025-02-18 10:10:54 +01:00
Brian Clozel
693db4374a Upgrade to Spring Security 6.3.6
Closes gh-1130
2025-02-18 10:10:27 +01:00