Commit Graph

77 Commits

Author SHA1 Message Date
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
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
Rossen Stoyanchev
4bfe85e6b3 Fix package cycle 2021-08-31 14:58:13 +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
Rossen Stoyanchev
60b0684d80 Minor refactoring and polishing 2021-08-13 04:48:49 +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
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
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
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
Rossen Stoyanchev
759b83ffa8 Upgrade to GraphQL Java 0.0.0-2021-07-21T06-48-56-713bb637
Use more efficient way to update the code registry in GraphQLSchema.

See gh-84
2021-07-21 13:52:49 +01:00
Rossen Stoyanchev
4078799e34 Auto-register Querydsl DataFetcher's only for top-level queries
Closes gh-93
2021-07-20 13:42:26 +01:00
Rossen Stoyanchev
c148eb40b4 Auto registration of Querydsl DataFetcher's
See gh-93
2021-07-19 16:26:44 +01:00
Rossen Stoyanchev
873ecd6b29 Add GraphQlSourceBuilderCustomizer
See gh-93, gh-85
2021-07-19 16:26:44 +01:00
Rossen Stoyanchev
706766536d Upgrade to GraphQL Java pre-17 version
See gh-84
2021-07-08 21:24:18 +01:00
Brian Clozel
f1bc239b57 Add Spring Security auto-configuration
This commit adds two new auto-configuration classes that provide the
relevant Spring Security infrastructure for GraphQL applications:

* a `ThreadLocalAccessor` that propagates the security context in
Spring MVC applications
* `DataFetcherExceptionResolver` implementations that resolve security
  exception from data fetchers, for both MVC and WebFlux

Closes gh-81
2021-07-06 16:58:34 +02:00
Brian Clozel
58d65d7a4c Refine auto-configurations conditions
Prior to this commit, auto-configurations were only checking for the
presence of GraphQL Java classes as guards, assuming that Spring
GraphQL classes were always on the classpath.

Auto-configurations are meant to be moved to the Spring Boot project in
the future, so this commit adds the relevant condition class checks to
reflect that spring-graphql might not be on the classpath.
2021-07-06 16:57:05 +02:00
Rossen Stoyanchev
69c2d08c71 Remove formatter-on/off comments 2021-07-06 15:51:50 +01:00
Brian Clozel
d09f371048 Add missing configuration metadata for graphql metrics 2021-07-02 14:57:25 +02:00
Brian Clozel
2be79c2c73 Remove configuration key for GraphQL schema path
Currently, the GraphQL schema is exposed under /graphql/schema (so
relative to the main graphql endpoint) and is configurable with the
`spring.graphql.schema.printer.path` configuration property.

We think we should make the schema location more consistent to help
tools and various Gateway products. Also, we don't see right now a
strong use case for such a configuration property.

This commit removes the configuration property and sets the schema
location under `/graphql/schema`(`/graphql` being the main graphql path
configured by the application).

Closes gh-79
2021-07-02 13:57:36 +02:00
Rossen Stoyanchev
f17ae9307c Extract schema handling and move into main spring-graphql module 2021-07-02 10:25:18 +01:00
Rossen Stoyanchev
4740696ebf Move GraphiQl handlers to main spring-graphql module 2021-07-02 10:01:10 +01:00
Rossen Stoyanchev
9178075da5 Return 405 "Allow:POST" for HTTP GET queries
See gh-70
2021-07-01 15:48:55 +01:00
Brian Clozel
ef0fe03fce Scan schema locations for well-known file extensions
This commit improves gh-56 to scan schema locations for more well-known
file extensions, as previously only `*.graphqls` was supported.
We're now scanning for `*.graphqls`, `*.gqls`, `*.graphql`, `*.gql`.

Closes gh-56
2021-06-30 21:06:17 +02:00
Stephane Nicoll
a1e8571853 Harmonize copyright header 2021-06-30 15:44:24 +02:00
Stephane Nicoll
9d4ebfe743 Polish 2021-06-30 15:44:24 +02:00
Stephane Nicoll
4a1ee14f88 Add default value for "spring.graphql.locations" 2021-06-30 15:44:24 +02:00
Brian Clozel
fdf446f3e6 Load multiple GraphQL schema files
Prior to this commit, the `spring.graphql.schema.location` would only
allow a single file as the source for the GraphQL schema.

This commit changes this configuration to
`spring.graphql.schema.locations` so that it accepts actual locations
(folders) and scans for `*.graphqls` files in those locations. All files
are parsed and merged as a single GraphQL `TypeDefinitionRegistry`.

Closes gh-56
2021-06-29 21:27:18 +02:00
Brian Clozel
eef61843d3 Add property for GraphiQL UI path
This commit adds a new `spring.graphql.graphiql.path` configuration
property for setting the path to the GraphiQL UI page.

This change requires updates in the static HTML page to link the
JavaScript fetcher back to the actual GraphQL API endpoint.

Closes gh-70
2021-06-29 13:52:08 +02:00
Rossen Stoyanchev
de234c94c4 Decouple GraphQlTester from Web details
Closes gh-65
2021-06-26 05:16:35 +01:00
Brian Clozel
57fb7c59f5 Fix build and disable jjavaformat + checkstyle
Right now the Spring JavaFormat and Checkstyle arrangement doesn't work
for the Spring GraphQL source code.

This commit disables the dedicated Gradle conventions until we find a
better solution.
2021-06-16 12:13:35 +02:00
Rossen Stoyanchev
0ce48dc978 Turn off auto-formatting in Boot starter tests 2021-06-16 10:59:28 +01:00
Rossen Stoyanchev
43f9e34c81 Turn off auto-formatting where it reduces readability 2021-06-15 14:01:52 +01:00
Brian Clozel
f8b2ad552f Refactor project build
This commit refactors the project build to better share dependency
management definitions between modules.

This also upgrades the project to Spring Boot 2.5.0.

Closes gh-45
2021-06-02 15:45:51 +02:00
Brian Clozel
f8b90b592d Apply Spring JavaFormat to Spring GraphQL Boot starter
This commit applies the build conventions to the Spring Boot GraphQL
starter module and fixes all formatting issues.

See gh-54
2021-06-02 14:30:00 +02:00
Brian Clozel
847c10be27 Add GraphQlTester test auto-configuration
This commit introduces the auto-configuration infrastructure for testing
Spring GraphQL applications with mock/embedded servers.

The new `@AutoConfigureGraphQlTester` annotation can contribute a
`GraphQlTester` bean to the test context for testing the application.

Closes gh-46
2021-05-31 21:35:54 +02:00
Rossen Stoyanchev
56917d8d83 ThreadLocal context propagation for DataFetcher's
The WebMvc starter now supports propagation of ThreadLocal values
extracted at the level of the HTTP handler.

Closes gh-53
2021-05-28 19:32:48 +01:00
Rossen Stoyanchev
ca18d03244 Add builder for WebGraphQlHandler
To allow adding more options when creating a WebGraphQlHandler.

See gh-53
2021-05-28 19:32:28 +01:00
Rossen Stoyanchev
eb88697b83 Polishing 2021-05-21 15:34:58 +01:00
Rossen Stoyanchev
cd8f4b672f Fix NPE on errors without a path
Errors that originate from GraphQL itself don't seem to have a path.
2021-05-21 15:34:58 +01:00
Rossen Stoyanchev
24bf029b02 Replace custom WebSocket handler mapping logic
Closes gh-35
2021-05-21 15:03:37 +01:00
Brian Clozel
5d4c08a30b Upgrade to Gradle 7.0.2 2021-05-18 17:53:08 +02:00
Rossen Stoyanchev
484fb932ef Replace QL with Ql for consistency with Spring naming 2021-05-14 21:32:54 +01:00
Rossen Stoyanchev
20b8a664bd Move DataFetcherExceptionResolver to execution
DataFetcherExceptionResolver and ErrorType are better in the
execution package next to where they're used.
2021-05-14 18:29:43 +01:00
Rossen Stoyanchev
1a4ef20f8a Add actual Javadoc to package-info 2021-05-14 16:26:01 +01:00
Rossen Stoyanchev
b1a4016132 Rename support package to execution
The package contains classes to help configure and invoke graphql.GraphQL
both of which are request execution.
2021-05-14 10:45:36 +01:00