@anker-in/shopify-sdk 1.2.0-beta.13 → 1.2.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js.map +1 -1
- package/dist/client/index.mjs.map +1 -1
- package/dist/index.d.mts +49 -49
- package/dist/index.d.ts +49 -49
- package/dist/index.js +147 -92
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +147 -92
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -14,15 +14,16 @@ function constructMetafieldIdentifiersQueryParams(metafieldIdentifiers, metafiel
|
|
|
14
14
|
const identifiers = Object.entries(metafieldIdentifiers).reduce(
|
|
15
15
|
(queryInput, [key, value]) => {
|
|
16
16
|
const metafieldIdentifiers2 = value;
|
|
17
|
+
const comboNamespace = `${metafieldNamespacePrefix}combo`;
|
|
17
18
|
const mappedIdentifiers = metafieldIdentifiers2.map((item) => {
|
|
18
|
-
if (SPECIAL_METAFIELD_NAMESPACES.includes(item.namespace)) {
|
|
19
|
+
if (SPECIAL_METAFIELD_NAMESPACES.includes(item.namespace) || item.namespace?.startsWith(comboNamespace)) {
|
|
19
20
|
return {
|
|
20
21
|
namespace: item.namespace,
|
|
21
22
|
key: item.key
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
return {
|
|
25
|
-
namespace:
|
|
26
|
+
namespace: comboNamespace,
|
|
26
27
|
key: item.namespace
|
|
27
28
|
};
|
|
28
29
|
});
|
|
@@ -32,10 +33,7 @@ function constructMetafieldIdentifiersQueryParams(metafieldIdentifiers, metafiel
|
|
|
32
33
|
queryInput[`${key}MetafieldIdentifiers`] = uniqueIdentifiers;
|
|
33
34
|
return queryInput;
|
|
34
35
|
},
|
|
35
|
-
{
|
|
36
|
-
productMetafieldIdentifiers: [],
|
|
37
|
-
variantMetafieldIdentifiers: []
|
|
38
|
-
}
|
|
36
|
+
{}
|
|
39
37
|
);
|
|
40
38
|
return identifiers;
|
|
41
39
|
}
|
|
@@ -1410,11 +1408,13 @@ async function getProduct(client, options) {
|
|
|
1410
1408
|
const { handle, graphqlQuery, metafieldIdentifiers } = options;
|
|
1411
1409
|
const query = graphqlQuery || getProductQuery2;
|
|
1412
1410
|
const variables = { handle };
|
|
1413
|
-
|
|
1414
|
-
variables
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1411
|
+
const data = await client.query(query, {
|
|
1412
|
+
...variables,
|
|
1413
|
+
...constructMetafieldIdentifiersQueryParams(
|
|
1414
|
+
metafieldIdentifiers,
|
|
1415
|
+
client.getConfig().getMetafieldNamespacePrefix()
|
|
1416
|
+
)
|
|
1417
|
+
});
|
|
1418
1418
|
if (!data?.product) {
|
|
1419
1419
|
return void 0;
|
|
1420
1420
|
}
|
|
@@ -1468,7 +1468,7 @@ var getAllProductsQuery = (
|
|
|
1468
1468
|
${imageFragment}
|
|
1469
1469
|
`
|
|
1470
1470
|
);
|
|
1471
|
-
async function
|
|
1471
|
+
async function fetchAllProducts(client, options, afterCursor) {
|
|
1472
1472
|
const { first = 250, query, graphqlQuery, sortKey, reverse, metafieldIdentifiers } = options;
|
|
1473
1473
|
const queryString = graphqlQuery || getAllProductsQuery;
|
|
1474
1474
|
const variables = {
|
|
@@ -1478,26 +1478,36 @@ async function fetchAllPages(client, options, afterCursor) {
|
|
|
1478
1478
|
sortKey,
|
|
1479
1479
|
reverse
|
|
1480
1480
|
};
|
|
1481
|
-
|
|
1482
|
-
variables
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1481
|
+
const data = await client.query(queryString, {
|
|
1482
|
+
...variables,
|
|
1483
|
+
...constructMetafieldIdentifiersQueryParams(
|
|
1484
|
+
metafieldIdentifiers,
|
|
1485
|
+
client.getConfig().getMetafieldNamespacePrefix()
|
|
1486
|
+
)
|
|
1487
|
+
});
|
|
1486
1488
|
if (!data || !data.products) {
|
|
1487
1489
|
return [];
|
|
1488
1490
|
}
|
|
1489
1491
|
const products = data.products.edges.map((edge) => normalizeProduct(edge.node));
|
|
1490
1492
|
if (data.products.pageInfo.hasNextPage) {
|
|
1491
|
-
const nextProducts = await
|
|
1493
|
+
const nextProducts = await fetchAllProducts(client, options, data.products.pageInfo.endCursor);
|
|
1492
1494
|
return [...products, ...nextProducts];
|
|
1493
1495
|
}
|
|
1494
1496
|
return products;
|
|
1495
1497
|
}
|
|
1496
1498
|
async function getAllProducts(client, options) {
|
|
1497
|
-
return
|
|
1499
|
+
return fetchAllProducts(client, options);
|
|
1498
1500
|
}
|
|
1499
1501
|
async function getProducts(client, options) {
|
|
1500
|
-
const {
|
|
1502
|
+
const {
|
|
1503
|
+
first = 250,
|
|
1504
|
+
after,
|
|
1505
|
+
query,
|
|
1506
|
+
graphqlQuery,
|
|
1507
|
+
sortKey,
|
|
1508
|
+
reverse,
|
|
1509
|
+
metafieldIdentifiers
|
|
1510
|
+
} = options;
|
|
1501
1511
|
const queryString = graphqlQuery || getAllProductsQuery;
|
|
1502
1512
|
const variables = {
|
|
1503
1513
|
first,
|
|
@@ -2070,10 +2080,13 @@ async function getCollection(client, options) {
|
|
|
2070
2080
|
const { handle, graphqlQuery, metafieldIdentifiers } = options;
|
|
2071
2081
|
const query = graphqlQuery || getCollectionQuery;
|
|
2072
2082
|
const variables = { handle };
|
|
2073
|
-
|
|
2074
|
-
variables
|
|
2075
|
-
|
|
2076
|
-
|
|
2083
|
+
const data = await client.query(query, {
|
|
2084
|
+
...variables,
|
|
2085
|
+
...constructMetafieldIdentifiersQueryParams(
|
|
2086
|
+
metafieldIdentifiers,
|
|
2087
|
+
client.getConfig().getMetafieldNamespacePrefix()
|
|
2088
|
+
)
|
|
2089
|
+
});
|
|
2077
2090
|
if (!data?.collection) {
|
|
2078
2091
|
return void 0;
|
|
2079
2092
|
}
|
|
@@ -2115,7 +2128,7 @@ var getAllCollectionsQuery = (
|
|
|
2115
2128
|
${imageFragment}
|
|
2116
2129
|
`
|
|
2117
2130
|
);
|
|
2118
|
-
async function
|
|
2131
|
+
async function fetchAllPages(client, options, afterCursor) {
|
|
2119
2132
|
const { first = 250, query, graphqlQuery, sortKey, reverse, metafieldIdentifiers } = options;
|
|
2120
2133
|
const queryString = graphqlQuery || getAllCollectionsQuery;
|
|
2121
2134
|
const variables = {
|
|
@@ -2125,25 +2138,40 @@ async function fetchAllPages2(client, options, afterCursor) {
|
|
|
2125
2138
|
sortKey,
|
|
2126
2139
|
reverse
|
|
2127
2140
|
};
|
|
2128
|
-
|
|
2129
|
-
variables
|
|
2130
|
-
|
|
2131
|
-
|
|
2141
|
+
const data = await client.query(queryString, {
|
|
2142
|
+
...variables,
|
|
2143
|
+
...constructMetafieldIdentifiersQueryParams(
|
|
2144
|
+
metafieldIdentifiers,
|
|
2145
|
+
client.getConfig().getMetafieldNamespacePrefix()
|
|
2146
|
+
)
|
|
2147
|
+
});
|
|
2132
2148
|
if (!data || !data.collections) {
|
|
2133
2149
|
return [];
|
|
2134
2150
|
}
|
|
2135
2151
|
const collections = data.collections.edges.map((edge) => normalizeCollection(edge.node));
|
|
2136
2152
|
if (data.collections.pageInfo.hasNextPage) {
|
|
2137
|
-
const nextCollections = await
|
|
2153
|
+
const nextCollections = await fetchAllPages(
|
|
2154
|
+
client,
|
|
2155
|
+
options,
|
|
2156
|
+
data.collections.pageInfo.endCursor
|
|
2157
|
+
);
|
|
2138
2158
|
return [...collections, ...nextCollections];
|
|
2139
2159
|
}
|
|
2140
2160
|
return collections;
|
|
2141
2161
|
}
|
|
2142
2162
|
async function getAllCollections(client, options) {
|
|
2143
|
-
return
|
|
2163
|
+
return fetchAllPages(client, options);
|
|
2144
2164
|
}
|
|
2145
2165
|
async function getCollections(client, options) {
|
|
2146
|
-
const {
|
|
2166
|
+
const {
|
|
2167
|
+
first = 250,
|
|
2168
|
+
after,
|
|
2169
|
+
query,
|
|
2170
|
+
graphqlQuery,
|
|
2171
|
+
sortKey,
|
|
2172
|
+
reverse,
|
|
2173
|
+
metafieldIdentifiers
|
|
2174
|
+
} = options;
|
|
2147
2175
|
const queryString = graphqlQuery || getAllCollectionsQuery;
|
|
2148
2176
|
const variables = {
|
|
2149
2177
|
first,
|
|
@@ -2152,10 +2180,13 @@ async function getCollections(client, options) {
|
|
|
2152
2180
|
sortKey,
|
|
2153
2181
|
reverse
|
|
2154
2182
|
};
|
|
2155
|
-
|
|
2156
|
-
variables
|
|
2157
|
-
|
|
2158
|
-
|
|
2183
|
+
const data = await client.query(queryString, {
|
|
2184
|
+
...variables,
|
|
2185
|
+
...constructMetafieldIdentifiersQueryParams(
|
|
2186
|
+
metafieldIdentifiers,
|
|
2187
|
+
client.getConfig().getMetafieldNamespacePrefix()
|
|
2188
|
+
)
|
|
2189
|
+
});
|
|
2159
2190
|
if (!data || !data.collections) {
|
|
2160
2191
|
return {
|
|
2161
2192
|
collections: [],
|
|
@@ -2244,7 +2275,7 @@ function normalizeMetafields2(metafields) {
|
|
|
2244
2275
|
// src/api/blog/get-blog.ts
|
|
2245
2276
|
async function getBlog(client, options) {
|
|
2246
2277
|
const { handle, graphqlQuery, metafieldIdentifiers } = options;
|
|
2247
|
-
const hasMetafields = metafieldIdentifiers
|
|
2278
|
+
const hasMetafields = metafieldIdentifiers?.blog?.length;
|
|
2248
2279
|
const fragment = hasMetafields ? blogWithMetafieldsFragment : blogFragment;
|
|
2249
2280
|
const defaultQuery = (
|
|
2250
2281
|
/* GraphQL */
|
|
@@ -2262,10 +2293,13 @@ async function getBlog(client, options) {
|
|
|
2262
2293
|
);
|
|
2263
2294
|
const query = graphqlQuery || defaultQuery;
|
|
2264
2295
|
const variables = { handle };
|
|
2265
|
-
|
|
2266
|
-
variables
|
|
2267
|
-
|
|
2268
|
-
|
|
2296
|
+
const data = await client.query(query, {
|
|
2297
|
+
...variables,
|
|
2298
|
+
...constructMetafieldIdentifiersQueryParams(
|
|
2299
|
+
metafieldIdentifiers,
|
|
2300
|
+
client.getConfig().getMetafieldNamespacePrefix()
|
|
2301
|
+
)
|
|
2302
|
+
});
|
|
2269
2303
|
if (!data || !data.blog) {
|
|
2270
2304
|
return void 0;
|
|
2271
2305
|
}
|
|
@@ -2273,9 +2307,9 @@ async function getBlog(client, options) {
|
|
|
2273
2307
|
}
|
|
2274
2308
|
|
|
2275
2309
|
// src/api/blog/get-all-blogs.ts
|
|
2276
|
-
async function
|
|
2310
|
+
async function fetchAllPages2(client, options, afterCursor) {
|
|
2277
2311
|
const { first = 250, query, graphqlQuery, metafieldIdentifiers } = options;
|
|
2278
|
-
const hasMetafields = metafieldIdentifiers
|
|
2312
|
+
const hasMetafields = !!metafieldIdentifiers?.blog?.length;
|
|
2279
2313
|
const fragment = hasMetafields ? blogWithMetafieldsFragment : blogFragment;
|
|
2280
2314
|
const defaultQueryString = (
|
|
2281
2315
|
/* GraphQL */
|
|
@@ -2310,45 +2344,49 @@ async function fetchAllPages3(client, options, afterCursor) {
|
|
|
2310
2344
|
if (query) {
|
|
2311
2345
|
variables.query = query;
|
|
2312
2346
|
}
|
|
2313
|
-
|
|
2314
|
-
variables
|
|
2315
|
-
|
|
2316
|
-
|
|
2347
|
+
const data = await client.query(queryString, {
|
|
2348
|
+
...variables,
|
|
2349
|
+
...constructMetafieldIdentifiersQueryParams(
|
|
2350
|
+
metafieldIdentifiers,
|
|
2351
|
+
client.getConfig().getMetafieldNamespacePrefix()
|
|
2352
|
+
)
|
|
2353
|
+
});
|
|
2317
2354
|
if (!data || !data.blogs) {
|
|
2318
2355
|
return [];
|
|
2319
2356
|
}
|
|
2320
2357
|
const blogs = data.blogs.edges?.map((edge) => normalizeBlog(edge.node)) || [];
|
|
2321
2358
|
if (data.blogs.pageInfo.hasNextPage) {
|
|
2322
|
-
const nextBlogs = await
|
|
2359
|
+
const nextBlogs = await fetchAllPages2(client, options, data.blogs.pageInfo.endCursor);
|
|
2323
2360
|
return [...blogs, ...nextBlogs];
|
|
2324
2361
|
}
|
|
2325
2362
|
return blogs;
|
|
2326
2363
|
}
|
|
2327
2364
|
async function getAllBlogs(client, options) {
|
|
2328
|
-
return
|
|
2365
|
+
return fetchAllPages2(client, options);
|
|
2329
2366
|
}
|
|
2330
2367
|
|
|
2331
2368
|
// src/api/blog/get-article.ts
|
|
2332
2369
|
async function getArticle(client, options) {
|
|
2333
2370
|
const { blogHandle, articleHandle, graphqlQuery, metafieldIdentifiers } = options;
|
|
2334
|
-
const
|
|
2335
|
-
const
|
|
2336
|
-
const
|
|
2371
|
+
const hasArticleMetafields = !!metafieldIdentifiers?.article?.length;
|
|
2372
|
+
const hasBlogMetafields = !!metafieldIdentifiers?.blog?.length;
|
|
2373
|
+
const articleFrag = hasArticleMetafields ? articleWithMetafieldsFragment : articleFragment;
|
|
2374
|
+
const blogFrag = hasBlogMetafields ? blogWithMetafieldsFragment : blogFragment;
|
|
2337
2375
|
const defaultQuery = (
|
|
2338
2376
|
/* GraphQL */
|
|
2339
2377
|
`
|
|
2340
2378
|
query getArticle(
|
|
2341
2379
|
$blogHandle: String!
|
|
2342
2380
|
$articleHandle: String!
|
|
2343
|
-
${
|
|
2344
|
-
${
|
|
2381
|
+
${hasBlogMetafields ? "$blogMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
|
|
2382
|
+
${hasArticleMetafields ? "$articleMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
|
|
2345
2383
|
) {
|
|
2346
2384
|
blog(handle: $blogHandle) {
|
|
2347
|
-
...${
|
|
2385
|
+
...${hasBlogMetafields ? "blogWithMetafields" : "blog"}
|
|
2348
2386
|
articleByHandle(handle: $articleHandle) {
|
|
2349
|
-
...${
|
|
2387
|
+
...${hasArticleMetafields ? "articleWithMetafields" : "article"}
|
|
2350
2388
|
blog {
|
|
2351
|
-
...${
|
|
2389
|
+
...${hasBlogMetafields ? "blogWithMetafields" : "blog"}
|
|
2352
2390
|
}
|
|
2353
2391
|
}
|
|
2354
2392
|
}
|
|
@@ -2359,11 +2397,13 @@ async function getArticle(client, options) {
|
|
|
2359
2397
|
);
|
|
2360
2398
|
const query = graphqlQuery || defaultQuery;
|
|
2361
2399
|
const variables = { blogHandle, articleHandle };
|
|
2362
|
-
|
|
2363
|
-
variables
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2400
|
+
const data = await client.query(query, {
|
|
2401
|
+
...variables,
|
|
2402
|
+
...constructMetafieldIdentifiersQueryParams(
|
|
2403
|
+
metafieldIdentifiers,
|
|
2404
|
+
client.getConfig().getMetafieldNamespacePrefix()
|
|
2405
|
+
)
|
|
2406
|
+
});
|
|
2367
2407
|
if (!data || !data.blog || !data.blog.articleByHandle) {
|
|
2368
2408
|
return void 0;
|
|
2369
2409
|
}
|
|
@@ -2371,7 +2411,7 @@ async function getArticle(client, options) {
|
|
|
2371
2411
|
}
|
|
2372
2412
|
|
|
2373
2413
|
// src/api/blog/get-articles.ts
|
|
2374
|
-
async function
|
|
2414
|
+
async function fetchAllArticles(client, options, afterCursor) {
|
|
2375
2415
|
const {
|
|
2376
2416
|
first = 250,
|
|
2377
2417
|
query,
|
|
@@ -2380,7 +2420,7 @@ async function fetchAllPages4(client, options, afterCursor) {
|
|
|
2380
2420
|
reverse = false,
|
|
2381
2421
|
metafieldIdentifiers
|
|
2382
2422
|
} = options;
|
|
2383
|
-
const hasMetafields = metafieldIdentifiers
|
|
2423
|
+
const hasMetafields = !!metafieldIdentifiers?.article?.length;
|
|
2384
2424
|
const fragment = hasMetafields ? articleWithMetafieldsFragment : articleFragment;
|
|
2385
2425
|
const defaultQueryString = (
|
|
2386
2426
|
/* GraphQL */
|
|
@@ -2424,26 +2464,29 @@ async function fetchAllPages4(client, options, afterCursor) {
|
|
|
2424
2464
|
if (query) {
|
|
2425
2465
|
variables.query = query;
|
|
2426
2466
|
}
|
|
2427
|
-
|
|
2428
|
-
variables
|
|
2429
|
-
|
|
2430
|
-
|
|
2467
|
+
const data = await client.query(queryString, {
|
|
2468
|
+
...variables,
|
|
2469
|
+
...constructMetafieldIdentifiersQueryParams(
|
|
2470
|
+
metafieldIdentifiers,
|
|
2471
|
+
client.getConfig().getMetafieldNamespacePrefix()
|
|
2472
|
+
)
|
|
2473
|
+
});
|
|
2431
2474
|
if (!data || !data.articles) {
|
|
2432
2475
|
return [];
|
|
2433
2476
|
}
|
|
2434
2477
|
const articles = data.articles.edges?.map((edge) => normalizeArticle(edge.node)) || [];
|
|
2435
2478
|
if (data.articles.pageInfo.hasNextPage) {
|
|
2436
|
-
const nextArticles = await
|
|
2479
|
+
const nextArticles = await fetchAllArticles(client, options, data.articles.pageInfo.endCursor);
|
|
2437
2480
|
return [...articles, ...nextArticles];
|
|
2438
2481
|
}
|
|
2439
2482
|
return articles;
|
|
2440
2483
|
}
|
|
2441
2484
|
async function getArticles(client, options) {
|
|
2442
|
-
return
|
|
2485
|
+
return fetchAllArticles(client, options);
|
|
2443
2486
|
}
|
|
2444
2487
|
|
|
2445
2488
|
// src/api/blog/get-articles-in-blog.ts
|
|
2446
|
-
async function
|
|
2489
|
+
async function fetchAllPages3(client, options, afterCursor) {
|
|
2447
2490
|
const {
|
|
2448
2491
|
blogHandle,
|
|
2449
2492
|
first = 250,
|
|
@@ -2452,9 +2495,10 @@ async function fetchAllPages5(client, options, afterCursor) {
|
|
|
2452
2495
|
reverse = false,
|
|
2453
2496
|
metafieldIdentifiers
|
|
2454
2497
|
} = options;
|
|
2455
|
-
const
|
|
2456
|
-
const
|
|
2457
|
-
const
|
|
2498
|
+
const hasArticleMetafields = !!metafieldIdentifiers?.article?.length;
|
|
2499
|
+
const hasBlogMetafields = !!metafieldIdentifiers?.blog?.length;
|
|
2500
|
+
const articleFrag = hasArticleMetafields ? articleWithMetafieldsFragment : articleFragment;
|
|
2501
|
+
const blogFrag = hasBlogMetafields ? blogWithMetafieldsFragment : blogFragment;
|
|
2458
2502
|
const defaultQuery = (
|
|
2459
2503
|
/* GraphQL */
|
|
2460
2504
|
`
|
|
@@ -2464,11 +2508,11 @@ async function fetchAllPages5(client, options, afterCursor) {
|
|
|
2464
2508
|
$after: String
|
|
2465
2509
|
$sortKey: ArticleSortKeys!
|
|
2466
2510
|
$reverse: Boolean!
|
|
2467
|
-
${
|
|
2468
|
-
${
|
|
2511
|
+
${hasBlogMetafields ? "$blogMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
|
|
2512
|
+
${hasArticleMetafields ? "$articleMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
|
|
2469
2513
|
) {
|
|
2470
2514
|
blog(handle: $blogHandle) {
|
|
2471
|
-
...${
|
|
2515
|
+
...${hasBlogMetafields ? "blogWithMetafields" : "blog"}
|
|
2472
2516
|
articles(
|
|
2473
2517
|
first: $first
|
|
2474
2518
|
after: $after
|
|
@@ -2477,7 +2521,7 @@ async function fetchAllPages5(client, options, afterCursor) {
|
|
|
2477
2521
|
) {
|
|
2478
2522
|
edges {
|
|
2479
2523
|
node {
|
|
2480
|
-
...${
|
|
2524
|
+
...${hasArticleMetafields ? "articleWithMetafields" : "article"}
|
|
2481
2525
|
}
|
|
2482
2526
|
}
|
|
2483
2527
|
pageInfo {
|
|
@@ -2499,23 +2543,25 @@ async function fetchAllPages5(client, options, afterCursor) {
|
|
|
2499
2543
|
sortKey,
|
|
2500
2544
|
reverse
|
|
2501
2545
|
};
|
|
2502
|
-
|
|
2503
|
-
variables
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2546
|
+
const data = await client.query(query, {
|
|
2547
|
+
...variables,
|
|
2548
|
+
...constructMetafieldIdentifiersQueryParams(
|
|
2549
|
+
metafieldIdentifiers,
|
|
2550
|
+
client.getConfig().getMetafieldNamespacePrefix()
|
|
2551
|
+
)
|
|
2552
|
+
});
|
|
2507
2553
|
if (!data || !data.blog || !data.blog.articles) {
|
|
2508
2554
|
return [];
|
|
2509
2555
|
}
|
|
2510
2556
|
const articles = data.blog.articles.edges?.map((edge) => normalizeArticle(edge.node)) || [];
|
|
2511
2557
|
if (data.blog.articles.pageInfo.hasNextPage) {
|
|
2512
|
-
const nextArticles = await
|
|
2558
|
+
const nextArticles = await fetchAllPages3(client, options, data.blog.articles.pageInfo.endCursor);
|
|
2513
2559
|
return [...articles, ...nextArticles];
|
|
2514
2560
|
}
|
|
2515
2561
|
return articles;
|
|
2516
2562
|
}
|
|
2517
2563
|
async function getArticlesInBlog(client, options) {
|
|
2518
|
-
return
|
|
2564
|
+
return fetchAllPages3(client, options);
|
|
2519
2565
|
}
|
|
2520
2566
|
|
|
2521
2567
|
// src/api/page/normalize.ts
|
|
@@ -2538,7 +2584,7 @@ function normalizePage(page) {
|
|
|
2538
2584
|
// src/api/page/get-page.ts
|
|
2539
2585
|
async function getPage(client, options) {
|
|
2540
2586
|
const { handle, graphqlQuery, metafieldIdentifiers } = options;
|
|
2541
|
-
const hasMetafields = metafieldIdentifiers
|
|
2587
|
+
const hasMetafields = !!metafieldIdentifiers?.page?.length;
|
|
2542
2588
|
const fragment = hasMetafields ? pageWithMetafieldsFragment : pageFragment;
|
|
2543
2589
|
const defaultQuery = (
|
|
2544
2590
|
/* GraphQL */
|
|
@@ -2559,7 +2605,13 @@ async function getPage(client, options) {
|
|
|
2559
2605
|
if (hasMetafields) {
|
|
2560
2606
|
variables.pageMetafieldIdentifiers = metafieldIdentifiers;
|
|
2561
2607
|
}
|
|
2562
|
-
const data = await client.query(query,
|
|
2608
|
+
const data = await client.query(query, {
|
|
2609
|
+
...variables,
|
|
2610
|
+
...constructMetafieldIdentifiersQueryParams(
|
|
2611
|
+
metafieldIdentifiers,
|
|
2612
|
+
client.getConfig().getMetafieldNamespacePrefix()
|
|
2613
|
+
)
|
|
2614
|
+
});
|
|
2563
2615
|
if (!data || !data.page) {
|
|
2564
2616
|
return void 0;
|
|
2565
2617
|
}
|
|
@@ -2580,7 +2632,7 @@ function normalizeShop(shop) {
|
|
|
2580
2632
|
// src/api/shop/get-shop.ts
|
|
2581
2633
|
async function getShop(client, options) {
|
|
2582
2634
|
const { graphqlQuery, metafieldIdentifiers } = options;
|
|
2583
|
-
const hasMetafields = metafieldIdentifiers
|
|
2635
|
+
const hasMetafields = !!metafieldIdentifiers?.shop?.length;
|
|
2584
2636
|
const fragment = hasMetafields ? shopWithMetafieldsFragment : shopFragment;
|
|
2585
2637
|
const defaultQuery = (
|
|
2586
2638
|
/* GraphQL */
|
|
@@ -2597,10 +2649,13 @@ async function getShop(client, options) {
|
|
|
2597
2649
|
);
|
|
2598
2650
|
const query = graphqlQuery || defaultQuery;
|
|
2599
2651
|
const variables = {};
|
|
2600
|
-
|
|
2601
|
-
variables
|
|
2602
|
-
|
|
2603
|
-
|
|
2652
|
+
const data = await client.query(query, {
|
|
2653
|
+
...variables,
|
|
2654
|
+
...constructMetafieldIdentifiersQueryParams(
|
|
2655
|
+
metafieldIdentifiers,
|
|
2656
|
+
client.getConfig().getMetafieldNamespacePrefix()
|
|
2657
|
+
)
|
|
2658
|
+
});
|
|
2604
2659
|
if (!data || !data.shop) {
|
|
2605
2660
|
return void 0;
|
|
2606
2661
|
}
|