@@ -398,6 +398,62 @@ graphql:
398398By default GraphQL tools uses the location pattern `**/*.graphqls` to scan for GraphQL schemas on the classpath.
399399Use the `schemaLocationPattern` property to customize this pattern.
400400
401+ # # GraphQL Annotations
402+
403+ https://github.com/Enigmatis/graphql-java-annotations
404+
405+ The schema will be built using the GraphQL Annotations library in a code-first approach - instead of writing it
406+ manually, the schema will be constructed based on the Java code. Please see the documentation of the GraphQL Annotations
407+ library for a detailed documentation of the available annotations. This readme focuses on how GraphQL Annotations -
408+ GraphQL Spring Boot Starter integration works.
409+
410+ **Note:** *Although the GraphQL Annotations Starter has a dependency on GraphQL Java Tools and uses some interfaces from
411+ that project, it will ignore schema definition files. It is not possible to combine schema- and code-first approaches.*
412+
413+ # ## Configuration
414+
415+ ```
416+ graphql:
417+ annotations:
418+ base-package: com.example.graphl.schema # required
419+ always-prettify: true #true is the default value, no need to specify it
420+ ```
421+
422+ The most important parameter is the base package. The starter will look for schema-relevant classes in the specified
423+ package and its subpackages. `always-prettify` will "prettify" getter/setter methods - the get/set/is prefix will be
424+ removed from GraphQL fields automatically.
425+
426+ ### Root resolvers, directives, type extensions
427+
428+ The root resolvers must be marked by the `GraphQLQueryResolver`, `GraphQLMutationResolver` and `GraphQLSubscription`
429+ interfaces (from the GraphQL Java Tools library).
430+
431+ **Important:**
432+
433+ Unlike GraphQL Java Tools, GraphQL Annotations only supports *one* of them each. Furthermore, GraphQL Annotations
434+ only accepts a *class* as input, *not an instance*. It will either create a new instance of the class itself, or use
435+ static methods. This means that Spring dependency injection will not work in the usual way. The companion example
436+ project (which can be found in the [samples](https://github.com/graphql-java-kickstart/samples) repository)
437+ demonstrates possible workarounds for this issue.
438+
439+ `GraphQLDirectiveDefinition` and `GraphQLTypeExtension`-annotated classes are subject to the same limitation regarding
440+ dependency injection - but there can be any number of them.
441+
442+ ### Custom scalars and type functions
443+
444+ Custom scalars can be defined in the same way as in the case of using GraphQL Java Tools - just define the
445+ `GraphQLScalarType` beans.
446+
447+ The starter will also pick up `TypeFunction` beans and pass them to the schema builder.
448+
449+ In these cases the actual beans will be used, not just the classes. Spring dependency injection works as usual.
450+
451+ ### Custom Relay and GraphQL Annotation Processor
452+
453+ It is possible to define a bean implementing `Relay` and/or `GraphQLAnnotations`. If present, these will be passed to
454+ the schema builder. Spring dependency injection works as usual. Note that GraphQL Annotations provides default
455+ implementation for these which should be sufficient is most cases.
456+
401457# Tracing and Metrics
402458
403459[Apollo style tracing](https://github.com/apollographql/apollo-tracing) along with two levels of metrics based on them are currently configurable.
0 commit comments