Commit Graph

347 Commits

Author SHA1 Message Date
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
Rossen Stoyanchev
75184c55e6 Extract method to GraphQlTestUtils 2021-10-15 12:39:20 +01:00
Koen Punt
454c041546 Recursively instantiate beans in arguments
This commit ensures that Java beans using primary constructors are
properly instantiated when they're nested and that the instantiation
algorithm is called recursively.

Fixes gh-155
2021-10-06 11:37:52 +02:00
Rossen Stoyanchev
94ff0a2aaf Refactoring in reference docs
Consolidate the content on `@SchemaMapping` into its own sub-section
and make it consistent with the same for `@BatchMapping`.

See gh-130
2021-10-05 10:16:09 +01:00
Rossen Stoyanchev
429f6f44bf Polishing
Show map-based batch loading first which is easier to implement without
having to order results.

Use JUnit named arguments in BatchMappingInvocationTests.

See gh-130
2021-10-05 10:15:20 +01:00
Rossen Stoyanchev
fc042497f0 Polishing contribution
Closes gh-153
2021-10-01 19:18:13 +01:00
Adam Pounder
c04bffc044 Allow customising the creation of GraphQLSchema
See gh-153
2021-10-01 19:18:13 +01:00
Rossen Stoyanchev
21d9791484 Update reference docs for access to HTTP headers
Also rename existing methods for request headers to be consistent with
those for response headers and use "Http" in the name.

Closes gh-74
2021-10-01 17:36:49 +01:00
Rossen Stoyanchev
762b9f06c2 Support query files for input in GraphQlTester
Closes gh-67
2021-10-01 17:36:49 +01:00
Rossen Stoyanchev
5a07883f6a Make TestExecutionResult package private 2021-10-01 17:36:49 +01:00
Rossen Stoyanchev
6777d7613b Make GraphQlTester builders and request strategies top level classes 2021-10-01 17:36:49 +01:00
Rossen Stoyanchev
e644e5e192 Support classes for Builder, RequestStrategy, and RequestSpec
Also separate RequestStrategy from WebRequestStrategy since those are
delegated to internally and never used as a hierarchy. The generics
required to make them extend from each other bring no benefit.
2021-10-01 17:36:49 +01:00
Rossen Stoyanchev
65b5ff9a7c WebGraphQlTester exposes HTTP response headers
Closes gh-74
2021-10-01 17:36:49 +01:00
Rossen Stoyanchev
fb8e82dcc0 Inline GraphQlTesterBuilderConfig in DefaultGraphQlTester
It's simpler to pass the config options explicitly.
2021-10-01 17:36:49 +01:00
Rossen Stoyanchev
f0f883cc39 Inline RequestSpecDelegate in DefaultGraphQlTester
The delegate has almost no logic, simply holding fields and calling the
RequestStrategy, so it adds cognitive overhead without benefit.
2021-10-01 17:36:49 +01:00
Brian Clozel
6975e6c37b Configure ConversionService for argument conversion
This commit configures a `FormattingConversionService` into the argument
resolution infrastructure, using the expected conversion service for
both MVC and WebFlux.

Closes gh-148
2021-09-30 15:26:22 +02:00
Rossen Stoyanchev
a66b49540b Polishing docs and removing unused code 2021-09-29 18:25:24 +01:00
Rossen Stoyanchev
440b123cc4 Minor refactoring
Rename AnnotatedDataFetcherConfigurer -> AnnotatedControllerConfigurer,
since handler methods are now not only data fetchers but also
batch loaders.

Move DataFetcherHandlerMethod and BatchLoaderHandlerMethod into the
support package next to AnnotatedControllerConfigurer where they're used.

See gh-130
2021-09-29 17:56:08 +01:00
Rossen Stoyanchev
0f37af1b25 Update default extensions in reference docs
See gh-134
2021-09-29 15:59:52 +01:00
Rossen Stoyanchev
5109a1195f Update documentation for @BatchMapping
Closes gh-130
2021-09-28 15:09:39 +01:00
Rossen Stoyanchev
0bb8f58008 BatchLoaderRegistry extends DataLoaderRegistrar
Given that BatchLoaderRegistry is declared as a bean and injected into
ExecutionGraphQlService as a DataLoaderRegistrar, it makes sense to
have be a DataLoaderRegistrar vs declaring the bean as the
implementation type. A BatchLoaderRegistry is supposed to result in
DataLoader registrations so this makes sense in any case.
2021-09-27 09:23:01 +01:00
Rossen Stoyanchev
56ca50e6f3 Support for @BatchMapping methods
See gh-130
2021-09-27 09:22:32 +01:00
Rossen Stoyanchev
fbe87359ac Extract InvocableHandlerMethodSupport
This prepares the way to invoke handler methods other than those
adapted to a DataFetcher with DataFetcherEnvironment as input.

See gh-130
2021-09-27 09:21:28 +01:00
Rossen Stoyanchev
f8f6a3ed9f Register batch load function by name
This is an alternative to providing the key and value types, which are
only used to form the DataLoader name.

See gh-130
2021-09-27 09:20:42 +01:00
Rossen Stoyanchev
d68edb47c9 Polishing annotated DataFetcher tests
See gh-130
2021-09-27 09:20:05 +01:00
Rossen Stoyanchev
5a8a99aea2 Refactoring in AnnotatedDataFetcherConfigurer
Introduce MappingInfo to allow passing additional mapping metadata up
the stack. In preparation for @BatchMapping methods.

See gh-130
2021-09-27 09:19:21 +01:00
Brian Clozel
b03097ad47 Remove attributes from Argument annotation
Prior to this commit, the `@Argument` annotation would support two
attributes: `required` and `defaultValue`, specifying whether arguments
should be considered as required and default values to use if they're
not present.

This can be problematic as this can already be specified at the schema
level.

To avoid duplication and invalid setups betweens schema and Controllers,
this commit removes those attributes in favor of the schema definition.

Closes gh-150
2021-09-24 13:47:56 +02:00
Rossen Stoyanchev
e0952a2791 Dependency upgrades for the Boot 2.5.5 release 2021-09-23 16:31:58 +01:00
Brian Clozel
b0dedbeb64 Polish "Recursively instantiate arguments"
Closes gh-147
2021-09-22 19:51:52 +02:00
Koen Punt
77f5875eac Recursively instantiate input arguments
Prior to this commit, the `GraphQlArgumentInstantiator` would not
instantiate and bind properly types with a list attribute that has
elements which need to be instantiated with a primary constructor.

This commit ensures that every list that is encountered is
recursively passed to the instantiator, instead of trying to
convert the list using the databinder.

This also fixes gh-145, by directly accessing the arguments from
the arguments map, instead of the mapped propertyvalues used for
the DataBinder.

See gh-147
2021-09-22 19:03:00 +02:00
Brian Clozel
552c4f72d0 Add distribution summary metric for datafetcher calls
This commit adds a new `"graphql.request.datafetch.count"` distribution
summary metric for counting the number of data fetching calls per
request.

Closes gh-146
2021-09-22 16:53:08 +02:00
Rossen Stoyanchev
74ba9061d5 Polishing CORS support 2021-09-22 13:41:39 +01:00
Brian Clozel
b830fe9f3a Fix NPE for non-required missing input arguments
Prior to this commit, a missing, non-required input argument would throw
an NullPointerException instead of returning `null` or
`Optional.empty()`.

Fixes gh-144
2021-09-22 11:06:46 +02:00
Brian Clozel
17ce7b4838 Simplify asciidoctor setup for reference docs 2021-09-21 22:08:15 +02:00
Koen Punt
d550d384d8 Enable GraphiQL header editor
This commit enables a new tab in the GraphiQL UI that allows editing
request headers.

Closes gh-142
2021-09-21 21:06:57 +02:00