graphql-engine/server/tests-py/queries/graphql_query/relay/permissions/setup.yaml
Swann Moreau 5bc0355bdd [server] coalesce multiple run_sql calls in tests (#270)
GitOrigin-RevId: abd7303aaf8e7a8739fd10574249aec450082ef8
2021-01-06 16:07:22 +00:00

112 lines
2.0 KiB
YAML

type: bulk
args:
- type: run_sql
args:
sql: |
CREATE TABLE author(
id SERIAL PRIMARY KEY,
name TEXT UNIQUE NOT NULL
);
INSERT INTO author (name)
VALUES ('Author 1'), ('Author 2'), ('Author 3'), ('Author 4');
CREATE TABLE article (
id SERIAL PRIMARY KEY,
title TEXT,
content TEXT,
author_id INTEGER REFERENCES author(id),
is_published BOOLEAN NOT NULL DEFAULT false
);
INSERT INTO article (title, content, author_id, is_published)
VALUES
(
'Article 1',
'Sample article content 1',
1,
true
),
(
'Article 2',
'Sample article content 2',
1,
true
),
(
'Article 3',
'Sample article content 3',
1,
false
),
(
'Article 4',
'Sample article content 4',
2,
true
),
(
'Article 5',
'Sample article content 5',
2,
false
),
(
'Article 6',
'Sample article content 6',
3,
true
);
- type: track_table
args:
name: author
schema: public
- type: track_table
args:
name: article
schema: public
- type: create_object_relationship
args:
table: article
name: author
using:
foreign_key_constraint_on: author_id
- type: create_array_relationship
args:
table: author
name: articles
using:
foreign_key_constraint_on:
table: article
column: author_id
# Define permissions
- type: create_select_permission
args:
table: author
role: user
permission:
columns: '*'
filter:
id: x-hasura-user-id
- type: create_select_permission
args:
table: article
role: user
permission:
columns:
- title
- content
- is_published
- author_id
filter:
_or:
- author_id: x-hasura-user-id
- is_published: true