Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-22-2018 06:55 AM
I have a mutation in my graphQL schema that I want to resolve manually.
I came across the cypherMutation function in the docs but I find the description a little lacking without an example.
Can someone provide a simple example using the cypherMutation within a resolver to connect to a neo4j database and resove a graphQL request?
Solved! Go to Solution.
11-26-2018 10:06 AM
Hi @Banhawy - the idea of the cypherMutation
(and cypherQuery
) function is to just generate the Cypher query (and Cypher parameters) for a specific GraphQL request without handling the call to the database. A use case for when to use cypherMutation
instead of the auto-generated mutations would be if you want to have some additional authorization logic before sending the query to the database.
You can see some examples of using cypherMutation
in the tests for neo4j-graphql-js: https://github.com/neo4j-graphql/neo4j-graphql-js/blob/master/test/helpers/cypherTestHelpers.js#L56-...
11-26-2018 10:06 AM
Hi @Banhawy - the idea of the cypherMutation
(and cypherQuery
) function is to just generate the Cypher query (and Cypher parameters) for a specific GraphQL request without handling the call to the database. A use case for when to use cypherMutation
instead of the auto-generated mutations would be if you want to have some additional authorization logic before sending the query to the database.
You can see some examples of using cypherMutation
in the tests for neo4j-graphql-js: https://github.com/neo4j-graphql/neo4j-graphql-js/blob/master/test/helpers/cypherTestHelpers.js#L56-...
12-03-2018 02:46 AM
Oh I initially thought I had to define the Cypher query both in the GraphQL schema and in the resolver, this makes much more sense.
Thanks @William_Lyon!
05-07-2020 08:28 AM
This question approaches one that I have which is how to query the database from the api side of the application. For example, if I wanted to query graphql in place of Users.findOne() within a passport strategy like in the authentication/authorization blog code examples
All the sessions of the conference are now available online