mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 17:31:56 +03:00
88aa42a986
In hasura/graphql-engine#7172, an issue was found where under certain conditions a JSON field from Postgres would be parsed as a GraphQL input object, which is not possible in general, and also unnecessary. Luckily, this was already fixed by the time `v2.0.6` got around, presumably thanks to 4a83bb1834
. This adds a regression test.
https://github.com/hasura/graphql-engine-mono/pull/2158
GitOrigin-RevId: 1ded1456f6b89726e08f77cf3383ad88c04de451
119 lines
2.6 KiB
YAML
119 lines
2.6 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;
|
|
create table regression_7172 (
|
|
id serial primary key,
|
|
features json
|
|
);
|
|
insert into regression_7172 (features) values ('{"Start Color":44}');
|
|
|
|
- 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
|
|
|
|
- type: track_table
|
|
args:
|
|
schema: public
|
|
name: regression_7172
|