Skip to content

Commit

Permalink
[minor] Fix nits
Browse files Browse the repository at this point in the history
  • Loading branch information
lpinca committed Jan 13, 2024
1 parent 4f02cc9 commit 92c7d76
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ Creates a new `Shopify` instance.
[OAuth 2.0][oauth] access token. This option is mutually exclusive with the
`apiKey` and `password` options. If you are looking for a premade solution to
obtain an access token, take a look at the [shopify-token][] module.
- `agent` - Optional - An object that is passed as the `agent` option to `got`.
This allows to use a proxy server. See
[Got documentation](https://github.com/sindresorhus/got/tree/v11.8.6?tab=readme-ov-file#proxies)
for more details.
- `apiVersion` - Optional - A string to specify the [Shopify API
version][api-versioning] to use for requests. Defaults to the oldest supported
stable version.
Expand All @@ -53,6 +57,18 @@ Creates a new `Shopify` instance.
specifies a limit of 2 requests per second with a burst of 35 requests. When
set to `true` requests are limited as specified in the above example. Defaults
to `false`. Mutually exclusive with the `maxRetries` option.
- `hooks` - Optional - A list of `got`
[request hooks](https://github.com/sindresorhus/got/tree/v11.8.6#hooks) to
attach to all outgoing requests, like `beforeRetry`, `afterResponse`, etc.
Hooks should be provided in the same format that Got expects them and will
receive the same arguments Got passes unchanged.
- `maxRetries` - Optional - The number of times to attempt to make the request
to Shopify before giving up. Defaults to `0`, which means no automatic
retries. If set to a value greater than `0`, `shopify-api-node` will make up
to that many retries. `shopify-api-node` will respect the `Retry-After` header
for requests to the REST API, and the throttled cost data for requests to the
GraphQL API, and retry the request after that time has elapsed. Mutually
exclusive with the `autoLimit` option.
- `parseJson` - Optional - The function used to parse JSON. The function is
passed a single argument. This option allows the use of a custom JSON parser
that might be needed to properly handle long integer IDs. Defaults to
Expand All @@ -66,22 +82,6 @@ Creates a new `Shopify` instance.
- `timeout` - Optional - The number of milliseconds before the request times
out. If the request takes longer than `timeout`, it will be aborted. Defaults
to `60000`, or 1 minute.
- `maxRetries` - Optional - The number of times to attempt to make the request
to Shopify before giving up. Defaults to `0`, which means no automatic
retries. If set to a value greater than `0`, `shopify-api-node` will make up
to that many retries. `shopify-api-node` will respect the `Retry-After` header
for requests to the REST API, and the throttled cost data for requests to the
GraphQL API, and retry the request after that time has elapsed. Mutually
exclusive with the `autoLimit` option.
- `hooks` - Optional - A list of `got`
[request hooks](https://github.com/sindresorhus/got/tree/v11.8.6#hooks) to
attach to all outgoing requests, like `beforeRetry`, `afterResponse`, etc.
Hooks should be provided in the same format that Got expects them and will
receive the same arguments Got passes unchanged.
- `agent` - Optional - An object that is passed as the `agent` option to `got`.
This allows to use a proxy server. See
[Got documentation](https://github.com/sindresorhus/got/tree/v11.8.6?tab=readme-ov-file#proxies)
for more details.

#### Return value

Expand Down
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ Shopify.prototype.updateLimits = function updateLimits(header) {
*/
Shopify.prototype.request = function request(uri, method, key, data, headers) {
const options = {
agent: this.options.agent,
headers: { ...headers, ...this.baseHeaders },
stringifyJson: this.options.stringifyJson,
method,
parseJson: this.options.parseJson,
timeout: this.options.timeout,
responseType: 'json',
agent: this.options.agent,
method
stringifyJson: this.options.stringifyJson,
timeout: this.options.timeout
};

const afterResponse = (res) => {
Expand Down Expand Up @@ -275,16 +275,16 @@ Shopify.prototype.graphql = function graphql(data, variables) {
const uri = { pathname, ...this.baseUrl };
const json = variables !== undefined && variables !== null;
const options = {
agent: this.options.agent,
body: json ? this.options.stringifyJson({ query: data, variables }) : data,
headers: {
...this.baseHeaders,
'Content-Type': json ? 'application/json' : 'application/graphql'
},
method: 'POST',
parseJson: this.options.parseJson,
timeout: this.options.timeout,
responseType: 'json',
method: 'POST',
agent: this.options.agent,
body: json ? this.options.stringifyJson({ query: data, variables }) : data
timeout: this.options.timeout
};

const afterResponse = (res) => {
Expand Down

0 comments on commit 92c7d76

Please sign in to comment.