4.0.0
🎉 GraphQL Kotlin 4.0.0!
Namespace Cleanup
The library structure was updated to consistently group common features into sub-directories and all the modules were updated to use a matching package structure. See our Github discussion for more details.
Some examples
com.expediagroup.graphql.annotations.* --> com.expediagroup.graphql.generator.annotations.*
com.expediagroup.graphql.federation.* --> com.expediagroup.graphql.generator.federation.*
com.expediagroup.graphql.spring.operations.* --> com.expediagroup.graphql.server.operations.*
Optional and Default Arguments
In previous versions, optional arguments, or nullable in Kotlin, were by default given null at execution time if no argument was passed in. This means if you called the following function from GraphQL without any argument the output would be "input was null"
fun print(value: String?) = "input was $value"To support Kotlin default arguments we need to not pass anything to the Kotlin function when we invoke it, that means now that ALL nullable arguments must either:
- Specify a Kotlin default value
- Use the OptionalInput wrapper
fun defaultValue(value: String? = null) = "input was $value"
fun optionalInput(input: OptionalInput<String>): String = when (input) {
is OptionalInput.Undefined -> "input was not specified"
is OptionalInput.Defined<String> -> "input was ${input.value}"
}See more details in #1126
Server Improvements
We have abstracted the common GraphQL server logic to a new graphql-kotlin-server module. This allows us to simplify the logic and greatly reduce the amount of boilerplate code needed to create a GraphQL server in any framework.
GraphQL Kotlin servers now also support batch operations. This allows your client to send a list of GraphQL operations in a single HTTP request. Stay tuned for batch query processing optimizations coming up in future releases!
Check out our Spring based reference implementation and Ktor server example to see how easy it is to create GraphQL servers using graphql-kotlin. See our updated server documentation for additional details.
GraphQL Client Rewrite
In 4.0.0, we completely rewrote our GraphQL Kotlin Client to be more generic and provide additional functionality. GraphQLClient is now a generic interface with Ktor HTTP Client and Spring WebClient reference implementations. We also abstracted away the serialization logic and now support both Jackson and kotlinx-serialization formats!
The generated data models were simplified and now are just simple data classes. Input objects, enums, and scalar definitions are now shared across operations, whereas operation-specific definitions (like objects or polymorphic types) are now generated under their own packages. Finally, query and mutation objects are now passed directly to a generic execute method which allows us to also support batch requests.
val client = GraphQLKtorClient(url = URL("http://localhost:8080/graphql"))
val firstQuery = FirstQuery(variables = FirstQuery.Variables(foo = "bar"))
val secondQuery = SecondQuery(variables = SecondQuery.Variables(foo = "baz"))
val results: List<GraphQLResponse<*>> = client.execute(listOf(firstQuery, secondQuery))See the client documentation for additional details.
Plugin Updates
GraphQL Kotlin plugins can now be used to generate your GraphQL schema SDL artifact at build time.
import com.expediagroup.graphql.plugin.gradle.graphql
graphql {
schema {
packages = listOf("com.example")
}
}In the example above, our Gradle plugin will attempt to generate your schema artifact using graphql-kotlin-schema-generator. The schema generator will then scan specified packages, searching for classes implementing our Query, Mutation, and/or Subscription marker interfaces. You can customize the default schema generator behavior by providing custom hooks provider.
The Gradle plugin was also updated to use the Gradle Worker API to isolate the plugin classpath from the general build classpath.
See the Gradle and Maven plugin documentation for additional details.
3.x.x Support
Going forward we will only support the 3.x.x branch for critical security issues or urgent bug fixes.
Feedback
As with any open source project, we want to thank the community for using our library and providing valuable feedback and even pull requests. We will continue to support this library and use it in production at @ExpediaGroup, but the goal of the project is still to make GraphQL development easier for everyone. If you have a feature request or question, feel free to start a new discussion, create a new issue or reach out to our public Slack channel.
GitHub has the full list of contributors since we made the 4.0.0 cut.
Major Changes
- update FlowSubscriptionExecutionStrategy to support flow natively (#1120) @dariuszkuc
- [client] generate enums in UPPERCASE and fix kotlinx request serialization (#1087) @dariuszkuc
- Do not wrap exceptions twice (#1083) @smyrick
- cleanup usage of GraphQL request and response objects (#1077) @dariuszkuc
- [plugins] plugins support for graphql clients using kotlinx serialization (#1070) @dariuszkuc
- [plugin] update client generator to support kotlinx serialization (#1069) @dariuszkuc
- [client] create new GraphQL client serialization abstraction (#1066) @dariuszkuc
- Add support for federated tracing (#1065) @smyrick
- Generate context with suspend and nullable in subscriptions (#1053) @smyrick
- [client] Batch query support (#1030) @dariuszkuc
- [server] support batch requests (#1019) @dariuszkuc
- Move schema generator and federation to new generator package (#1009) @smyrick
- Move all types to common package and folder (#1005) @smyrick
- [client] move GraphQLKotlinClient implementations to specific packages (#1006) @dariuszkuc
- [plugin] refactor Gradle tasks to use Worker API (#1002) @dariuszkuc
- Move spring-server to com.expediagroup.graphql.server.spring (#999) @smyrick
- Common graphql-kotlin-server (#988) @smyrick
- move operation marker interfaces from spring-server to types (#985) @dariuszkuc
- Support default Kotlin values (#981) @smyrick
- [server] add support for flow subscriptions (#972) @dariuszkuc
- [server] update default GraphQLContext (#955) @dariuszkuc
- fixes typo and adds tests for subscription (context) (#950) @gerald24
- [plugin] Update Gradle extension to accept immutable lists (#909) @dariuszkuc
- [server] Remove federated type registry (#861) @smyrick
- Change federated resolver to include type name (#851) @smyrick
- [client] update ScalarConverter to accept any objects (#819) @dariuszkuc
- [generator] built-in support for optional input (#808) @dariuszkuc
- [client] change GQL client to interface and add webclient implementation (#837) @dariuszkuc
Minor Changes
- Call hooks for return type on properties (#1112) @smyrick
- Generate DataLoaders on every request (#1040) @smyrick
- Simplify setup of dataloaders in spring server (#1031) @jarlehansen
- [plugin] new generate-sdl GraphQL MOJO (#994) @dariuszkuc
- [plugin] new graphqlGenerateSDL GraphQL task (#993) @dariuszkuc
- [plugins] create sdl-generator module that can generate graphql schema (#990) @dariuszkuc
- [plugins] update introspection query (#973) @dariuszkuc
- [plugins] allow renaming of the downloaded/introspected schema (#956) @dariuszkuc
- update to graphql java 16 (#943) @dariuszkuc
- fix(spring-server): adding credentials by default (#937) @libetl
Patch Changes
- [client] support selection of multiple enums (#1115) @dariuszkuc
- [client] fix unknown enum import (#1107) @dariuszkuc
- Support OptionalInput of any list or array (#1103) @smyrick
- Fix playground route logic (#1101) @smyrick
- Add unit tests for optional input wrappers (#1102) @smyrick
- update to latest version of kotlinpoet (#1092) @dariuszkuc
- [build] update to use latest dependencies (#1089) @dariuszkuc
- Add data loader registry to subscription execution (#1085) @smyrick
- Update graphql-java 16.2 (#1035) @smyrick
- [plugin] updates to Gradle plugin tasks configuration avoidance (#1028) @dariuszkuc
- fix passing doc string as format parameter (#1024) @brennantaylor
- [generator] create Kotlin PropertyDataFetcher (#1018) @dariuszkuc
- revert: add common supbackages back (#1008) @dariuszkuc
- [build] update to Kotlin 1.4, Spring Boot 2.4.2 and Ktor 1.5 (#1007) @dariuszkuc
- [generator] additional test for nested optional input values (#976) @dariuszkuc
- [build] exclude unnecessary plugin dependencies (#974) @dariuszkuc
- [plugin] fix generation of self referencing types (#948) @dariuszkuc
- [federation] Update error message for invalid field selection (#932) @smyrick
- feat: catching field name collision on schema generation (#928) @Dragonazz
- [generator] Only add directives with valid locations (#925) @smyrick
- [plugin] improve client generation exception handling (#915) @dariuszkuc
- [plugin] support query file directory in Gradle extension (#914) @dariuszkuc
- [plugin] fix client generation when selecting custom scalars (#916) @dariuszkuc
- [client] update parameterizedType cache to use concurrent hash map (#913) @dariuszkuc
- [plugin] update Gradle plugin extension to use Actions (#901) @dariuszkuc
- [client] update GraphQLWebClient to correctly apply codecs (#900) @dariuszkuc
- [server] update to SpringBoot 2.3 (#898) @dariuszkuc
- [client] Throw error on non-successful HTTP responses (#889) @nqv
- Refactor federation code for readability (#887) @smyrick
- [client] fix generation of duplicate classes (#883) @dariuszkuc
- Fix issue with GraphQLName on properties (#870) @smyrick
- [client] Remove duplicate accept header (#869) @smyrick
- [client] Remove duplicate header (#865) @MarkusLund
- [server] Add separate configuration for SDL route (#862) @smyrick
- Fix subscriptions messaging and tests (#845) @smyrick
- Include reflection as a dependency for all subprojects (#856) @smyrick
- Update to kotlin 1.4 (#844) @smyrick
Non-version Changes
- [docs] fix subscription docs and formatting (#1121) @dariuszkuc
- Fixed typo "reccomend" => "recommend" (#1117) @Puharesource
- Update the docs with general changes (#1113) @smyrick
- Add docs for set support (#1111) @smyrick
- fix hooks provider docs and remove unnecessary suppressions (#1108) @dariuszkuc
- Add docs on the spring specific context requirements (#1099) @smyrick
- Reactive context-path added to Playground (#1098) @joaodias14
- [build] update release build to automatically release to nexus (#1093) @dariuszkuc
- [build] update publish plugin (#1091) @dariuszkuc
- [build] update to latest dokka (#1090) @dariuszkuc
- Update the docs on the exception handler (#1086) @smyrick
- Bump ssri from 8.0.0 to 8.0.1 in /examples/federation/gateway (#1081) @dependabot
- [docs] update serialization docs to use introspection (#1078) @dariuszkuc
- Add documentation for subscription hooks (#1072) @smyrick
- Incorrect Gradle Target for Executing/Building the Example Spring Server (#1063) @acidbluebriggs
- Delete versioned 4.x.x docs for renamed current docs (#1060) @smyrick
- fix release-docs workflow (#1061) @dariuszkuc
- Move federation docs under generator folder (#1059) @smyrick
- Add trailing slash (#1058) @smyrick
- Add docs back to url (#1057) @smyrick
- Update index redirect (#1056) @smyrick
- Update website publish (#1055) @smyrick
- Update to docusaurus 2 (#1049) @smyrick
- [docs] updating invalid refresh link in index.html (#1044) @dariuszkuc
- Rename older docs version (#1042) @smyrick
- Delete older alpha docs (#1041) @smyrick
- Add tests to show use of completable future wrappers (#1032) @smyrick
- [build] include client examples as part of the examples build (#1025) @dariuszkuc
- Add note on interface as arguments (#1017) @smyrick
- [examples] use proper junit5 method order (#1016) @dariuszkuc
- Update example subscription tests (#1015) @smyrick
- Scope package of examples (#1014) @smyrick
- [build] upload failure reports on CI and release workflows (#1013) @dariuszkuc
- Update simple subscription test to use single client (#1012) @smyrick
- [build] enable GH action to upload build reports on failure (#1011) @dariuszkuc
- [build] update Gradle wrapper to 6.8 (#995) @dariuszkuc
- [build] specify timeouts for GH workflows (#998 #996) @dariuszkuc
- Remove spark examples (#992) @smyrick
- [build] update Gradle version to 6.7.1 (#991) @dariuszkuc
- [build] update gpg key (#989) @dariuszkuc
- [docs] update contact info (#969) @dariuszkuc
- Bump ini from 1.3.5 to 1.3.8 in /examples/federation/gateway (#968) @dependabot
- Bump ini from 1.3.5 to 1.3.8 in /website (#967) @dependabot
- add ktor example (#951) @adamsz-lume
- Update data fetching docs (#933) @smyrick
- Ensure artifact is published to maven before maven integration tests (#922) @mgilbey
- [docs] add SpringOne 2020 presentation (#918) @dariuszkuc
- Bump object-path from 0.11.4 to 0.11.5 in /examples/federation/gateway (#912) @dependabot
- [docs] fix small typo (#904) @xetra11
- refactor(doc): change to intended syntax usage (#907) @xetra11
- Update README with discussions links (#894) @smyrick
- Start each subscription with init message (#891) @smyrick
- README: fix broken URL (#888) @pjwalstrom
- Separate release docs and code (#868) @smyrick
- [examples] update GraphQL client examples to use latest code (#859) @dariuszkuc
- Update docs on library release (#852) @smyrick
- [build] revert Kotlin version to 1.3.72 (#858) @dariuszkuc
- Update gradle wrapper in examples (#857) @smyrick
- Update to gradle 6.6.1 (#853) @smyrick
- [docs] update latest released version to 3.6.1 (#848) @dariuszkuc
- Add test to verify interface implementations can be ignored (#846) @smyrick
- [build] officially start targeting 4.0.0 (#847) @dariuszkuc