Skip to content

Commit b56e8d6

Browse files
authored
Merge pull request #6220 from Shopify/decrease-normalizestorefqdn-calls
Remove redundant calls to normalizeStoreFqdn
2 parents fc54a46 + a883d5b commit b56e8d6

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

.changeset/flat-schools-dance.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/cli-kit': patch
3+
---
4+
5+
Remove redundant calls to normalizeStoreFqdn in requests

packages/cli-kit/src/public/node/api/admin.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const mockedResult = {
2828
}
2929

3030
const token = 'token'
31-
const Session: AdminSession = {token, storeFqdn: 'store'}
31+
const Session: AdminSession = {token, storeFqdn: 'store.myshopify.com'}
3232

3333
describe('admin-graphql-api', () => {
3434
test('calls the graphql client twice: get api version and then execute the request', async () => {
@@ -83,7 +83,7 @@ describe('admin-graphql-api', () => {
8383
api: 'Admin',
8484
addedHeaders: {
8585
'X-Shopify-Access-Token': 'shptka_token',
86-
'X-Shopify-Shop': 'store',
86+
'X-Shopify-Shop': 'store.myshopify.com',
8787
},
8888
url: `https://${defaultThemeKitAccessDomain}/cli/admin/api/2022-01/graphql.json`,
8989
token: themeAccessToken,
@@ -131,7 +131,7 @@ describe('admin-rest-api', () => {
131131
await admin.restRequest('GET', '/themes', Session)
132132

133133
// Then
134-
expect(spyFetch).toHaveBeenLastCalledWith('https://store/admin/api/unstable/themes.json', {
134+
expect(spyFetch).toHaveBeenLastCalledWith('https://store.myshopify.com/admin/api/unstable/themes.json', {
135135
headers,
136136
method: 'GET',
137137
})
@@ -164,7 +164,7 @@ describe('admin-rest-api', () => {
164164
headers: {
165165
'Content-Type': 'application/json',
166166
'X-Shopify-Access-Token': 'shptka_token',
167-
'X-Shopify-Shop': 'store',
167+
'X-Shopify-Shop': 'store.myshopify.com',
168168
},
169169
method: 'GET',
170170
},

packages/cli-kit/src/public/node/api/admin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from '../../../private/node/api/rest.js'
1717
import {RequestModeInput, shopifyFetch} from '../http.js'
1818
import {PublicApiVersions} from '../../../cli/api/graphql/admin/generated/public_api_versions.js'
19-
import {normalizeStoreFqdn} from '../context/fqdn.js'
19+
2020
import {themeKitAccessDomain} from '../../../private/node/constants.js'
2121
import {serviceEnvironment} from '../../../private/node/context/service.js'
2222
import {DevServerCore} from '../vendor/dev_server/index.js'
@@ -36,7 +36,7 @@ const LatestApiVersionByFQDN = new Map<string, string>()
3636
export async function adminRequest<T>(query: string, session: AdminSession, variables?: GraphQLVariables): Promise<T> {
3737
const api = 'Admin'
3838
const version = await fetchLatestSupportedApiVersion(session)
39-
let storeDomain = await normalizeStoreFqdn(session.storeFqdn)
39+
let storeDomain = session.storeFqdn
4040
const addedHeaders = themeAccessHeaders(session)
4141

4242
if (serviceEnvironment() === 'local') {
@@ -78,7 +78,7 @@ export async function adminRequestDoc<TResult, TVariables extends Variables>(
7878
if (!apiVersion) {
7979
apiVersion = await fetchLatestSupportedApiVersion(session, preferredBehaviour)
8080
}
81-
let storeDomain = await normalizeStoreFqdn(session.storeFqdn)
81+
let storeDomain = session.storeFqdn
8282
const addedHeaders = themeAccessHeaders(session)
8383

8484
if (serviceEnvironment() === 'local') {

packages/cli-kit/src/public/node/session.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ describe('ensureAuthenticatedTheme', () => {
173173

174174
test('returns the password when is provided and custom_app_token', async () => {
175175
// When
176-
const got = await ensureAuthenticatedThemes('mystore', 'password')
176+
const got = await ensureAuthenticatedThemes('mystore.myshopify.com', 'password')
177177

178178
// Then
179179
expect(got).toEqual({token: 'password', storeFqdn: 'mystore.myshopify.com'})
@@ -183,7 +183,7 @@ describe('ensureAuthenticatedTheme', () => {
183183

184184
test('returns the password when is provided and theme_access_token', async () => {
185185
// When
186-
const got = await ensureAuthenticatedThemes('mystore', 'shptka_password')
186+
const got = await ensureAuthenticatedThemes('mystore.myshopify.com', 'shptka_password')
187187

188188
// Then
189189
expect(got).toEqual({token: 'shptka_password', storeFqdn: 'mystore.myshopify.com'})

packages/cli-kit/src/public/node/session.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {normalizeStoreFqdn} from './context/fqdn.js'
21
import {BugError} from './error.js'
32
import {getPartnersToken} from './environment.js'
43
import {nonRandomUUID} from './crypto.js'
@@ -190,7 +189,7 @@ export async function ensureAuthenticatedThemes(
190189
${outputToken.json(scopes)}
191190
`)
192191
if (password) {
193-
const session = {token: password, storeFqdn: await normalizeStoreFqdn(store)}
192+
const session = {token: password, storeFqdn: store}
194193
const authMethod = isThemeAccessSession(session) ? 'theme_access_token' : 'custom_app_token'
195194
setLastSeenAuthMethod(authMethod)
196195
setLastSeenUserIdAfterAuth(nonRandomUUID(password))

0 commit comments

Comments
 (0)