mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-22 23:11:41 +03:00
5bc0355bdd
GitOrigin-RevId: abd7303aaf8e7a8739fd10574249aec450082ef8
71 lines
1.4 KiB
YAML
71 lines
1.4 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
|
|
);
|
|
CREATE TABLE article (
|
|
id SERIAL PRIMARY KEY,
|
|
title TEXT,
|
|
content TEXT,
|
|
author_id INTEGER REFERENCES author(id),
|
|
is_published BOOLEAN,
|
|
published_on TIMESTAMP
|
|
);
|
|
create view author_simple as
|
|
select * from author;
|
|
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
|
|
|
|
#Article table
|
|
- type: track_table
|
|
args:
|
|
schema: public
|
|
name: article
|
|
|
|
#Create author simple view
|
|
- type: track_table
|
|
args:
|
|
schema: public
|
|
name: author_simple
|
|
|
|
#Create author complex view
|
|
- 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
|