Skip to content

Commit 1686460

Browse files
committed
example generation of multiple clients
1 parent ba8cab8 commit 1686460

File tree

5 files changed

+49
-7
lines changed

5 files changed

+49
-7
lines changed

build.gradle.kts

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import com.expediagroup.graphql.plugin.gradle.graphql
2+
import com.expediagroup.graphql.plugin.generator.GraphQLClientType
3+
import com.expediagroup.graphql.plugin.gradle.tasks.GraphQLDownloadSDLTask
4+
import com.expediagroup.graphql.plugin.gradle.tasks.GraphQLGenerateClientTask
25

36
plugins {
47
application
58
id("org.jetbrains.kotlin.jvm") version "1.3.72"
6-
id("com.expediagroup.graphql") version "4.0.0-alpha.1"
9+
id("com.expediagroup.graphql") version "4.0.0-alpha.7"
710
}
811

912
repositories {
@@ -14,7 +17,7 @@ repositories {
1417
dependencies {
1518
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.72")
1619
implementation("org.jetbrains.kotlin:kotlin-reflect:1.3.72")
17-
implementation("com.expediagroup:graphql-kotlin-spring-client:4.0.0-alpha.1")
20+
implementation("com.expediagroup:graphql-kotlin-spring-client:4.0.0-alpha.7")
1821
}
1922

2023
application {
@@ -29,8 +32,42 @@ tasks {
2932

3033
graphql {
3134
client {
32-
endpoint = "http://localhost:8080/graphql"
33-
packageName = "com.expediagroup.graphql.generated"
34-
clientType = com.expediagroup.graphql.plugin.generator.GraphQLClientType.WEBCLIENT
35+
sdlEndpoint = "http://localhost:8080/sdl"
36+
packageName = "com.example.generated"
37+
clientType = GraphQLClientType.WEBCLIENT
38+
queryFileDirectory = "${project.projectDir.absolutePath}/src/main/resources/first"
39+
}
40+
}
41+
42+
// above graphql extension configuration is equivalent to the below
43+
//val graphqlDownloadSDL by tasks.getting(GraphQLDownloadSDLTask::class) {
44+
// endpoint.set("http://localhost:8080/sdl")
45+
//}
46+
//
47+
//val graphqlGenerateClient by tasks.getting(GraphQLGenerateClientTask::class) {
48+
// clientType.set(GraphQLClientType.WEBCLIENT)
49+
// packageName.set("com.example.generated")
50+
// schemaFile.set(graphqlDownloadSDL.outputFile)
51+
// queryFileDirectory.set("${project.projectDir.absolutePath}/src/main/resources/first")
52+
// dependsOn("graphqlDownloadSDL")
53+
//}
54+
55+
val graphqlDownloadOtherSDL by tasks.registering(GraphQLDownloadSDLTask::class) {
56+
endpoint.set("http://localhost:8081/sdl")
57+
dependsOn("graphqlGenerateClient")
58+
}
59+
60+
val graphqlGenerateOtherClient by tasks.registering(GraphQLGenerateClientTask::class) {
61+
clientType.set(GraphQLClientType.WEBCLIENT)
62+
packageName.set("com.example.generated2")
63+
schemaFile.set(graphqlDownloadOtherSDL.get().outputFile)
64+
queryFileDirectory.set("${project.projectDir.absolutePath}/src/main/resources/second")
65+
outputDirectory.set(project.layout.buildDirectory.dir("generated/source/graphql/main"))
66+
dependsOn("graphqlDownloadOtherSDL")
67+
}
68+
69+
tasks {
70+
compileKotlin {
71+
dependsOn("graphqlGenerateOtherClient")
3572
}
3673
}

src/main/kotlin/com/expediagroup/graphql/client/Application.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.expediagroup.graphql.client
22

3-
import com.expediagroup.graphql.generated.ConferenceQuery
4-
import com.expediagroup.graphql.generated.GreetingsQuery
3+
import com.example.generated.ConferenceQuery
4+
import com.example.generated.GreetingsQuery
55
import kotlinx.coroutines.runBlocking
66
import org.springframework.web.reactive.function.client.WebClient
77

File renamed without changes.
File renamed without changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
query ExampleQuery {
2+
generateRandomId
3+
generateList
4+
generateNullableNumber
5+
}

0 commit comments

Comments
 (0)