graphql-engine/docs/graphql/manual/schema/views.rst
Rikin Kachhia 6c2f64b68a
update docs (#1748)
* increase roles TOC depth
* update enum docs page
* open external links in docs in new tabs
* update nested object sort docs
2019-03-13 15:34:40 +05:30

36 lines
935 B
ReStructuredText

Customise schema with views
===========================
.. contents:: Table of contents
:backlinks: none
:depth: 1
:local:
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 kind of use-cases can be supported using database views.
Please see the following pages for details about the above use-cases:
- :doc:`../queries/control-access`
- :doc:`../queries/derived-data`
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 <https://www.postgresql.org/docs/current/static/sql-createview.html>`__
- Select the ``Track this`` checkbox to expose the new view over the GraphQL API
- Hit the ``Run`` button