Commit Graph

359 Commits

Author SHA1 Message Date
rstoyanchev
2c77433ebd Support custom "subscription" type name
Closes gh-590
2023-01-04 16:21:32 +00:00
rstoyanchev
3bee3e81cc Use ParameterNameDiscoverer with BatchMapping
Closes gh-562
2022-12-19 20:22:46 +00:00
Brian Clozel
d1300f56bf Add reachability metadata for GraphQL client resources
This commit adds reachability metadata for resources loaded by the
`GraphQlClient` and `GraphQlTester` when using the `document("name")`
API variant. This method loads the query file from the classpath at
particular locations, namely `"classpath:graphql-documents/"` and
`"classpath:graphql-test/"` with the `".graphql"` and `".gql"` file
extensions.

This commit adds the relevant resource metadata so that such resources
are loaded in the GraalVM native image at build time when the client or
the tester are reachable through the static analysis.

Fixes gh-575
2022-12-09 15:15:37 +01:00
Brian Clozel
5f1ca8cda3 Add reachability metadata for RSocket client
Prior to this commit, using the RSocket client in a native image would
fail when setting up the codecs, if the chosen transport was WebSocket.
This is due to the fact that the `GraphQlWebSocketMessage` type was not
registered for reflection and the proper codec could not be detected as
a result.

This commit adds reflection metadata for this type.

Fixes gh-574
2022-12-09 15:13:12 +01:00
Brian Clozel
0362bdf100 Log schema resources during application startup
This commit logs the number of schema resources that were loaded to
create the GraphQL schema, at the INFO level. If DEBUG is enabled for
this package, the description of all schema resources will be logged as
well.

Closes gh-566
2022-12-08 17:06:43 +01:00
rstoyanchev
0bd30582e5 Add factory method for DataFetcherExceptionHandler
Closes gh-552
2022-12-08 14:43:41 +00:00
rstoyanchev
75d5d4b33a Allow binding raw map to Map<String,?>
Closes gh-554
2022-12-08 14:43:41 +00:00
rstoyanchev
c43c0bec2e Polishing
Closes gh-559
2022-12-06 15:39:35 +00:00
Mark Paluch
ca0d0b46f9 Add builder customizers for Querydsl and QBE DataFetcher
We now provide Builder customizers to customize DataFetchers
created out of Querydsl and Query by Example repositories
by letting repositories implement customizer interfaces.

See gh-559
2022-12-06 15:39:35 +00:00
Brian Clozel
573e89987f Adapt to GraphQL over HTTP spec changes
As of graphql/graphql-over-http#215, the official media type for GraphQL
HTTP responses is now `"application/graphql-response+json"` instead of
`"application/graphql+json"`. The latter is now deprecated and support
will be removed in the future.

This commit now favors the new media type.
HTTP Clients are still supposed to send requests with the
`"application/json"` content type.

Closes gh-563
2022-12-05 14:47:51 +01:00
Brian Clozel
eb9b1f308d Add reflection hint for GraphQlWebSocketMessage
Prior to this commit, GraphQL applications using the WebSocket transport
would fail with an `java.lang.IllegalArgumentException: No JSON Encoder`
as the JSON codec was reflecting on the `GraphQlWebSocketMessage` to
check that it can handle this type, during startup time.

`GraphQlWebSocketMessage` is the message type being used for sending and
receiving GraphQL requests. This commit registers binding reflection on
this type as soon as a `GraphQlWebSocketHandler` (mvc or webflux) is
registered as a bean in the application.

This type is also used on the client side in the client
`WebSocketGraphQlTransport`. Because clients cannot be reliably detected
here in the application context or via classpath checks, this commit
also adds a JSON metadata file that adds reflection on the type, if and
only if the `WebSocketGraphQlTransport` is reachable by the static
analysis performed by GraalVM.

Fixes gh-560
2022-12-02 15:32:21 +01:00
Brian Clozel
a43c92854f Fix NullPointerException in Tracing support
Prior to this commit, using the tracing support could result in an
NullPointerException since the instrumentation expected the tracing
propagation information to be always available from the request
extensions.

This commit improves the strategy for extracing the inbound propagation
information.

First, the instrumentation now looks up the propagation information in
the GraphQL context first, then in the request extensions as a fallback.
We ensure that no NPE can be raised if the information is missing.
Some clients might change the propagation information in the request
extensions, but in the HTTP world, most clients will send those as HTTP
headers. We are adding a new `PropagationWebGraphQlInterceptor` that can
be configured on the application to copy the relevant HTTP headers from
the HTTP request to the GraphQL context. For other transports, we
currently advise the request extensions - both WebSocket and RSocket
multiplex over the same transport message, making this approach
impossible.

Fixes gh-547
2022-12-02 09:05:23 +01:00
Brian Clozel
5b4eb8cb73 Align observation convention with Micrometer best practices
This commit ensures that the contextual names of the observations all
start with `"graphql"` (lowercase) and that all key values are prefixed
with `"graphql.*"` for a cleaner namespace.

Fixes gh-558
2022-12-02 09:04:10 +01:00
rstoyanchev
6958e39f5c Fix isOmitted to return true for omitted arguments
Closes gh-553
2022-12-01 12:54:15 +00:00
rstoyanchev
6119be935a Improve optional argument support for ProjectedPayload
This commit adds support for the ArgumentValue wrapper for passing null
when the argument is not present.

Closes gh-550
2022-12-01 12:53:04 +00:00
rstoyanchev
d8b3dad505 Polishing ProjectedPayloadMethodArgumentResolver
See gh-550
2022-12-01 11:38:47 +00:00
rstoyanchev
78bdf306f9 Support schema transforming GraphQLTypeVisitor
Closes gh-536
2022-11-17 17:05:55 +00:00
Brian Clozel
757d48255a Add AOT support for annotated Controllers
Prior to this commit, Spring for GraphQL would not support AOT and
GraalVM Native. Applications can perform reflection, load resources or
require JDK proxies at runtime and we need to contribute `RuntimeHints`
during the AOT phase.

This commit adds a new `BeanFactoryInitializationAotProcessor` component
that introspects GraphQL controllers and registers the relevant
reflection hints for binding on argument types and schema types.
This also registers JDK proxies for `@ProjectedPayload` support if
Spring Data Commons is present in the classpath.

Closes gh-495
2022-11-15 21:24:17 +01:00
rstoyanchev
fb636ad554 Support maxBatchSize via BatchMapping annotation
Closes gh-520
2022-11-14 17:13:03 +00:00
rstoyanchev
1eca67700f Support for default DataLoaderOptions
Closes gh-522
2022-11-09 15:52:41 +00:00
rstoyanchev
ca90cedf3b Refine null handling in ClientResponseField#toEntity
closes gh-525
2022-11-04 13:53:52 +00:00
rstoyanchev
05939d5e7e Merge branch '1.0.x' 2022-11-04 13:50:57 +00:00
rstoyanchev
5905f02bd6 Deprecate ResponseField getError and hasValue
See gh-499
2022-11-04 11:01:58 +00:00
rstoyanchev
2dafd5dfc7 Merge branch '1.0.x' 2022-11-04 08:40:30 +00:00
rstoyanchev
02f96b6bf4 Raise exception for any field error in retrieve
This commit aligns the behavior of retrieve with its Javadoc such that
any field error, including errors on nested fields, raises a
FieldAccessException

Closes gh-499
2022-11-04 06:36:15 +00:00
rstoyanchev
be9a21562c Polishing GraphQlArgumentBinder
See gh-349
2022-10-24 18:15:17 +01:00
rstoyanchev
16b1f94e69 Support binding to class with enum generic type
Closes gh-349
2022-10-21 18:24:17 +01:00
rstoyanchev
36501c1c28 Polishing
See gh-394
2022-10-21 17:33:33 +01:00
rstoyanchev
7f89bb92f6 Support argument binding to java.util.Set property
Closes gh-394
2022-10-21 16:27:33 +01:00
rstoyanchev
d9f815ed70 Add support for checking if an argument was omitted
Closes gh-518
2022-10-21 14:33:12 +01:00
rstoyanchev
8d80e5f883 Remove DataBinder from GraphQlArgumentBinder
DataBinder is not a great fit to bind GraphQL arguments which
are essentially a (structured) map of maps and collections, rather
than a (flat) map of property values with JavaBean paths.

We already navigate recursively the GraphQL arguments map, which
corresponds to the target Object structure, creating values, so all
we have to do is check for matching bean properties at each level
and set them.

See gh-516
2022-10-20 15:31:07 +01:00
rstoyanchev
5c75f7cf10 Merge branch '1.0.x' 2022-10-19 10:19:19 +01:00
rstoyanchev
11fab7dafd Polishing
See gh-449
2022-10-19 09:07:53 +01:00
rstoyanchev
d38ffeae6b Consistent raw value handling in GraphQlArgumentBinder
This commit ensures a single method is used to bind raw values,
whether those a top level argument value, or a value nested within a
collection or map.

See gh-449
2022-10-19 06:06:57 +01:00
rstoyanchev
bc8ee162f9 Minor refactoring in GraphQlArgumentBinder
See gh-449
2022-10-19 06:06:57 +01:00
rstoyanchev
9be5a95948 Support binding to Map as target value
Before this commit, we supported binding to a higher level object,
or a scalar, or a List of either, but not to a Map of either, which
requires similar support as what we have for a List, i.e. creating
the target Map and populating it in a recursive manner.

This commit adds that support.

Closes gh-449
2022-10-19 06:06:57 +01:00
Brian Clozel
1b19189500 Add Observability support
Prior to this commit, metrics instrumentation was provided by Spring
Boot, using Micrometer metrics. The `Instrumentation` would publish two
timers and a counter, but would not support tracing.

This commit replaces the former with a dedicated support in Spring for
GraphQL directly. This uses the new `Observation` API from Micrometer
and publishes two observations:

* a request execution observation, with timing and tracing included
* a data fetching observation with the request execution as a parent
  observation

Closes gh-501
2022-10-18 15:51:48 +02:00
rstoyanchev
ea8fed8800 Merge branch '1.0.x' 2022-10-17 17:44:19 +01:00
rstoyanchev
13683eea17 Support Optional for ProjectPayload arguments
Closes gh-506
2022-10-17 17:27:44 +01:00
rstoyanchev
30b16898f3 Merge branch '1.0.x' 2022-10-13 17:13:05 +01:00
rstoyanchev
f3d07c1bd8 Polishing contribution
Closes gh-498
2022-10-13 17:02:08 +01:00
Iván Rodríguez Murillo
0faa63beea Allow use of loadbalanced RSocketRequester
See gh-498
2022-10-13 15:55:21 +01:00
Brian Clozel
c414411278 Upgrade dependencies
* switch to expected Hibernate version
* upgrade log4j2 dependency
2022-10-11 14:26:22 +02:00
Brian Clozel
00ca12f414 Switch to Reactor and Context Propagation SNAPSHOTs 2022-10-06 15:56:39 +02:00
rstoyanchev
d6c855898f Merge branch '1.0.x' 2022-09-20 14:06:57 +01:00
rstoyanchev
84904170a8 Support binding to generic Object constructor arg
Closes gh-447
2022-09-20 13:52:38 +01:00
rstoyanchev
dfed05a822 Consistent access to raw arguments map
See gh-493
2022-09-20 13:52:38 +01:00
rstoyanchev
02c9ab1dc0 Merge branch '1.0.x' 2022-09-19 17:07:54 +01:00
rstoyanchev
1773f6ed33 Apply validation only when annotations detected
Closes gh-445
2022-09-19 15:34:36 +01:00
rstoyanchev
76f97da412 Polishing validation code
See gh-445
2022-09-19 15:34:36 +01:00