EXPEDIA GROUP TECHNOLOGY — SOFTWARE

GraphQL Kotlin 4.0.0 Release

Simplified GraphQL server setup, rewrite of the client, and improved build plugins

Dariusz Kuc
Apr 20 · 3 min read

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.

A view of mountains, forest, and a lake, from the position of someone seated in a wooden boat on the lake.
A view of mountains, forest, and a lake, from the position of someone seated in a wooden boat on the lake.
Photo by Luca Bravo on Unsplash

Major changes and features

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.

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.

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.

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.

See the Gradle and Maven plugin documentation for additional details.

Further reading

For additional details on how to use the library please check out the previous stories ([1], [2], [3], [4]), examples and the documentation available on GitHub pages.

We are also open for feedback so please start a discussion or raise an issue for any new features you would like to see!

Expedia Group Technology

Stories from the Expedia Group Technology teams

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store