mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
825e256523
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7289 GitOrigin-RevId: a1d0174034c9f2ee3577b05932db6a159aca4220
225 lines
4.4 KiB
YAML
225 lines
4.4 KiB
YAML
- description: create table 1
|
|
url: /v1/query
|
|
status: 200
|
|
response:
|
|
result_type: CommandOk
|
|
result:
|
|
query:
|
|
type: run_sql
|
|
args:
|
|
source: pg1
|
|
sql: |
|
|
create table author_local(
|
|
id serial primary key,
|
|
name text unique
|
|
);
|
|
INSERT INTO author_local (name)
|
|
VALUES ('Author 1'), ('Author 2');
|
|
|
|
create table article_local(
|
|
id serial primary key,
|
|
author_id serial,
|
|
title text
|
|
);
|
|
INSERT INTO article_local (author_id, title)
|
|
VALUES (1, 'Article 1'), (1, 'Article 2'), (2, 'New Article 1'), (2, 'New Article 2');
|
|
|
|
- description: track table
|
|
url: /v1/metadata
|
|
status: 200
|
|
response:
|
|
message: success
|
|
query:
|
|
type: pg_track_table
|
|
args:
|
|
table: author_local
|
|
source: pg1
|
|
configuration:
|
|
custom_name: authorDetails
|
|
custom_root_fields:
|
|
select_by_pk: author_detail
|
|
insert_one: add_author
|
|
delete_by_pk: delete_one_author
|
|
column_config:
|
|
id:
|
|
custom_name: author_id
|
|
|
|
- description: track table
|
|
url: /v1/metadata
|
|
status: 200
|
|
response:
|
|
message: success
|
|
query:
|
|
type: pg_track_table
|
|
args:
|
|
table: article_local
|
|
source: pg1
|
|
|
|
- description: Simple GraphQL query to fetch items from the source table
|
|
url: /v1/graphql
|
|
status: 200
|
|
response:
|
|
data:
|
|
authorDetails:
|
|
- author_id: 1
|
|
name: "Author 1"
|
|
__typename: authorDetails
|
|
- author_id: 2
|
|
name: "Author 2"
|
|
__typename: authorDetails
|
|
articleLocal:
|
|
- id: 1
|
|
title: "Article 1"
|
|
__typename: ArticleLocal
|
|
- id: 2
|
|
title: "Article 2"
|
|
__typename: ArticleLocal
|
|
query:
|
|
query: |
|
|
query {
|
|
authorDetails {
|
|
author_id
|
|
name
|
|
__typename
|
|
}
|
|
articleLocal (where: {authorId: {_eq: 1}}) {
|
|
id
|
|
title
|
|
__typename
|
|
}
|
|
}
|
|
|
|
- description: Lookup by pk
|
|
url: /v1/graphql
|
|
status: 200
|
|
response:
|
|
data:
|
|
author_detail:
|
|
author_id: 1
|
|
name: "Author 1"
|
|
__typename: authorDetails
|
|
articleLocalByPk:
|
|
title: "New Article 1"
|
|
__typename: ArticleLocal
|
|
query:
|
|
query: |
|
|
query {
|
|
author_detail(author_id: 1) {
|
|
author_id
|
|
name
|
|
__typename
|
|
}
|
|
articleLocalByPk(id: 3){
|
|
title
|
|
__typename
|
|
}
|
|
}
|
|
|
|
- description: Aggregate
|
|
url: /v1/graphql
|
|
status: 200
|
|
response:
|
|
data:
|
|
articleLocalAggregate:
|
|
__typename: ArticleLocalAggregate
|
|
aggregate:
|
|
__typename: ArticleLocalAggregateFields
|
|
count: 2
|
|
query:
|
|
query: |
|
|
query MyQuery {
|
|
articleLocalAggregate(where: {authorId: {_eq: 2}}) {
|
|
__typename
|
|
aggregate {
|
|
__typename
|
|
count
|
|
}
|
|
}
|
|
}
|
|
|
|
- description: Insert
|
|
url: /v1/graphql
|
|
status: 200
|
|
response:
|
|
data:
|
|
add_author:
|
|
__typename: authorDetails
|
|
author_id: 3
|
|
name: Author 3
|
|
query:
|
|
query: |
|
|
mutation MyMutation {
|
|
add_author(object: {name: "Author 3", author_id: 3}) {
|
|
__typename
|
|
author_id
|
|
name
|
|
}
|
|
}
|
|
|
|
- description: Delete by pk
|
|
url: /v1/graphql
|
|
status: 200
|
|
response:
|
|
data:
|
|
delete_one_author:
|
|
__typename: authorDetails
|
|
author_id: 3
|
|
name: Author 3
|
|
query:
|
|
query: |
|
|
mutation MyMutation {
|
|
delete_one_author(author_id: 3) {
|
|
__typename
|
|
author_id
|
|
name
|
|
}
|
|
}
|
|
|
|
- description: untrack table
|
|
url: /v1/metadata
|
|
status: 200
|
|
response:
|
|
message: success
|
|
query:
|
|
type: pg_untrack_table
|
|
args:
|
|
table: author_local
|
|
source: pg1
|
|
|
|
- description: drop table
|
|
url: /v1/query
|
|
status: 200
|
|
response:
|
|
result_type: CommandOk
|
|
result:
|
|
query:
|
|
type: run_sql
|
|
args:
|
|
source: pg1
|
|
sql: |
|
|
drop table author_local;
|
|
|
|
- description: untrack table
|
|
url: /v1/metadata
|
|
status: 200
|
|
response:
|
|
message: success
|
|
query:
|
|
type: pg_untrack_table
|
|
args:
|
|
table: article_local
|
|
source: pg1
|
|
|
|
- description: drop table
|
|
url: /v1/query
|
|
status: 200
|
|
response:
|
|
result_type: CommandOk
|
|
result:
|
|
query:
|
|
type: run_sql
|
|
args:
|
|
source: pg1
|
|
sql: |
|
|
drop table article_local;
|