-
Notifications
You must be signed in to change notification settings - Fork 222
Add support for executing GraphQL queries on non-dev stores #6689
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
base: main
Are you sure you want to change the base?
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
1c51daa to
7a95eed
Compare
bece5d5 to
5568d31
Compare
7a95eed to
c867e4d
Compare
c867e4d to
e531736
Compare
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success3509 tests passing in 1411 suites. Report generated by 🧪jest coverage report action from 6b3de7d |
| * @throws AbortError if attempting to run a mutation on a non-dev store. | ||
| */ | ||
| export function validateMutationStore(graphqlOperation: string, store: OrganizationStore): void { | ||
| if (isMutation(graphqlOperation) && store.storeType !== 'APP_DEVELOPMENT') { |
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.
Do all stores have a storeType? Worried that if the storeType is undefined this could be a problem? But maybe if the storeType is undefined we shouldn't allow mutations.
6b3de7d to
422c255
Compare
28408ea to
b7caf67
Compare
422c255 to
42fc35c
Compare
42fc35c to
99d6e3d
Compare
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 declarationsWe found no new type declarations in this PR Existing type declarationspackages/cli-kit/dist/public/node/api/admin.d.ts@@ -41,6 +41,14 @@ export declare function adminRequestDoc<TResult, TVariables extends Variables>(o
* @returns - An array of supported API versions.
*/
export declare function supportedApiVersions(session: AdminSession, preferredBehaviour?: RequestModeInput): Promise<string[]>;
+/**
+ * GraphQL query to retrieve all API versions.
+ *
+ * @param session - Shopify admin session including token and Store FQDN.
+ * @param preferredBehaviour - Custom request behaviour for retries and timeouts.
+ * @returns - An array of supported and unsupported API versions.
+ */
+export declare function fetchApiVersions(session: AdminSession, preferredBehaviour?: RequestModeInput): Promise<ApiVersion[]>;
/**
* Returns the Admin API URL for the given store and version.
*
@@ -50,6 +58,10 @@ export declare function supportedApiVersions(session: AdminSession, preferredBeh
* @returns - Admin API URL.
*/
export declare function adminUrl(store: string, version: string | undefined, session?: AdminSession): string;
+interface ApiVersion {
+ handle: string;
+ supported: boolean;
+}
/**
* Executes a REST request against the Admin API.
*
@@ -82,4 +94,5 @@ export interface RestResponse {
headers: {
[key: string]: string[];
};
-}
\ No newline at end of file
+}
+export {};
\ No newline at end of file
|

WHY are these changes introduced?
This PR adds support for executing GraphQL operations on production stores, while maintaining safety by restricting mutations to development stores only.
WHAT is this pull request doing?
executeBulkOperationandexecuteOperationservices to accept a store object instead of just the FQDNstoreByDomainmethod to support retrieving all store typesHow to test your changes?
Try executing a query on a production store:
This should succeed.
Try executing a mutation on a production store:
This should fail with an error message indicating mutations can only be executed on Dev Stores.
Try executing a mutation on a development store:
This should succeed.
Measuring impact
How do we know this change was effective? Please choose one:
Checklist