Typings for Shopify Admin API
npm install shopify-admin-api-typings2020-04.
npm i -S shopify-admin-api-typings
js
import { Order, OrderConnection } from "shopify-admin-api-typings";
`
Here is how you can get strongly typed queries with apollo:
`ts
const QUERY_ORDERS = gql
;
const {
data: { orders },
} = await client.query<{ orders: OrderConnection }>({
query: QUERY_ORDERS,
});
`
Use the Partial<> utility if you want to create subsets of the type without getting type errors.
`js
const variant: Partial = { name: "#001" };
`
Build your own typings
If you want to customise the namings or the Admin API version you can build your own typings. To do that, you need to create a Private app with Admin API enabled.
1. Clone this repository
`sh
git clone https://github.com/caki0915/shopify-admin-api-typings.git
`
2. Rename .env.example to .env.
3. Inside .env add your Shopify Admin API endpoint and access-token.
4. Run npm start`