graphql-engine/server/tests-py/queries/graphql_query/relay/permissions/setup.yaml
Rakesh Emmadi 4e229dc568
relay fixes (#5013)
* fix relay introspection failing if any views exist, fix #5020

* reduce base64 encoded node id length, close #5037

* make node field type non-nullable in an edge

* more relay tests with permissions & complete restructure of test yaml files

Co-authored-by: Aravind <aravindkp@outlook.in>
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
2020-06-16 19:55:49 +05:30

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
);
# Track tables and define relationships
- 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