mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 21:12:09 +03:00
a375f8c105
https://github.com/hasura/graphql-engine-mono/pull/1692 Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> GitOrigin-RevId: fcef85910899859f7421cad554c022f8023965ea
109 lines
2.4 KiB
YAML
109 lines
2.4 KiB
YAML
type: bulk
|
|
args:
|
|
|
|
# To model this:
|
|
|
|
# query {
|
|
# profiles {
|
|
# id
|
|
# message {
|
|
# id
|
|
# msg
|
|
# }
|
|
# }
|
|
# }
|
|
|
|
#Profile table
|
|
|
|
- type: run_sql
|
|
args:
|
|
sql: |
|
|
create table profiles (
|
|
id serial primary key,
|
|
name text
|
|
);
|
|
insert into profiles (name) values
|
|
( 'alice' ),
|
|
( 'bob' ),
|
|
( 'alice');
|
|
create table authors (
|
|
id serial primary key,
|
|
name text
|
|
);
|
|
create table employees (
|
|
id serial primary key,
|
|
name text
|
|
);
|
|
insert into employees (name) values ('alice'),(NULL),('bob');
|
|
create table students (
|
|
id serial primary key,
|
|
name text not null,
|
|
physics integer,
|
|
maths integer
|
|
);
|
|
insert into students (name, physics, maths) values ('alice', 45, 48), ('bob', 32, 40);
|
|
create function total_marks(student_row students)
|
|
returns integer as $$
|
|
select student_row.physics + student_row.maths
|
|
$$ language sql stable;
|
|
create function total_marks_offset(student_row students, "offset" integer)
|
|
returns integer as $$
|
|
select student_row.physics + student_row.maths - "offset"
|
|
$$ language sql stable;
|
|
create function total_marks_session(student_row students, hasura_session json)
|
|
returns integer as $$
|
|
select student_row.physics + student_row.maths - (hasura_session ->> 'x-hasura-offset')::integer
|
|
$$ language sql stable;
|
|
|
|
- type: track_table
|
|
args:
|
|
schema: public
|
|
name: profiles
|
|
|
|
- type: add_remote_schema
|
|
args:
|
|
name: my-remote-schema
|
|
definition:
|
|
url: http://localhost:4000
|
|
forward_client_headers: false
|
|
|
|
- type: track_table
|
|
args:
|
|
schema: public
|
|
name: authors
|
|
|
|
- type: track_table
|
|
args:
|
|
schema: public
|
|
name: employees
|
|
|
|
- type: track_table
|
|
args:
|
|
schema: public
|
|
name: students
|
|
|
|
- type: add_computed_field
|
|
args:
|
|
table: students
|
|
name: total_marks
|
|
definition:
|
|
function: total_marks
|
|
table_argument: student_row
|
|
|
|
- type: add_computed_field
|
|
args:
|
|
table: students
|
|
name: total_marks_offset
|
|
definition:
|
|
function: total_marks_offset
|
|
table_argument: student_row
|
|
|
|
- type: add_computed_field
|
|
args:
|
|
table: students
|
|
name: total_marks_session
|
|
definition:
|
|
function: total_marks_session
|
|
table_argument: student_row
|
|
session_argument: hasura_session
|