You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 11, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: packages/admin-api-client/README.md
+45-40Lines changed: 45 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,18 @@
1
1
# Admin API Client
2
2
3
-
The Admin API Client library is for developers who want to interact with Shopify's GraphQL `Admin API`. The features of this library are designed to be lightweight and minimally opinionated.
4
-
5
-
## Getting Started
6
-
7
-
Install the package:
3
+
The Admin API Client library is for developers who want to interact with Shopify's `Admin API`. The features of this library are designed to be lightweight and minimally opinionated.
| customFetchApi? |`(url: string, init?: {method?: string, headers?: HeaderInit, body?: string}) => Promise<Response>`| A replacement `fetch` function that will be used in all client network requests. By default, the client uses `window.fetch()`. |
58
61
| logger? |`(logContent:`[`UnsupportedApiVersionLog`](#unsupportedapiversionlog)` \| `[`HTTPResponseLog`](#httpresponselog)`\|`[`HTTPRetryLog`](#httpretrylog)`) => void`| A logger function that accepts [log content objects](#log-content-types). This logger will be called in certain conditions with contextual information. |
| fetch |`(operation: string, options?:`[`AdminAPIClientRequestOptions`](#adminapiclientrequestoptions-properties)`) => Promise<Response>`| Fetches data from Admin API using the provided GQL `operation` string and [`AdminAPIClientRequestOptions`](#adminapiclientrequestoptions-properties) object and returns the network response. |
68
71
| request |`<TData>(operation: string, options?:`[`AdminAPIClientRequestOptions`](#adminapiclientrequestoptions-properties)`) => Promise<`[`ClientResponse<TData>`](#clientresponsetdata)`>`| Requests data from Admin API using the provided GQL `operation` string and [`AdminAPIClientRequestOptions`](#adminapiclientrequestoptions-properties) object and returns a normalized response object. |
| apiUrl |`string`| The API URL generated from the provided store domain and api version |
79
82
| retries? |`number`| The number of retries the client will attempt when the API responds with a `Too Many Requests (429)` or `Service Unavailable (503)` response |
| headers? |`{[key: string]: string}`| Customized headers to be included in the API request |
88
91
| retries? |`number`| Alternative number of retries for the request. Retries only occur for requests that were abandoned or if the server responds with a `Too Many Request (429)` or `Service Unavailable (503)` response. Minimum value is `0` and maximum value is `3`. |
| data? |`TData \| any`| Data returned from the Admin API. If `TData` was provided to the function, the return type is `TData`, else it returns type `any`. |
95
98
| errors? |[`ResponseErrors`](#responseerrors)| Error object that contains any API or network errors that occured while fetching the data from the API. It does not include any `UserErrors`. |
96
99
| extensions? |`{[key: string]: any}`| Additional information on the GraphQL response data and context. It can include the `context` object that contains the localization context information used to generate the returned API response. |
This client is compatible with the `@shopify/api-codegen-preset` package.
287
290
You can use that package to create types from your operations with the [Codegen CLI](https://www.graphql-cli.com/codegen/).
@@ -329,9 +332,9 @@ There are different ways to [configure codegen](https://github.com/Shopify/shopi
329
332
Once the script runs, it'll create the file `./types/admin.generated.d.ts`.
330
333
When TS includes that file, it'll automatically cause the client to detect the types for each query.
331
334
332
-
## Log Content Types
335
+
### Log Content Types
333
336
334
-
### `UnsupportedApiVersionLog`
337
+
#### `UnsupportedApiVersionLog`
335
338
336
339
This log content is sent to the logger whenever an unsupported API version is provided to the client.
337
340
@@ -340,7 +343,7 @@ This log content is sent to the logger whenever an unsupported API version is pr
340
343
|type|`LogType['Unsupported_Api_Version']`| The type of log content. Is always set to `Unsupported_Api_Version`|
341
344
| content |`{apiVersion: string, supportedApiVersions: string[]}`| Contextual info including the provided API version and the list of currently supported API versions. |
342
345
343
-
### `HTTPResponseLog`
346
+
#### `HTTPResponseLog`
344
347
345
348
This log content is sent to the logger whenever a HTTP response is received by the client.
346
349
@@ -349,7 +352,7 @@ This log content is sent to the logger whenever a HTTP response is received by t
349
352
|type|`LogType['HTTP-Response']`| The type of log content. Is always set to `HTTP-Response`|
350
353
| content |`{`[`requestParams`](#requestparams)`: [url, init?], response: Response}` | Contextual data regarding the request and received response |
351
354
352
-
### `HTTPRetryLog`
355
+
#### `HTTPRetryLog`
353
356
354
357
This log content is sent to the logger whenever the client attempts to retry HTTP requests.
355
358
@@ -358,14 +361,16 @@ This log content is sent to the logger whenever the client attempts to retry HTT
358
361
|type|`LogType['HTTP-Retry']`| The type of log content. Is always set to `HTTP-Retry`|
359
362
| content |`{`[`requestParams`](#requestparams)`: [url, init?], lastResponse?: Response, retryAttempt: number, maxRetries: number}` | Contextual data regarding the upcoming retry attempt. <br /><br/>`requestParams`: [parameters](#requestparams) used in the request<br/>`lastResponse`: previous response <br/> `retryAttempt`: the current retry attempt count <br/> `maxRetries`: the maximum number of retries |
| retries?|`number`| Alternative number of retries for the request. Retries only occur for requests that were abandoned or if the server responds with a `Too Many Request (429)` or `Service Unavailable (503)` response. Minimum value is `0` and maximum value is `3.`|
424
429
| data?|`{ [key: string]: any } \| string`| Request body data. |
425
430
426
-
## `PostRequestOptions` properties
431
+
### `PostRequestOptions` properties
427
432
428
433
Same options as for [GET requests](#getrequestoptions-properties), but `data` isn't optional.
429
434
430
-
## `PutRequestOptions` properties
435
+
### `PutRequestOptions` properties
431
436
432
437
Same options as for [POST requests](#postrequestoptions-properties).
433
438
434
-
## `DeleteRequestOptions` properties
439
+
### `DeleteRequestOptions` properties
435
440
436
441
Same options as for [GET requests](#getrequestoptions-properties).
0 commit comments