This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop sending deprecated field in webhook queries
- Loading branch information
Showing
8 changed files
with
210 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@shopify/shopify-api': minor | ||
--- | ||
|
||
Stop sending the privateMetafieldNamespaces field in webhook queries to avoid the API duplication warning, and added a new shopify.utils.versionPriorTo method to help with cases like this one where apps will need to stop doing something that was deprecated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# shopify.utils.versionPriorTo | ||
|
||
This method determines if the given version is older than the configured `apiVersion` for the `shopifyApi` object. | ||
Its main use is when you want to tweak behaviour depending on your current API version, though apps won't typically need this kind of check. | ||
|
||
## Example | ||
|
||
```ts | ||
const shopify = shopifyApi({ | ||
apiVersion: ApiVersion.July23, | ||
}); | ||
|
||
if (shopify.utils.versionPriorTo(ApiVersion.July23)) { | ||
// false in this example, as both versions are July23 | ||
} | ||
if (shopify.utils.versionPriorTo(ApiVersion.October23)) { | ||
// true in this example, as ApiVersion.October23 is newer than ApiVersion.July23, i.e. the configured version is older | ||
// than the reference one | ||
} | ||
``` | ||
|
||
## Parameters | ||
|
||
### apiVersion | ||
|
||
`ApiVersion` | :exclamation: required | ||
|
||
The API version to check against. | ||
|
||
## Return | ||
|
||
`boolean` | ||
|
||
Whether the reference version is older than the configured version. | ||
|
||
[Back to shopify.utils](./README.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import {shopify} from '../../__tests__/test-helper'; | ||
import {ApiVersion} from '../../types'; | ||
|
||
describe('versionCompatible', () => { | ||
it('returns true if version is Unstable', () => { | ||
shopify.config.apiVersion = ApiVersion.Unstable; | ||
|
||
const result = shopify.utils.versionCompatible(ApiVersion.April23); | ||
|
||
expect(result).toBe(true); | ||
}); | ||
|
||
it('returns true if version is equal to the configured one', () => { | ||
shopify.config.apiVersion = ApiVersion.April23; | ||
|
||
const result = shopify.utils.versionCompatible(ApiVersion.April23); | ||
|
||
expect(result).toBe(true); | ||
}); | ||
|
||
it('returns true if version is newer than the configured one', () => { | ||
shopify.config.apiVersion = ApiVersion.April23; | ||
|
||
const result = shopify.utils.versionCompatible(ApiVersion.January23); | ||
|
||
expect(result).toBe(true); | ||
}); | ||
|
||
it('returns false if version is older than the configured one', () => { | ||
shopify.config.apiVersion = ApiVersion.January23; | ||
|
||
const result = shopify.utils.versionCompatible(ApiVersion.April23); | ||
|
||
expect(result).toBe(false); | ||
}); | ||
}); | ||
|
||
describe('versionPriorTo', () => { | ||
it('returns false if version is Unstable (unstable is newer than any version)', () => { | ||
shopify.config.apiVersion = ApiVersion.Unstable; | ||
|
||
const result = shopify.utils.versionPriorTo(ApiVersion.April23); | ||
|
||
expect(result).toBe(false); | ||
}); | ||
|
||
it('returns false if version is equal to the configured one', () => { | ||
shopify.config.apiVersion = ApiVersion.April23; | ||
|
||
const result = shopify.utils.versionPriorTo(ApiVersion.April23); | ||
|
||
expect(result).toBe(false); | ||
}); | ||
|
||
it('returns false if version is newer than the configured one', () => { | ||
shopify.config.apiVersion = ApiVersion.April23; | ||
|
||
const result = shopify.utils.versionPriorTo(ApiVersion.January23); | ||
|
||
expect(result).toBe(false); | ||
}); | ||
|
||
it('returns true if version is older than the configured one', () => { | ||
shopify.config.apiVersion = ApiVersion.January23; | ||
|
||
const result = shopify.utils.versionPriorTo(ApiVersion.April23); | ||
|
||
expect(result).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters