-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace isStorefrontPasswordProtected with API call #5166
Conversation
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success2007 tests passing in 906 suites. Report generated by 🧪jest coverage report action from 4510992 |
packages/theme/src/cli/utilities/theme-environment/storefront-session.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎩 and code both LGTM - for other reviewers, you may need to flush your store password by providing an incorrect value or changing the password via admin to trigger the input.
1afd8f6
to
e55902a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small naming nit but lgtm!
We were previously determining whether or not a storefront was password protected by making a HTTP request to the storefront and checking the response status. This worked for us in the past but is a known fragile piece. We've now shipped the ability to query whether the storefront is password protected directly in the Admin API so we no longer need to guess. This replaces all instances of `isStorefrontPasswordProtected` with the updated API call.
e55902a
to
f004019
Compare
Force Push Patch Notes
|
Differences in type declarationsWe detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:
New type declarationspackages/cli-kit/dist/cli/api/graphql/admin/generated/online_store_password_protection.d.tsimport * as Types from './types.js';
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
export type OnlineStorePasswordProtectionQueryVariables = Types.Exact<{
[key: string]: never;
}>;
export type OnlineStorePasswordProtectionQuery = {
onlineStore: {
passwordProtection: {
enabled: boolean;
};
};
};
export declare const OnlineStorePasswordProtection: DocumentNode<OnlineStorePasswordProtectionQuery, OnlineStorePasswordProtectionQueryVariables>;
Existing type declarationspackages/cli-kit/dist/public/node/themes/api.d.ts@@ -22,4 +22,5 @@ export declare function metafieldDefinitionsByOwnerType(type: MetafieldOwnerType
name: string;
category: string;
};
-}[]>;
\ No newline at end of file
+}[]>;
+export declare function passwordProtected(session: AdminSession): Promise<boolean>;
\ No newline at end of file
|
WHY are these changes introduced?
We were previously determining whether or not a storefront was password protected by making a HTTP request to the storefront and checking the response status. This worked for us in the past but is a known fragile piece.
We've now shipped the ability to query whether the storefront is password protected directly in the Admin API so we no longer need to guess. This replaces all instances of
isStorefrontPasswordProtected
with the updated API call.WHAT is this pull request doing?
Replaces a fragile process of guessing the meaning of an HTTP status code with making an explicit call to the Admin API to determine whether or not a storefront is password protected.
How to test your changes?
gg-query-password-setting
and runpnpm install && pnpm run build
shopify theme dev --path <local theme path>
shopify theme dev --path <local theme path>
Checklist