neo4j / graphql

A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations.
https://neo4j.com/docs/graphql-manual/current/
Apache License 2.0
501 stars 147 forks source link

Get translation result in cypher #302

Open DavidCarnerosPrado opened 3 years ago

DavidCarnerosPrado commented 3 years ago

Hello,

In the old neo4j-graphql-js library it was possible to access the result of graphql translation to cypher

import {cypherQuery } from `neo4j-graphql-js`;
...
let cypher = cypherQuery(params, ctx, resolveInfo);

In my case, I want to be able to get the translation of cypher in the resolvers before executing it in the database so I can add things to cypher directly.

Is there any function to do this in this new library? If not, will it be added in the future?

Thanks in advance.

danstarns commented 3 years ago

Hey, we removed this functionality due to it being leaky of the internals of the lib, and that the produced cypher is autogenerated and not particularly human-readable or usable. So we can better provide support and gauge if this is something we would need, could you share your use case ?

jrsperry commented 3 years ago

This functionality to me at least would be very helpful from a debugging standpoint, even if it's not human readable. I've had to resort turning to the logs in my neo4j database in order to see the output and to test on my local database.

darrellwarde commented 3 years ago

Debug logging of the executed Cypher is available, see https://neo4j.com/docs/graphql-manual/current/troubleshooting/#_debug_logging

jrsperry commented 3 years ago

well that is much easier. thanks!

EarthlingDavey commented 3 years ago

@danstarns hi, I'm not OP but I can share my use case.

With neo4j-graphql-js I'd get the cypher string and parse out the RETURN ... fragment.

That would allow for me to write a custom cypher query with the inserted return string, that returns:

I'm hoping there's an alternative way using @neo4j/graphq only?

jrsperry commented 2 years ago

Although it is accessible to view in the Debug logs, it’d be helpful to have the translated query exposed so you can execute and consume the results elsewhere. I have a Java api that I use for some graph calls in coordination with the graphql api and I end up having to forward graphql statements to the api and parse json returns from the graphql api. I wanted to use the official product and not the neo4j labs java version. If I had the translated cypher and params then I could execute it from java and eliminate the need for another api that needs to connect to the DB and decrease my network traffic and overall footprint.

EarthlingDavey commented 2 years ago

@danstarns It's a bit sparse, but we have 2 genuine use cases here for your consideration. Thanks :)

darrellwarde commented 1 year ago

Loosely related to #2136!

helenesanche commented 1 year ago

@darrellwarde Is there any cross-over between this feature and https://github.com/neo4j/graphql/pull/2136 that we can leverage to bundle the work together?