Search code examples
graphqlgraphql-jshasuratypegraphql

Graphql Introspection result does not contain relation columns


Thanks for taking time to review my question, I am executing an introspection query and the result contains tables and columns. As listed in the image below.

{
  "name": "tbl_enterprise",
  "kind": "OBJECT",
  "description": "columns and relationships of \"tbl_enterprise\"",
  "fields": [
    {
      "name": "activity",
      "description": null,
      "type": {
        "name": "bigint",
        "kind": "SCALAR",
        "ofType": null
      }
    },
    {
      "name": "activity_category",
      "description": null,
      "type": {
        "name": "bigint",
        "kind": "SCALAR",
        "ofType": null
      }
    },
    {
      "name": "individual_trader",
      "description": null,
      "type": {
        "name": "Float",
        "kind": "SCALAR",
        "ofType": null
      }
    }
  ]
}

My problem is: inside the fields I do have the relation with the table name but there is no information about the which column is related to the table. As in below you can see there is a field listed in the tbl_enterprise table as column which has type of tbl_person this is also listed as a column which is very nice but it does not contain which column is the foreign key in the table tbl_enterprise

NOT: the relation is one to one and there is a column called individual_trader inside the table tbl_enterprise.

{
  "name": "tbl_person",
  "description": "An object relationship",
  "type": {
    "name": "tbl_person",
    "kind": "OBJECT",
    "ofType": null
  }
}

Can someone help me if there is the possibility to list the relation with the column.


Solution

  • GraphQL does not specify how relationships are implemented. It makes no assumption about the structure of the underlying database, whether it is relational, document-oriented (ex: MongoDB), a graph db (such as Neo4J), a flat-file, or a series of REST endpoints. Therefore it cannot determine which field(s) might be foreign keys. Indeed in many GraphQL models the foreign keys are not even included in the type model because they are not needed when rendering the objects in a UI.