Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

cypherMutation function errors when attempting a selection across relation when using additional labels directive #502

Closed
wworrall opened this issue Aug 28, 2020 · 0 comments

Comments

@wworrall
Copy link
Contributor

wworrall commented Aug 28, 2020

Building upon the solution presented by @Crodaycat (thanks!!) on this issue: 256

A problem exists when cypherMutation is called using a nested selection to return both the created node and the related node when additional labels are in use.

CreateNodeA(id: "nodeA", nodeBId: "nodeB") {
  id
  nodeB {
    id
  }
}
"stacktrace": [
            "TypeError: Cannot read property 'tenantLabel' of undefined",
            "    at eval (lodash.templateSources[5]:5:25)",
            "    at /workspace/node_modules/neo4j-graphql-js/dist/utils.js:532:7",
            "    at Array.map (<anonymous>)",
            "    at getAdditionalLabels (/workspace/node_modules/neo4j-graphql-js/dist/utils.js:529:32)",
            "    at relationFieldOnNodeType (/workspace/node_modules/neo4j-graphql-js/dist/translate.js:266:681)",
            "    at buildCypherSelection (/workspace/node_modules/neo4j-graphql-js/dist/selections.js:442:76)",
            "    at recurse (/workspace/node_modules/neo4j-graphql-js/dist/selections.js:97:33)",
            "    at buildCypherSelection (/workspace/node_modules/neo4j-graphql-js/dist/selections.js:553:17)",
            "    at nodeCreate (/workspace/node_modules/neo4j-graphql-js/dist/translate.js:1458:69)",
            "    at translateMutation (/workspace/node_modules/neo4j-graphql-js/dist/translate.js:1267:12)"
          ]

This problem only exists when a custom mutation is in use which leverages cypherMutation to create the raw cypher for the mutation and extends it (in the above use case, to also create the relation to node B). In the normal use case for creating a node with the neo4j-graphql-js generated "CreateNodeA" mutation, we would never be in the situation of selecting a relationship on creation since relations are not created yet

@wworrall wworrall changed the title cypherMutation function fails when using additional labels and a selection across relations cypherMutation function errors when attempting a selection across relation when using additional labels directive Aug 28, 2020
johnymontana pushed a commit that referenced this issue Sep 7, 2020
* pass context through createNode use cypherParams in buildCypherSelection

* Also pass cypherParms in to buildCypherSelection when updating node
@wworrall wworrall closed this as completed Sep 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant