com.coxautodev.graphql.client.GraphQLClient.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of graphql-java-client Show documentation
Show all versions of graphql-java-client Show documentation
A client for calling GraphQL services from the JVM.
The newest version!
package com.coxautodev.graphql.client
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.registerKotlinModule
import org.apache.http.client.methods.HttpPost
import org.apache.http.client.methods.HttpRequestBase
import org.apache.http.entity.StringEntity
import org.apache.http.impl.client.HttpClientBuilder
/**
* @author Andrew Potter
*/
class GraphQLClient @JvmOverloads constructor(private val url: String, private val configurer: (HttpRequestBase) -> Unit = {}) {
private val mapper = ObjectMapper().registerKotlinModule()
private val client = HttpClientBuilder.create().build()
@JvmOverloads
fun queryForResult(text: String, vars: Map = mapOf()): GraphQLResponse