mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 20:41:49 +03:00
7194dc691c
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3024 GitOrigin-RevId: 30c0e7d713375d0c54ff7145d00985e3ade4f1a9
192 lines
3.5 KiB
YAML
192 lines
3.5 KiB
YAML
type: bulk
|
|
args:
|
|
|
|
|
|
- type: run_sql
|
|
args:
|
|
sql: |
|
|
-- author table
|
|
create table author(
|
|
id serial primary key,
|
|
name text unique
|
|
);
|
|
-- article table
|
|
CREATE TABLE article (
|
|
id SERIAL PRIMARY KEY,
|
|
title TEXT,
|
|
content TEXT,
|
|
author_id INTEGER REFERENCES author(id),
|
|
is_published BOOLEAN,
|
|
published_on TIMESTAMP NOT NULL DEFAULT NOW()
|
|
);
|
|
-- post table
|
|
CREATE TABLE post (
|
|
id SERIAL PRIMARY KEY,
|
|
title TEXT,
|
|
content TEXT,
|
|
author_id INTEGER REFERENCES author(id)
|
|
);
|
|
|
|
-- insert data
|
|
INSERT INTO author (name)
|
|
VALUES
|
|
('Author 1'),
|
|
('Author 2')
|
|
;
|
|
|
|
INSERT INTO article (title,content,author_id,is_published)
|
|
VALUES
|
|
(
|
|
'Article 1',
|
|
'Sample article content 1',
|
|
1,
|
|
false
|
|
),
|
|
(
|
|
'Article 2',
|
|
'Sample article content 2',
|
|
1,
|
|
true
|
|
),
|
|
(
|
|
'Article 3',
|
|
'Sample article content 3',
|
|
2,
|
|
true
|
|
)
|
|
;
|
|
|
|
INSERT INTO post (title, content, author_id)
|
|
VALUES
|
|
(
|
|
'Post 1',
|
|
'Post 1 Content',
|
|
1
|
|
),
|
|
(
|
|
'Post 2',
|
|
'Post 2 Content',
|
|
1
|
|
),
|
|
(
|
|
'Post 3',
|
|
'Post 3 Content',
|
|
1
|
|
),
|
|
(
|
|
'Post 4',
|
|
'Post 4 Content',
|
|
2
|
|
),
|
|
(
|
|
'Post 5',
|
|
'Post 5 Content',
|
|
2
|
|
)
|
|
;
|
|
|
|
- type: track_table
|
|
args:
|
|
schema: public
|
|
name: author
|
|
|
|
- type: track_table
|
|
args:
|
|
schema: public
|
|
name: article
|
|
|
|
- type: track_table
|
|
args:
|
|
schema: public
|
|
name: post
|
|
|
|
#Object relationship article <-> author
|
|
- type: create_object_relationship
|
|
args:
|
|
table: article
|
|
name: author
|
|
using:
|
|
foreign_key_constraint_on: author_id
|
|
|
|
#Array relationship author <-> article
|
|
- type: create_array_relationship
|
|
args:
|
|
table: author
|
|
name: articles
|
|
using:
|
|
foreign_key_constraint_on:
|
|
table: article
|
|
column: author_id
|
|
|
|
#Array relationship author <-> post
|
|
- type: create_array_relationship
|
|
args:
|
|
table: author
|
|
name: posts
|
|
using:
|
|
foreign_key_constraint_on:
|
|
table: post
|
|
column: author_id
|
|
|
|
#Select pemissions on User
|
|
- type: create_select_permission
|
|
args:
|
|
table: author
|
|
role: user
|
|
permission:
|
|
columns: '*'
|
|
filter: {}
|
|
allow_aggregations: true
|
|
limit: 1
|
|
|
|
- type: create_select_permission
|
|
args:
|
|
table: article
|
|
role: user
|
|
permission:
|
|
columns: '*'
|
|
filter: {}
|
|
allow_aggregations: false
|
|
limit: 1
|
|
|
|
- type: create_select_permission
|
|
args:
|
|
table: post
|
|
role: user
|
|
permission:
|
|
columns: '*'
|
|
filter: {}
|
|
allow_aggregations: true
|
|
limit: 1
|
|
|
|
- type: create_select_permission
|
|
args:
|
|
table: article
|
|
role: user_with_filter
|
|
permission:
|
|
columns: '*'
|
|
filter:
|
|
author_id:
|
|
_eq: X-Hasura-User-Id
|
|
allow_aggregations: true
|
|
|
|
- type: create_select_permission
|
|
args:
|
|
table: article
|
|
role: role_without_access_to_cols
|
|
permission:
|
|
columns: []
|
|
filter: {}
|
|
allow_aggregations: true
|
|
limit: 1
|
|
|
|
- type: create_select_permission
|
|
args:
|
|
table: article
|
|
role: role_with_access_to_cols
|
|
permission:
|
|
columns: '*'
|
|
filter: {}
|
|
allow_aggregations: true
|
|
limit: 1
|