Customise schema with views

Table of contents

Use cases

You may want to customise your GraphQL schema to:

  • Limit scope (i.e. expose only a subset of the columns in a table)
  • Fetch derived data (aggregations like count, average, etc.) in queries

These kinds of use cases can be supported using database views.

Please see the following pages for details about the above use cases:

Creating views

Views can be created using SQL which can be run in the Hasura console:

  • Head to the Data -> SQL section of the Hasura console
  • Enter your create view SQL statement
  • Select the Track this checkbox to expose the new view over the GraphQL API
  • Hit the Run button