mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 04:51:35 +03:00
42da1dbc2e
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4563 GitOrigin-RevId: 0ae1f226a63dae34e6cb0d001b4915c05b0974cf
255 lines
4.9 KiB
YAML
255 lines
4.9 KiB
YAML
# Test with graphql-default naming convention
|
|
|
|
- description: PG add source
|
|
url: /v1/metadata
|
|
status: 200
|
|
response:
|
|
message: success
|
|
query:
|
|
type: pg_add_source
|
|
args:
|
|
name: pg1
|
|
configuration:
|
|
connection_info:
|
|
database_url:
|
|
from_env: HASURA_GRAPHQL_PG_SOURCE_URL_1
|
|
pool_settings:
|
|
max_connections: 50
|
|
idle_timeout: 180
|
|
retries:
|
|
customization:
|
|
naming_convention: graphql-default
|
|
|
|
- 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: author_details
|
|
custom_root_fields:
|
|
select_by_pk: author_detail
|
|
insert_one: add_author
|
|
delete_by_pk: delete_one_author
|
|
|
|
- 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:
|
|
author_details:
|
|
- id: 1
|
|
name: 'Author 1'
|
|
__typename: AuthorDetails
|
|
- 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 {
|
|
author_details {
|
|
id
|
|
name
|
|
__typename
|
|
}
|
|
articleLocal (where: {authorId: {_eq: 1}}) {
|
|
id
|
|
title
|
|
__typename
|
|
}
|
|
}
|
|
|
|
- description: Lookup by pk
|
|
url: /v1/graphql
|
|
status: 200
|
|
response:
|
|
data:
|
|
author_detail:
|
|
id: 1
|
|
name: 'Author 1'
|
|
__typename: AuthorDetails
|
|
articleLocalByPk:
|
|
title: 'New Article 1'
|
|
__typename: ArticleLocal
|
|
query:
|
|
query: |
|
|
query {
|
|
author_detail(id: 1) {
|
|
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
|
|
id: 3
|
|
name: Author 3
|
|
query:
|
|
query: |
|
|
mutation MyMutation {
|
|
add_author(object: {name: "Author 3", id: 3}) {
|
|
__typename
|
|
id
|
|
name
|
|
}
|
|
}
|
|
|
|
- description: Delete by pk
|
|
url: /v1/graphql
|
|
status: 200
|
|
response:
|
|
data:
|
|
delete_one_author:
|
|
__typename: AuthorDetails
|
|
id: 3
|
|
name: Author 3
|
|
query:
|
|
query: |
|
|
mutation MyMutation {
|
|
delete_one_author(id: 3) {
|
|
__typename
|
|
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;
|
|
|
|
- description: PG Drop Source 1
|
|
url: /v1/metadata
|
|
status: 200
|
|
response:
|
|
message: success
|
|
query:
|
|
type: pg_drop_source
|
|
args:
|
|
name: pg1
|