-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphql.js
46 lines (41 loc) · 1.06 KB
/
graphql.js
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
const { ApolloClient, HttpLink, DefaultOptions, InMemoryCache } = require('@apollo/client/core');
const fetch = require('cross-fetch');
const gql = require('graphql-tag');
const defaultOptions = {
watchQuery: {
fetchPolicy: 'no-cache',
errorPolicy: 'ignore',
},
query: {
fetchPolicy: 'no-cache',
errorPolicy: 'all',
},
}
async function main() {
const client = new ApolloClient({
link: new HttpLink({
fetch,
uri: 'https://subgraph.iott.network/subgraphs/name/iotex/pebble-subgraph',
}),
cache: new InMemoryCache()
});
const queryResult = await client.query({
query: gql`
{
devices (where : {address : "0xe07806d11cbb41e29a95fdc6f4b27ee95291b603"}){
id
name
address
firmware
lastDataTime
data
config
owner
}
}
`,
});
//console.log(_.get(data, 'data.data.devices'));
console.log(queryResult.data.devices);
}
main();