Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attributes get lost when calling a connection multiple times using aliases #392

Closed
dmoree opened this issue Aug 5, 2021 · 0 comments · Fixed by #403
Closed

Attributes get lost when calling a connection multiple times using aliases #392

dmoree opened this issue Aug 5, 2021 · 0 comments · Fixed by #403
Labels
bug Something isn't working

Comments

@dmoree
Copy link
Contributor

dmoree commented Aug 5, 2021

Describe the bug
Similar to #350 the parameters passed do not correspond to the aliased fields leaving aliasing broken when using a connection field multiple times.

Type definitions
Based on the neo-push schema with an added boolean flag on Comment

To Reproduce

  1. Clone repository Deleted
  2. Seed and start server Deleted
  3. Run each query in GraphiQL at http://localhost:4000/graphql (or as defined in .env)
Flagged
query PostsWithFlaggedComments {
  posts {
    commentsConnection(where: { node: { flag: true } }) {
      edges {
        node {
          id
          flag
        }
      }
    }
  }
}
{
  "data": {
    "posts": [
      {
        "commentsConnection": {
          "edges": [
            {
              "node": {
                "id": "91971f9b-142f-491a-9373-fe282631848b",
                "flag": true
              }
            },
            {
              "node": {
                "id": "2fe20b67-1b40-4946-bc80-f6789057b4ee",
                "flag": true
              }
            }
          ]
        }
      }
    ]
  }
}
Unflagged
query PostsWithUnflaggedComments {
  posts {
    commentsConnection(where: { node: { flag: false } }) {
      edges {
        node {
          id
          flag
        }
      }
    }
  }
}
{
  "data": {
    "posts": [
      {
        "commentsConnection": {
          "edges": [
            {
              "node": {
                "id": "59036026-39e0-4761-99ab-9ed8ad369e0b",
                "flag": false
              }
            }
          ]
        }
      }
    ]
  }
}
Both
flagged last
query PostsWithUnflaggedAndFlaggedComments {
  posts {
    unflagged: commentsConnection(where: { node: { flag: false } }) {
      edges {
        node {
          id
          flag
        }
      }
    }
    flagged: commentsConnection(where: { node: { flag: true } }) {
      edges {
        node {
          id
          flag
        }
      }
    }
  }
}
{
  "data": {
    "posts": [
      {
        "unflagged": {
          "edges": [
            {
              "node": {
                "id": "91971f9b-142f-491a-9373-fe282631848b",
                "flag": true
              }
            },
            {
              "node": {
                "id": "2fe20b67-1b40-4946-bc80-f6789057b4ee",
                "flag": true
              }
            }
          ]
        },
        "flagged": {
          "edges": [
            {
              "node": {
                "id": "91971f9b-142f-491a-9373-fe282631848b",
                "flag": true
              }
            },
            {
              "node": {
                "id": "2fe20b67-1b40-4946-bc80-f6789057b4ee",
                "flag": true
              }
            }
          ]
        }
      }
    ]
  }
}
unflagged last
query PostsWithFlaggedAndUnflaggedComments {
  posts {
    flagged: commentsConnection(where: { node: { flag: true } }) {
      edges {
        node {
          id
          flag
        }
      }
    }
    unflagged: commentsConnection(where: { node: { flag: false } }) {
      edges {
        node {
          id
          flag
        }
      }
    }
  }
}
{
  "data": {
    "posts": [
      {
        "flagged": {
          "edges": [
            {
              "node": {
                "id": "59036026-39e0-4761-99ab-9ed8ad369e0b",
                "flag": false
              }
            }
          ]
        },
        "unflagged": {
          "edges": [
            {
              "node": {
                "id": "59036026-39e0-4761-99ab-9ed8ad369e0b",
                "flag": false
              }
            }
          ]
        }
      }
    ]
  }
}

Expected Behavior

The library should be able to alias a connection field multiple times without overwriting any parameters.

Screenshots

Entire graph
Screen Shot 2021-08-05 at 12 35 19 PM

System (please complete the following information):

Additional Context

Debugger output for PostsWithFlaggedAndUnflaggedComments

@neo4j/graphql:graphql Incoming GraphQL:
Query:
query PostsWithFlaggedAndUnflaggedComments {
  posts {
    flagged: commentsConnection(where: {node: {flag: true}}) {
      edges {
        node {
          id
          flag
        }
      }
    }
    unflagged: commentsConnection(where: {node: {flag: false}}) {
      edges {
        node {
          id
          flag
        }
      }
    }
  }
}
Variables:
{} +0ms
  @neo4j/graphql:auth Could not get .authorization, .Authorization or .cookies.token from req +0ms
  @neo4j/graphql:execute About to execute Cypher:
Cypher:
MATCH (this:Post)
CALL {
WITH this
MATCH (this)-[this_has_comment:HAS_COMMENT]->(this_comment:Comment)
WHERE this_comment.flag = $this_commentsConnection.args.where.node.flag
WITH collect({ node: { id: this_comment.id, flag: this_comment.flag } }) AS edges
RETURN { edges: edges, totalCount: size(edges) } AS flagged
}
CALL {
WITH this
MATCH (this)-[this_has_comment:HAS_COMMENT]->(this_comment:Comment)
WHERE this_comment.flag = $this_commentsConnection.args.where.node.flag
WITH collect({ node: { id: this_comment.id, flag: this_comment.flag } }) AS edges
RETURN { edges: edges, totalCount: size(edges) } AS unflagged
}
RETURN this { flagged, unflagged } as this
Params:
{
  "this_commentsConnection": {
    "args": {
      "where": {
        "node": {
          "flag": false
        }
      }
    }
  }
} +0ms
  @neo4j/graphql:execute Execute successful, received 1 records +13ms

@dmoree dmoree added bug Something isn't working inbox labels Aug 5, 2021
@darrellwarde darrellwarde linked a pull request Aug 6, 2021 that will close this issue
6 tasks
@darrellwarde darrellwarde linked a pull request Aug 10, 2021 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants