mirror of
https://github.com/zhigang1992/graphql-engine.git
synced 2026-05-24 08:54:11 +08:00
add python based tests, remove haskell tests
this does not generate coverage report yet
This commit is contained in:
committed by
Shahidh K Muhammed
parent
b07d04a4a4
commit
596bccde49
@@ -331,18 +331,6 @@ workflows:
|
||||
<<: *filter_only_vtags
|
||||
requires:
|
||||
- check_build_worthiness
|
||||
- test_server_pg_10.4:
|
||||
<<: *filter_only_vtags
|
||||
requires:
|
||||
- build_server
|
||||
- test_server_pg_9.6:
|
||||
<<: *filter_only_vtags
|
||||
requires:
|
||||
- build_server
|
||||
- test_server_pg_9.5:
|
||||
<<: *filter_only_vtags
|
||||
requires:
|
||||
- build_server
|
||||
- pytest_server_pg_10.4:
|
||||
<<: *filter_only_vtags
|
||||
requires:
|
||||
@@ -358,9 +346,6 @@ workflows:
|
||||
- all_server_tests_pass:
|
||||
<<: *filter_only_vtags
|
||||
requires:
|
||||
- test_server_pg_10.4
|
||||
- test_server_pg_9.6
|
||||
- test_server_pg_9.5
|
||||
- pytest_server_pg_10.4
|
||||
- pytest_server_pg_9.6
|
||||
- pytest_server_pg_9.5
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
import time
|
||||
from context import HGECtx, HGECtxError
|
||||
|
||||
def pytest_addoption(parser):
|
||||
@@ -21,3 +22,4 @@ def hge_ctx(request):
|
||||
yield hge_ctx # provide the fixture value
|
||||
print("teardown hge_ctx")
|
||||
hge_ctx.teardown()
|
||||
time.sleep(2)
|
||||
|
||||
@@ -48,6 +48,10 @@ class WebhookServer(http.server.HTTPServer):
|
||||
self.error_queue = error_queue
|
||||
super().__init__(server_address, WebhookHandler)
|
||||
|
||||
def server_bind(self):
|
||||
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
self.socket.bind(self.server_address)
|
||||
|
||||
class HGECtx:
|
||||
def __init__(self, hge_url, pg_url):
|
||||
server_address = ('0.0.0.0', 5592)
|
||||
@@ -127,5 +131,7 @@ class HGECtx:
|
||||
self.http.close()
|
||||
self.engine.dispose()
|
||||
self.httpd.shutdown()
|
||||
self.httpd.server_close()
|
||||
self.ws.close()
|
||||
self.web_server.join()
|
||||
self.wst.join()
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table author(
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
content TEXT,
|
||||
author_id INTEGER NOT NULL REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
#Insert Author table data
|
||||
- type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- name: Author 1
|
||||
- name: Author 2
|
||||
|
||||
#Insert aticle table data
|
||||
- type: insert
|
||||
args:
|
||||
table: article
|
||||
objects:
|
||||
- content: Sample article content 1
|
||||
title: Article 1
|
||||
author_id: 1
|
||||
- content: Sample article content 2
|
||||
title: Article 2
|
||||
author_id: 1
|
||||
- content: Sample article content 3
|
||||
author_id: 1
|
||||
title: Article 3
|
||||
- content: Sample article content 4
|
||||
author_id: 2
|
||||
title: Article 4
|
||||
- content: Sample article content 5
|
||||
author_id: 2
|
||||
title: Article 5
|
||||
@@ -0,0 +1,18 @@
|
||||
type: bulk
|
||||
args:
|
||||
#Drop relationship first
|
||||
- type: drop_relationship
|
||||
args:
|
||||
relationship: articles
|
||||
table:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table article
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table author
|
||||
@@ -0,0 +1,30 @@
|
||||
description: A user can delete his articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '1'
|
||||
response:
|
||||
data:
|
||||
delete_article:
|
||||
affected_rows: 1
|
||||
returning:
|
||||
- author_id: 1
|
||||
id: 1
|
||||
title: Article 1
|
||||
content: Sample article content 1
|
||||
query:
|
||||
query: |
|
||||
mutation delete_article {
|
||||
delete_article (
|
||||
where: {id: {_eq: 1}}
|
||||
) {
|
||||
affected_rows
|
||||
returning{
|
||||
id
|
||||
title
|
||||
content
|
||||
author_id
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
description: A user cannot delete other users articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '5'
|
||||
response:
|
||||
data:
|
||||
delete_article:
|
||||
affected_rows: 0
|
||||
returning: []
|
||||
query:
|
||||
query: |
|
||||
mutation delete_article {
|
||||
delete_article (
|
||||
where: {id: {_eq: 1}}
|
||||
)
|
||||
{ affected_rows
|
||||
returning
|
||||
{ id
|
||||
title
|
||||
content
|
||||
author_id
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table author(
|
||||
id serial primary key,
|
||||
name text unique,
|
||||
payments_done boolean not null default false
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
content TEXT,
|
||||
author_id INTEGER NOT NULL REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
#Insert Author table data
|
||||
- type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- name: Author 1
|
||||
- name: Author 2
|
||||
- name: Author 3
|
||||
payments_done: true
|
||||
|
||||
#Insert aticle table data
|
||||
- type: insert
|
||||
args:
|
||||
table: article
|
||||
objects:
|
||||
- content: Sample article content 1
|
||||
title: Article 1
|
||||
author_id: 1
|
||||
- content: Sample article content 2
|
||||
title: Article 2
|
||||
author_id: 1
|
||||
- content: Sample article content 3
|
||||
author_id: 1
|
||||
title: Article 3
|
||||
- content: Sample article content 4
|
||||
author_id: 2
|
||||
title: Article 4
|
||||
- content: Sample article content 5
|
||||
author_id: 2
|
||||
title: Article 5
|
||||
|
||||
#Prevent deletion if payments to the author is not yet done
|
||||
- type: create_delete_permission
|
||||
args:
|
||||
table: author
|
||||
role: user
|
||||
permission:
|
||||
filter:
|
||||
$and:
|
||||
- id: X-HASURA-USER-ID
|
||||
- payments_done: true
|
||||
|
||||
|
||||
#A user can delete only his articles
|
||||
- type: create_select_permission
|
||||
args:
|
||||
table: article
|
||||
role: user
|
||||
permission:
|
||||
columns:
|
||||
- id
|
||||
- title
|
||||
- content
|
||||
- author_id
|
||||
filter:
|
||||
$and:
|
||||
- author_id: X-HASURA-USER-ID
|
||||
|
||||
#A user can delete only his articles
|
||||
- type: create_delete_permission
|
||||
args:
|
||||
table: article
|
||||
role: user
|
||||
permission:
|
||||
filter:
|
||||
$and:
|
||||
- author_id: X-HASURA-USER-ID
|
||||
@@ -0,0 +1,18 @@
|
||||
type: bulk
|
||||
args:
|
||||
#Drop relationship first
|
||||
- type: drop_relationship
|
||||
args:
|
||||
relationship: articles
|
||||
table:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table article
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table author
|
||||
@@ -1,6 +1,19 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table author(
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Create resident table
|
||||
- type: run_sql
|
||||
args:
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table author
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
|
||||
@@ -1,28 +1,33 @@
|
||||
description: Upserts author with id 1 as a user (Error)
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '1'
|
||||
query:
|
||||
query: |
|
||||
mutation insert_author {
|
||||
insert_author (
|
||||
objects: [
|
||||
{
|
||||
id: 1
|
||||
name: "Author 1 Updated"
|
||||
- description: Upserts author with id 1 as a user (Error)
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '1'
|
||||
response:
|
||||
data:
|
||||
insert_author:
|
||||
affected_rows: 0
|
||||
returning: []
|
||||
query:
|
||||
query: |
|
||||
mutation insert_author {
|
||||
insert_author (
|
||||
objects: [
|
||||
{
|
||||
id: 1
|
||||
name: "Author 1 Updated"
|
||||
}
|
||||
],
|
||||
on_conflict: {
|
||||
constraint: author_pkey,
|
||||
action: ignore
|
||||
}
|
||||
],
|
||||
on_conflict: {
|
||||
constraint: author_pkey,
|
||||
action: ignore
|
||||
}
|
||||
) {
|
||||
affected_rows
|
||||
returning {
|
||||
id
|
||||
name
|
||||
) {
|
||||
affected_rows
|
||||
returning {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +153,26 @@ args:
|
||||
_is_null: false
|
||||
allow_upsert: true
|
||||
|
||||
#Insert Author table data
|
||||
- type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- name: Author 1
|
||||
- name: Author 2
|
||||
|
||||
#Insert aticle table data
|
||||
- type: insert
|
||||
args:
|
||||
table: article
|
||||
objects:
|
||||
- content: Sample article content
|
||||
title: Article 1
|
||||
- content: Sample article content
|
||||
title: Article 2
|
||||
- content: Sample article content
|
||||
title: Article 3
|
||||
|
||||
#Company insert permission for user
|
||||
- type: create_insert_permission
|
||||
args:
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
description: invalid on_conflict action
|
||||
url: /v1alpha1/graphql
|
||||
status: 400
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '1'
|
||||
query:
|
||||
query: |
|
||||
mutation insert_article {
|
||||
insert_article (
|
||||
objects: [
|
||||
{
|
||||
content: "Updated Article 1 content",
|
||||
id: 1,
|
||||
author_id: 1
|
||||
},
|
||||
{
|
||||
content: "Updated Article 2 content",
|
||||
id: 2,
|
||||
author_id: 1
|
||||
},
|
||||
}
|
||||
],
|
||||
on_conflict: {
|
||||
action: random
|
||||
}
|
||||
) {
|
||||
returning {
|
||||
title
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
description: Upserts article data via GraphQL mutation with only constraint
|
||||
url: /v1alpha1/graphql
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '1'
|
||||
status: 400
|
||||
query:
|
||||
query: |
|
||||
mutation insert_article {
|
||||
insert_article (
|
||||
objects: [
|
||||
{
|
||||
content: "Updated Article 1 content",
|
||||
id: 1,
|
||||
author_id: 1
|
||||
},
|
||||
{
|
||||
content: "Updated Article 2 content",
|
||||
id: 2,
|
||||
author_id: 1
|
||||
}
|
||||
],
|
||||
on_conflict: {
|
||||
constraint: article_pkey
|
||||
}
|
||||
) {
|
||||
returning {
|
||||
title
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
description: Upserts article data via GraphQL mutation (Error 01)
|
||||
url: /v1alpha1/graphql
|
||||
status: 400
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '1'
|
||||
query:
|
||||
query: |
|
||||
mutation insert_article {
|
||||
insert_article (
|
||||
objects: [
|
||||
{
|
||||
content: "Updated Article 1 content",
|
||||
id: 1
|
||||
},
|
||||
{
|
||||
content: "Updated Article 2 content",
|
||||
id: 2
|
||||
}
|
||||
],
|
||||
on_conflict: {
|
||||
action: update
|
||||
}
|
||||
) {
|
||||
returning {
|
||||
title
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
description: Upserts article data via GraphQL mutation (Error 03)
|
||||
url: /v1alpha1/graphql
|
||||
status: 400
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '1'
|
||||
query:
|
||||
query: |
|
||||
mutation insert_article {
|
||||
insert_article (
|
||||
objects: [
|
||||
{
|
||||
content: "Updated Article 1 content",
|
||||
id: 1,
|
||||
author_id: 1
|
||||
},
|
||||
{
|
||||
content: "Updated Article 2 content",
|
||||
id: 2,
|
||||
author_id: 1
|
||||
}
|
||||
],
|
||||
on_conflict: {
|
||||
action: update,
|
||||
constraint: random_constraint
|
||||
}
|
||||
) {
|
||||
returning {
|
||||
title
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
description: Users cannot update id of his article
|
||||
url: /v1alpha1/graphql
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '1'
|
||||
status: 500
|
||||
query:
|
||||
query: |
|
||||
mutation update_article {
|
||||
update_article(
|
||||
where: {id: {_eq: 1}},
|
||||
_set: {
|
||||
id: 2
|
||||
}
|
||||
) {
|
||||
affected_rows
|
||||
returning{
|
||||
id
|
||||
title
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,8 @@ args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
|
||||
@@ -12,7 +12,9 @@ args:
|
||||
args:
|
||||
sql: |
|
||||
drop table article
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table author
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
description: Nested select on article
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
article:
|
||||
- id: 2
|
||||
title: Article 2
|
||||
content: Sample article content 2
|
||||
is_published: true
|
||||
author:
|
||||
id: 1
|
||||
name: Author 1
|
||||
is_registered: true
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
article (
|
||||
where : {_and: [
|
||||
{is_published: {_eq: true}}
|
||||
{author: {is_registered: {_eq: true}}}
|
||||
]
|
||||
}
|
||||
) {
|
||||
id
|
||||
title
|
||||
content
|
||||
is_published
|
||||
author {
|
||||
id
|
||||
name
|
||||
is_registered
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
description: Nested select on article
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
article:
|
||||
- content: Sample article content 1
|
||||
is_published: false
|
||||
author:
|
||||
name: Author 1
|
||||
is_registered: true
|
||||
id: 1
|
||||
id: 1
|
||||
title: Article 1
|
||||
- content: Sample article content 3
|
||||
is_published: false
|
||||
author:
|
||||
name: Author 2
|
||||
is_registered: true
|
||||
id: 2
|
||||
id: 3
|
||||
title: Article 3
|
||||
- content: Sample article content 4
|
||||
is_published: true
|
||||
author:
|
||||
name: Author 3
|
||||
is_registered: false
|
||||
id: 3
|
||||
id: 4
|
||||
title: Article 4
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
article (
|
||||
where : {_or:
|
||||
[
|
||||
{is_published: {_eq: false}}
|
||||
{author: {is_registered: {_eq: false}}}
|
||||
]
|
||||
}
|
||||
) {
|
||||
id
|
||||
title
|
||||
content
|
||||
is_published
|
||||
author {
|
||||
id
|
||||
name
|
||||
is_registered
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
description: Select author and their articles filtering on both name and id
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
author:
|
||||
- name: Author 2
|
||||
articles:
|
||||
- content: Sample article content 3
|
||||
id: 3
|
||||
title: Article 3
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
author (
|
||||
where: { _and: {
|
||||
name: {_in: [ "Author 2", "Author 3" ] }
|
||||
id: {_in: [ 1, 2 ] }
|
||||
}
|
||||
) {
|
||||
name
|
||||
articles{
|
||||
id
|
||||
title
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
description: Select author and their articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
author:
|
||||
- name: Author 3
|
||||
articles:
|
||||
- content: Sample article content 4
|
||||
id: 4
|
||||
title: Article 4
|
||||
id: 3
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
author (where: {id: {_gt: 2}}) {
|
||||
id
|
||||
name
|
||||
articles {
|
||||
id
|
||||
title
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
description: Select author and their articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
author:
|
||||
- name: Author 2
|
||||
id: 2
|
||||
articles:
|
||||
- content: Sample article content 3
|
||||
id: 3
|
||||
title: Article 3
|
||||
- name: Author 3
|
||||
id: 3
|
||||
articles:
|
||||
- content: Sample article content 4
|
||||
id: 4
|
||||
title: Article 4
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
author (
|
||||
where: {id: {_gte: 2}}
|
||||
) {
|
||||
id
|
||||
name
|
||||
articles{
|
||||
id
|
||||
title
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
description: Select author and their articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
author:
|
||||
- name: Author 2
|
||||
articles:
|
||||
- content: Sample article content 3
|
||||
id: 3
|
||||
title: Article 3
|
||||
- name: Author 3
|
||||
articles:
|
||||
- content: Sample article content 4
|
||||
id: 4
|
||||
title: Article 4
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
author (
|
||||
where: {name: {_in: [ "Author 2", "Author 3" ] }}
|
||||
) {
|
||||
name
|
||||
articles{
|
||||
id
|
||||
title
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
description: Select author and their articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
author:
|
||||
- name: Author 1
|
||||
id: 1
|
||||
articles:
|
||||
- content: Sample article content 1
|
||||
id: 1
|
||||
title: Article 1
|
||||
- content: Sample article content 2
|
||||
id: 2
|
||||
title: Article 2
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
author (
|
||||
where: {id: {_lt: 2}}
|
||||
) {
|
||||
id
|
||||
name
|
||||
articles{
|
||||
id
|
||||
title
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
description: Select author and their articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
author:
|
||||
- name: Author 2
|
||||
id: 2
|
||||
articles:
|
||||
- content: Sample article content 3
|
||||
id: 3
|
||||
title: Article 3
|
||||
- name: Author 1
|
||||
id: 1
|
||||
articles:
|
||||
- content: Sample article content 2
|
||||
id: 2
|
||||
title: Article 2
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
author (
|
||||
where: {id: {_lte: 2}}
|
||||
) {
|
||||
id
|
||||
name
|
||||
articles(
|
||||
where: {id: {_gt: 1}}
|
||||
) {
|
||||
id
|
||||
title
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
description: Select author and their articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
author:
|
||||
- name: Author 2
|
||||
id: 2
|
||||
articles: []
|
||||
- name: Author 3
|
||||
id: 3
|
||||
articles:
|
||||
- content: Sample article content 4
|
||||
id: 4
|
||||
title: Article 4
|
||||
is_published: true
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
author (where: {name: {_neq: "Author 1"}}) {
|
||||
id
|
||||
name
|
||||
articles (
|
||||
where: {is_published: {_neq: false}}
|
||||
) {
|
||||
id
|
||||
title
|
||||
content
|
||||
is_published
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
description: Select author and their articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
author:
|
||||
- name: Author 1
|
||||
id: 1
|
||||
articles:
|
||||
- content: Sample article content 2
|
||||
id: 2
|
||||
title: Article 2
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
author (
|
||||
where: {name: {_nin: [ "Author 2", "Author 3" ] }}
|
||||
) {
|
||||
id
|
||||
name
|
||||
articles(
|
||||
where: { id : { _gt: 1}}
|
||||
) {
|
||||
id
|
||||
title
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
- description: Select author and their articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response: &response
|
||||
data:
|
||||
author:
|
||||
- name: Author 2
|
||||
id: 2
|
||||
articles:
|
||||
- content: Sample article content 3
|
||||
id: 3
|
||||
title: Article 3
|
||||
- name: Author 3
|
||||
id: 3
|
||||
articles:
|
||||
- content: Sample article content 4
|
||||
id: 4
|
||||
title: Article 4
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
author (
|
||||
where: {_not: {id: {_lt: 2}}}
|
||||
) {
|
||||
id
|
||||
name
|
||||
articles{
|
||||
id
|
||||
title
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
- description: Select author and their articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
<<: *response
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
author (
|
||||
where: {id: {_gte: 2}}
|
||||
) {
|
||||
id
|
||||
name
|
||||
articles{
|
||||
id
|
||||
title
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
description: Simple GraphQL object query on author
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
orders:
|
||||
- id: 2
|
||||
received_at: '2018-09-21T09:40:44+00:00'
|
||||
delivered_at: '2018-09-21T09:50:44+00:00'
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
orders (where: {delivered_at: {_is_null: false}}) {
|
||||
id
|
||||
received_at
|
||||
delivered_at
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
description: Get all the orders which are not delivered at (delivered_at is NULL)
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
orders:
|
||||
- id: 1
|
||||
received_at: '2018-09-21T09:39:44+00:00'
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
orders (
|
||||
where: {delivered_at: {_is_null: true}})
|
||||
{
|
||||
id
|
||||
received_at
|
||||
}
|
||||
}
|
||||
151
server/tests-py/queries/graphql_query/boolexp/basic/setup.yaml
Normal file
151
server/tests-py/queries/graphql_query/boolexp/basic/setup.yaml
Normal file
@@ -0,0 +1,151 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table author(
|
||||
id serial primary key,
|
||||
name text unique,
|
||||
is_registered boolean not null default false
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
content TEXT,
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE city (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
country TEXT NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: city
|
||||
|
||||
#Set timezone
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
SET TIME ZONE 'UTC';
|
||||
|
||||
#Article order
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE orders (
|
||||
id SERIAL PRIMARY KEY,
|
||||
received_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
delivered_at TIMESTAMP WITH TIME ZONE
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: orders
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
|
||||
#Insert Authors
|
||||
- type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- name: Author 1
|
||||
is_registered: true
|
||||
- name: Author 2
|
||||
is_registered: true
|
||||
- name: Author 3
|
||||
is_registered: false
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1,
|
||||
false
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1,
|
||||
true
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2,
|
||||
false
|
||||
),
|
||||
(
|
||||
'Article 4',
|
||||
'Sample article content 4',
|
||||
3,
|
||||
true
|
||||
)
|
||||
|
||||
- type: insert
|
||||
args:
|
||||
table: city
|
||||
objects:
|
||||
- name: Durham
|
||||
country: USA
|
||||
- name: New York
|
||||
country: USA
|
||||
- name: Framlingham
|
||||
country: UK
|
||||
- name: New Orleans
|
||||
country: USA
|
||||
|
||||
- type: insert
|
||||
args:
|
||||
table: orders
|
||||
objects:
|
||||
- received_at: '2018-09-21T09:39:44Z'
|
||||
- received_at: '2018-09-21T09:40:44Z'
|
||||
delivered_at: '2018-09-21T09:50:44Z'
|
||||
@@ -0,0 +1,29 @@
|
||||
type: bulk
|
||||
args:
|
||||
#Drop relationship first
|
||||
- type: drop_relationship
|
||||
args:
|
||||
relationship: articles
|
||||
table:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table article
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table author
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table city
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table orders
|
||||
@@ -0,0 +1,43 @@
|
||||
description: Nested select on article
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
article:
|
||||
- content: Sample article content 2
|
||||
author:
|
||||
name: Author 1
|
||||
id: 1
|
||||
id: 2
|
||||
title: Article 2
|
||||
tags:
|
||||
- bestseller
|
||||
- latest
|
||||
- content: Sample article content 3
|
||||
author:
|
||||
name: Author 2
|
||||
id: 2
|
||||
id: 3
|
||||
title: Article 3
|
||||
tags:
|
||||
- latest
|
||||
query:
|
||||
variables:
|
||||
tags:
|
||||
- bestseller
|
||||
- latest
|
||||
query: |
|
||||
query ($tags: jsonb) {
|
||||
article (
|
||||
where: {tags: {_contained_in: $tags }}
|
||||
) {
|
||||
id
|
||||
title
|
||||
content
|
||||
tags
|
||||
author {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
description: Nested select on article
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
article:
|
||||
- content: Sample article content 3
|
||||
author:
|
||||
name: Author 2
|
||||
id: 2
|
||||
id: 3
|
||||
title: Article 3
|
||||
tags:
|
||||
- latest
|
||||
query:
|
||||
variables:
|
||||
tags:
|
||||
- latest
|
||||
query: |
|
||||
query ($tags: jsonb) {
|
||||
article (
|
||||
where: {tags: {_contained_in: $tags }}
|
||||
) {
|
||||
id
|
||||
title
|
||||
content
|
||||
tags
|
||||
author {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
description: Select author and their articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
article:
|
||||
- content: Sample article content 2
|
||||
author:
|
||||
name: Author 1
|
||||
id: 1
|
||||
id: 2
|
||||
title: Article 2
|
||||
tags:
|
||||
- bestseller
|
||||
- latest
|
||||
- content: Sample article content 3
|
||||
author:
|
||||
name: Author 2
|
||||
id: 2
|
||||
id: 3
|
||||
title: Article 3
|
||||
tags:
|
||||
- latest
|
||||
query:
|
||||
query: |
|
||||
query ($tags: jsonb) {
|
||||
article (
|
||||
where: { tags: {_contains: "latest"}}
|
||||
) {
|
||||
id
|
||||
title
|
||||
content
|
||||
tags
|
||||
author {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
description: Select author and their articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
author:
|
||||
- name: Author 1
|
||||
id: 1
|
||||
articles:
|
||||
- content: Sample article content 2
|
||||
id: 2
|
||||
title: Article 2
|
||||
tags:
|
||||
- bestseller
|
||||
- latest
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
author (
|
||||
where: { articles: {tags: {_contains: "bestseller"}}}
|
||||
) {
|
||||
id
|
||||
name
|
||||
articles(
|
||||
where: {tags: {_contains: "bestseller"}}
|
||||
) {
|
||||
id
|
||||
title
|
||||
content
|
||||
tags
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
description: Select products having key 'SIM type' in spec
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
product:
|
||||
- id: 3
|
||||
category: Mobile
|
||||
name: mobile1
|
||||
spec:
|
||||
Operating System Type: osType1
|
||||
Weight: 200g
|
||||
Processor: processor2
|
||||
SIM type: DualSim
|
||||
Sensors: Accelerometer sensor, E-compass, Proximity sensor
|
||||
Network type: 4G
|
||||
RAM: 3GB
|
||||
Touchscreen: true
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
product (
|
||||
where: {spec: {_has_key: "SIM type" }}
|
||||
) {
|
||||
id
|
||||
category
|
||||
name
|
||||
spec
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
description: Select products having key 'SIM type' in spec
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
product:
|
||||
- id: 2
|
||||
category: Laptop
|
||||
name: laptop2
|
||||
spec:
|
||||
Disk: 128GB
|
||||
Weight: 1.2Kg
|
||||
OS: os2
|
||||
Processor: processor2
|
||||
RAM: 16GB
|
||||
Touchscreen: true
|
||||
- id: 3
|
||||
category: Mobile
|
||||
name: mobile1
|
||||
spec:
|
||||
Operating System Type: osType1
|
||||
Weight: 200g
|
||||
SIM type: DualSim
|
||||
Sensors: Accelerometer sensor, E-compass, Proximity sensor
|
||||
Network type: 4G
|
||||
Processor: processor2
|
||||
RAM: 3GB
|
||||
Touchscreen: true
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
product (
|
||||
where: {spec: {_has_keys_all: ["Touchscreen","RAM"] }}
|
||||
) {
|
||||
id
|
||||
category
|
||||
name
|
||||
spec
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
description: Select products having key 'SIM type' in spec
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
product:
|
||||
- id: 1
|
||||
category: Laptop
|
||||
name: laptop1
|
||||
spec:
|
||||
Disk: 128GB
|
||||
Weight: 1.2Kg
|
||||
Processor: processor1
|
||||
Operating System: os1
|
||||
RAM: 8GB
|
||||
- id: 2
|
||||
category: Laptop
|
||||
name: laptop2
|
||||
spec:
|
||||
Disk: 128GB
|
||||
Weight: 1.2Kg
|
||||
Processor: processor2
|
||||
OS: os2
|
||||
RAM: 16GB
|
||||
Touchscreen: true
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
product (
|
||||
where: {spec: {_has_keys_any: ["OS","Operating System"] }}
|
||||
) {
|
||||
id
|
||||
category
|
||||
name
|
||||
spec
|
||||
}
|
||||
}
|
||||
144
server/tests-py/queries/graphql_query/boolexp/jsonb/setup.yaml
Normal file
144
server/tests-py/queries/graphql_query/boolexp/jsonb/setup.yaml
Normal file
@@ -0,0 +1,144 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table author(
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
content TEXT,
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP,
|
||||
tags JSONB
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE product (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
category TEXT NOT NULL,
|
||||
spec JSONB NOT NULL
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: product
|
||||
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2')
|
||||
|
||||
- type: insert
|
||||
args:
|
||||
table: article
|
||||
objects:
|
||||
- title: Article 1
|
||||
content: Sample article content 1
|
||||
author_id: 1
|
||||
|
||||
- title: Article 2
|
||||
content: Sample article content 2
|
||||
author_id: 1
|
||||
tags:
|
||||
- bestseller
|
||||
- latest
|
||||
|
||||
- title: Article 3
|
||||
content: Sample article content 3
|
||||
author_id: 2
|
||||
tags:
|
||||
- latest
|
||||
|
||||
|
||||
- type: insert
|
||||
args:
|
||||
table: product
|
||||
objects:
|
||||
|
||||
- category: Laptop
|
||||
name: laptop1
|
||||
spec:
|
||||
Operating System: os1
|
||||
RAM: 8GB
|
||||
Disk: 128GB
|
||||
Weight: 1.2Kg
|
||||
Processor: processor1
|
||||
|
||||
- category: Laptop
|
||||
name: laptop2
|
||||
spec:
|
||||
OS: os2
|
||||
RAM: 16GB
|
||||
Disk: 128GB
|
||||
Weight: 1.2Kg
|
||||
Processor: processor2
|
||||
Touchscreen: yes
|
||||
|
||||
- category: Mobile
|
||||
name: mobile1
|
||||
spec:
|
||||
Operating System Type: osType1
|
||||
RAM: 3GB
|
||||
Weight: 200g
|
||||
Processor: processor2
|
||||
Network type: 4G
|
||||
SIM type: DualSim
|
||||
Sensors: Accelerometer sensor, E-compass, Proximity sensor
|
||||
Touchscreen: yes
|
||||
|
||||
- category: Electric kettle
|
||||
name: kettle1
|
||||
spec:
|
||||
power: 1500W
|
||||
capacity: 1.5L
|
||||
dimensions:
|
||||
width: 20cm
|
||||
height: 19cm
|
||||
depth: 18cm
|
||||
@@ -0,0 +1,22 @@
|
||||
type: bulk
|
||||
args:
|
||||
#Drop relationship first
|
||||
- type: drop_relationship
|
||||
args:
|
||||
relationship: articles
|
||||
table:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table article
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table author
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table product
|
||||
@@ -0,0 +1,20 @@
|
||||
description: Select cities ending with ham
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
city:
|
||||
- name: New York
|
||||
country: USA
|
||||
- name: New Orleans
|
||||
country: USA
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
city (
|
||||
where: {name: {_ilike: "new %" }}
|
||||
) {
|
||||
name
|
||||
country
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
description: Select cities ending with ham
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
city:
|
||||
- name: Durham
|
||||
country: USA
|
||||
- name: Framlingham
|
||||
country: UK
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
city (
|
||||
where: {name: {_like: "%ham" }}
|
||||
) {
|
||||
name
|
||||
country
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
description: Select cities ending with ham
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
city:
|
||||
- name: Durham
|
||||
country: USA
|
||||
- name: Framlingham
|
||||
country: UK
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
city (
|
||||
where: {name: {_nilike: "new %" }}
|
||||
) {
|
||||
name
|
||||
country
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
description: Select cities ending with ham
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
city:
|
||||
- name: New York
|
||||
country: USA
|
||||
- name: New Orleans
|
||||
country: USA
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
city (
|
||||
where: {name: {_nlike: "%ham" }}
|
||||
) {
|
||||
name
|
||||
country
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
description: Select cities ending with ham
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
city:
|
||||
- name: New York
|
||||
country: USA
|
||||
- name: New Orleans
|
||||
country: USA
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
city (
|
||||
where: {name: {_nsimilar: "_*ham" }}
|
||||
) {
|
||||
name
|
||||
country
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
description: Select cities ending with ham
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
city:
|
||||
- name: Framlingham
|
||||
country: UK
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
city (
|
||||
where: {name: {_similar: "_*gham" }}
|
||||
) {
|
||||
name
|
||||
country
|
||||
}
|
||||
}
|
||||
121
server/tests-py/queries/graphql_query/boolexp/search/setup.yaml
Normal file
121
server/tests-py/queries/graphql_query/boolexp/search/setup.yaml
Normal file
@@ -0,0 +1,121 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table author(
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
content TEXT,
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE city (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
country TEXT NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: city
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2'),
|
||||
('Author 3')
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1,
|
||||
false
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1,
|
||||
true
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2,
|
||||
false
|
||||
),
|
||||
(
|
||||
'Article 4',
|
||||
'Sample article content 4',
|
||||
3,
|
||||
true
|
||||
)
|
||||
|
||||
- type: insert
|
||||
args:
|
||||
table: city
|
||||
objects:
|
||||
- name: Durham
|
||||
country: USA
|
||||
- name: New York
|
||||
country: USA
|
||||
- name: Framlingham
|
||||
country: UK
|
||||
- name: New Orleans
|
||||
country: USA
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
type: bulk
|
||||
args:
|
||||
#Drop relationship first
|
||||
- type: drop_relationship
|
||||
args:
|
||||
relationship: articles
|
||||
table:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table article
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table author
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table city
|
||||
@@ -1,10 +1,19 @@
|
||||
description: Nested select on article with limit
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
article:
|
||||
- id: 3
|
||||
title: Article 3
|
||||
content: Sample article content 3
|
||||
author:
|
||||
name: Author 2
|
||||
id: 2
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
article(limit: 3, offset: 2) {
|
||||
article(limit: 1, order_by: id_desc) {
|
||||
id
|
||||
title
|
||||
content
|
||||
@@ -0,0 +1,31 @@
|
||||
description: Nested select on article with limit
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
article:
|
||||
- id: 3
|
||||
title: Article 3
|
||||
content: Sample article content 3
|
||||
author:
|
||||
name: Author 2
|
||||
id: 2
|
||||
- id: 2
|
||||
title: Article 2
|
||||
content: Sample article content 2
|
||||
author:
|
||||
name: Author 1
|
||||
id: 1
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
article(limit: 2, order_by: id_desc) {
|
||||
id
|
||||
title
|
||||
content
|
||||
author {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
description: Nested select on article with negative offset. Expecting error. Currently 500. Idealy should be 400
|
||||
url: /v1alpha1/graphql
|
||||
status: 500
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
article(offset: -1) {
|
||||
id
|
||||
title
|
||||
content
|
||||
author {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
description: Nested select on article with offset 1 and limit 2
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
article:
|
||||
- id: 2
|
||||
title: Article 2
|
||||
content: Sample article content 2
|
||||
author:
|
||||
name: Author 1
|
||||
id: 1
|
||||
- id: 1
|
||||
title: Article 1
|
||||
content: Sample article content 1
|
||||
author:
|
||||
name: Author 1
|
||||
id: 1
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
article(limit: 2, offset: 1, order_by: id_desc) {
|
||||
id
|
||||
title
|
||||
content
|
||||
author {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
description: Nested select on article with offset 2 and limit 1
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
article:
|
||||
- id: 1
|
||||
title: Article 1
|
||||
content: Sample article content 1
|
||||
author:
|
||||
name: Author 1
|
||||
id: 1
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
article(limit: 1, offset: 2, order_by: id_desc) {
|
||||
id
|
||||
title
|
||||
content
|
||||
author {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
description: Nested select on article with string offset
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
article:
|
||||
- id: 2
|
||||
title: Article 2
|
||||
content: Sample article content 2
|
||||
author:
|
||||
name: Author 1
|
||||
id: 1
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
article(offset: "1", limit: 1, order_by: id_desc) {
|
||||
id
|
||||
title
|
||||
content
|
||||
author {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
70
server/tests-py/queries/graphql_query/offset/setup.yaml
Normal file
70
server/tests-py/queries/graphql_query/offset/setup.yaml
Normal file
@@ -0,0 +1,70 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table author(
|
||||
id serial primary key,
|
||||
name text unique
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
content TEXT,
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Insert values
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into author (name)
|
||||
values
|
||||
('Author 1'),
|
||||
('Author 2')
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into article (title,content,author_id)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2
|
||||
)
|
||||
|
||||
10
server/tests-py/queries/graphql_query/offset/teardown.yaml
Normal file
10
server/tests-py/queries/graphql_query/offset/teardown.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
type: bulk
|
||||
args:
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table article
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table author
|
||||
@@ -0,0 +1,60 @@
|
||||
- description: Other Users cannot see unpublished articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
headers:
|
||||
X-Hasura-Role: anonymous
|
||||
response:
|
||||
data:
|
||||
article: []
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
article (
|
||||
where: { is_published: {_eq: false}}
|
||||
) {
|
||||
id
|
||||
title
|
||||
content
|
||||
is_published
|
||||
author {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
- description: Other Users can only see published articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
headers:
|
||||
X-Hasura-Role: anonymous
|
||||
response:
|
||||
data:
|
||||
article:
|
||||
- id: 2
|
||||
title: Article 2
|
||||
content: Sample article content 2
|
||||
is_published: true
|
||||
author:
|
||||
id: 1
|
||||
name: Author 1
|
||||
- id: 3
|
||||
title: Article 3
|
||||
content: Sample article content 3
|
||||
is_published: true
|
||||
author:
|
||||
id: 2
|
||||
name: Author 2
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
article {
|
||||
id
|
||||
title
|
||||
content
|
||||
is_published
|
||||
author {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
170
server/tests-py/queries/graphql_query/permissions/setup.yaml
Normal file
170
server/tests-py/queries/graphql_query/permissions/setup.yaml
Normal file
@@ -0,0 +1,170 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table author(
|
||||
id serial primary key,
|
||||
name text unique,
|
||||
is_registered boolean not null default false,
|
||||
remarks_internal text
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
content TEXT,
|
||||
author_id INTEGER NOT NULL REFERENCES author(id),
|
||||
is_published BOOLEAN NOT NULL default FALSE,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
name: author
|
||||
table: article
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
#Article select permission for user
|
||||
- type: create_select_permission
|
||||
args:
|
||||
table: article
|
||||
role: user
|
||||
permission:
|
||||
columns:
|
||||
- id
|
||||
- title
|
||||
- content
|
||||
- is_published
|
||||
filter:
|
||||
$or:
|
||||
- author_id: X-HASURA-USER-ID
|
||||
- is_published: true
|
||||
|
||||
#Article select permission for anonymous (only published articles)
|
||||
- type: create_select_permission
|
||||
args:
|
||||
table: article
|
||||
role: anonymous
|
||||
permission:
|
||||
columns:
|
||||
- id
|
||||
- title
|
||||
- content
|
||||
- is_published
|
||||
filter:
|
||||
is_published: true
|
||||
|
||||
#Article insert permission for user
|
||||
- type: create_insert_permission
|
||||
args:
|
||||
table: article
|
||||
role: user
|
||||
permission:
|
||||
check:
|
||||
author_id: X-Hasura-User-Id
|
||||
|
||||
#Author select permission for user
|
||||
- type: create_select_permission
|
||||
args:
|
||||
table: author
|
||||
role: user
|
||||
permission:
|
||||
columns:
|
||||
- id
|
||||
- name
|
||||
- is_registered
|
||||
filter:
|
||||
_or:
|
||||
- id: X-HASURA-USER-ID
|
||||
- articles:
|
||||
is_published:
|
||||
_eq: true
|
||||
|
||||
#Author select permission for anonymous users
|
||||
#Only authors with atleast one article will be shown
|
||||
- type: create_select_permission
|
||||
args:
|
||||
table: author
|
||||
role: anonymous
|
||||
permission:
|
||||
columns:
|
||||
- id
|
||||
- name
|
||||
filter:
|
||||
articles:
|
||||
is_published:
|
||||
_eq: true
|
||||
|
||||
#Author insert permission for user
|
||||
- type: create_insert_permission
|
||||
args:
|
||||
table: author
|
||||
role: user
|
||||
permission:
|
||||
check:
|
||||
id: X-HASURA-USER-ID
|
||||
allow_upsert: true
|
||||
|
||||
#Insert Author values
|
||||
- type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- name: Author 1
|
||||
remarks_internal: remark 1
|
||||
- name: Author 2
|
||||
remarks_internal: remark 2
|
||||
- name: Author 3
|
||||
remarks_internal: remark 3
|
||||
|
||||
#Insert Article values
|
||||
- type: insert
|
||||
args:
|
||||
table: article
|
||||
objects:
|
||||
- title: Article 1
|
||||
content: Sample article content 1
|
||||
author_id: 1
|
||||
is_published: false
|
||||
|
||||
- title: Article 2
|
||||
content: Sample article content 2
|
||||
author_id: 1
|
||||
is_published: true
|
||||
|
||||
- title: Article 3
|
||||
content: Sample article content 3
|
||||
author_id: 2
|
||||
is_published: true
|
||||
|
||||
- title: Article 4
|
||||
content: Sample article content 4
|
||||
author_id: 3
|
||||
is_published: false
|
||||
@@ -0,0 +1,14 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table article
|
||||
cascade: true
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table author
|
||||
cascade: true
|
||||
@@ -0,0 +1,36 @@
|
||||
description: User can only get his unpublished articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '1'
|
||||
response:
|
||||
data:
|
||||
article:
|
||||
- id: 3
|
||||
title: Article 3
|
||||
content: Sample article content 3
|
||||
is_published: true
|
||||
author:
|
||||
id: 2
|
||||
name: Author 2
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
article (
|
||||
where: { _and:
|
||||
[ { is_published : {_eq : true}}
|
||||
{ author : { id : {_neq : 1}}}
|
||||
]
|
||||
}
|
||||
) {
|
||||
id
|
||||
title
|
||||
content
|
||||
is_published
|
||||
author {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
- description: User cannot access remarks column
|
||||
url: /v1alpha1/graphql
|
||||
status: 400
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '1'
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
author {
|
||||
id
|
||||
name
|
||||
remarks_internal
|
||||
}
|
||||
}
|
||||
- description: Admin can access remarks column
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
response:
|
||||
data:
|
||||
author:
|
||||
- name: Author 1
|
||||
id: 1
|
||||
remarks_internal: remark 1
|
||||
- name: Author 2
|
||||
id: 2
|
||||
remarks_internal: remark 2
|
||||
- name: Author 3
|
||||
id: 3
|
||||
remarks_internal: remark 3
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
author {
|
||||
id
|
||||
name
|
||||
remarks_internal
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
description: User can only get his unpublished articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '1'
|
||||
response:
|
||||
data:
|
||||
article:
|
||||
- id: 1
|
||||
title: Article 1
|
||||
content: Sample article content 1
|
||||
is_published: false
|
||||
author:
|
||||
id: 1
|
||||
name: Author 1
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
article (
|
||||
where: { is_published : {_eq : false}}
|
||||
) {
|
||||
id
|
||||
title
|
||||
content
|
||||
is_published
|
||||
author {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
description: User can only get his unpublished articles
|
||||
url: /v1alpha1/graphql
|
||||
status: 200
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '1'
|
||||
response:
|
||||
data:
|
||||
article:
|
||||
- id: 1
|
||||
title: Article 1
|
||||
content: Sample article content 1
|
||||
is_published: false
|
||||
author:
|
||||
id: 1
|
||||
name: Author 1
|
||||
query:
|
||||
query: |
|
||||
query {
|
||||
article (
|
||||
where: { is_published : {_eq : false}}
|
||||
) {
|
||||
id
|
||||
title
|
||||
content
|
||||
is_published
|
||||
author {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
description: 'Insert into order table with a null value'
|
||||
url: /v1/query
|
||||
status: 200
|
||||
response:
|
||||
affected_rows: 1
|
||||
returning:
|
||||
- id: 1
|
||||
placed: "2017-08-19T14:22:11+00:00"
|
||||
shipped: null
|
||||
query:
|
||||
type: insert
|
||||
args:
|
||||
table: orders
|
||||
objects:
|
||||
- placed: "2017-08-19T14:22:11+00:00"
|
||||
shipped: null
|
||||
returning:
|
||||
- id
|
||||
- placed
|
||||
- shipped
|
||||
@@ -31,6 +31,22 @@ args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
|
||||
#Order table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE orders (
|
||||
id SERIAL PRIMARY KEY,
|
||||
placed TIMESTAMPTZ NOT NULL,
|
||||
shipped TIMESTAMPTZ
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: orders
|
||||
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
@@ -49,3 +65,8 @@ args:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
#Set timezone
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
SET TIME ZONE 'UTC';
|
||||
|
||||
@@ -12,7 +12,14 @@ args:
|
||||
args:
|
||||
sql: |
|
||||
drop table article
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table author
|
||||
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table orders
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
description: Upserts article data via GraphQL mutation (Error 01)
|
||||
url: /v1/query
|
||||
status: 400
|
||||
response:
|
||||
code: permission-denied
|
||||
error: 'no such column exists : "name"'
|
||||
path: '$.args.returning'
|
||||
query:
|
||||
type: insert
|
||||
args:
|
||||
table: article
|
||||
objects:
|
||||
- content: Updated Article 1 content
|
||||
id: 1
|
||||
- content: Updated Article 2 content
|
||||
id: 2
|
||||
on_conflict:
|
||||
action: update
|
||||
returning:
|
||||
- name
|
||||
- id
|
||||
@@ -0,0 +1,23 @@
|
||||
# The inserts are ignored on conflict
|
||||
description: Upserts article data via GraphQL mutation
|
||||
url: /v1/query
|
||||
status: 200
|
||||
response:
|
||||
affected_rows: 0
|
||||
returning: []
|
||||
query:
|
||||
type: insert
|
||||
args:
|
||||
table: article
|
||||
objects:
|
||||
- content: Updated Article 1 content
|
||||
id: 1
|
||||
- content: Updated Article 2 content
|
||||
id: 2
|
||||
on_conflict:
|
||||
constraint_on:
|
||||
- id
|
||||
action: ignore
|
||||
returning:
|
||||
- content
|
||||
- id
|
||||
@@ -0,0 +1,22 @@
|
||||
description: Upserts article data via GraphQL mutation with only constraint (Error)
|
||||
url: /v1/query
|
||||
response:
|
||||
path: '$.on_conflict'
|
||||
error: "the key 'action' was not present"
|
||||
code: parse-failed
|
||||
status: 400
|
||||
query:
|
||||
type: insert
|
||||
args:
|
||||
table: article
|
||||
objects:
|
||||
- content: Updated Article 1 content
|
||||
id: 1
|
||||
- content: Updated Article 2 content
|
||||
id: 2
|
||||
on_conflict:
|
||||
constraint_on:
|
||||
- id
|
||||
returning:
|
||||
- name
|
||||
- id
|
||||
@@ -0,0 +1,19 @@
|
||||
description: Upserts article data via GraphQL mutation (Error 02)
|
||||
url: /v1/query
|
||||
status: 400
|
||||
query:
|
||||
type: insert
|
||||
args:
|
||||
table: article
|
||||
objects:
|
||||
- content: Updated Article 1 content
|
||||
id: 1
|
||||
- content: Updated Article 2 content
|
||||
id: 2
|
||||
on_conflict:
|
||||
constraint_on:
|
||||
- id
|
||||
action: random
|
||||
returning:
|
||||
- name
|
||||
- id
|
||||
@@ -0,0 +1,23 @@
|
||||
description: Upserts article data via GraphQL mutation (Error 03)
|
||||
url: /v1/query
|
||||
status: 400
|
||||
response:
|
||||
code: not-exists
|
||||
error: column "name" does not exist
|
||||
path: '$.args.on_conflict.constraint_on[0]'
|
||||
query:
|
||||
type: insert
|
||||
args:
|
||||
table: article
|
||||
objects:
|
||||
- content: Updated Article 1 content
|
||||
id: 1
|
||||
- content: Updated Article 2 content
|
||||
id: 2
|
||||
on_conflict:
|
||||
constraint_on:
|
||||
- name
|
||||
action: update
|
||||
returning:
|
||||
- content
|
||||
- id
|
||||
@@ -49,3 +49,23 @@ args:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
#Insert Author table data
|
||||
- type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- name: Author 1
|
||||
- name: Author 2
|
||||
|
||||
#Insert aticle table data
|
||||
- type: insert
|
||||
args:
|
||||
table: article
|
||||
objects:
|
||||
- content: Sample article content
|
||||
title: Article 1
|
||||
- content: Sample article content
|
||||
title: Article 2
|
||||
- content: Sample article content
|
||||
title: Article 3
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
description: Insert into order table as user role (Check Constraint Error)
|
||||
url: /v1/query
|
||||
status: 400
|
||||
headers:
|
||||
X-Hasura-Role: merchant
|
||||
response:
|
||||
path: $.args
|
||||
error: 'insert on "address" for role "merchant" is not allowed. '
|
||||
code: permission-denied
|
||||
query:
|
||||
type: insert
|
||||
args:
|
||||
table: address
|
||||
objects:
|
||||
- door_no: 12-21
|
||||
street: Madhapur
|
||||
city: Hyderabad
|
||||
resident_id: 1
|
||||
@@ -0,0 +1,25 @@
|
||||
description: Upserts article data via GraphQL mutation as User role
|
||||
url: /v1/query
|
||||
status: 200
|
||||
header:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: 1
|
||||
response:
|
||||
affected_rows: 1
|
||||
returning:
|
||||
- content: Updated Article 1 content
|
||||
id: 1
|
||||
query:
|
||||
type: insert
|
||||
args:
|
||||
table: article
|
||||
objects:
|
||||
- content: Updated Article 1 content
|
||||
id: 1
|
||||
on_conflict:
|
||||
constraint_on:
|
||||
- id
|
||||
action: update
|
||||
returning:
|
||||
- content
|
||||
- id
|
||||
@@ -0,0 +1,22 @@
|
||||
description: Upserts author with id 1 as a user (Error)
|
||||
url: /v1/query
|
||||
status: 200
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '1'
|
||||
response:
|
||||
affected_rows: 0
|
||||
returning: []
|
||||
query:
|
||||
type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- id: 1
|
||||
name: "Author 1 Updated"
|
||||
on_conflict:
|
||||
constraint: author_pkey
|
||||
action: ignore
|
||||
returning:
|
||||
- name
|
||||
- id
|
||||
@@ -0,0 +1,17 @@
|
||||
description: Inserts author without bio as a student (Error)
|
||||
url: /v1/query
|
||||
status: 400
|
||||
headers:
|
||||
X-Hasura-Role: student
|
||||
response:
|
||||
path: $.args
|
||||
error: Check constraint violation. insert check constraint failed
|
||||
code: permission-error
|
||||
query:
|
||||
type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- id: 5
|
||||
name: Student 1
|
||||
is_registered: false
|
||||
@@ -0,0 +1,21 @@
|
||||
description: Inserts author with bio as a student
|
||||
url: /v1/query
|
||||
status: 200
|
||||
responose:
|
||||
affected_rows: 1
|
||||
returning:
|
||||
- id: 5
|
||||
name: Student 1
|
||||
is_registered: false
|
||||
bio: Electrical Engineering
|
||||
headers:
|
||||
X-Hasura-Role: student
|
||||
query:
|
||||
type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- id: 5
|
||||
name: Student 1
|
||||
is_registered: false
|
||||
bio: Electrical Engineering
|
||||
@@ -0,0 +1,22 @@
|
||||
description: Upserts author with id 1 as a user (Error)
|
||||
url: /v1/query
|
||||
status: 400
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '5'
|
||||
response:
|
||||
path: $.args
|
||||
error: Check constraint violation. insert check constraint failed
|
||||
code: permission-error
|
||||
query:
|
||||
type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- id: 5
|
||||
name: Author 5
|
||||
is_registered: true
|
||||
returning:
|
||||
- id
|
||||
- name
|
||||
- is_registered
|
||||
@@ -0,0 +1,24 @@
|
||||
description: Inserts author with id 5
|
||||
url: /v1/query
|
||||
status: 200
|
||||
response:
|
||||
affected_rows: 1
|
||||
returning:
|
||||
- id: 5
|
||||
name: Author 5
|
||||
is_registered: false
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '5'
|
||||
query:
|
||||
type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- id: 5
|
||||
name: Author 5
|
||||
is_registered: false
|
||||
returning:
|
||||
- id
|
||||
- name
|
||||
- is_registered
|
||||
@@ -0,0 +1,22 @@
|
||||
description: Upserts author with id 1 as a user (Error)
|
||||
url: /v1/query
|
||||
status: 400
|
||||
headers:
|
||||
X-Hasura-Role: user
|
||||
X-Hasura-User-Id: '5'
|
||||
response:
|
||||
path: $.args
|
||||
error: Check constraint violation. insert check constraint failed
|
||||
code: permission-error
|
||||
query:
|
||||
type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- id: 10
|
||||
name: Author 10
|
||||
is_registered: false
|
||||
returning:
|
||||
- id
|
||||
- name
|
||||
- is_registered
|
||||
161
server/tests-py/queries/v1/insert/permissions/setup.yaml
Normal file
161
server/tests-py/queries/v1/insert/permissions/setup.yaml
Normal file
@@ -0,0 +1,161 @@
|
||||
type: bulk
|
||||
args:
|
||||
|
||||
#Author table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
create table author(
|
||||
id serial primary key,
|
||||
name text unique,
|
||||
bio text,
|
||||
is_registered boolean not null default false
|
||||
);
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
#Article table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE article (
|
||||
id SERIAL PRIMARY KEY,
|
||||
title TEXT,
|
||||
content TEXT,
|
||||
author_id INTEGER REFERENCES author(id),
|
||||
is_published BOOLEAN,
|
||||
published_on TIMESTAMP
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: article
|
||||
|
||||
#Create resident table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE resident (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
age INTEGER NOT NULL
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: resident
|
||||
|
||||
#Create address table
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
CREATE TABLE address (
|
||||
id SERIAL PRIMARY KEY,
|
||||
door_no TEXT NOT NULL,
|
||||
street TEXT NOT NULL,
|
||||
city TEXT NOT NULL,
|
||||
resident_id INTEGER REFERENCES resident(id)
|
||||
)
|
||||
- type: track_table
|
||||
args:
|
||||
schema: public
|
||||
name: address
|
||||
|
||||
#Object relationship
|
||||
- type: create_object_relationship
|
||||
args:
|
||||
table: article
|
||||
name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
|
||||
#Array relationship
|
||||
- type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
|
||||
#Article select permission for user
|
||||
- type: create_select_permission
|
||||
args:
|
||||
table: article
|
||||
role: user
|
||||
permission:
|
||||
columns: '*'
|
||||
filter:
|
||||
$or:
|
||||
- author_id: X-HASURA-USER-ID
|
||||
- is_published: true
|
||||
|
||||
#Article insert permission for user
|
||||
- type: create_insert_permission
|
||||
args:
|
||||
table: article
|
||||
role: user
|
||||
permission:
|
||||
check:
|
||||
author_id: X-Hasura-User-Id
|
||||
|
||||
#Author select permission for user
|
||||
- type: create_select_permission
|
||||
args:
|
||||
table: author
|
||||
role: user
|
||||
permission:
|
||||
columns:
|
||||
- id
|
||||
- name
|
||||
- is_registered
|
||||
filter:
|
||||
id: X-HASURA-USER-ID
|
||||
|
||||
#Author insert permission for user
|
||||
#Only admin can set is_registered to true
|
||||
- type: create_insert_permission
|
||||
args:
|
||||
table: author
|
||||
role: user
|
||||
permission:
|
||||
check:
|
||||
$and:
|
||||
- id: X-HASURA-USER-ID
|
||||
- is_registered: false
|
||||
allow_upsert: true
|
||||
|
||||
#Author insert permission for student
|
||||
#A Student should specify their Bio
|
||||
- type: create_insert_permission
|
||||
args:
|
||||
table: author
|
||||
role: student
|
||||
permission:
|
||||
check:
|
||||
bio:
|
||||
_is_null: false
|
||||
allow_upsert: true
|
||||
|
||||
#Insert Author table data
|
||||
- type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- name: Author 1
|
||||
- name: Author 2
|
||||
|
||||
#Insert aticle table data
|
||||
- type: insert
|
||||
args:
|
||||
table: article
|
||||
objects:
|
||||
- content: Sample article content
|
||||
title: Article 1
|
||||
- content: Sample article content
|
||||
title: Article 2
|
||||
- content: Sample article content
|
||||
title: Article 3
|
||||
29
server/tests-py/queries/v1/insert/permissions/teardown.yaml
Normal file
29
server/tests-py/queries/v1/insert/permissions/teardown.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
type: bulk
|
||||
args:
|
||||
#Drop relationship first
|
||||
- type: drop_relationship
|
||||
args:
|
||||
table:
|
||||
name: author
|
||||
schema: public
|
||||
relationship: articles
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table address
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table resident
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table article
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
drop table author
|
||||
18
server/tests-py/queries/v1/metadata/clear_metadata.yaml
Normal file
18
server/tests-py/queries/v1/metadata/clear_metadata.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
- description: Clear metadata
|
||||
url: /v1/query
|
||||
status: 200
|
||||
response:
|
||||
message: success
|
||||
query:
|
||||
type: clear_metadata
|
||||
args: {}
|
||||
|
||||
- description: Check if metadata is cleared
|
||||
url: /v1/query
|
||||
status: 200
|
||||
response:
|
||||
query_templates: []
|
||||
tables: []
|
||||
query:
|
||||
type: export_metadata
|
||||
args: {}
|
||||
@@ -0,0 +1,6 @@
|
||||
- description: Clear metadata
|
||||
url: /v1/query
|
||||
status: 200
|
||||
query:
|
||||
type: dump_internal_state
|
||||
args: {}
|
||||
36
server/tests-py/queries/v1/metadata/export_metadata.yaml
Normal file
36
server/tests-py/queries/v1/metadata/export_metadata.yaml
Normal file
@@ -0,0 +1,36 @@
|
||||
description: Reload schema cache (metadata)
|
||||
url: /v1/query
|
||||
status: 200
|
||||
response:
|
||||
query_templates: []
|
||||
tables:
|
||||
- table: author
|
||||
array_relationships:
|
||||
- name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
column: author_id
|
||||
table: article
|
||||
comment: List all articles of the author
|
||||
select_permissions: []
|
||||
object_relationships: []
|
||||
event_triggers: []
|
||||
insert_permissions: []
|
||||
update_permissions: []
|
||||
delete_permissions: []
|
||||
- table: article
|
||||
object_relationships:
|
||||
- name: author
|
||||
using:
|
||||
foreign_key_constraint_on: author_id
|
||||
comment: null
|
||||
select_permissions: []
|
||||
event_triggers: []
|
||||
insert_permissions: []
|
||||
update_permissions: []
|
||||
delete_permissions: []
|
||||
array_relationships: []
|
||||
|
||||
query:
|
||||
type: export_metadata
|
||||
args: {}
|
||||
@@ -49,4 +49,36 @@ args:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: author_id
|
||||
comment: List all articles of the author
|
||||
|
||||
#Insert Author table data
|
||||
- type: insert
|
||||
args:
|
||||
table: author
|
||||
objects:
|
||||
- name: Author 1
|
||||
- name: Author 2
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
sql: |
|
||||
insert into article (title,content,author_id,is_published)
|
||||
values
|
||||
(
|
||||
'Article 1',
|
||||
'Sample article content 1',
|
||||
1,
|
||||
false
|
||||
),
|
||||
(
|
||||
'Article 2',
|
||||
'Sample article content 2',
|
||||
1,
|
||||
true
|
||||
),
|
||||
(
|
||||
'Article 3',
|
||||
'Sample article content 3',
|
||||
2,
|
||||
true
|
||||
)
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
type: bulk
|
||||
args:
|
||||
#Drop relationship first
|
||||
- type: drop_relationship
|
||||
args:
|
||||
relationship: articles
|
||||
table:
|
||||
schema: public
|
||||
name: author
|
||||
|
||||
- type: run_sql
|
||||
args:
|
||||
cascade: true
|
||||
sql: |
|
||||
drop table article
|
||||
- type: run_sql
|
||||
args:
|
||||
cascade: true
|
||||
sql: |
|
||||
drop table author
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
description: Create object relationship using foreign key
|
||||
url: /v1/query
|
||||
status: 400
|
||||
response:
|
||||
path: $.args
|
||||
error: no foreign constraint exists on the given column
|
||||
code: constraint-error
|
||||
query:
|
||||
type: create_array_relationship
|
||||
args:
|
||||
table: author
|
||||
name: articles
|
||||
using:
|
||||
foreign_key_constraint_on:
|
||||
table: article
|
||||
column: published_on
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user