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

Ability to override apiVersion from graphql api client after its defined from shopifyApp (used in shopify-app-remix) #1889

Open
muchisx opened this issue Dec 18, 2024 · 1 comment

Comments

@muchisx
Copy link

muchisx commented Dec 18, 2024

Overview

In here, you can see that the version of the client becomes hardcoded once the shopifyApp is declared once with the first version.

return async function query(operation, options) {
const client = new params.api.clients.Graphql({
session,
apiVersion: options?.apiVersion,
});

An example of this is the shopify remix template shopify.server.ts file, here:

https://github.com/Shopify/shopify-app-template-remix/blob/465a566475badecfd81ccc56ceefd704e3a1a99b/app/shopify.server.ts#L10-L15

const shopify = shopifyApp({
  apiKey: process.env.SHOPIFY_API_KEY,
  apiSecretKey: process.env.SHOPIFY_API_SECRET || "",
  apiVersion: ApiVersion.October24,  // <-------- Hardcoding api version here, ideally this would be a fallback/default instead,
  scopes: process.env.SCOPES?.split(","),
  appUrl: process.env.SHOPIFY_APP_URL || "",
  authPathPrefix: "/auth",
  sessionStorage: new PrismaSessionStorage(prisma),
  distribution: AppDistribution.AppStore,
  future: {
    unstable_newEmbeddedAuthStrategy: true,
    removeRest: true,
  },
  ...(process.env.SHOP_CUSTOM_DOMAIN
    ? { customShopDomains: [process.env.SHOP_CUSTOM_DOMAIN] }
    : {}),
});

What we want to acheive is to have a default for most operations in provided by the shopifyApp config and then the ability to override it in the graphql client exported from the majority of the auth contexts.

Like so:

export const loader = async ({ request }: LoaderFunctionArgs) => {
  const {
    admin: { graphql },
  } = await authenticate.admin(request);

  const res = graphql(UNSTABLE_QUERY, {
    apiVersion: ApiVersion.Unstable,
  })

As of today, I've tried and I can't get it to work, which leads me to believe that even if the apiVersion param is exposed by the graphql function's options, it's not passed down.

@lizkenyon
Copy link
Contributor

Hi there 👋

I think this would be a good improvement. I am going to move this to the teams work backlog for the new year.

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

No branches or pull requests

2 participants