mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 13:02:11 +03:00
b67bc98c14
This splits two naming convention tests into four classes (and four YAML files), which might seem overkill, but allows us to provision sources declaratively in the future. As each class will require a custom source configuration, we are able to annotate them accordingly, which means the test cases are decoupled from the source database URL, letting us generate a new database for each test case and automatically add it as a source to HGE. The future changes are already prepared, but this has been extracted out as it splits the YAML files, which is a large change best reviewed in isolation. The test case `test_type_and_field_names` has been split into: * `TestNamingConventionsTypeAndFieldNamesGraphqlDefault` * `TestNamingConventionsTypeAndFieldNamesHasuraDefault` The test case `test_type_and_field_names_with_prefix_and_suffix` has been split into: * `TestNamingConventionsTypeAndFieldNamesGraphqlDefaultWithPrefixAndSuffix` * `TestNamingConventionsTypeAndFieldNamesHasuraDefaultWithPrefixAndSuffix` The YAML files have been split in the same way. This was fairly trivial as each test case would add a source, run some tests with the `graphql_default` naming convention, drop the source, and then repeat for the `hasura_default` naming convention. I simply split the file in two. There is a little bit of duplication for provisioning the various database tables, which I think is worth it. PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5496 GitOrigin-RevId: 94825e755c427a5414230f69985b534991b3aad6
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
|