Skip to content
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

Check organization beta flags for gated template specifications #4271

Merged
merged 3 commits into from
Aug 8, 2024

Conversation

amcaplan
Copy link
Contributor

@amcaplan amcaplan commented Aug 5, 2024

WHY are these changes introduced?

Fills in a stubbed-out bit which is now made possible by @gracejychang's recent work connecting us to Business Platform!

WHAT is this pull request doing?

Rather than stubbing out feature flags, actually check for their presence!

How to test your changes?

  1. Look at the list of extensions at https://github.com/Shopify/extensions-templates/blob/main/templates.json and pick a gated extension (marked by organizationBetaFlag).
  2. Pointing to Spin, run app generate extension and note that the gated template doesn't appear.
  3. Now, create the flag in business platform using the Maintenance::CreateFeatureFlagTask maintenance task.
  4. The gated template still shouldn't appear.
  5. Now, enable the flag on your organization.
  6. Now the gated template appears in the list!

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Contributor

github-actions bot commented Aug 5, 2024

Thanks for your contribution!

Depending on what you are working on, you may want to request a review from a Shopify team:

  • Themes: @shopify/advanced-edits
  • UI extensions: @shopify/ui-extensions-cli
    • Checkout UI extensions: @shopify/checkout-ui-extensions-api-stewardship
  • Hydrogen: @shopify/hydrogen
  • Other: @shopify/app-management

@amcaplan amcaplan force-pushed the check-org-flags-on-generate branch 2 times, most recently from ec8cdf1 to 952083d Compare August 5, 2024 20:47
@amcaplan amcaplan marked this pull request as ready for review August 6, 2024 12:58
Copy link
Contributor

github-actions bot commented Aug 6, 2024

We detected some changes at either packages/*/src or packages/cli-kit/assets/cli-ruby/** and there are no updates in the .changeset.
If the changes are user-facing, run "pnpm changeset add" to track your changes and include them in the next release CHANGELOG.

Copy link
Contributor

github-actions bot commented Aug 6, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
72.65% (+0.14% 🔼)
7922/10904
🟡 Branches
69.4% (+0.05% 🔼)
3887/5601
🟡 Functions
71.36% (+0.07% 🔼)
2081/2916
🟡 Lines
72.99% (+0.15% 🔼)
7487/10258
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / organization_beta_flags.ts
100% 100% 100% 100%

Test suite run success

1808 tests passing in 822 suites.

Report generated by 🧪jest coverage report action from fc2858d

@amcaplan amcaplan force-pushed the check-org-flags-on-generate branch from c9f0457 to 91b7b46 Compare August 6, 2024 13:00
Copy link
Contributor

@gonzaloriestra gonzaloriestra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

* @param organizationId - Organization ID as a numeric value.
* @param variables - GraphQL variables to pass to the query.
* @returns The response of the query of generic type <T>.
*/
export async function businessPlatformOrganizationsRequest<TResult>(
export async function businessPlatformOrganizationsRequestDoc<TResult>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused. Why do we need two functions to run the query? Is this related to the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first function above uses classic manually typed schemas, while this function uses auto-generated types.

I do eventually need to learn more about the auto-generated stuff, but I think for this PR it's not relevant, as the GraphQL string is generated at runtime.

@amcaplan amcaplan force-pushed the check-org-flags-on-generate branch from 91b7b46 to fc2858d Compare August 8, 2024 14:03
Copy link
Contributor

github-actions bot commented Aug 8, 2024

Differences in type declarations

We 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:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/node/api/business-platform.d.ts
@@ -24,10 +24,20 @@ export declare function businessPlatformRequestDoc<TResult, TVariables extends V
  *
  * @param query - GraphQL query to execute.
  * @param token - Business Platform token.
+ * @param organizationId - Organization ID as a numeric (non-GID) value.
+ * @param variables - GraphQL variables to pass to the query.
+ * @returns The response of the query of generic type <T>.
+ */
+export declare function businessPlatformOrganizationsRequest<T>(query: string, token: string, organizationId: string, variables?: GraphQLVariables): Promise<T>;
+/**
+ * Executes a GraphQL query against the Business Platform Organizations API. Uses typed documents.
+ *
+ * @param query - GraphQL query to execute.
+ * @param token - Business Platform token.
  * @param organizationId - Organization ID as a numeric value.
  * @param variables - GraphQL variables to pass to the query.
  * @returns The response of the query of generic type <T>.
  */
-export declare function businessPlatformOrganizationsRequest<TResult>(query: TypedDocumentNode<TResult, GraphQLVariables> | TypedDocumentNode<TResult, Exact<{
+export declare function businessPlatformOrganizationsRequestDoc<TResult>(query: TypedDocumentNode<TResult, GraphQLVariables> | TypedDocumentNode<TResult, Exact<{
     [key: string]: never;
 }>>, token: string, organizationId: string, variables?: GraphQLVariables): Promise<TResult>;
\ No newline at end of file

@amcaplan amcaplan added this pull request to the merge queue Aug 8, 2024
Merged via the queue into main with commit 3b2029a Aug 8, 2024
36 checks passed
@amcaplan amcaplan deleted the check-org-flags-on-generate branch August 8, 2024 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants