Skip to content

Commit 95a1060

Browse files
fetch and pass correct approval scopes for the app when building the UI extension payload
1 parent 0625063 commit 95a1060

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

bin/get-graphql-schemas.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ async function fetchFiles() {
170170
*/
171171
async function fetchFilesFromLocal() {
172172
for (const schema of schemas) {
173-
const localRepoDirectory = execSync(`/opt/dev/bin/dev cd --no-chdir ${schema.repo}`).toString().split('/areas')[0].trim()
173+
const localRepoDirectory = execSync(`/opt/dev/bin/dev cd --no-chdir ${schema.repo === 'world' ? '//' : schema.repo}`).toString().split('/areas')[0].trim()
174174
const sourcePath = path.join(localRepoDirectory, schema.pathToFile)
175175
console.log('Copying', sourcePath, 'to', schema.localPath)
176176
fs.copyFileSync(sourcePath, schema.localPath)

packages/app/src/cli/api/graphql/app-management/generated/active-app-release-from-api-key.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type ActiveAppReleaseFromApiKeyQuery = {
1313
id: string
1414
key: string
1515
organizationId: string
16-
activeRoot: {clientCredentials: {secrets: {key: string}[]}}
16+
activeRoot: {grantedShopifyApprovalScopes: string[]; clientCredentials: {secrets: {key: string}[]}}
1717
activeRelease: {
1818
id: string
1919
version: {
@@ -131,6 +131,7 @@ export const ActiveAppReleaseFromApiKey = {
131131
],
132132
},
133133
},
134+
{kind: 'Field', name: {kind: 'Name', value: 'grantedShopifyApprovalScopes'}},
134135
],
135136
},
136137
},

packages/app/src/cli/api/graphql/app-management/generated/active-app-release.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type ActiveAppReleaseQuery = {
1313
id: string
1414
key: string
1515
organizationId: string
16-
activeRoot: {clientCredentials: {secrets: {key: string}[]}}
16+
activeRoot: {grantedShopifyApprovalScopes: string[]; clientCredentials: {secrets: {key: string}[]}}
1717
activeRelease: {
1818
id: string
1919
version: {
@@ -35,7 +35,7 @@ export type AppVersionInfoFragment = {
3535
id: string
3636
key: string
3737
organizationId: string
38-
activeRoot: {clientCredentials: {secrets: {key: string}[]}}
38+
activeRoot: {grantedShopifyApprovalScopes: string[]; clientCredentials: {secrets: {key: string}[]}}
3939
activeRelease: {
4040
id: string
4141
version: {
@@ -130,6 +130,7 @@ export const AppVersionInfoFragmentDoc = {
130130
],
131131
},
132132
},
133+
{kind: 'Field', name: {kind: 'Name', value: 'grantedShopifyApprovalScopes'}},
133134
],
134135
},
135136
},
@@ -293,6 +294,7 @@ export const ActiveAppRelease = {
293294
],
294295
},
295296
},
297+
{kind: 'Field', name: {kind: 'Name', value: 'grantedShopifyApprovalScopes'}},
296298
],
297299
},
298300
},

packages/app/src/cli/api/graphql/app-management/queries/active-app-release.graphql

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ fragment AppVersionInfo on App {
1414
key
1515
}
1616
}
17+
grantedShopifyApprovalScopes
1718
}
1819
activeRelease {
1920
id
2021
version {
2122
name
22-
appModules {
23-
...ReleasedAppModule
24-
}
23+
appModules {
24+
...ReleasedAppModule
25+
}
2526
}
2627
}
2728
}

packages/app/src/cli/utilities/developer-platform-client/app-management-client.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ export class AppManagementClient implements DeveloperPlatformClient {
342342
async appFromIdentifiers(apiKey: string): Promise<OrganizationApp | undefined> {
343343
const {app} = await this.activeAppVersionRawResult(apiKey)
344344
const {name, appModules} = app.activeRelease.version
345-
const appAccessModule = appModules.find((mod) => mod.specification.externalIdentifier === 'app_access')
346345
const appHomeModule = appModules.find((mod) => mod.specification.externalIdentifier === 'app_home')
347346
const apiSecretKeys = app.activeRoot.clientCredentials.secrets.map((secret) => ({secret: secret.key}))
348347
return {
@@ -351,7 +350,7 @@ export class AppManagementClient implements DeveloperPlatformClient {
351350
apiKey: app.key,
352351
apiSecretKeys,
353352
organizationId: String(numberFromGid(app.organizationId)),
354-
grantedScopes: (appAccessModule?.config?.scopes as string[] | undefined) ?? [],
353+
grantedScopes: app.activeRoot.grantedShopifyApprovalScopes,
355354
applicationUrl: appHomeModule?.config?.app_url as string | undefined,
356355
flags: [],
357356
developerPlatformClient: this,

0 commit comments

Comments
 (0)