This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Query { | |
val film: Film? | |
val films: List<Film> | |
} | |
interface Mutation { | |
val createFilm: Film | |
} | |
interface Subscription { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"data": { | |
"film": { | |
"id": "0", | |
"title": "Amelie", | |
"actors": [ | |
{ | |
"id": "0", | |
"firstName": "Audrey", | |
"lastName": "Tautou" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Instantiate DSL context | |
val context = cinemaContextOf(createKtorAdapter()) | |
val result = context.query { | |
film(id = 0L) { | |
id() | |
title() | |
actors { | |
id() | |
firstName() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query { | |
film(id: 0) { | |
id | |
title | |
actors { | |
id | |
firstName | |
lastName | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun createKtorAdapter(): CinemaAdapter { | |
// Create Ktor http client | |
val client = HttpClient { | |
install(WebSockets) | |
} | |
// Create Jackson object mapper | |
val mapper = jacksonObjectMapper() | |
.registerModule(ParameterNamesModule(JsonCreator.Mode.PROPERTIES)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun cinemaContextOf(adapter: CinemaAdapter): CinemaContext = CinemaContextImpl(adapter) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<parent> | |
<groupId>io.github.ermadmi78</groupId> | |
<artifactId>kobby-maven-tutorial</artifactId> | |
<version>0.0.0-SNAPSHOT</version> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
kotlin("jvm") | |
id("io.github.ermadmi78.kobby") version "1.4.0" | |
} | |
dependencies { | |
// Add this dependency to enable Jackson annotation generation in DTO classes | |
compileOnly("com.fasterxml.jackson.core:jackson-annotations:2.12.2") | |
// Add this dependency to enable default Ktor adapters generation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Query { | |
film(id: ID!): Film | |
films: [Film!]! | |
} | |
type Mutation { | |
createFilm(title: String!): Film! | |
} | |
type Subscription { |
NewerOlder