Skip to content

GraphQL JSON Result

Ghislain B edited this page Apr 2, 2018 · 13 revisions

The GraphQL JSON result will always follow a certain structure where only the dataset name and the nodes array will change. As so if we look at the GraphqlResult TypeScript interface, the JSON result will always follow this structure:

GraphqlResult TypeScript interface

The datasetName is the only dynamic portion of the structure and in our demo will be users.

export interface GraphqlResult {
  data: {
    [datasetName: string]: {
      nodes: any[],
      totalCount: number
    }
  }
}

Users demo

If we consider that we defined a grid of Users and we provided the datasetName: 'users' with 3 defined columns (firstName, lastName, email). The JSON result could look like the following:

{
  "data": {
    "users": {
      "totalCount": 2,
      "pageInfo": {
        "hasNextPage": false
      },
      "nodes": [
        {
          "id": 0,
          "firstName": "John",
          "lastName": "Doe",
          "email": "[email protected]"
        },
        {
          "id": 1,
          "firstName": "Jane",
          "lastName": "Doe",
          "email": "[email protected]"
        }
      ]
    }
  }
}

Contents

Clone this wiki locally