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

[api-codegen] Project isn't "consuming" output from storefront generated graphql types #1901

Open
seaders opened this issue Dec 23, 2024 · 1 comment

Comments

@seaders
Copy link

seaders commented Dec 23, 2024

Issue summary

Issue is as stated, snapshots:

Image

I've a backend that works 99% with the admin API, but, because there's nowhere to do a cartCreate with it, that has to be from the storefront. I'm using @shopify/shopify-api v11.6.1 and everything runs perfectly, at run-time, and everything with the admin side of things works absolutely perfectly at compile time and run-time.

With the storefront side of things, in vscode, there's no automatic association between the generated code and the actual response, even though the code is generated perfectly.

A similar call with the admin api, without anything changing in the project settings,

Image

If I go and manually reference the generated file, we get what we want,

Image

.graphqlrc.ts

import { ApiType, shopifyApiProject } from "@shopify/api-codegen-preset"

export default {
  schema: "https://shopify.dev/storefront-graphql-direct-proxy/2024-10",
  projects: {
    default: shopifyApiProject({
      apiType: ApiType.Admin,
      apiVersion: "2024-10",
      documents: ["./lib/shopify/admin/*.ts"],
      outputDir: "./lib/graphql-types/admin"
    }),
    storefront: shopifyApiProject({
      apiType: ApiType.Storefront,
      apiVersion: "2024-10",
      documents: ["./lib/shopify/storefront/*.ts"],
      outputDir: "./lib/graphql-types/storefront"
    })
  }
}

Admin gen command
npx graphql-codegen

Storefront gen command
npx graphql-codegen -p storefront

I've followed the advice in #1058 to get 90% of the way there, but not all the way.

At the end of the day, especially because this is the only storefront call I make with our backend, and I can manually reference that output, or just type it out myself, it's not really a big issue, but it does seem like a bug, and should work "out of the box" like with admin.

Before opening this issue, I have:

  • [ x ] Upgraded to the latest version of the relevant packages
    • @shopify/* package and version:
    "@shopify/admin-api-client": "^1.0.4",
    "@shopify/graphql-client": "^1.2.1",
    "@shopify/shopify-api": "^11.6.1",
    "@shopify/shopify-app-session-storage": "^3.0.9",
---
    "@shopify/api-codegen-preset": "^1.1.3",
  • Node version: v20.18.1
  • Operating system: OSX 15.2
  • [ x] Set { logger: { level: LogSeverity.Debug } } in my configuration, when applicable
  • [x ] Found a reliable way to reproduce the problem that indicates it's a problem with the package
  • [ x] Looked for similar issues in this repository
  • [x ] Checked that this isn't an issue with a Shopify API
@seaders
Copy link
Author

seaders commented Dec 23, 2024

No idea the actual reason, but I know now what causes this. Using pnpm. I set up a vanilla project to see if I could figure some things out, and couldn't get anything working at all. Found a stack overflow that said the age old rm -rf node_modules && npm i, which I did, instead of my usual pnpm, and everything worked exactly right.

I then did the same again, but pnpm i and? Same problem, no "connection" to the storefront and the typehinting for the storefront side was lost.

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

1 participant