# How to use cypherMutation function from neo4j-graphql-js

**URL:** <https://community.neo4j.com/t/how-to-use-cyphermutation-function-from-neo4j-graphql-js/3199>\
**Category:** GraphQL & GRANDstack\
**Tags:** operations, knowledge-base\
**Created:** [November 22, 2018, 2:55pm UTC](https://community.neo4j.com/t/how-to-use-cyphermutation-function-from-neo4j-graphql-js/3199 "2018-11-22T14:55:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Banhawy](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/banhawy/32/1733_2.png) [@Banhawy](https://community.neo4j.com/u/Banhawy)\
**Post date:** [November 22, 2018, 2:55pm UTC](https://community.neo4j.com/t/how-to-use-cyphermutation-function-from-neo4j-graphql-js/3199/1 "2018-11-22T14:55:59Z")

</div>

I have a mutation in my graphQL schema that I want to resolve manually.

I came across the **cypherMutation** function in the [docs](https://grandstack.io/docs/neo4j-graphql-js-api.html#cyphermutationparams-context-resolveinfo) 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?

---

<div class="post-metadata">

**Author:** ![lyonwj](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/lyonwj/32/27358_2.png) [@lyonwj](https://community.neo4j.com/u/lyonwj)\
**Post date:** [November 26, 2018, 6:06pm UTC](https://community.neo4j.com/t/how-to-use-cyphermutation-function-from-neo4j-graphql-js/3199/2 "2018-11-26T18:06:30Z")

</div>

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: [neo4j-graphql-js/cypherTestHelpers.js at master · neo4j-graphql/neo4j-graphql-js · GitHub](https://github.com/neo4j-graphql/neo4j-graphql-js/blob/master/test/helpers/cypherTestHelpers.js#L56-L82)

---

<div class="post-metadata">

**Author:** ![Banhawy](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/banhawy/32/1733_2.png) [@Banhawy](https://community.neo4j.com/u/Banhawy)\
**Post date:** [December 3, 2018, 10:46am UTC](https://community.neo4j.com/t/how-to-use-cyphermutation-function-from-neo4j-graphql-js/3199/3 "2018-12-03T10:46:15Z")

</div>

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 @lyonwj!

---

<div class="post-metadata">

**Author:** ![rosebuttress](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/rosebuttress/32/10903_2.png) [@rosebuttress](https://community.neo4j.com/u/rosebuttress)\
**Post date:** [May 7, 2020, 3:28pm UTC](https://community.neo4j.com/t/how-to-use-cyphermutation-function-from-neo4j-graphql-js/3199/4 "2020-05-07T15:28:12Z")

</div>

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
