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