GraphQL Typescript types
Backend
Brush comes with an easy way to generate GraphQL Typescript types for both Shopify’s Admin and Storefront API objets.
In order to generate them:
-
Run
yarn add -D @shopify/api-codegen-preset -
Add this to the
scriptsentries of yourpackage.jsonfile:
"graphql-codegen": "graphql-codegen --project admin && graphql-codegen --project storefront && rm -rf ./_brush/shopify-types/*schema.json"- Run
npm run graphql-codegen. All types are now available in/_brush/shopify-types.