-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpermissions.ts
62 lines (59 loc) · 1.53 KB
/
permissions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { HasuraApi } from '@deep-foundation/hasura/api';
import { Trigger } from './trigger';
const DEFAULT_SCHEMA = process.env.MIGRATIONS_SCHEMA || 'public';
const DEFAULT_MP_TABLE = process.env.MIGRATIONS_MP_TABLE || 'mp_example__links__mp';
const DEFAULT_GRAPH_TABLE = process.env.MIGRATIONS_GRAPH_TABLE || 'mp_example__links';
export const up = async ({
SCHEMA = DEFAULT_SCHEMA, MP_TABLE = DEFAULT_MP_TABLE, GRAPH_TABLE = DEFAULT_GRAPH_TABLE, ID_FIELD = 'id', api
}: {
SCHEMA?: string; MP_TABLE?: string; GRAPH_TABLE?: string; ID_FIELD?: string;
api: HasuraApi;
}) => {
await api.query({
type: 'create_select_permission',
args: {
table: MP_TABLE,
role: 'guest',
permission: {
columns: '*',
filter: {},
limit: 999,
allow_aggregations: true
}
}
});
await api.query({
type: 'create_select_permission',
args: {
table: MP_TABLE,
role: 'user',
permission: {
columns: '*',
filter: {},
limit: 999,
allow_aggregations: true
}
}
});
};
export const down = async ({
SCHEMA = DEFAULT_SCHEMA, MP_TABLE = DEFAULT_MP_TABLE, GRAPH_TABLE = DEFAULT_GRAPH_TABLE, api
}: {
SCHEMA?: string; MP_TABLE?: string; GRAPH_TABLE?: string; ID_FIELD?: string;
api: HasuraApi;
}) => {
await api.query({
type: 'drop_select_permission',
args: {
table: MP_TABLE,
role: 'guest',
}
});
await api.query({
type: 'drop_select_permission',
args: {
table: MP_TABLE,
role: 'user',
}
});
};