https://github.com/bkwld/shopify-admin-api-typings
Typings for shopify admin API
https://github.com/bkwld/shopify-admin-api-typings
Last synced: over 1 year ago
JSON representation
Typings for shopify admin API
- Host: GitHub
- URL: https://github.com/bkwld/shopify-admin-api-typings
- Owner: BKWLD
- License: mit
- Created: 2024-03-14T03:28:25.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-15T21:21:57.000Z (over 2 years ago)
- Last Synced: 2025-03-05T10:02:05.643Z (over 1 year ago)
- Language: JavaScript
- Size: 640 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Shopify Admin API Types


[](https://opensource.org/licenses/MIT)
## Overview
Auto-generated Typescript type definitions for **Shopify Admin API**. Current version includes all types for version: `2020-04`.
If you're looking for typings for **Shopify Storefront Api**, checkout the [shopify-storefront-api-typings](https://www.npmjs.com/package/shopify-storefront-api-typings) package.

## How to use
1. Install package: `npm i -S shopify-admin-api-typings`
2. Import typings in your code. (vscode should find the typings and auto import for you).
```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`
query Orders {
orders(first: 5) {
edges {
node {
createdAt
}
}
}
}
`;
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`