2020-02-13 20:38:23 +03:00
|
|
|
type: bulk
|
|
|
|
args:
|
2021-01-06 19:06:24 +03:00
|
|
|
|
2020-02-13 20:38:23 +03:00
|
|
|
- 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
|
|
|
|
);
|
2021-01-18 09:56:25 +03:00
|
|
|
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);
|
2020-02-13 20:38:23 +03:00
|
|
|
|
|
|
|
- type: track_table
|
|
|
|
args:
|
|
|
|
name: user
|
|
|
|
schema: public
|
|
|
|
|
2021-01-18 09:56:25 +03:00
|
|
|
- type: track_table
|
|
|
|
args:
|
|
|
|
name: article
|
|
|
|
schema: public
|
|
|
|
|
2020-02-13 20:38:23 +03:00
|
|
|
- type: set_custom_types
|
|
|
|
args:
|
|
|
|
input_objects:
|
|
|
|
- name: UserInput
|
|
|
|
fields:
|
|
|
|
- name: name
|
|
|
|
type: String!
|
|
|
|
- name: email
|
|
|
|
type: String!
|
|
|
|
|
2020-03-20 09:46:45 +03:00
|
|
|
- name: InObject
|
|
|
|
fields:
|
|
|
|
- name: id
|
|
|
|
type: ID
|
|
|
|
- name: name
|
|
|
|
type: String
|
|
|
|
- name: age
|
|
|
|
type: Int
|
|
|
|
|
2020-02-13 20:38:23 +03:00
|
|
|
objects:
|
|
|
|
- name: UserId
|
|
|
|
fields:
|
|
|
|
- name: id
|
|
|
|
type: Int!
|
|
|
|
relationships:
|
|
|
|
- name: user
|
|
|
|
type: object
|
|
|
|
remote_table: user
|
|
|
|
field_mapping:
|
|
|
|
id: id
|
2021-01-18 09:56:25 +03:00
|
|
|
- name: articles
|
|
|
|
type: array
|
|
|
|
remote_table: article
|
|
|
|
field_mapping:
|
|
|
|
id: user_id
|
2020-02-13 20:38:23 +03:00
|
|
|
|
2020-03-20 09:46:45 +03:00
|
|
|
- name: OutObject
|
|
|
|
fields:
|
|
|
|
- name: id
|
|
|
|
type: ID! # For issue https://github.com/hasura/graphql-engine/issues/4061
|
|
|
|
- name: name
|
|
|
|
type: String
|
|
|
|
|
2020-02-13 20:38:23 +03:00
|
|
|
- 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
|
2020-03-20 09:46:45 +03:00
|
|
|
|
|
|
|
- type: create_action
|
|
|
|
args:
|
|
|
|
name: mirror
|
|
|
|
definition:
|
|
|
|
kind: synchronous
|
|
|
|
arguments:
|
|
|
|
- name: arg
|
2021-01-06 19:06:24 +03:00
|
|
|
type: InObject!
|
|
|
|
output_type: OutObject
|
2020-03-20 09:46:45 +03:00
|
|
|
handler: http://127.0.0.1:5593/mirror-action
|
2020-04-16 10:25:19 +03:00
|
|
|
|
|
|
|
- type: create_action
|
|
|
|
args:
|
|
|
|
name: get_user_by_email
|
|
|
|
definition:
|
|
|
|
type: query
|
|
|
|
arguments:
|
|
|
|
- name: email
|
2021-01-06 19:06:24 +03:00
|
|
|
type: String!
|
|
|
|
output_type: UserId!
|
2020-04-16 10:25:19 +03:00
|
|
|
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
|
2021-01-06 19:06:24 +03:00
|
|
|
type: String!
|
2020-04-16 10:25:19 +03:00
|
|
|
output_type: '[UserId]!'
|
|
|
|
handler: http://127.0.0.1:5593/get-users-by-email
|
2021-01-12 15:03:21 +03:00
|
|
|
|
|
|
|
- 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
|