Closed lynx-r closed 6 years ago
Hi @lynx-r , thanks for the feedback.
If you're talking about the Query Builders they were created for two use cases:
import gql.DSL
import graphql.GraphQLSchema
import graphql.ExecutionResult
import graphql.schema.DataFetchingEnvironment
GraphQLSchema schema = ...
ExecutionResult result = DSL.execute(schema) {
query('byYear', [year: '1962']) {
returns(Film) {
title
year
}
alias 'first'
}
}
import gql.DSL
import com.mashape.unirest.http.Unirest
import groovy.json.JsonOutput
String queryString = DSL.buildQuery {
query('byYear', [year: '1962']) {
returns(Film) {
title
year
}
alias 'first'
}
query('byYear', [year: '2015']) {
returns {
title
year
bond
}
alias 'last'
}
}
// Then you can use an HTTP client like e.g Unirest (http://unirest.io/java.html)
Unirest
.post("http://anyotherservice.com/graphql")
.body(JsonOutput.toJson([query: queryString]))
.asJson()
I hope this helps
Excellen! Exactly what I want to see. I want to use this approach in the code https://github.com/piomin/sample-graphql-microservices .
I haven't found any clues in docs about how I can specify address where queries should be send. I.e. I want to send a query to another server. How can I specify an address and a port?