GraphQL Kotlin 4.0.0 Release
Simplified GraphQL server setup, rewrite of the client, and improved build plugins
GraphQL Kotlin consists of a number of libraries that aim to simplify the running of GraphQL servers and clients using Kotlin. It’s been over 10 months since the last major release of graphql-kotlin and after numerous pre-releases, we are pleased to announce the 4.0.0 release!
Check out the release notes for a full list of all changes that are included in the release.
Major changes and features
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.
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.
See the client documentation for additional details.
GraphQL Kotlin plugins can now be used to generate your GraphQL schema SDL artifact at build time.
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 a 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.