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

Invalid Cypher/variables generated for certain GraphQL queries #106

Closed
kipz opened this issue Sep 18, 2018 · 0 comments
Closed

Invalid Cypher/variables generated for certain GraphQL queries #106

kipz opened this issue Sep 18, 2018 · 0 comments

Comments

@kipz
Copy link
Contributor

kipz commented Sep 18, 2018

Over at https://atomist.com, we're looking Apollo with neo4j-graphql-js, but some of our graphql queries aren't working as expected:

The following GraphQL request:

query chatChannel {
  ChatTeam(id: "T1L0VDKJP", atmTeamId: "T1L0VDKJP") {
    channels(name: "handlers", atmTeamId: "T1L0VDKJP") {
      name
      repos(owner: "atomisthqa", name: "handlers", atmTeamId: "T1L0VDKJP") {
        name
        owner
      }
    }
  }
}

Results in the following Cypher with Variables:

MATCH (chatTeam:ChatTeam {atmTeamId:$atmTeamId,id:$id}) RETURN chatTeam {channels: [(chatTeam)-[:HAS_CHANNEL]->(chatTeam_channels:ChatChannel{name:$1-name,atmTeamId:$1-atmTeamId}) | chatTeam_channels { .name ,repos: [(chatTeam_channels)<-[:CHANNEL]-(chatTeam_channels_repos:Repo{owner:$2-owner,name:$2-name,atmTeamId:$2-atmTeamId}) | chatTeam_channels_repos { .name , .owner }] }] } AS chatTeam SKIP $offset
{ offset: 0,
  first: -1,
  atmTeamId: 'T1L0VDKJP',
  id: 'T1L0VDKJP',
  '1-name': 'handlers',
  '1-atmTeamId': 'T1L0VDKJP',
  '2-owner': 'atomisthqa',
  '2-name': 'handlers',
  '2-atmTeamId': 'T1L0VDKJP' }

which leads to the following error being returned from neo4j:

{
  "data": {
    "ChatTeam": null
  },
  "errors": [
    {
      "message": "Variable `name` not defined (line 1, column 151 (offset: 150))\n\"MATCH (chatTeam:ChatTeam {atmTeamId:$atmTeamId,id:$id}) RETURN chatTeam {channels: [(chatTeam)-[:HAS_CHANNEL]->(chatTeam_channels:ChatChannel{name:$1-name,atmTeamId:$1-atmTeamId}) | chatTeam_channels { .name ,repos: [(chatTeam_channels)<-[:CHANNEL]-(chatTeam_channels_repos:Repo{owner:$2-owner,name:$2-name,atmTeamId:$2-atmTeamId}) | chatTeam_channels_repos { .name , .owner }] }] } AS chatTeam SKIP $offset\"\n                                                                                                                                                       ^",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "ChatTeam"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "code": "Neo.ClientError.Statement.SyntaxError",
          "name": "Neo4jError",
          "stacktrace": [
            "Neo4jError: Variable `name` not defined (line 1, column 151 (offset: 150))",
            "\"MATCH (chatTeam:ChatTeam {atmTeamId:$atmTeamId,id:$id}) RETURN chatTeam {channels: [(chatTeam)-[:HAS_CHANNEL]->(chatTeam_channels:ChatChannel{name:$1-name,atmTeamId:$1-atmTeamId}) | chatTeam_channels { .name ,repos: [(chatTeam_channels)<-[:CHANNEL]-(chatTeam_channels_repos:Repo{owner:$2-owner,name:$2-name,atmTeamId:$2-atmTeamId}) | chatTeam_channels_repos { .name , .owner }] }] } AS chatTeam SKIP $offset\"",
            "                                                                                                                                                       ^",
          
          ]
        }
      }
    }
  ]
}

It looks like the generated variable names are invalid, as manually renaming them and running via the neo4j console appears to work.

Versions:

neo4j: 3.4.0

"graphql": "^14.0.2",
"graphql-tools": "^3.1.1",
"neo4j-graphql-js": "^0.2.0"
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant