Skip to content

Commit 92c7d76

Browse files
committed
[minor] Fix nits
1 parent 4f02cc9 commit 92c7d76

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ Creates a new `Shopify` instance.
4141
[OAuth 2.0][oauth] access token. This option is mutually exclusive with the
4242
`apiKey` and `password` options. If you are looking for a premade solution to
4343
obtain an access token, take a look at the [shopify-token][] module.
44+
- `agent` - Optional - An object that is passed as the `agent` option to `got`.
45+
This allows to use a proxy server. See
46+
[Got documentation](https://github.com/sindresorhus/got/tree/v11.8.6?tab=readme-ov-file#proxies)
47+
for more details.
4448
- `apiVersion` - Optional - A string to specify the [Shopify API
4549
version][api-versioning] to use for requests. Defaults to the oldest supported
4650
stable version.
@@ -53,6 +57,18 @@ Creates a new `Shopify` instance.
5357
specifies a limit of 2 requests per second with a burst of 35 requests. When
5458
set to `true` requests are limited as specified in the above example. Defaults
5559
to `false`. Mutually exclusive with the `maxRetries` option.
60+
- `hooks` - Optional - A list of `got`
61+
[request hooks](https://github.com/sindresorhus/got/tree/v11.8.6#hooks) to
62+
attach to all outgoing requests, like `beforeRetry`, `afterResponse`, etc.
63+
Hooks should be provided in the same format that Got expects them and will
64+
receive the same arguments Got passes unchanged.
65+
- `maxRetries` - Optional - The number of times to attempt to make the request
66+
to Shopify before giving up. Defaults to `0`, which means no automatic
67+
retries. If set to a value greater than `0`, `shopify-api-node` will make up
68+
to that many retries. `shopify-api-node` will respect the `Retry-After` header
69+
for requests to the REST API, and the throttled cost data for requests to the
70+
GraphQL API, and retry the request after that time has elapsed. Mutually
71+
exclusive with the `autoLimit` option.
5672
- `parseJson` - Optional - The function used to parse JSON. The function is
5773
passed a single argument. This option allows the use of a custom JSON parser
5874
that might be needed to properly handle long integer IDs. Defaults to
@@ -66,22 +82,6 @@ Creates a new `Shopify` instance.
6682
- `timeout` - Optional - The number of milliseconds before the request times
6783
out. If the request takes longer than `timeout`, it will be aborted. Defaults
6884
to `60000`, or 1 minute.
69-
- `maxRetries` - Optional - The number of times to attempt to make the request
70-
to Shopify before giving up. Defaults to `0`, which means no automatic
71-
retries. If set to a value greater than `0`, `shopify-api-node` will make up
72-
to that many retries. `shopify-api-node` will respect the `Retry-After` header
73-
for requests to the REST API, and the throttled cost data for requests to the
74-
GraphQL API, and retry the request after that time has elapsed. Mutually
75-
exclusive with the `autoLimit` option.
76-
- `hooks` - Optional - A list of `got`
77-
[request hooks](https://github.com/sindresorhus/got/tree/v11.8.6#hooks) to
78-
attach to all outgoing requests, like `beforeRetry`, `afterResponse`, etc.
79-
Hooks should be provided in the same format that Got expects them and will
80-
receive the same arguments Got passes unchanged.
81-
- `agent` - Optional - An object that is passed as the `agent` option to `got`.
82-
This allows to use a proxy server. See
83-
[Got documentation](https://github.com/sindresorhus/got/tree/v11.8.6?tab=readme-ov-file#proxies)
84-
for more details.
8585

8686
#### Return value
8787

index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ Shopify.prototype.updateLimits = function updateLimits(header) {
149149
*/
150150
Shopify.prototype.request = function request(uri, method, key, data, headers) {
151151
const options = {
152+
agent: this.options.agent,
152153
headers: { ...headers, ...this.baseHeaders },
153-
stringifyJson: this.options.stringifyJson,
154+
method,
154155
parseJson: this.options.parseJson,
155-
timeout: this.options.timeout,
156156
responseType: 'json',
157-
agent: this.options.agent,
158-
method
157+
stringifyJson: this.options.stringifyJson,
158+
timeout: this.options.timeout
159159
};
160160

161161
const afterResponse = (res) => {
@@ -275,16 +275,16 @@ Shopify.prototype.graphql = function graphql(data, variables) {
275275
const uri = { pathname, ...this.baseUrl };
276276
const json = variables !== undefined && variables !== null;
277277
const options = {
278+
agent: this.options.agent,
279+
body: json ? this.options.stringifyJson({ query: data, variables }) : data,
278280
headers: {
279281
...this.baseHeaders,
280282
'Content-Type': json ? 'application/json' : 'application/graphql'
281283
},
284+
method: 'POST',
282285
parseJson: this.options.parseJson,
283-
timeout: this.options.timeout,
284286
responseType: 'json',
285-
method: 'POST',
286-
agent: this.options.agent,
287-
body: json ? this.options.stringifyJson({ query: data, variables }) : data
287+
timeout: this.options.timeout
288288
};
289289

290290
const afterResponse = (res) => {

0 commit comments

Comments
 (0)