mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 17:31:56 +03:00
5bc0355bdd
GitOrigin-RevId: abd7303aaf8e7a8739fd10574249aec450082ef8
108 lines
2.0 KiB
YAML
108 lines
2.0 KiB
YAML
type: bulk
|
|
args:
|
|
|
|
#Author table
|
|
|
|
- type: run_sql
|
|
args:
|
|
sql: |
|
|
create table author(
|
|
id serial primary key,
|
|
name text unique
|
|
);
|
|
CREATE TABLE article (
|
|
id SERIAL PRIMARY KEY,
|
|
title TEXT,
|
|
content TEXT,
|
|
author_id INTEGER NOT NULL REFERENCES author(id),
|
|
is_published BOOLEAN NOT NULL default FALSE,
|
|
published_on TIMESTAMP
|
|
);
|
|
|
|
- type: track_table
|
|
args:
|
|
schema: public
|
|
name: author
|
|
|
|
#Article table
|
|
- type: track_table
|
|
args:
|
|
schema: public
|
|
name: article
|
|
|
|
#Object relationship
|
|
- type: create_object_relationship
|
|
args:
|
|
name: author_obj_rel_fk
|
|
table: article
|
|
using:
|
|
foreign_key_constraint_on: author_id
|
|
|
|
#Object relationship
|
|
- type: create_object_relationship
|
|
args:
|
|
name: author_obj_rel_manual
|
|
table: article
|
|
using:
|
|
manual_configuration:
|
|
remote_table:
|
|
schema: public
|
|
name: author
|
|
column_mapping:
|
|
author_id: id
|
|
|
|
#Array relationship
|
|
- type: create_array_relationship
|
|
args:
|
|
table: author
|
|
name: articles
|
|
using:
|
|
foreign_key_constraint_on:
|
|
table: article
|
|
column: author_id
|
|
|
|
#Article select permission for user
|
|
- type: create_select_permission
|
|
args:
|
|
table: article
|
|
role: user
|
|
permission:
|
|
columns:
|
|
- id
|
|
- title
|
|
- content
|
|
filter:
|
|
$or:
|
|
- author_id: X-HASURA-USER-ID
|
|
- is_published: true
|
|
|
|
#Article insert permission for user
|
|
- type: create_insert_permission
|
|
args:
|
|
table: article
|
|
role: user
|
|
permission:
|
|
check:
|
|
author_id: X-Hasura-User-Id
|
|
|
|
#Author select permission for user
|
|
- type: create_select_permission
|
|
args:
|
|
table: author
|
|
role: user
|
|
permission:
|
|
columns:
|
|
- name
|
|
filter:
|
|
id: X-HASURA-USER-ID
|
|
|
|
#Author insert permission for user
|
|
- type: create_insert_permission
|
|
args:
|
|
table: author
|
|
role: user
|
|
permission:
|
|
check:
|
|
id: X-HASURA-USER-ID
|
|
|