1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "beforeSdl": `input SearchInput { limit: Int! }
12type Query { user(id: ID!): User search(input: SearchInput!): [User!]! }
13type User { id: ID! name: String! email: String }`,
14 "afterSdl": `input SearchInput { limit: Int! }
15type Query { user(id: ID!): User search(input: SearchInput!): [User!]! }
16type User { id: ID! name: String! }`,
17 "documents": [
18 {
19 "path": "client/fragments/user-card.graphql",
20 "source": "fragment UserCard on User { id mail: email }"
21 },
22 {
23 "path": "client/queries/account.graphql",
24 "source": "query Account($id: ID!) { user(id: $id) { ...UserCard } }\nquery Healthy($input: SearchInput!) { search(input: $input) { id name } }"
25 },
26 {
27 "path": "client/queries/legacy.graphql",
28 "source": "query Legacy { retiredField }"
29 }
30 ],
31 "variableCases": [
32 {
33 "name": "typical search",
34 "operationName": "Healthy",
35 "variables": {
36 "input": {
37 "limit": 10
38 }
39 }
40 }
41 ]
42};
43
44
45const run = await client.actor("bread-kim/graphql-client-operation-regression-gate").call(input);
46
47
48console.log('Results from dataset');
49console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
50const { items } = await client.dataset(run.defaultDatasetId).listItems();
51items.forEach((item) => {
52 console.dir(item);
53});
54
55