Skip to content

Commit 7cb53c4

Browse files
committed
refactor: simplify cursor handling and clean up sponsor field mapping in GraphQL queries
1 parent 536b553 commit 7cb53c4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

apps/site/next-data/generators/supportersData.mjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ async function fetchSponsorshipsQuery() {
132132
let cursor = null;
133133

134134
while (true) {
135-
const data = await graphql(SPONSORSHIPS_QUERY, { cursor });
135+
const data = await graphql(
136+
SPONSORSHIPS_QUERY,
137+
cursor ? { cursor } : undefined
138+
);
136139

137140
if (data.errors) {
138141
throw new Error(JSON.stringify(data.errors));
@@ -145,7 +148,7 @@ async function fetchSponsorshipsQuery() {
145148

146149
const { nodes, pageInfo } = nodeRes;
147150
const mapped = nodes.map(n => {
148-
const s = n.sponsor || n.sponsorEntity || n.sponsorEntity; // support different field names
151+
const s = n.sponsor || n.sponsorEntity; // support different field names
149152
return {
150153
name: s?.name || s?.login || null,
151154
image: s?.avatarUrl || null,
@@ -180,7 +183,7 @@ async function fetchDonationsQuery() {
180183

181184
const { nodes } = nodeRes;
182185
return nodes.map(n => {
183-
const s = n.sponsor || n.sponsorEntity || n.sponsorEntity; // support different field names
186+
const s = n.sponsor || n.sponsorEntity; // support different field names
184187
return {
185188
name: s?.name || s?.login || null,
186189
image: s?.avatarUrl || null,
@@ -191,7 +194,7 @@ async function fetchDonationsQuery() {
191194
}
192195

193196
const graphql = async (query, variables = {}) => {
194-
const res = await fetch(GITHUB_GRAPHQL_URL, {
197+
const res = await fetchWithRetry(GITHUB_GRAPHQL_URL, {
195198
method: 'POST',
196199
headers: {
197200
'Content-Type': 'application/json',

0 commit comments

Comments
 (0)