neo4j-graphql-java icon indicating copy to clipboard operation
neo4j-graphql-java copied to clipboard

add ability to transform graphql statements before transpiling

Open danielmischler opened this issue 5 years ago • 2 comments

E.g. given

type Order {
  firstName: String!
  lastName: String!
  name: String
}

and (coming from an external client)

mutation {
  addOrder(firstName: "John", lastName:"Doe") {
    name
  }
}

it would be great if there is a way to store the data in neo4j like

(o:Order)--(a:Address {firstName: "John", lastName: "Doe"})

There should also be a possibility to post process the returned data before sending it back to the external client

val name = "$firstName $lastName"

danielmischler avatar Mar 13 '19 09:03 danielmischler

The pre and post processing should be possible in your code using the transpiler.

Preprocessing via graphql java apis Ie parse/modify/generate.

We could add another method that takes the ast.

Postprocessing by walking over the bolt results

jexp avatar May 21 '19 05:05 jexp

You can achieve the post processing with the following schema:

type Order {
  firstName: String!
  lastName: String!
  name: String @cypher(statement:"WITH (this) RETURN this.firstName + ' ' + this.lastName")
}

The Query:

{order{name}}

will result in the following cypher:

MATCH (order:`Order`) RETURN order { name:apoc.cypher.runFirstColumnSingle('WITH $this AS this WITH (this) RETURN this.firstName + \' \' + this.lastName', { this:order }) } AS order

Andy2003 avatar Sep 03 '20 09:09 Andy2003