Skip to content

Latest commit

 

History

History
92 lines (88 loc) · 3.18 KB

related_multiple.md

File metadata and controls

92 lines (88 loc) · 3.18 KB

Related rows for tables with multiple foreign keys

If another table has multiple foreign keys back to the same table, related row fields are created to avoid name clashes:

{
  users {
    nodes {
      id
      name
      issues_by_user_list {
        nodes {
          id
          title
          updated_by {
            name
          }
          user {
            name
          }
        }
      }
      issues_by_updated_by_list {
        nodes {
          id
          title
          updated_by {
            name
          }
          user {
            name
          }
        }
      }
    }
  }
}

Try this query

Expected output:

{
    "users": {
        "nodes": [
            {
                "id": 1,
                "name": "cleopaws",
                "issues_by_user_list": {
                    "nodes": [
                        {
                            "id": 111,
                            "title": "Not enough dog stuff",
                            "updated_by": {
                                "name": "simonw"
                            },
                            "user": {
                                "name": "cleopaws"
                            }
                        }
                    ]
                },
                "issues_by_updated_by_list": {
                    "nodes": []
                }
            },
            {
                "id": 2,
                "name": "simonw",
                "issues_by_user_list": {
                    "nodes": []
                },
                "issues_by_updated_by_list": {
                    "nodes": [
                        {
                            "id": 111,
                            "title": "Not enough dog stuff",
                            "updated_by": {
                                "name": "simonw"
                            },
                            "user": {
                                "name": "cleopaws"
                            }
                        }
                    ]
                }
            }
        ]
    }
}