Commit Graph

381 Commits

Author SHA1 Message Date
Brian Clozel
201c828b38 Polish 2021-11-25 10:55:37 +01:00
Brian Clozel
b9932735db Revert "Auto-configure DataLoaderRegistrar components"
This reverts commit 36a84f58bd.
2021-11-25 10:55:20 +01:00
Janne Valkealahti
f498407087 Add gitignore for eclipse
- For eclipse and vscode language server
  ignore generic files/dirs created.

Closes: gh-194
2021-11-24 20:16:08 +01:00
Brian Clozel
36a84f58bd Auto-configure DataLoaderRegistrar components
This commit configures all `DataLoaderRegistrar` application components
with the `GraphQlService`. This allows applications to contribute
`DataLoader` instances without using the annotated-controller
programming model.

Closes gh-189
2021-11-24 16:18:40 +01:00
Brian Clozel
d0adceee4b Configure GraphQlProperties even if GraphQlSource is defined
Prior to this commit, the main GraphQL auto-configuration would be
guarded with a condition on a `GraphQlSource` bean being missing. While
we want to prevent the auto-configuration from registering such a bean
if the user configuration already did so, we should still contribute the
`GraphQlProperties` bean to the context, as it is required for other
purposes.

This commit moves the condition directly on the bean method to avoid
this.

Fixes gh-186
2021-11-24 10:16:38 +01: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
Mingyuan Wu
d9404ea3d6 Upgrade to Spring Boot 2.6
Closes gh-187
2021-11-22 14:32:50 +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
0df1884500 Add option for expected errors to GraphQlTester
Closes: gh-175
2021-11-16 21:43:52 +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
2d5f9ce2a0 Upgrade to Gradle 7.3 2021-11-10 22:21:51 +01: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
Rossen Stoyanchev
2da6bd3824 Refactoring in spring-graphql tests
Add GraphQlResponse wrapper around ExecutionResult to provide access to
data with JSONPath and type conversion, along with convenience methods
to verify errors.
2021-11-08 09:42:07 +00:00
Rossen Stoyanchev
3318e81885 Refactoring in spring-graphql tests
Change GraphQlTestUtils to match how tests have evolved with regards to
how GraphQlSource is initialized and ensure all tests use it.
2021-11-08 09:42:07 +00:00
Koen Punt
2e820dce7a Fix typo 2021-11-03 21:15:39 +00:00
Rossen Stoyanchev
5aac81c003 Polishing contribution
Closes gh-176
2021-11-03 17:25:26 +00:00
Koen Punt
a06ebdcd9c Allow variables with null values in GraphQlTester
See gh-176
2021-11-03 17:25:26 +00:00
Rossen Stoyanchev
5aaf5b1df4 Context for batch loading functions
Batch loading functions registered via BatchLoaderRegistry now have
Reactor Context propagated to them and also have access to the
GraphQLContext from the ExecutionInput.

Closes gh-173
2021-11-03 17:08:19 +00:00
Rossen Stoyanchev
6f16e5e6ea Add mention of directives in documentation
Closes gh-177
2021-11-02 14:57:47 +00:00
Rossen Stoyanchev
f5c17b52d3 Filter Kotlin Continuation in BatchLoaderHandlerMethod
Closes gh-174
2021-11-02 14:50:25 +00:00
Rossen Stoyanchev
b321e350aa Polishing
See gh-3
2021-11-01 18:17:44 +00:00
Rossen Stoyanchev
4dcb9ea7c6 Support Locale as a controller method argument
Closes gh-3
2021-11-01 18:17:44 +00:00
Rossen Stoyanchev
2c8638dd6a HTTP handlers set Locale in ExecutionInput
See gh-3
2021-11-01 18:17:44 +00:00
Brian Clozel
f4a7c80cac Publish CI image as 1.0.x tag 2021-10-29 21:44:18 +02:00
Brian Clozel
c2559c2893 Configure Docker CI image building 2021-10-28 16:35:03 +02:00
Rossen Stoyanchev
dbf0fd704e Update GraphQlTest Javadoc 2021-10-28 14:17:04 +01:00
Rossen Stoyanchev
6dabd7c212 Update docs and samples on "slice" tests
See gh-75
2021-10-28 12:29:24 +01:00
Rossen Stoyanchev
59d5458333 Update sample tests after test config improvements
See gh-75
2021-10-27 21:53:15 +01:00
Brian Clozel
02d6cb1c59 Refine GraphQL testing infrastructure
After the introduction of the `@GraphQlTest` annotation, this commit
adds further refinements to the testing infrastructure.

Now, `@GraphQlTest` is completely independent of any web framework and
contributes a `GraphQlTester` component.

`@SpringBootTest` integration tests with mock servers only require an
`@AutoConfigureWebGraphQlTest` to get a `WebGraphQlTester` component.

Closes gh-75
2021-10-27 21:16:03 +02:00
Rossen Stoyanchev
ba6cf88a7d Polishing and minor refactoring
Closes gh-168
2021-10-27 16:52:08 +01:00
Mark Paluch
f1a67e560b Limit field projection according to field selection.
We now request only property paths from the repository query
that are requested through a GraphQL query if the result type
is not a projection. That reduces the amount of data being
retrieved from the underlying data store.

See gh-168
2021-10-27 16:51:32 +01:00
Mark Paluch
7fea8730db Migrate QuerydslDataFetcher to use fluent Querydsl API
Remove supporting classes for external projection as projections are
handled by Spring Data directly.

See gh-168
2021-10-27 16:51:21 +01:00
Hantsy Bai
eecddb314c Update index.adoc
It should be `List` here?
2021-10-27 11:41:54 +01:00
Rossen Stoyanchev
23d2450e64 Polishing 2021-10-26 12:55:10 +01:00
Brian Clozel
d58dd5c765 Upgrade JDK versions in CI pipeline
Closes gh-170
2021-10-25 09:52:23 +02:00
Brian Clozel
652bb70cf1 Upgrade Ubuntu version in CI pipeline
Closes gh-171
2021-10-25 09:51:48 +02:00
Brian Clozel
207f0ae1a3 Fix typo in Spring Boot testing support
See gh-75
2021-10-22 22:04:27 +02:00
Brian Clozel
e053e14158 Add GraphQlTest annotation
Prior to this commit, we could only test Spring GraphQL applications
with a complete application - all application and infrastructure
components were involved. While using `@SpringBootTest` is often useful
for complete integration tests (with or without a live running server),
we often want to write lean integration tests and test slices of our
application.

Just like `@WebMvcTest` or `@WebFluxTest`, this commit introduces the
support for `@GraphQlTest`. This annotation helps us to test a
particular slice of our application: a hand-picked selection of
`@Controller`, plus `RuntimeWiringConfigurer` and `WebInterceptor`
beans.

Other `@Component` must be imported or mocked for those tests.

This commit also refactors the existing auto-configuration to enable
this use case. The `WebGraphQlHandlerAutoConfiguration` now holds the
required components for `@GraphQlTest`, while other web-related
auto-configurations bring the web framework and transport
infrastructures.

Closes gh-75
2021-10-22 22:00:02 +02:00
Rossen Stoyanchev
69e34baadf Polishing
See gh-162
2021-10-21 15:54:00 +01:00
Rossen Stoyanchev
20bae75ed8 Add WebSocketInterceptor
See gh-162
2021-10-20 21:21:31 +01:00
Rossen Stoyanchev
811d32b647 Update section on GraphQlSource.Builder
See gh-154, gh-167
2021-10-18 18:47:53 +01:00
Rossen Stoyanchev
f05fd3550a Polishing in ClassNameTypeResolver 2021-10-15 17:32:41 +01:00
Rossen Stoyanchev
cedc6ede3d Support DataFetchingFieldSelectionSet as an argument 2021-10-15 17:19:22 +01:00
Rossen Stoyanchev
28b3d13b0b Add example of custom scalar type
Closes gh-161
2021-10-15 16:59:08 +01:00
Rossen Stoyanchev
d5d57c9a2c Update Javadoc for BatchMapping
Closes gh-166
2021-10-15 16:19:11 +01:00
Rossen Stoyanchev
acd060c50e Support for default TypeResolver
See gh-154
2021-10-15 14:33:58 +01:00