-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathallCardsFromUser.js
49 lines (44 loc) · 1.11 KB
/
allCardsFromUser.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
47
48
49
const { GraphQLClient, gql } = require("graphql-request");
const AllCardsFromUser = gql`
query AllCardsFromUser($slug: String!, $cursor: String) {
user(slug: $slug) {
cards(after: $cursor) {
nodes {
slug
tokenOwner {
from
amounts {
wei
}
}
}
pageInfo {
endCursor
}
}
}
}
`;
const slug = "soraredata";
async function main() {
const graphQLClient = new GraphQLClient("https://api.sorare.com/graphql", {
headers: {
// 'Authorization': `Bearer <YourJWTorOAuthToken>`,
// 'APIKEY': '<YourOptionalAPIKey>'
},
});
let cursor = null;
do {
console.log("Page starting from cursor", cursor);
const data = await graphQLClient.request(AllCardsFromUser, {
slug,
cursor,
});
const paginatedCards = data["user"]["paginatedCards"];
paginatedCards["nodes"].forEach((card) => {
console.log(card);
});
cursor = paginatedCards["pageInfo"]["endCursor"];
} while (cursor != null);
}
main().catch((error) => console.error(error));