Thanks, since @gja 's approach is the simplest I’ve used that and it works.
Next question:
How do I pass the API Key in Dgraph Client for Java?
private val client = {
val channel = ManagedChannelBuilder.forAddress(DGRAPH_HOST, DGRAPH_PORT).usePlaintext.build // Where to put the KEY?
val stub = DgraphGrpc.newStub(channel)
new DgraphClient(stub)
}
@wiradikusuma Hi. We are still working on adding Slash GraphQL to dgraph4j. It should be in a week or so. In the meanwhile, it’s possible to connect to slash GraphQL similar to the other languages
Create a GRPC connection with SSL (using system SSL certificates). useTransportSecurity() instead of usePlainText
Passing the API Key as call credentials on the stub (withCallCredentials, passing in a CallCredentials that passes the api key in the ‘authorization’ field)
private val client = {
val channel = ManagedChannelBuilder.forAddress("myapp-01.us-west-2.aws.cloud.dgraph.io", 9080).useTransportSecurity().build
val stub = DgraphGrpc.newStub(channel).withCallCredentials(
MoreCallCredentials.from(OAuth2Credentials.create(new AccessToken("sOmEwEiRdCoDe3kSOV32NO8Af90yca952MnUcUs=", null))))
new DgraphClient(stub)
}
But then after a minute I got this:
Caused by: io.grpc.netty.shaded.io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection timed out: no further information: myapp-01.us-west-2.aws.cloud.dgraph.io/12.34.56.78:9080
Caused by: java.net.ConnectException: Connection timed out: no further information
at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)