@shopify/hydrogen 1.7.2 → 1.7.4
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.
|
@@ -9,11 +9,6 @@ import { META_ENV_SSR } from '../../foundation/ssr-interop.js';
|
|
|
9
9
|
import { getStorefrontApiRequestHeaders } from '../../utilities/storefrontApi.js';
|
|
10
10
|
import { parseJSON } from '../../utilities/parse.js';
|
|
11
11
|
import { useQuery } from '../../foundation/useQuery/hooks.js';
|
|
12
|
-
// Check if the response body has GraphQL errors
|
|
13
|
-
// https://spec.graphql.org/June2018/#sec-Response-Format
|
|
14
|
-
const shouldCacheResponse = (body) => {
|
|
15
|
-
return !body?.errors;
|
|
16
|
-
};
|
|
17
12
|
/**
|
|
18
13
|
* The `useShopQuery` hook allows you to make server-only GraphQL queries to the Storefront API. It must be a descendent of a `ShopifyProvider` component.
|
|
19
14
|
*/
|
|
@@ -31,6 +26,13 @@ export function useShopQuery({ query, variables = {}, cache, preload = false, })
|
|
|
31
26
|
const log = getLoggerWithContext(serverRequest);
|
|
32
27
|
const { storeDomain, storefrontApiVersion, storefrontToken, storefrontId, privateStorefrontToken, } = useShop();
|
|
33
28
|
const body = query ? graphqlRequestBody(query, variables) : '';
|
|
29
|
+
let _response;
|
|
30
|
+
// Check if the response body has GraphQL errors
|
|
31
|
+
// https://spec.graphql.org/June2018/#sec-Response-Format
|
|
32
|
+
// and that the response is not an error
|
|
33
|
+
const shouldCacheResponse = (body) => {
|
|
34
|
+
return !body?.errors && _response?.ok;
|
|
35
|
+
};
|
|
34
36
|
const { data, error } = useQuery([storeDomain, storefrontApiVersion, body], async (request) => {
|
|
35
37
|
const { url, requestInit } = useCreateShopRequest({
|
|
36
38
|
body,
|
|
@@ -41,7 +43,7 @@ export function useShopQuery({ query, variables = {}, cache, preload = false, })
|
|
|
41
43
|
storefrontId,
|
|
42
44
|
privateStorefrontToken,
|
|
43
45
|
});
|
|
44
|
-
const response = await fetch(url, requestInit);
|
|
46
|
+
const response = (_response = await fetch(url, requestInit));
|
|
45
47
|
const text = await response.text();
|
|
46
48
|
try {
|
|
47
49
|
const data = parseJSON(text);
|
|
@@ -172,7 +172,7 @@ export async function renderApiRoute(request, route, hydrogenConfig, { session,
|
|
|
172
172
|
headers: response.headers,
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
|
-
else {
|
|
175
|
+
else if (!response.headers.get('hydrogen-concatenate')) {
|
|
176
176
|
// This request was made by a native form presumably because the client components had yet to hydrate,
|
|
177
177
|
// Because of this, we need to redirect instead of just rendering the response.
|
|
178
178
|
// Doing so prevents odd refresh / back behavior. The redirect response also should *never* be cached.
|
package/dist/esnext/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "1.7.
|
|
1
|
+
export declare const LIB_VERSION = "1.7.4";
|
package/dist/esnext/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = '1.7.
|
|
1
|
+
export const LIB_VERSION = '1.7.4';
|
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=14"
|
|
9
9
|
},
|
|
10
|
-
"version": "1.7.
|
|
10
|
+
"version": "1.7.4",
|
|
11
11
|
"description": "Modern custom Shopify storefronts",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"main": "dist/esnext/index.js",
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
"connect": "^3.7.0",
|
|
143
143
|
"es-module-lexer": "^0.10.0",
|
|
144
144
|
"fast-glob": "^3.2.11",
|
|
145
|
-
"graphql": "^16.
|
|
145
|
+
"graphql": "^16.8.1",
|
|
146
146
|
"graphql-tag": "^2.12.6",
|
|
147
147
|
"history": "^5.3.0",
|
|
148
148
|
"kolorist": "^1.5.1",
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
"react-helmet-async": "^1.3.0",
|
|
154
154
|
"serve-static": "^1.15.0",
|
|
155
155
|
"set-cookie-parser": "^2.5.0",
|
|
156
|
-
"undici": "^
|
|
156
|
+
"undici": "^6.13.0",
|
|
157
157
|
"uuid": "^8.3.2",
|
|
158
158
|
"vite-plugin-inspect": "^0.3.6",
|
|
159
159
|
"web-streams-polyfill": "^3.2.0",
|