Commit Graph

155 Commits

Author SHA1 Message Date
rstoyanchev
50b794cae0 Minor refactoring in RequestInput 2022-01-21 13:16:44 +00:00
rstoyanchev
bc70922ea2 Polishing contribution
Closes gh-203
2022-01-17 21:32:58 +00:00
Jordie
175673d291 Convert websocket error message payload to array
As expected in graphql-ws protocol

See gh-200
2022-01-17 21:25:40 +00:00
rstoyanchev
6d37d9bbc7 Polishing contribution
Closes gh-256
2022-01-17 21:22:43 +00:00
Minsu Lee
ab29a96a8d Fix subprotocol for subscriptions-transport-ws
See gh-256
2022-01-17 21:20:53 +00:00
rstoyanchev
d8d8229a33 Polishing
Missed one deprecation and doc updates.

See gh-244
2022-01-17 21:09:00 +00:00
rstoyanchev
5ff3f8b18d Refactor auto-registration of Querydsl and QBE fetchers
Replace the TypeVisitor with a WiringFactory that checks for existing
registrations in RuntimeWiring.Builder.

Closes gh-244
2022-01-14 19:00:36 +00:00
rstoyanchev
2ecac0bd35 Multiple WiringFactory registrations
CombinedWiringFactory makes use of multiple WiringFactory instances
possible, but RuntimeWiring.Builder does not use it by default.

This change enables use of multiple WiringFactory instances through
an extra callback on RuntimeWiringConfigurer that allows multiple
parties to add their own WiringFactory.

See gh-244
2022-01-14 18:44:54 +00:00
Brian Clozel
5b0496cbce Allow setting custom ExecutionId on RequestInput
Prior to this commit, we would use the request id as an execution id,
regardless of the overall GraphQL configuration.

This commit:

* adds a new executionId field on `RequestInput` and uses it in the
  `ExecutionInput`, if provided
* only uses the request id as a fallback if it's been asked to
* auto-detect in the `GraphQlService` whether a custom
  `ExecutionIdProvider` implementation was configured on `GraphQL`.

Closes gh-243
2022-01-13 14:41:31 +01:00
Brian Clozel
10abd919ec Configure WebSocket transport with GraphiQL
This commit enhances the GraphiQL `index.html` to rely in the
graphiql-tools fetcher function; this supports both HTTP and WebSocket
transports.

As a follow-up, this also updates the `GraphiQlHandler` implementations
to also send a `wsPath` query param if a specific path has been
configured for the WebSocket support.

As an additional change, this commit also improves the fix for gh-231 as
it was incomplete: the generated query params were not taking the
context path into account.

Closes gh-131
Closes gh-231
2022-01-10 17:05:23 +01:00
rstoyanchev
8c655cb25d Simplify access to response headers in WebOutput
The response headers can now be changed directly without the need to
go through the builder.

See gh-229
2022-01-10 10:10:49 +00:00
rstoyanchev
22985efe6a Expose ExecutionInput in WebOutput
WebOutput now exposes the ExecutionInput prepared for the request and
no longer provides access to the WebInput which is already available
to a WebInterceptor.

Closes gh-229
2022-01-10 10:10:49 +00:00
rstoyanchev
c84f342daf Extract RequestOutput base class
See gh-229
2022-01-10 10:10:49 +00:00
rstoyanchev
6106ef630a Polishing
See gh-239
2022-01-10 10:10:49 +00:00
Koen Punt
3fc447e50d Allow null values to async handler methods
Previously when the argument contained a null value (for example for nullified
continuation when using a suspend fun), it would fail to convert the arguments,
because of a `NullPointerException`.

By allowing the mono value be nullable it converts the arguments successfully.

Closes gh-239
2022-01-10 10:10:49 +00:00
Brian Clozel
1dc328cf65 Handle context path in GraphiQlHandler
Prior to this commit, the MVC `GraphiQlHandler` variant would not
generate a redirect link with the context path prefix.

This commit takes the context path into account and adds test coverage
to both variants.

Fixes gh-231
2022-01-07 20:33:09 +01:00
Brian Clozel
dd81d72fcb Start moving testing infra as test fixtures
This commit applies the `java-test-fixtures` to the project modules and
starts moving common infrastructure to the testFixtures configuration.

See gh-217
2021-12-10 22:52:14 +01:00
Brian Clozel
3e29e71a6e Add support for Bean Validation
This commit adds support for validating handler method inputs after
binding from the data fetching environment and before invoking the
handler method.

This support is based on Bean Validation and is enabled only if the
application context contains a `Validator` bean.

Closes gh-110
2021-12-10 15:50:16 +01:00
Rossen Stoyanchev
58f2afebb5 Polishing contribution
Closes gh-215
2021-12-09 21:23:59 +00:00
Rossen Stoyanchev
5919178d91 Refactoring in GraphQL argument initialization
Consolidate GraphQL argument initialization by pushing logic from
ArgumentMethodArgumentResolver down into GraphQlArgumentInitializer,
which now takes the DataFetchingEnvironment, an optional argument name,
and a target type, and does the rest of the work.
2021-12-09 10:26:37 +00:00
Rossen Stoyanchev
b22cef00ab Support context parameters in @BatchMapping methods
Closes gh-172
2021-12-08 13:44:19 +00:00
Rossen Stoyanchev
50aeaba63e Add support for @ContextValue method parameters
See gh-172
2021-12-08 09:47:49 +00:00
Rossen Stoyanchev
e6453ef9b0 Ensure DataLoaderOptions are per request
See gh-212
2021-12-07 20:56:56 +00:00
Rossen Stoyanchev
6b1d5ebf64 Move graphiql index.html to spring-graphql
Closes gh-209
2021-12-02 15:53:36 +00:00
Rossen Stoyanchev
5597f543bd Polishing contribution
Closes gh-202
2021-12-01 18:39:17 +00:00
Rossen Stoyanchev
85cdadc2c8 Resolve merge conflict
The convert method in ArgumentMethodArgumentResolver is gone and in any
case ProjectedPayloadMethodArgumentResolver mainly needs to know the
name of the argument if an Argument annotation is present.

See gh-202
2021-12-01 17:28:23 +00:00
Mark Paluch
5aa72f216f Support for projected payloads
Controller methods now accept interface projections for individual or all
request arguments when Spring Data is on the class path.

See gh-202
2021-12-01 11:59:58 +00:00
Rossen Stoyanchev
4d99d2ab31 Refactoring in query package
Increase sharing between QBE and Querydsl:
- shared GraphQLTypeVisitor for auto-registration
- utility methods for repository info
2021-11-26 19:19:08 +00:00
Rossen Stoyanchev
38f9f987e4 Combine querydsl and querybyexample into one package
Following the addition of Query By Example, it makes sense to
consolidate the two that mirror each other, are closely related, and
can share package private support.

See gh-191
2021-11-26 19:19:08 +00:00
Rossen Stoyanchev
0f1073b7b5 Remove deprecated annotation 2021-11-26 19:19:08 +00:00
Rossen Stoyanchev
f81334f985 Move GraphQlArgumentInitializer to data package
Following the changes in #191, GraphQlArgumentInitializer is no longer
package private and also needs to be used in the DataFetcher for
Query By Example. As a first step, this change moves the class to
the top-level data package that is a parent of both.

See gh-191
2021-11-26 16:13:15 +00:00
Rossen Stoyanchev
3321121c41 Polishing and minor refactoring in GraphQlArgumentInitializer 2021-11-26 15:56:40 +00:00
Rossen Stoyanchev
425dc9c461 Polishing
See gh-191
2021-11-26 14:42:10 +00:00
Rossen Stoyanchev
cc5a8427a8 Update documentation
See gh-201
2021-11-26 14:26:50 +00:00
Rossen Stoyanchev
46d4d3d648 Polishing contribution
Closes gh-201
2021-11-25 18:12:23 +00:00
Mark Paluch
8704177741 Detect if repository is a QuerydslBinderCustomizer
We now detect Querydsl customizers during auto-registration for
repositories that implement QuerydslBinderCustomizer as default
interface method.

See gh-201
2021-11-25 18:00:27 +00:00
Rossen Stoyanchev
5c5cfdd277 Polishing contribution
Closes gh-201
2021-11-25 17:55:34 +00:00
Greg L. Turnquist
c9b5652833 Support for Query By Example based DataFetcher
This adds support for Spring Data's recent fluent query API via
Query by Example. It tests against Spring Data JPA and Spring Data MongoDB
for imperative, and Spring Data MongoDB for reactive support. To support
MongoDB testing, it uses Testcontainers.

See gh-191
2021-11-25 17:55:34 +00:00
Brian Clozel
b6897168cf Polish
See gh-183
2021-11-25 16:43:11 +01:00
Brian Clozel
cfd0403008 Make id mandatory for RequestInput
This commit is a follow up of 2e4158c and makes the following changes:

* the id is now a mandatory attribute for `WebInput` and `RequestInput`
* a consistent IdGenerator strategy is configured for all requests

Closes gh-183
2021-11-25 12:30:56 +01:00
Rossen Stoyanchev
9ce4b6801e Allow mapping annotations at the class level
Closes gh-195
2021-11-25 11:09:30 +00:00
Rossen Stoyanchev
5f260d12f6 Polishing 2021-11-25 10:44:33 +00:00
Brian Clozel
2e4158cae8 Set ExecutionId on web requests
Prior to this commit, the `WebInput` would hold an `id` attribute that
correlate the request and response messages on a multiplexed connection.

This commit moves this concept directly to the `RequestInput` so that it
can be used as an `ExecutionId` for all types of transports, if
availble.

This id was already set on the `WebInput` in the WebFlux case with the
id coming from the exchange, but it also creates an id and set it for
the MVC case. This id is then propagated to GraphQL's `ExecutionInput`.

See gh-183
2021-11-23 20:10:53 +01:00
Rossen Stoyanchev
b69b92d2c8 Update DataFetcherExceptionResolverAdapter
Make it protected since it needs to be extended and add factory method
with a BiFunction as an alternative.
2021-11-17 11:27:20 +00:00
Rossen Stoyanchev
e2a53759cb Switch DataFetcherExceptionHandler to async contract 2021-11-17 03:50:33 +00:00
Rossen Stoyanchev
5c0b32912a Simplify setup for annotated controller tests 2021-11-12 21:44:10 +00:00
Rossen Stoyanchev
9a7bab42c9 Support Principal as a method argument
Closes gh-119
2021-11-12 19:47:18 +00:00
Rossen Stoyanchev
3669d29c5f Extract base class for BatchMapping tests
See gh-119
2021-11-12 19:47:18 +00:00
Brian Clozel
02089a8542 Upgrade to Spring Boot 2.6.0-RC1
This commit upgrades the experimental starter to Spring Boot 2.6.0-RC1
and aligns all dependency versions to the Spring Boot dependency
management in 2.6.

This commit also removes temporary workarounds in the testing support or
in declared dependencies now that we've moved to 2.6.

While we're now using Spring Boot 2.6 as a reference version for this
project, the baseline didn't change and this commit documents the
requirements for this project; the Spring Data version, for our QueryDSL
support, is a specific example of that.

Fixes gh-181
2021-11-09 09:39:14 +01:00
Rossen Stoyanchev
98f3d4f6ed Refactoring in spring-graphql tests
Add GraphQlSetup that provides a unified workflow for test setup
including the creation of a GraphQsSource, a GraphQlService, a
WebGraphQlHandler, and/or HTTP handlers. The workflow also helps to
collect input (schema, data fetchers) in ways that are convenient
for testing purposes.
2021-11-08 09:42:07 +00:00