The data platform that powers your Kotlin application

Easily create cross-platform native apps with Kotlin and GraphQL.

Grafbase + Kotlin

Kotlin gives you all the tools you need to build production scale applications. Whether you need to fetch data on the server, at build time when creating a static export, or caching on demand, Kotlin has you covered.

Kotlin Client
package com.example.grafbaseandroid.API

import android.util.Log
import io.ktor.client.HttpClient
import io.ktor.client.engine.android.Android
import io.ktor.client.plugins.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.serialization.kotlinx.json.*
import io.ktor.client.plugins.logging.*
import io.ktor.client.request.*
import io.ktor.http.*
import kotlinx.serialization.json.Json

private const val TIME_OUT = 60_000

val ktorHttpClient = HttpClient(Android) {
  install(ContentNegotiation) {
    json(Json {
      prettyPrint = true
      isLenient = true
      ignoreUnknownKeys = true
    })

    engine {
      connectTimeout = TIME_OUT
      socketTimeout = TIME_OUT
    }
  }

  install(Logging) {
    logger = object : Logger {
      override fun log(message: String) {
        Log.v("Logger Ktor =>", message)
      }
    }

    level = LogLevel.ALL
  }

  defaultRequest {
    header(HttpHeaders.ContentType, ContentType.Application.Json)
    url {
      protocol = URLProtocol.HTTP
      host = "10.0.2.2"
      port = 4000
      path("graphql")
    }
  }
}
Kotlin Client
package com.example.grafbaseandroid.API

import android.util.Log
import io.ktor.client.HttpClient
import io.ktor.client.engine.android.Android
import io.ktor.client.plugins.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.serialization.kotlinx.json.*
import io.ktor.client.plugins.logging.*
import io.ktor.client.request.*
import io.ktor.http.*
import kotlinx.serialization.json.Json

private const val TIME_OUT = 60_000

val ktorHttpClient = HttpClient(Android) {
  install(ContentNegotiation) {
    json(Json {
      prettyPrint = true
      isLenient = true
      ignoreUnknownKeys = true
    })

    engine {
      connectTimeout = TIME_OUT
      socketTimeout = TIME_OUT
    }
  }

  install(Logging) {
    logger = object : Logger {
      override fun log(message: String) {
        Log.v("Logger Ktor =>", message)
      }
    }

    level = LogLevel.ALL
  }

  defaultRequest {
    header(HttpHeaders.ContentType, ContentType.Application.Json)
    url {
      protocol = URLProtocol.HTTP
      host = "10.0.2.2"
      port = 4000
      path("graphql")
    }
  }
}

Testimonials

?
Simon Grimm@schlimmson

Tried @grafbase and was impressed how easy & fast it was to create your serverless GraphQL API + local instance 🔥

?
Rasmus Hjulskov@RasmusHjulskov

Current fantasy tech stack 🚀: - @nextjs - @tailwindcss - @typescript - @trpcio - @grafbase - @ClerkDev

?
Kate@whoiskatrin

As an engineer, I'm always on the lookout for tools that make my job easier and more efficient. @grafbase has quickly become a go-to for me in my #GraphQL development work. Its real-time query execution and intuitive schema management have saved me countless hours of debugging

?
Roy@royboy789

Done playing with @Cloudflare Pages & Workers, for now. Now to learn some @grafbase and see how if it can play a role, because it is pretty nifty!

?
Bobby Blastbeats@tubbo

not sure if @grafbase is so good that it will actually obviate my entire job, or if it's good enough that i can use it at work without someone questioning my existence. either way, i am sold on the concept of "upload some SDL and query shit, stop worrying about the DB infra".

?
Ben@nurodev

Damn, trying out the @grafbase beta & it's super slick! Feels like what @planetscaledata is doing for databases, @Grafbase is going for #GraphQL 🔥

Start building with Kotlin

We’ve made it super easy to get started integrating Grafbase with Kotlin.

Quickstart

Learn the basics of Grafbase and deploy to production in only a few short steps.

Developer Guides

Learn how to use Grafbase with frontend frameworks, external APIs, and more.

React Examples

See how Grafbase works with Kotlin in an example