Passing real session to REST and GQL clients result in inconsistent behaviour. This is due to a custom if condition in the REST client that the GQL client doesn't have.
This only happens when using the testConfig test helper. While the consistent behaviour between the two is highly encouraged. It's not recommended to use a real session when using a testConfig. It's supposed to be a quick helper for unit tests, so all requests should be mocked.
For e2e tests, use a real config that points to a test Shopify store.
WHAT is this pull request doing?
This pull request includes changes to make the GraphQL (GQL) client behavior on custom app configurations consistent with the REST client. The most important changes include adding tests to ensure the correct behavior and updating the client classes to handle custom store app access tokens appropriately.
Consistent Behavior for Custom App Configurations:
.changeset/clever-taxis-retire.md: Added a minor bugfix entry to make GQL client behavior on custom app configurations consistent with the REST client.
WHY are these changes introduced?
Fixes https://github.com/Shopify/shopify-app-js/issues/1756
Passing real session to REST and GQL clients result in inconsistent behaviour. This is due to a custom
if
condition in the REST client that the GQL client doesn't have.This only happens when using the
testConfig
test helper. While the consistent behaviour between the two is highly encouraged. It's not recommended to use a real session when using atestConfig
. It's supposed to be a quick helper for unit tests, so all requests should be mocked.For e2e tests, use a real config that points to a test Shopify store.
WHAT is this pull request doing?
This pull request includes changes to make the GraphQL (GQL) client behavior on custom app configurations consistent with the REST client. The most important changes include adding tests to ensure the correct behavior and updating the client classes to handle custom store app access tokens appropriately.
Consistent Behavior for Custom App Configurations:
.changeset/clever-taxis-retire.md
: Added a minor bugfix entry to make GQL client behavior on custom app configurations consistent with the REST client.Test Enhancements:
packages/apps/shopify-api/lib/clients/admin/__tests__/admin_graphql_client.test.ts
: Added a test to verify that the GraphQL client adapts to private app requests only ifisCustomStoreApp
is set to false.packages/apps/shopify-api/lib/clients/admin/__tests__/rest_client.test.ts
: Added a test to verify that the REST client adapts to private app requests only ifisCustomStoreApp
is set to false.Client Class Updates:
packages/apps/shopify-api/lib/clients/admin/graphql/client.ts
: Updated theGraphqlClient
class to use the appropriate access token based on theisCustomStoreApp
configuration.Type of change
Checklist
pnpm changeset
to create a draft changelog entry (do NOT update theCHANGELOG.md
files manually)