mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-23 15:32:27 +03:00
e053ffe8ec
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4585 GitOrigin-RevId: 8e9e7eef0017e9c634167b08c4d2a61ee7ac1fdf
214 lines
4.2 KiB
YAML
214 lines
4.2 KiB
YAML
# Test with graphql-default naming convention
|
|
|
|
# Please note that we don't need to set the naming convention in the source
|
|
# customisation as we are using the environment variable (already set)
|
|
# HASURA_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:
|
|
|
|
- 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(
|
|
author_id serial primary key,
|
|
name text unique
|
|
);
|
|
INSERT INTO author_local (name)
|
|
VALUES ('Author 1'), ('Author 2');
|
|
|
|
- description: track table
|
|
url: /v1/metadata
|
|
status: 200
|
|
response:
|
|
message: success
|
|
query:
|
|
type: pg_track_table
|
|
args:
|
|
table: author_local
|
|
source: pg1
|
|
|
|
- description: Simple GraphQL query to fetch items from the source table
|
|
url: /v1/graphql
|
|
status: 200
|
|
response:
|
|
data:
|
|
authorLocal:
|
|
- authorId: 1
|
|
name: 'Author 1'
|
|
__typename: AuthorLocal
|
|
- authorId: 2
|
|
name: 'Author 2'
|
|
__typename: AuthorLocal
|
|
query:
|
|
query: |
|
|
query {
|
|
authorLocal {
|
|
authorId
|
|
name
|
|
__typename
|
|
}
|
|
}
|
|
|
|
- description: Simple GraphQL query with field aliases to fetch items from the source table
|
|
url: /v1/graphql
|
|
status: 200
|
|
response:
|
|
data:
|
|
a:
|
|
- b: 1
|
|
c: 'Author 1'
|
|
d: AuthorLocal
|
|
- b: 2
|
|
c: 'Author 2'
|
|
d: AuthorLocal
|
|
query:
|
|
query: |
|
|
query {
|
|
a: authorLocal {
|
|
b: authorId
|
|
c: name
|
|
d: __typename
|
|
}
|
|
}
|
|
|
|
- description: Lookup by pk
|
|
url: /v1/graphql
|
|
status: 200
|
|
response:
|
|
data:
|
|
authorLocalByPk:
|
|
authorId: 1
|
|
name: 'Author 1'
|
|
__typename: AuthorLocal
|
|
query:
|
|
query: |
|
|
query {
|
|
authorLocalByPk(authorId: 1) {
|
|
authorId
|
|
name
|
|
__typename
|
|
}
|
|
}
|
|
|
|
- description: Aggregate
|
|
url: /v1/graphql
|
|
status: 200
|
|
response:
|
|
data:
|
|
authorLocalAggregate:
|
|
__typename: AuthorLocalAggregate
|
|
aggregate:
|
|
__typename: AuthorLocalAggregateFields
|
|
count: 1
|
|
query:
|
|
query: |
|
|
query MyQuery {
|
|
authorLocalAggregate(where: {name: {_eq: "Author 2"}}) {
|
|
__typename
|
|
aggregate {
|
|
__typename
|
|
count
|
|
}
|
|
}
|
|
}
|
|
|
|
- description: Insert
|
|
url: /v1/graphql
|
|
status: 200
|
|
response:
|
|
data:
|
|
insertAuthorLocal:
|
|
__typename: AuthorLocalMutationResponse
|
|
returning:
|
|
- __typename: AuthorLocal
|
|
authorId: 3
|
|
name: Author 3
|
|
query:
|
|
query: |
|
|
mutation MyMutation {
|
|
insertAuthorLocal(objects: {name: "Author 3", authorId: 3}) {
|
|
__typename
|
|
returning {
|
|
__typename
|
|
authorId
|
|
name
|
|
}
|
|
}
|
|
}
|
|
|
|
- description: Delete by pk
|
|
url: /v1/graphql
|
|
status: 200
|
|
response:
|
|
data:
|
|
deleteAuthorLocalByPk:
|
|
__typename: AuthorLocal
|
|
authorId: 3
|
|
name: Author 3
|
|
query:
|
|
query: |
|
|
mutation MyMutation {
|
|
deleteAuthorLocalByPk(authorId: 3) {
|
|
__typename
|
|
authorId
|
|
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: PG Drop Source 1
|
|
url: /v1/metadata
|
|
status: 200
|
|
response:
|
|
message: success
|
|
query:
|
|
type: pg_drop_source
|
|
args:
|
|
name: pg1
|