Skip to content

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

Open
@seaders

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions