opencypher/cypher-for-gremlin

Generating json response

VINAYAK179 opened this issue · 6 comments

Hello,

I have successfully installed the plugin and getting the response using cypher. Is there any way so that I can generate the response in json format directly.

Thanks

Hello @VINAYAK179 ,

To my knowledge, the Gremlin Client does not expose JSON response.

It is possible to configure Gremlin Server to support REST, but processor request message parameter necessary for Cypher for Gremlin to work is not handled.

So REST will only work for Gremlin (not Cypher). The only way I can imagine to achieve this is doing client side translation, then sending the translated query to Gremlin REST endpoint.

Hello @dwitry ,

Thank You for the answer. I understood the point of translating Cypher query to gremlin and will do it. I have some question related to query to Gremlin REST endpoint after translation.
I will add the HTTP socket for json response. After doing this how to query the gremlin server, can you please explain with an sample example. Also whether only adding HTTP socket to server is enough or any other additions are required.
Note : I am using Java for connection and retrieval the result

After doing this how to query the gremlin server, can you please explain with an sample example.

Any client for Java will do, for example OkHttp:

MediaType JSON = MediaType.get("application/json; charset=utf-8");

OkHttpClient okHttpClient = new OkHttpClient.Builder().build();

Request request = new Request.Builder()
    .url("http://localhost:8182")
    .post(
            RequestBody.create(JSON,"{\"gremlin\" : \"" + translatedQuery + "\"}")
    )
    .build();


Response response = okHttpClient.newCall(request).execute();

System.out.println(response.body().string());

Also whether only adding HTTP socket to server is enough or any other additions are required.

Setting channelizer to org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer in server config yaml should be enough.

I am using ConfiguredGraphFactory to access one of multiple stored graphs are any changes needed in the above code to open the specific graph using ConfiguredGraphFactory.

You may need to add aliases to request body if you are using it.

Closing issue after a week of inactivity. Don't hesitate to open a new issue if you have any more questions.