https://github.com/blaugold/graphql-kotlin-support
Commonly needed functionality for the development of GraphQL APIs, specifically with graphql-kotlin.
https://github.com/blaugold/graphql-kotlin-support
graphql kotlin
Last synced: 9 months ago
JSON representation
Commonly needed functionality for the development of GraphQL APIs, specifically with graphql-kotlin.
- Host: GitHub
- URL: https://github.com/blaugold/graphql-kotlin-support
- Owner: blaugold
- License: mit
- Created: 2020-10-26T16:10:49.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-12-06T15:46:45.000Z (about 5 years ago)
- Last Synced: 2025-02-02T16:23:18.805Z (11 months ago)
- Topics: graphql, kotlin
- Language: Kotlin
- Homepage:
- Size: 132 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[ ](https://bintray.com/gabriel-terwesten-oss/maven/graphql-kotlin-support/_latestVersion)
# graphql-kotlin-support
A library which provides some commonly needed functionality for the development of GraphQL APIs, specifically with
[graphql-kotlin].
- Efficient and ergonomic `GlobalId` implementation
- `AttributeException`: Flexible abstraction for exposing error attributes to clients
- Data fetching exception handling including exception resolution, logging and transformation of
`AttributeException`s into `GraphQLError`s.
- Handling of function returning `Mono`
- Propagation of request reactor `Context` to coroutines and returned `Mono`s.
- Data loading declarations with idiomatic Kotlin
## 📦 Modules
- [example](./example) - Example project which uses `graphql-kotlin-support-starter` and `graphql-kotlin`
- [graphql-kotlin-support](./graphql-kotlin-support) - Contains the support functionality for global ids, exception
handling, data loading and execution context
- [graphql-kotlin-support-spring](./graphql-kotlin-support-spring) - Spring specific support functionality, including
for integration with [Project Reactor](https://projectreactor.io/) and [graphql-kotlin]
- [graphql-kotlin-support-autoconfigure](./graphql-kotlin-support-autoconfigure) - Autoconfiguration for Spring Boot
- [graphql-kotlin-support-starter](./graphql-kotlin-support-starter) - Spring Boot Starter
# Install
## Repository
All the modules are available through `jcenter`.
## Spring & graphql-kotlin
To quickly get started, when you are using Spring and [graphql-kotlin], add a dependency to the Spring Boot Starter to
your project:
With maven:
```xml
com.gabrielterwesten
graphql-kotlin-support-starter
0.3.0
```
With gradle:
```kotlin
implementation("com.gabrielterwesten:graphql-kotlin-support-starter:0.3.0")
```
### Auto configuration
With the autoconfiguration applied you will be able to return `Mono`s from your resolvers. Further you will be able to
use subclasses of `GlobalId` in place of `com.expediagroup.graphql.scalars.ID`, in your schema.
The reactor context, from the server request, will be propagated to coroutines and `Mono`s which are returned from
resolvers.
Coroutines in resolvers will be started with `CoroutineStart.UNDISPATCHED`, meaning they will start to execute
immediately. This is necessary to allow `DataLoaderDispatcherInstrumentation` to work properly.
If you have a `GlobalIdRegistrationRepository` configured, this repository will be used to encode/decode `GlobalId`s.
The attributes of any caught `AttributeException` will be added to the `extensions` property of the corresponding
`GraphQLError`. When the Spring Boot Devtools properties are active, the stack trace of the caught exception will
also be included in `extensions`.
For more information on how to customize the configuration, take a look a the [example](./example) project.
## Development
### Formatting
The project uses `spotless` to enforce a consistent code style. Formatting is configured for the most common files
types, namely **kotlin** and **markdown**.
Before committing run `./gradlew spotlessCheck` to find formatting errors and `./gradlew spotlessApply` to fix them.
[graphql-kotlin]: https://expediagroup.github.io/graphql-kotlin/docs/getting-started.html