GraphQL Query

You can read data with a GraphQL query. The best way to get started is with the Hasura console or with a GraphQL explorer, like GraphiQL.

Here is an GraphQL query that selects title, body, and done for every row in your todos table.

Query
query GetTodos {
  todos {
    title
    body
    done
  }
}
Response
{
  "data": {
    "todos": [
      {
        "title": "Delete Firebase account",
        "body": "Migrate to nhost.io",
        "done": false
      }
    ]
  }
}

GraphQL queries can be more complex, with filters, limits, sorting and aggregation.

This GraphQL query selects all items in the todo table that aren't done, with the total number of comments and the last five comments.

Query
query GetTodosWithLatestComments {
  todos(where: { done: { _eq: false } }) {
    title
    body
    comments(limit: 5, order_by: { created_at: desc }) {
      comment
      created_at
      author
    }
    comments_aggregate {
      aggregate {
        count(columns: id)
      }
    }
  }
}
Response
{
  "data": {
    "todos": [
      {
        "title": "Delete Firebase account",
        "body": "Migrate to nhost.io",
        "comments": [
          {
            "comment": "Let's do this",
            "created_at": "2019-10-31T08:34:25.621167+00:00",
            "author": "John"
          },
          {
            "comment": "🎉",
            "created_at": "2019-10-31T08:33:18.465623+00:00",
            "author": "Charlie"
          }
        ],
        "comments_aggregate": {
          "aggregate": {
            "count": 2
          }
        }
      }
    ]
  }
}

A great place to get started with setting up queries is in the Hasura Console.