graphql-kotlin - Libraries for running a GraphQL server in Kotlin - Kotlin Resources

GraphQL Kotlin

Build Status Docs codecov Slack

GraphQL Kotlin is a collection of libraries built on top of graphql-java that aim to simplify running a GraphQL server in Kotlin

📦 Modules

⌨️ Usage

Below is a basic example of how graphql-kotlin-schema-generator converts your Kotlin code into a GraphQL schema. For more details, see our documentation below or in the individual module READMEs

data class Widget(val id: Int, val value: String)

class WidgetService {
  fun widgetById(id: Int): Widget? {
    // grabs widget from a data source, might return null
  }
}

// Generate the schema
val config = SchemaGeneratorConfig(supportedPackages = listOf("org.example"))
val queries = listOf(TopLevelObject(WidgetService()))

toSchema(config, queries)

will generate

type Query {
  widgetById(id: Int!): Widget
}

type Widget {
  id: Int!
  value: String!
}

Then using graphql-kotlin-spring-server you can easily make your schema available as a GraphQL server with Spring Boot.

// Mark the class as a Spring GraphQL Query
@Component
class WidgetService : Query {
  fun widgetById(id: Int): Widget? {}
}

@SpringBootApplication
class Application

fun main(args: Array<String>) {
    runApplication<Application>(*args)
}

📋 Documentation

Examples and documentation are available on our documentation site hosted in GitHub Pages.

If you have a question about something you can not find in our documentation, the indivdual module READMEs, or javadocs, feel free to create an issue and tag it with the question label.

If you would like to contribute to our documentation see the website directory for more information.

👥 Contact

This project is part of Expedia Group Open Source but also maintained by a dedicated team

  • Expedia Group
    • https://expediagroup.github.io
    • oss@expediagroup.com
  • @ExpediaGroup/graphql-kotlin-committers

✏️ Contributing

To get started, please fork the repo and checkout a new branch. You can then build the library locally with Gradle

shell script ./gradlew clean build

See more info in CONTRIBUTING.md

⚖️ License

This library is licensed under the Apache License, Version 2.0

compile "com.expediagroup:graphql-kotlin:2.0.0.RC1"

Related Libraries

graphql-kotlin

Libraries for running a GraphQL server in Kotlin

Last updated 3 mins ago