@shopify/hydrogen-react 0.0.0-next-6783a31 → 0.0.0-next-5c16c78
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/README.md +24 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -178,11 +178,31 @@ GraphQL autocompletion and validation will now work in `.graphql` files and in [
|
|
|
178
178
|
|
|
179
179
|
If you're having trouble getting it to work, then consult our [troubleshooting section](#graphql-autocompletion).
|
|
180
180
|
|
|
181
|
-
##
|
|
181
|
+
## TypeScript
|
|
182
182
|
|
|
183
|
-
Improve your development experience by
|
|
183
|
+
Improve your development experience by using storefront-kit's generated Types and helpers.
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
### Storefront API types
|
|
186
|
+
|
|
187
|
+
Storefront-Kit ships with generated TypeScript types that match the Storefront API and its objects. Import them from the `/storefront-api-types` package path:
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
import type {Product} from '@shopify/hydrogen-react/storefront-api-types';
|
|
191
|
+
|
|
192
|
+
const product: Product = {};
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
You can also use TypeScript's built-in helpers to create your own Types to fit your needs:
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
const partialProduct: Partial<Product> = {};
|
|
199
|
+
|
|
200
|
+
const productTitle: Pick<Product, 'title'> = '';
|
|
201
|
+
|
|
202
|
+
const productExceptTitle: Omit<Product, 'title'> = {};
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### GraphQL CodeGen
|
|
186
206
|
|
|
187
207
|
To use GraphQL CodeGen, follow [their guide](https://the-guild.dev/graphql/codegen/docs/getting-started/installation) to get started. Then, when you have a `codegen.ts` file, you can modify the following lines in the codegen object to improve the CodgeGen experience:
|
|
188
208
|
|
|
@@ -205,7 +225,7 @@ const config: CodegenConfig = {
|
|
|
205
225
|
};
|
|
206
226
|
```
|
|
207
227
|
|
|
208
|
-
###
|
|
228
|
+
### The `StorefrontApiResponseError` and `StorefrontApiResponseOk` helpers
|
|
209
229
|
|
|
210
230
|
The following is an example:
|
|
211
231
|
|
|
@@ -230,32 +250,6 @@ async function FetchApi<DataGeneric>() {
|
|
|
230
250
|
}
|
|
231
251
|
```
|
|
232
252
|
|
|
233
|
-
### Use the `StorefrontApiResponse` helper
|
|
234
|
-
|
|
235
|
-
If you're using a library that handles 400/500 level errors for you, then you can use `StorefrontApiResponse`. To add typing to objects that are trying to match a Storefront API object shape, you can import the shape.
|
|
236
|
-
|
|
237
|
-
The following is an example:
|
|
238
|
-
|
|
239
|
-
```ts
|
|
240
|
-
import type {Product} from '@shopify/hydrogen-react/storefront-api-types';
|
|
241
|
-
|
|
242
|
-
const product: Product = {};
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
### Use TypeScript's helpers
|
|
246
|
-
|
|
247
|
-
To create your own object shapes, you can use TypeScript's built-in helpers.
|
|
248
|
-
|
|
249
|
-
The following is an example:
|
|
250
|
-
|
|
251
|
-
```ts
|
|
252
|
-
const partialProduct: Partial<Product> = {};
|
|
253
|
-
|
|
254
|
-
const productTitle: Pick<Product, 'title'> = '';
|
|
255
|
-
|
|
256
|
-
const productExceptTitle: Omit<Product, 'title'> = {};
|
|
257
|
-
```
|
|
258
|
-
|
|
259
253
|
## Troubleshooting
|
|
260
254
|
|
|
261
255
|
The following will help you troubleshoot common problems in this version of Hydrogen UI.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/hydrogen-react",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-5c16c78",
|
|
4
4
|
"description": "React components, hooks, and utilities for creating custom Shopify storefronts",
|
|
5
5
|
"homepage": "https://github.com/Shopify/hydrogen-ui/tree/main/packages/react",
|
|
6
6
|
"license": "MIT",
|