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.
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
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
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 missing, non-required input argument would throw
an NullPointerException instead of returning `null` or
`Optional.empty()`.
Fixes gh-144
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
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.
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
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
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
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.
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
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
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.