Skip to content

Filtering through two @cypher connected objects fails with cypher syntax error #7045

@dumitru-marian-barbu

Description

@dumitru-marian-barbu

Type definitions

type A @node {
  hasB: B @cypher(statement: "MATCH (this)-[:HAS]->(b:B) RETURN b", columnName: "b")
  name: String!
}

type B @node {
  hasC: C @cypher(statement: "MATCH (this)-[:HAS]->(c:c) RETURN c", columnName: "c")
}

type C @node {
  name: String!
}

Test data

query {
  as(where: {
    hasB:  {
       hasC:  {
          name:  {
             eq: "test"
          }
       }
    }
  }) {
    name
  }
}

Steps to reproduce

One just needs to execute that query. The filtering that goes through two @cypher annotations fails with:

{
  "errors": [
    {
      "message": "Variable `this2` not defined (line 12, column 7 (offset: 208))\n\"WHERE this2.name = $param0\"\n       ^",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "as"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "gqlStatus": "50N42",
          "gqlStatusDescription": "error: general processing exception - unexpected error. Unexpected error has occurred. See debug log for details.",
          "diagnosticRecord": {
            "OPERATION": "",
            "OPERATION_CODE": "0",
            "CURRENT_SCHEMA": "/"
          },
          "classification": "UNKNOWN",
          "name": "Neo4jError",
          "code": "Neo.ClientError.Statement.SyntaxError",
          "retriable": false,
          "stacktrace": [
            "Neo4jError: Variable `this2` not defined (line 12, column 7 (offset: 208))",
            "\"WHERE this2.name = $param0\"",
            "       ^",
            "",
            "    at captureStacktrace (/usr/src/app/node_modules/neo4j-driver-core/lib/result.js:624:17)",
            "    at new Result (/usr/src/app/node_modules/neo4j-driver-core/lib/result.js:112:23)",
            "    at newCompletedResult (/usr/src/app/node_modules/neo4j-driver-core/lib/transaction.js:528:12)",
            "    at Object.run (/usr/src/app/node_modules/neo4j-driver-core/lib/transaction.js:360:20)",
            "    at TransactionPromise.Transaction.run (/usr/src/app/node_modules/neo4j-driver-core/lib/transaction.js:181:34)",
            "    at ManagedTransaction.run (/usr/src/app/node_modules/neo4j-driver-core/lib/transaction-managed.js:54:21)",
            "    at Executor.transactionRun (/usr/src/app/node_modules/@neo4j/graphql/src/classes/Executor.ts:291:28)",
            "    at /usr/src/app/node_modules/@neo4j/graphql/src/classes/Executor.ts:269:33",
            "    at TransactionExecutor._safeExecuteTransactionWork (/usr/src/app/node_modules/neo4j-driver-core/lib/internal/transaction-executor.js:211:26)",
            "    at TransactionExecutor.<anonymous> (/usr/src/app/node_modules/neo4j-driver-core/lib/internal/transaction-executor.js:198:46)"
          ]
        }
      }
    }
  ],
}

What happened

We used to use @relationship for these and filtering worked fine (in version 5). Once upgraded to version 7, we had to switch to @cypher. It is then that we found out that the cypher generated does not properly compile.

Expected behaviour

No response

Version

7.4.3

Database version

5.26.19

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingconfirmedConfirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions