Commit Graph

78 Commits

Author SHA1 Message Date
Brian Clozel
5747def15b Upgrade to GraphQL Java 24.0
This commit sets the new GraphQL Java baseline to 24.0 for this Spring
for GraphQL generation.

This also uses the new `DataLoader#getName` property in the batch loader
registry and the observability instrumentation.

Closes gh-1210
Closes gh-1211
2025-05-16 09:27:24 +02:00
Brian Clozel
20142fc4de Merge branch '1.3.x' 2025-05-12 11:50:43 +02:00
Brian Clozel
ce9472fdd9 Upgrade to GraphiQL 4.0.0
Closes gh-1209
2025-05-12 11:50:14 +02:00
Brian Clozel
450cef197f Merge branch '1.3.x' 2025-04-15 22:33:50 +02:00
Brian Clozel
6ddaeadbd5 Fix codegen documentation section
Closes gh-1188
2025-04-15 22:33:28 +02:00
Brian Clozel
ac9616fd9f Revert ArgumentValue->FieldValue changes
See gh-1187
See gh-1190
See gh-1174
2025-04-15 12:02:29 +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
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
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
3c97533725 Document use of local context in Controllers
See gh-1167
2025-04-01 17:24:18 +02: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
a5ec819748 Merge branch '1.3.x' 2025-03-14 09:40:35 +01:00
rstoyanchev
cf1c99f489 Support DataLoader in EntityMapping methods
Closes gh-1095
2025-03-13 12:06:52 +00: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
Mark Paluch
8dce170a12 Update annotation processor documentation for Querydsl.
Reflect jakarta classifiers for Querydsl annotation processing. Also, update to Java 22+ conventions requiring annotation processor paths instead of relying on annotation processors present in dependencies.

Closes gh-1121
2025-02-17 11:57:59 +01:00
Brian Clozel
c5fef9b4ab Document GraphQL over HTTP spec support
This commit concludes the support for the "GraphQL over HTTP" spec, with
both clients and servers complying with the expected behavior for the
"application/graphql-response+json" response media type.

Closes gh-1117
2025-02-13 17:38:13 +01:00
Salman
8f303e630f Fix reference navigation to Spring Boot
Closes gh-1097
2025-01-13 10:40:46 +01:00
Simone Conte
3105e6f43d Remove duplicated wording in federation.adoc 2024-12-04 12:15:49 +00:00
rstoyanchev
88d7ea7894 Pass localContext only if available
See gh-1066
2024-10-21 18:31:47 +01:00
Brian Clozel
d7ed85045b Produce INTERNAL_ERROR observation outcome
Prior to this commit, the `DefaultExecutionRequestObservationConvention`
would only produce "INTERNAL_ERROR" outcomes if the response is null or
if an unresolved exception remains.

The `ExceptionResolversExceptionHandler` will catch all unresolved
exceptions and add them to the errors map with the
`ErorType.INTERNAL_ERROR` error type. This means that the
"INTERNAL_ERROR" outcome is never used.

This commit ensures that this outcome is also used if at least one
resolved error is of `ErorType.INTERNAL_ERROR`.

Fixes gh-1058
2024-10-09 12:25:01 +02:00
rstoyanchev
ba1dcf0baf Document behavior when "first" and "last" present
Closes gh-1055
2024-09-16 12:08:37 +01:00
rstoyanchev
71b709253d Polishing documentation on pagination
See gh-1055
2024-09-16 12:07:38 +01:00
Brian Clozel
1979e435c3 Upgrade to GraphQL Java 22.2
This also documents the new subscription ordering feature as reported
and requested in #949.

Closes gh-1044
2024-08-21 18:12:48 +02:00
Brian Clozel
311531b74f Move client and testing docs to compiled code snippets
Prior to this commit, the "client" and "testing" sections of the
reference documentation were using inline code snippets.
Because of this, several snippets were out of date or invalid.

This commit moves all those code snippets to actual Java classes
compiled with the documentation.

Fixes gh-1042
2024-08-21 10:44:54 +02:00
Brian Clozel
c1ed773cc7 Document minimum standalone setup for GraphQL support
Most Spring for GraphQL applications use Spring Boot as a way to
auto-configure the required infrastructure for running GraphQL
applications.

This commit documents a minimal setup for Spring applications not
relying on Spring Boot. This assumes an existing infrastructure for a
Spring MVC application.

Closes gh-606
2024-07-12 16:06:48 +02:00
Hantsy Bai
1dcc2ddc3a Update transports.adoc
fix `GraphQlWebFluxAutoConfiguration` format in websocket section.
2024-06-25 09:54:56 +01:00
Brian Clozel
6e155c0321 Update reference doc links to Spring Boot 3.3.x
Closes gh-1016
2024-06-20 09:57:58 +02:00
Brian Clozel
a9a8d0b745 Add fragments support in GraphQlTester
This commit adds support for GraphQL fragments with `GraphQlTester`.
Fragments allow to avoid repetition in GraphQL requests by reusing
field selection sets.

For example, the "releases" fragment can be reused in multiple queries
and make the overall document shorter:

```
query frameworkReleases {
  project(slug: "spring-framework") {
    name
    ...releases
  }
}
query graphqlReleases {
  project(slug: "spring-graphql") {
    name
    ...releases
  }
}

fragment releases on Project {
  releases {
    version
  }
}
```

With this change, `GraphQlTester` accepts fragments as `String` or can
load them by their name using the configured `DocumentSource`, similarly
to the document support.

Closes gh-964
2024-06-03 18:27:19 +02:00
rstoyanchev
c35fc08783 Fix link to samples
See gh-208
2024-05-23 17:27:30 +01:00
rstoyanchev
351ce9fbd5 Update Samples section of reference
See gh-208
2024-05-23 17:14:18 +01:00
rstoyanchev
f9a34efe1f Merge branch '1.2.x' 2024-05-18 13:08:08 +01:00
rstoyanchev
aa1ee77867 Document how to configure custom ExecutionStrategy
Closes gh-832
2024-05-18 13:05:02 +01:00
rstoyanchev
dd2a3d21d5 Tests and docs for AuthenticationWebSocketInterceptor
Closes gh-268
2024-05-17 14:18:58 +01:00
rstoyanchev
f4c6fca42f Update docs for blocking controller method support
See gh-958
2024-05-07 17:45:57 +01:00
rstoyanchev
0ab80ee5ce Improve class mapping in SchemaMappingInspector 2024-05-03 20:01:56 +01:00
rstoyanchev
b8c4899475 Update docs for Kotlin method signatures
See gh-954
2024-05-01 08:01:05 +01:00
rstoyanchev
432d982579 Polishing federation section of the reference
See gh-922
2024-04-24 09:33:15 +01:00
Brian Clozel
b8b4774f11 Merge branch '1.2.x' 2024-04-16 17:17:38 +02:00
Brian Clozel
1d98f9b45f Document schema Namespacing with annotated controllers
Closes gh-863
2024-04-16 17:16:44 +02:00
rstoyanchev
31f50752d8 Update docs for batched EntityMapping methods
Closes gh-922
2024-04-15 12:40:03 +01:00
rstoyanchev
3f7e0f1be5 Polishing Federation section in docs 2024-04-15 12:40:03 +01:00
rstoyanchev
d45d31b1f1 Update docs for schema interface mappings
Closes gh-871
2024-04-15 12:40:03 +01:00
rstoyanchev
0b491b9635 Polishing docs 2024-04-15 12:40:03 +01:00
rstoyanchev
b84d521f1d Polishing documentation
See gh-608
2024-04-11 18:00:09 +01:00
Toby
3f5fc1a5b3 Support keepAlive in WebSocket client
See gh-608
2024-04-11 15:09:17 +01:00
rstoyanchev
d31b94ec02 Documentation update in WebSocket section
See gh-534
2024-04-11 14:20:02 +01:00
Brian Clozel
9e4d77395a Configure Jackson codec specifically for GraphQL HTTP endpoints
Prior to this commit, the `GraphQlHttpHandler` implementations would use
the JSON codecs configured in the web Framework (MVC or WebFlux) for
reading and writing GraphQL payloads as JSON documents.

This can cause issues in cases the application configures the JSON codec
in a way that makes it incompatible with the expected GraphQL documents.
For example, not serializing empty values and arrays.

This commit adds new constructors in `GraphQlHttpHandler`
implementations that can get a custom JSON codec for GraphQL payloads.

Closes gh-860
2024-04-02 18:11:35 +02:00
rstoyanchev
1e6a5a09d7 Polishing in SchemaMappingInspector
See gh-934
2024-03-26 10:12:29 +00:00