GraphQL Kotlin Multiplatform
GraphQL Kotlin Multiplatform is a GraphQL client for Kotlin Multiplatform. It is a multiplatform library that allows you
to interact with a GraphQL server from Kotlin code.
It is built on top of graphql-kotlin.
Significant changes have been made to the original library to make it work on Kotlin Multiplatform. This included
providing Ktor client support for all platforms and utilization of only multiplatform libraries.

Table of contents
Features
- Multiplatform
- Uses Ktor as the underlying HTTP client
- Type-safe
- Client Configurable
Quick Start
Installation
GraphQL Multiplatform is available
on Maven Central
as a Kotlin Multiplatform library. You can either add it to your multiplatform project as shown below:
commonMain.dependencies {
implementation("xyz.mcxross.graphql:graphql-multiplatform.client")
}
Then apply the plugin to your project:
plugins {
id("xyz.mcxross.graphql-multiplatform")
}
:warning: Note: Currently, only Kotlin Multiplatform projects are supported.
Usage
Applying the plugin to your project will generate a graphql
block in your build.gradle.kts
file. You can configure
the client by setting the endpoint
and packageName
properties.
graphql {
client {
endpoint = "https://api.example.com/graphql"
packageName = "com.example.graphql"
}
}
The plugin will add a generateClient
task to your project. Running this task will generate the client code in the package
specified in the packageName
property.
./gradlew generateClient
What's included
Client
- A multiplatform GraphQL client that allows you to interact with a GraphQL server
Plugin
- A Gradle plugin that generates Kotlin code from your GraphQL schema
Contribution
We welcome contributions to GraphQL Kotlin Multiplatform. Please refer to the contribution guide for
more information.
License
Copyright 2024 McXross
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.