forked from greemo/wundergraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed.ts
More file actions
58 lines (56 loc) · 1.13 KB
/
seed.ts
File metadata and controls
58 lines (56 loc) · 1.13 KB
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
import { createClient } from '../components/generated/client';
import fetch from 'node-fetch';
const seed = async () => {
const client = createClient({
customFetch: fetch as any,
});
const user = await client.query({
operationName: 'UserByEmail',
input: {
email: 'jens@wundergraph.com',
},
});
if (user?.data?.db_findFirstUser) {
return;
}
const nodes = await client.mutate({
operationName: 'CreateNode',
input: {
data: [
{
name: 'A',
created_at: new Date(2020, 0, 1).toISOString(),
},
{
name: 'B',
created_at: new Date(2020, 0, 2).toISOString(),
},
{
name: 'C',
created_at: new Date(2020, 0, 3).toISOString(),
},
{
name: 'D',
created_at: new Date(2020, 0, 4).toISOString(),
},
],
},
});
console.log('seed:nodes', nodes);
const out = await client.mutate({
operationName: 'CreateUser',
input: {
data: {
name: 'Jens',
email: 'jens@wundergraph.com',
Filter: {
create: {
node_created_after: new Date(2020, 0, 2).toISOString(),
},
},
},
},
});
console.log('seed:user', JSON.stringify(out));
};
seed();