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

Custom cypher query on root query field with no arguments throws error #177

Closed
smkhalsa opened this issue Jan 11, 2019 · 0 comments
Closed

Comments

@smkhalsa
Copy link
Contributor

If I query a root query field with a custom cypher query that does not have any arguments, I get an error. I believe this is because the second argument of the resulting call to apoc.cypher.runFirstColumn is empty.

For example, if I have the following schema...

type Album implements SongCollection {
  id: ID!
  name: String!
  songs: [Song!]! @cypher(statement: "MATCH (this)-[r:HAS_SONG]->(s:Song) RETURN s ORDER BY r.number")
  imageName: String  
  artists: [Artist!]! @relation(name: "BY_ARTIST", direction: "OUT")
  songRelations: [SongAlbumRelation!]!
}

type Query {
  PopularAlbums: [Album!]! @cypher(statement: "Match (a:Album) return a ORDER BY a.name") # TODO: update with actual logic
}

... and make this query...

query {
  PopularAlbums {
    name
  }
}

... I get the following error:

{
  "errors": [
    {
      "message": "Invalid input ',': expected whitespace, comment or an expression (line 1, column 77 (offset: 76))\n\"WITH apoc.cypher.runFirstColumn(\"Match (a:Album) return a ORDER BY a.name\", , True) AS x UNWIND x AS `album`\"\n                                                                             ^",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "PopularAlbums"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "code": "Neo.ClientError.Statement.SyntaxError",
          "name": "Neo4jError",
          "stacktrace": [
            "Neo4jError: Invalid input ',': expected whitespace, comment or an expression (line 1, column 77 (offset: 76))",
            "\"WITH apoc.cypher.runFirstColumn(\"Match (a:Album) return a ORDER BY a.name\", , True) AS x UNWIND x AS `album`\"",
            "                                                                             ^",
            "",
            "    at captureStacktrace (/Users/smkhalsa/code/kundalini-server/node_modules/neo4j-driver/lib/v1/result.js:200:15)",
            "    at new Result (/Users/smkhalsa/code/kundalini-server/node_modules/neo4j-driver/lib/v1/result.js:73:19)",
            "    at Session._run (/Users/smkhalsa/code/kundalini-server/node_modules/neo4j-driver/lib/v1/session.js:173:14)",
            "    at Session.run (/Users/smkhalsa/code/kundalini-server/node_modules/neo4j-driver/lib/v1/session.js:154:19)",
            "    at _callee$ (/Users/smkhalsa/code/kundalini-server/node_modules/neo4j-graphql-js/dist/index.js:60:28)",
            "    at tryCatch (/Users/smkhalsa/code/kundalini-server/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:62:40)",
            "    at Generator.invoke [as _invoke] (/Users/smkhalsa/code/kundalini-server/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:296:22)",
            "    at Generator.prototype.(anonymous function) [as next] (/Users/smkhalsa/code/kundalini-server/node_modules/babel-runtime/node_modules/regenerator-runtime/runtime.js:114:21)",
            "    at step (/Users/smkhalsa/code/kundalini-server/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)",
            "    at /Users/smkhalsa/code/kundalini-server/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14"
          ]
        }
      }
    }
  ],
  "data": null
}

the resulting neo4j query is

WITH apoc.cypher.runFirstColumn("Match (a:Album) return a ORDER BY a.name", , True) AS x UNWIND x AS `album`
    RETURN `album` { .name } AS `album` SKIP $offset
{ offset: 0, first: -1 }
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