graphql-engine/server/tests-py/queries/actions/sync/schema_setup.yaml
hasura-bot 513a3d0c19 Fix action relationship type and input arguments (closes #6402) (#284)
Co-authored-by: Antoine Leblanc <antoine@hasura.io>
GITHUB_PR_NUMBER: 6417
GITHUB_PR_URL: https://github.com/hasura/graphql-engine/pull/6417
GitOrigin-RevId: 37b67a4d04e0ed3b16fc5fc9bf025b24b1f1bf6e
2021-01-18 06:57:24 +00:00

150 lines
2.9 KiB
YAML

type: bulk
args:
- type: run_sql
args:
sql: |
CREATE TABLE "user"(
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
email TEXT NOT NULL,
is_admin BOOLEAN NOT NULL DEFAULT false
);
CREATE TABLE "article"(
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
user_id INTEGER
);
INSERT INTO "article" (name, user_id) VALUES
('foo', 1),
('bar', 1),
('bar', 1),
('baz', 2);
- type: track_table
args:
name: user
schema: public
- type: track_table
args:
name: article
schema: public
- type: set_custom_types
args:
input_objects:
- name: UserInput
fields:
- name: name
type: String!
- name: email
type: String!
- name: InObject
fields:
- name: id
type: ID
- name: name
type: String
- name: age
type: Int
objects:
- name: UserId
fields:
- name: id
type: Int!
relationships:
- name: user
type: object
remote_table: user
field_mapping:
id: id
- name: articles
type: array
remote_table: article
field_mapping:
id: user_id
- name: OutObject
fields:
- name: id
type: ID! # For issue https://github.com/hasura/graphql-engine/issues/4061
- name: name
type: String
- type: create_action
args:
name: create_user
definition:
kind: synchronous
arguments:
- name: email
type: String!
- name: name
type: String!
output_type: UserId
handler: http://127.0.0.1:5593/create-user
- type: create_action
args:
name: create_users
definition:
kind: synchronous
arguments:
- name: users
type: '[UserInput!]!'
output_type: '[UserId]'
handler: http://127.0.0.1:5593/create-users
- type: create_action
args:
name: mirror
definition:
kind: synchronous
arguments:
- name: arg
type: InObject!
output_type: OutObject
handler: http://127.0.0.1:5593/mirror-action
- type: create_action
args:
name: get_user_by_email
definition:
type: query
arguments:
- name: email
type: String!
output_type: UserId!
handler: http://127.0.0.1:5593/get-user-by-email
- type: create_action
args:
name: get_users_by_email
definition:
type: query
arguments:
- name: email
type: String!
output_type: '[UserId]!'
handler: http://127.0.0.1:5593/get-users-by-email
- type: create_select_permission
args:
table: user
role: user
permission:
columns:
- id
- name
- email
filter:
id: X-Hasura-User-Id
- type: create_action_permission
args:
action: get_user_by_email
role: user