Skip to content

Commit

Permalink
pass 'operationName' in the introspection query (#3126)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinbonnin committed Nov 19, 2021
1 parent 403a4b1 commit 1c30bda
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ object SchemaDownloader {
headers: Map<String, String>
): String {

val response = SchemaHelper.executeQuery(introspectionQuery, emptyMap(), endpoint, headers)
val body = mapOf(
"query" to introspectionQuery,
"operationName" to "IntrospectionQuery"
)
val response = SchemaHelper.executeQuery(body, endpoint, headers)

return response.body.use { responseBody ->
responseBody!!.string()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ internal object SchemaHelper {
.readTimeout(readTimeoutSeconds, TimeUnit.SECONDS)
.build()
}

/**
* @param variables a map representing the variable as Json values
*/
internal fun executeQuery(query: String, variables: Map<String, Any>, url: String, headers: Map<String, String>): Response {
val body = mapOf("query" to query, "variables" to variables).toJson().toByteArray().toRequestBody("application/json".toMediaTypeOrNull())
internal fun executeQuery(map: Map<String, Any?>, url: String, headers: Map<String, String>): Response {
val body = map.toJson().toByteArray().toRequestBody("application/json".toMediaTypeOrNull())
val request = Request.Builder()
.post(body)
.apply {
Expand All @@ -53,4 +49,10 @@ internal object SchemaHelper {

return response
}
/**
* @param variables a map representing the variable as Json values
*/
internal fun executeQuery(query: String, variables: Map<String, Any>, url: String, headers: Map<String, String>): Response {
return executeQuery(mapOf("query" to query, "variables" to variables), url, headers)
}
}

0 comments on commit 1c30bda

Please sign in to comment.