This commit configures a `FormattingConversionService` into the argument
resolution infrastructure, using the expected conversion service for
both MVC and WebFlux.
Closes gh-148
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
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.
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
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
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
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.
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
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
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
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.
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
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
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.
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
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
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
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
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