graphql-engine/server/tests-py/queries/graphql_query/agg_perm/setup.yaml
2021-12-02 14:22:42 +00:00

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