Commit Graph

304 Commits

Author SHA1 Message Date
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
Brian Clozel
93c696f9bc Allow CORS configuration using config properties
Prior to this commit, a Spring GraphQL application would need to
implement `WebMvcConfigurer` or `WebFluxConfigurer` to register a
specific CORS configuration and map it to the GraphQL endpoint.

This commit adds new configuration properties under the
`spring.graphql.cors.*` namespace that helps configuring CORS for the
GraphQL endpoint.

Closes gh-26
2021-09-21 20:28:48 +02:00
Brian Clozel
543be8429f Introduce version attributes in asciidoctor docs
This commit introduces versions as dynamic attributes in the reference
docs. This also fixes a few incomplete references that were logging
warnings during the documentation build.
2021-09-21 20:28:48 +02:00
Rossen Stoyanchev
ea37c3b5a7 Simplify AnnotatedDataFetcherConfigurer config
Now that we don't use JSON conversion for input arguments, we can
declare AnnotatedDataFetcherConfigurer in shared config.

See gh-122
2021-09-21 12:52:07 +01:00
Brian Clozel
02b16bdc65 Polish "Support contructor binding for input arguments"
Prior to this commit, only default constructors were supported for
instantiating input argument types. This commit adds a new
`GraphQlInstantiator` class that manages the instantiation and binding
of data fetching environment arguments. Default constructors and
primary constructors are now handled.

Also, List-like properties were not bound from the data fetching
environment arguments to the `MutablePropertyValues` used for binding.
This commit ensures that List elements are bound to the property values
with array-like property paths.

Fixes gh-139
Fixes gh-141
2021-09-21 09:45:45 +02:00
Koen Punt
2f5aa588ef Support contructor binding for input arguments
See gh-139
2021-09-21 09:44:34 +02:00
Brian Clozel
f69aa39211 Only scan for *.graphqls and *.gqls schema files
Prior to this commit, the auto-configuration was scanning for
`"*.graphql,*.gql,*.graphqls,*.gqls"` files in the configured locations.
This was not flexible enough, as developers could not customize the
considered file extensions when scanning for files.

This commit provides a new `spring.graphql.schema.file-extensions`
configuration property that enables such customizations.

Because `"*.graphql,*.gql"` extensions seem to be tied to queries
(and not schemas), this commit also changes the default value to only
consider the `"*.graphqls,*.gqls"` file extensions by default.

Closes gh-134
Closes gh-135
2021-09-20 10:29:41 +02:00
Rossen Stoyanchev
94809537cb Upgrade GraphQL Java 17.2 -> 17.3 2021-09-20 07:39:46 +01:00
Brian Clozel
4dfb662669 Refactor input argument binding
Prior to this commit, `@Argument`-annotated controller method parameters
were bound from the environment by serializing the environment argument
map to JSON and deserialized back to the target parameter type.

This allowed to cover a large spectrum of cases but showed some
limitations: performance could be improved and custom scalars could be
overridden in the process.

This commit removes the (de)serialization process and instead:

* runs through the environment argument map to collect all properties in
  a `MutablePropertyValues` map
* instantiate the target type if necessary
* binds properties to the target type using a `DataBinder`

With this change, scalar types should not be erased and arguments now
support a wider range of Collection types.

Closes gh-122
2021-09-17 14:00:37 +02:00
Brian Clozel
762f59b2f3 Configure compiler conventions in modules
This commit applies the Compiler Conventions Gradle plugin to the
project modules and fix the issues raised by the compiler linter.

This commit also moves version management to the main build file for a
few dependencies, aligning the versions in the process.
2021-09-16 19:54:25 +02:00
Brian Clozel
5c5554b6b1 Add compiler conventions in Gradle build
This commit configures a CompilerConventions Gradle Plugin that
configures the compiler for main and test sources.
2021-09-16 17:37:49 +02:00
Rossen Stoyanchev
9e8682ff8c Polishing contribution
See gh-132
2021-09-16 11:41:59 +01:00
Koen Punt
3ef86492e3 Filter out Kotlin Continuation when resolving arguments
The `kotlin.coroutines.Continuation` argument that is passed for
suspended function was parsed erroneously as a GraphQL "source"
argument. This commit adds a resolver for Continuation that resolves
it  to `null`, which allows suspended functions to work.

Closes gh-132
2021-09-16 11:39:10 +01:00
Rossen Stoyanchev
892d2bd344 Use properties for Boot and GraphQL Java versions 2021-09-16 11:15:47 +01:00
Rossen Stoyanchev
1b72e8107d Update Spring Boot version 2.5.0 -> 2.5.4 2021-09-16 10:21:45 +01:00
Rossen Stoyanchev
b021663f5b Update docs for batch loading
Closes gh-63
2021-09-15 15:54:00 +01:00
Koen Punt
e24943ac70 docblock update 2021-09-14 17:55:55 +01:00
Rossen Stoyanchev
1bdcb8afe8 Add DataLoaderMethodArgumentResolver
This commit adds support for DataLoader<K,V> arguments on annotated
handler methods, where the key for the lookup is the class name of the
value type or the parameter name.

See gh-63
2021-09-14 09:15:41 +01:00
Rossen Stoyanchev
ddafc93c6c Add BatchLoaderRegistry
The registry is an application API for registering batch loading
functions along with DataLoaderOption's.

See gh-63
2021-09-14 09:09:44 +01:00
Rossen Stoyanchev
9228872f44 Improve exception logging 2021-09-13 10:54:39 +01:00
Rossen Stoyanchev
a056d5ba06 Add Exceptions section to Boot starter ref docs
See gh-121
2021-09-03 14:01:10 +01:00
Brian Clozel
0587913ccb Allow configuring schema through GraphQlSource customizer
As of gh-117, the GraphQlAutoConfiguration throws an exception if no
schema file was found while scanning configured locations.
This prevents developers from manually configuring the schema using
`GraphQlSourceBuilderCustomizer` instances.

This commit ensures that a `MissingSchemaException` is only raised if no
schema was configured at the time we're building the actual
GraphQlSource.

This exception is later wrapped by the GraphQlAutoConfiguration to raise
an `InvalidSchemaLocationsException` with useful information about
configured schema locations.

Fixes gh-124
2021-09-02 11:36:49 +02:00
Brian Clozel
771c42bfbe Fix missing GitHub credentials in release pipeline 2021-08-31 18:06:37 +02:00
Brian Clozel
0c17ad59bf Upgrade JDK versions 2021-08-31 17:39:49 +02:00
Brian Clozel
d3316d7a72 Upgrade Ubuntu in CI image 2021-08-31 17:39:31 +02:00
Rossen Stoyanchev
4bfe85e6b3 Fix package cycle 2021-08-31 14:58:13 +01:00
Rossen Stoyanchev
a98ca42981 Add resolver for @Argument Map<String, Object>
Closes gh-113
2021-08-31 14:44:47 +01:00
Rossen Stoyanchev
60e65078c2 Fix outdated links in README files 2021-08-31 07:44:10 +01:00
Rossen Stoyanchev
8cebe20a56 Defensively build GraphQLError
GraphqlErrorBuilder expects a non-null error message so we need to
check if the exception has one, or otherwise the resulting assert
error masks the original one.
2021-08-30 16:49:28 +01:00
Rossen Stoyanchev
cae12820e4 Replace @GraphQlController in documentation snippets 2021-08-30 16:44:56 +01:00
Rossen Stoyanchev
4bd229d4b9 Deprecate @GraphQlController in favor of @Controller 2021-08-30 14:56:01 +01:00
Brian Clozel
7c58fb90af Fix configuration metadata for schema location property
Fixes gh-118
2021-08-27 20:39:46 +02:00
Brian Clozel
625f0b685b Add FailureAnalyzer for schema location issues
Prior to this commit, the schema locations configured with
`spring.graphql.schema.locations` could fail in several cases:
* one of the provided locations cannot be resolved as a Resource
* none of the provided locations holds an actual schema file

The latter can happen if several classpath locations match a given
location and the wrong one is considered first.

This commit introduces a new `MissingSchemaException` that holds the
locations information. We're adding the relevant FailureAnalyzer to help
developers troubleshoot such configurations issues.

Fixes gh-117
2021-08-27 20:36:05 +02:00
Brian Clozel
73aec66200 Dependency upgrades
GraphQL Java 17.1 -> 17.2
Reactor -> 2020.0.9 -> 2020.0.10
Spring Data 2021.0.3 -> 2021.0.4
Spring Security 5.5.1 -> 5.5.2
Jackson 2.12.4 -> 2.12.5
AssertJ 3.19.0 -> 3.20.2
2021-08-27 11:01:55 +02:00
Brian Clozel
c6430869a0 Upgrade to Gradle 7.2 2021-08-27 11:01:25 +02:00
Rossen Stoyanchev
7495f43670 Support GraphQLContext as a method argument 2021-08-26 19:50:01 +01:00
Rossen Stoyanchev
60b0684d80 Minor refactoring and polishing 2021-08-13 04:48:49 +01:00
Rossen Stoyanchev
6a71dc958d Fix link in README
Closes gh-109
2021-08-11 05:31:10 +01:00
Rossen Stoyanchev
50eef472c5 Add reference docs for annotated DataFetcher's
Closes gh-90
2021-08-11 05:23:27 +01:00
Rossen Stoyanchev
020303d0fd Dependency upgrades
GraphQL Java 17.0 -> 17.1
Reactor -> 2020.0.7 -> 2020.0.9
Spring Framework 5.3.7 -> 5.3.9
Spring Data 2021.0.1 -> 2021.0.3
Jackson 2.12.3 -> 2.12.4
2021-08-10 08:15:30 +01:00
Rossen Stoyanchev
a78abb7dc8 Polishing and minor refactoring in reference docs 2021-08-10 08:08:04 +01:00
Rossen Stoyanchev
3567a062ab Add RuntimeWiringConfigurer
Closes gh-107
2021-08-09 16:36:18 +01:00
Rossen Stoyanchev
8db2bf9680 Move querydsl support into sub-package
Following the addition of annotated DataFetcher's the `~.data.method`
with #90, it makes sense to have querydsl support at the same level
in a sibling package.
2021-08-09 12:49:36 +01:00
Rossen Stoyanchev
0d0b84dc8a Support for annotated DataFetcher's
Closes gh-61, gh-90
2021-08-09 12:37:47 +01:00