Commit Graph

293 Commits

Author SHA1 Message Date
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
Rossen Stoyanchev
c2a996e564 Refactoring in spring-graphql tests 2021-08-04 13:20:22 +01:00
Rossen Stoyanchev
317d75cc8a Upgrade to GraphQL Java 17.0
Closes gh-84
2021-08-03 10:25:57 +01:00
Rossen Stoyanchev
15e2e6c271 Minor refactoring in GraphQlSource.Builder
Rename runtimeWiring to configureRuntimeWiring for consistency with
the configureGraphQl methods that's also Consumer based.
2021-07-26 16:50:12 +01:00
Brian Clozel
6cd0491077 Rename oci-build-task concourse resource 2021-07-26 15:42:23 +02:00
Brian Clozel
5c7b809aa3 Simplify GraphQlSource auto-configuration
This commit simplifies the `GraphQL` configuration by focusing the
infrastructure around the `GraphQlSource` auto-configuration.

With this commit, the auto-configuration contributes a single
`GraphQlSource` bean and removes the previoulsy contributed beans:
`GraphQlSource.Builder` and `RuntimeWiring`.

If a developer wants to take full control over the GraphQL setup, then
contributing a `GraphQlSource` bean is the easiest solution.

This commit also improves the `GraphQlSource.Builder` and allows for
customizing the `RuntimeWiring.Builder` instead of providing a direct
instance. This aligns well with the `RuntimeWiringBuilderCustomizer`
interface provided by the starter.

Closes gh-101
2021-07-23 10:00:29 +02:00
Brian Clozel
11fdb43238 Upgrade CI image 2021-07-23 10:00:29 +02:00
Brian Clozel
ed48f8f06e Upgrade to Artifactory Resource 0.0.17 2021-07-23 10:00:29 +02:00
em
a17a2c0af6 Rename RuntimeWiringCustomizer in reference docs
See 9d4ebfe743
Closes gh-102
2021-07-23 09:58:36 +02:00
Rossen Stoyanchev
0dbc3f12cd Minor sample refactoring 2021-07-21 16:06:12 +01:00
Rossen Stoyanchev
39702b9745 Extract boot starter docs into a dedicated asciidoc file 2021-07-21 14:30:58 +01:00
Rossen Stoyanchev
69b2476231 Show config for test support in reference docs
Closes gh-96
2021-07-21 14:18:10 +01:00