Kobby - Gradle codegen plugin of Kotlin DSL Client by GraphQL schema

Hi All.

I have recently released a beta version of Kobby Gradle Plugin - a codegenerator of Kotlin DSL Client by GraphQL schema. The generated DSL supports execution of complex GraphQL queries and mutations in Kotlin with syntax similar to native GraphQL syntax.
Moreover, you can customize generated DSL by means of GraphQL schema directives and Kotlin extension functions.

The Kobby plugin is placed here:

Usage example (Spring Boot GraphQL server with generated by means of Kobby client) your can see here:


How does this compare to Expedia’s kotlin library

Expedia Kotlin library supports GraphQL server and client. Kobby is focused on GraphQL client only. Thus, it is correct to compare only the client parts of these frameworks.

Both Expedia and Kobby are codegenerator plugins. But Expedia generates only predefined GraphQL queries. That is, you need to know all the queries you want to execute at compile time. For more details see here:

Whereas Kobby generates a GraphQL query generator. You get an engine that allows you to generate any GraphQL query at runtime by your GraphQL schema.

What advantages does this give us? We can distribute the engine generated with Kobby as a client library. Imagine you are writing a microservice with the GraphQL API. We can divide this microservice into 2 modules - API and implementation. In the API module, we will place the GraphQL schema, and, using Kobby, we will generate the GraphQL query generator by this schema. Next, we publish the API module to the Maven repository, and any client of our microservice can add dependency to this artifact to itself in order to perform the GraphQL queries it needs. We do not know what kind of queries the clients of our microservice will need, but we do not need to know this - Kobby allows to generate any query at runtime.

The client of our microservice can be either another microservice or an Android application. But to be honest, I haven’t tried using the client generated with Kobby in an Android app yet. You can be a pioneer in this. :wink:

Another unobvious advantage of Kobby is its adherence to the “fail first” paradigm. Imagine that you are participating in the development of a large microservices platform. If you change the API of your microservice, then your clients will know about it at compile time, not at runtime, as is the case with REST or the “usual” GraphQL API.

An example of a GraphQL microservice, split into 2 modules, and publishing its API through the Maven repository, you can see here:

1 Like

Also note that you can use the Kobby generated client with a server that build by means of the Expedia library. These two libraries do not compete, but complement each other.

1 Like

Hi All. Kobby supports GraphQL subscriptions now:

Hi All. Kobby Maven plugin is released. Usage example see here:

1 Like

Hi All.

I have released the first stable version of the Kobby Plugin. You can use it to generate Kotlin client API by GraphQL schema. Release contains:

  • Gradle Plugin
  • Maven Plugin
  • Documentation
  • Test cases
  • Examples

Hello everyone. I posted a tutorial article:

For Russian-speaking audience: