Skip to content

Commit db481d2

Browse files
committed
PR feedback on function signature
1 parent 8d02b7a commit db481d2

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

packages/app/src/cli/services/graphql/common.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ describe('resolveApiVersion', () => {
123123
{handle: '2024-07', supported: true},
124124
])
125125

126-
const result = await resolveApiVersion(mockAdminSession, '2024-04')
126+
const result = await resolveApiVersion(mockAdminSession, '2024-04', '2026-01')
127127

128128
expect(result).toBe('2024-04')
129129
expect(fetchApiVersions).toHaveBeenCalledWith(mockAdminSession)

packages/app/src/cli/services/graphql/common.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,24 @@ export function validateSingleOperation(graphqlOperation: string): void {
5050
* The 'unstable' version is always allowed without validation.
5151
*
5252
* @param adminSession - Admin session containing store credentials.
53-
* @param versionFlag - The API version to validate.
54-
* @param minimumVersion - Optional minimum version to use as a fallback when no version is specified.
53+
* @param userSpecifiedVersion - The API version to validate.
54+
* @param minimumDefaultVersion - Optional minimum version to use as a fallback when no version is specified.
5555
* @throws AbortError if the provided version is not allowed.
5656
*/
5757
export async function resolveApiVersion(
5858
adminSession: {token: string; storeFqdn: string},
59-
versionFlag?: string,
60-
minimumVersion?: string,
59+
userSpecifiedVersion?: string,
60+
minimumDefaultVersion?: string,
6161
): Promise<string> {
62-
if (versionFlag === 'unstable') return versionFlag
62+
if (userSpecifiedVersion === 'unstable') return userSpecifiedVersion
6363

6464
const availableVersions = await fetchApiVersions(adminSession)
6565

66-
// Return the most recent supported version, or minimumVersion if specified, whichever is newer
67-
if (!versionFlag) {
66+
if (!userSpecifiedVersion) {
67+
// Return the most recent supported version, or minimumDefaultVersion if specified, whichever is newer.
6868
const supportedVersions = availableVersions.filter((version) => version.supported).map((version) => version.handle)
69-
70-
if (minimumVersion) {
71-
supportedVersions.push(minimumVersion)
69+
if (minimumDefaultVersion) {
70+
supportedVersions.push(minimumDefaultVersion)
7271
}
7372

7473
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -77,9 +76,10 @@ export async function resolveApiVersion(
7776

7877
// Check if the user provided version is allowed. Unsupported versions (RC) are allowed here.
7978
const versionList = availableVersions.map((version) => version.handle)
80-
if (versionList.includes(versionFlag)) return versionFlag
79+
if (versionList.includes(userSpecifiedVersion)) return userSpecifiedVersion
8180

82-
const firstLine = outputContent`Invalid API version: ${versionFlag}`.value
81+
// Invalid user provided version.
82+
const firstLine = outputContent`Invalid API version: ${userSpecifiedVersion}`.value
8383
const secondLine = outputContent`Allowed versions: ${versionList.join(', ')}`.value
8484
throw new AbortError(firstLine, secondLine)
8585
}

0 commit comments

Comments
 (0)