graphql-engine/server/tests-py/queries/graphql_mutation/insert/views/setup.yaml

78 lines
1.5 KiB
YAML

type: bulk
args:
#Author table
- type: run_sql
args:
sql: |
create table author(
id serial primary key,
name text unique,
is_registered boolean not null default false
);
- type: track_table
args:
schema: public
name: author
#Article table
- type: run_sql
args:
sql: |
CREATE TABLE article (
id SERIAL PRIMARY KEY,
title TEXT,
content TEXT,
author_id INTEGER REFERENCES author(id),
is_published BOOLEAN,
published_on TIMESTAMP
)
- type: track_table
args:
schema: public
name: article
#Create author simple view
- type: run_sql
args:
sql: |
create view author_simple as
select * from author;
- type: track_table
args:
schema: public
name: author_simple
#Create author complex view
- type: run_sql
args:
sql: |
create view author_complex as
select a.id as author_id, b.title as article_title
from author a join article b on (a.id = b.author_id);
- type: track_table
args:
schema: public
name: author_complex
#Create object relations on views
- type: create_object_relationship
args:
table: article
name: author_simple
using:
manual_configuration:
remote_table: author_simple
column_mapping:
author_id: id
- type: create_object_relationship
args:
table: article
name: author_complex
using:
manual_configuration:
remote_table: author_complex
column_mapping:
author_id: author_id