Skip to content

Commit 3097bfc

Browse files
dariuszkucsmyrick
andauthored
[plugins] update introspection query (#973)
* [plugins] update introspection query `graphql-java` version 16 updated their introspection query to support repeatable directives. Updated introspection query can only be executed against servers that are running latest version of `graphql-java`. Adding old version of the introspection query as we dont need repeatable directive info for generating the client code * Update introspectSchema.kt Co-authored-by: Shane Myrick <[email protected]>
1 parent e518536 commit 3097bfc

File tree

1 file changed

+93
-2
lines changed
  • plugins/graphql-kotlin-plugin-core/src/main/kotlin/com/expediagroup/graphql/plugin

1 file changed

+93
-2
lines changed

plugins/graphql-kotlin-plugin-core/src/main/kotlin/com/expediagroup/graphql/plugin/introspectSchema.kt

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.expediagroup.graphql.plugin
1818

1919
import com.expediagroup.graphql.plugin.config.TimeoutConfig
20-
import graphql.introspection.IntrospectionQuery
2120
import graphql.introspection.IntrospectionResultToSchema
2221
import graphql.schema.idl.SchemaPrinter
2322
import io.ktor.client.HttpClient
@@ -33,6 +32,98 @@ import io.ktor.http.contentType
3332
import io.ktor.util.KtorExperimentalAPI
3433
import kotlinx.coroutines.TimeoutCancellationException
3534

35+
private const val INTROSPECTION_QUERY =
36+
"""
37+
query IntrospectionQuery {
38+
__schema {
39+
queryType { name }
40+
mutationType { name }
41+
subscriptionType { name }
42+
types {
43+
...FullType
44+
}
45+
directives {
46+
name
47+
description
48+
locations
49+
args {
50+
...InputValue
51+
}
52+
}
53+
}
54+
}
55+
fragment FullType on __Type {
56+
kind
57+
name
58+
description
59+
fields(includeDeprecated: true) {
60+
name
61+
description
62+
args {
63+
...InputValue
64+
}
65+
type {
66+
...TypeRef
67+
}
68+
isDeprecated
69+
deprecationReason
70+
}
71+
inputFields {
72+
...InputValue
73+
}
74+
interfaces {
75+
...TypeRef
76+
}
77+
enumValues(includeDeprecated: true) {
78+
name
79+
description
80+
isDeprecated
81+
deprecationReason
82+
}
83+
possibleTypes {
84+
...TypeRef
85+
}
86+
}
87+
fragment InputValue on __InputValue {
88+
name
89+
description
90+
type { ...TypeRef }
91+
defaultValue
92+
}
93+
fragment TypeRef on __Type {
94+
kind
95+
name
96+
ofType {
97+
kind
98+
name
99+
ofType {
100+
kind
101+
name
102+
ofType {
103+
kind
104+
name
105+
ofType {
106+
kind
107+
name
108+
ofType {
109+
kind
110+
name
111+
ofType {
112+
kind
113+
name
114+
ofType {
115+
kind
116+
name
117+
}
118+
}
119+
}
120+
}
121+
}
122+
}
123+
}
124+
}
125+
"""
126+
36127
/**
37128
* Runs introspection query against specified GraphQL endpoint and returns underlying schema.
38129
*/
@@ -54,7 +145,7 @@ suspend fun introspectSchema(endpoint: String, httpHeaders: Map<String, Any> = e
54145
header(name, value)
55146
}
56147
body = mapOf(
57-
"query" to IntrospectionQuery.INTROSPECTION_QUERY,
148+
"query" to INTROSPECTION_QUERY,
58149
"operationName" to "IntrospectionQuery"
59150
)
60151
}

0 commit comments

Comments
 (0)