shopify-api-js icon indicating copy to clipboard operation
shopify-api-js copied to clipboard

GraphQL Codegen Fails with Multiple Errors When Generating Types for Shopify API

Open bushev opened this issue 1 year ago • 0 comments

Hi,

I'm trying to make types work following that guide: https://github.com/Shopify/shopify-api-js/blob/main/packages/shopify-api/docs/guides/graphql-types.md

But once I've tried to generate types, the codegen cli fails with the following error:

[~/IdeaProjects/my_project]$ npm run graphql-codegen

> [email protected] graphql-codegen
> graphql-codegen

✔ Parse Configuration
⚠ Generate outputs
  ❯ Generate to ./types/admin.schema.json
    ✔ Load GraphQL schemas
    ✔ Load GraphQL documents
    ✖ GraphQL Document Validation failed with 15 errors;
      Error 1: Cannot query field "service" on type "QueryRoot".
      at /Users/user1/IdeaProjects/my_project/node_modules/@graphql-tools/apollo-engine-loader/esm/index.js:3:5
      Error 2: Unknown type "Service".
      at /Users/user1/IdeaProjects/my_project/node_modules/@graphql-tools/apollo-engine-loader/esm/index.js:4:14
      Error 3: This anonymous operation must be the only defined operation.
      at /Users/user1/IdeaProjects/my_project/node_modules/@graphql-tools/prisma-loader/cjs/prisma-yml/Cluster.js:2:7
      Error 4: Unknown type "GenerateClusterTokenRequest".
      at /Users/user1/IdeaProjects/my_project/node_modules/@graphql-tools/prisma-loader/cjs/prisma-yml/Cluster.js:2:25
      Error 5: Cannot query field "generateClusterToken" on type "Mutation".
      at /Users/user1/IdeaProjects/my_project/node_modules/@graphql-tools/prisma-loader/cjs/prisma-yml/Cluster.js:3:9
      Error 6: This anonymous operation must be the only defined operation.
      at /Users/user1/IdeaProjects/my_project/node_modules/@graphql-tools/prisma-loader/cjs/prisma-yml/Cluster.js:2:7
      Error 7: Unknown type "GenerateClusterTokenRequest".
      at /Users/user1/IdeaProjects/my_project/node_modules/@graphql-tools/prisma-loader/cjs/prisma-yml/Cluster.js:2:25
      Error 8: Cannot query field "addServiceToCloudDBIfMissing" on type "Mutation".
      at /Users/user1/IdeaProjects/my_project/node_modules/@graphql-tools/prisma-loader/cjs/prisma-yml/Cluster.js:3:9
      Error 9: This anonymous operation must be the only defined operation.
      at /Users/user1/IdeaProjects/my_project/node_modules/@graphql-tools/prisma-loader/esm/prisma-yml/Cluster.js:2:7
      Error 10: Unknown type "GenerateClusterTokenRequest".
      at /Users/user1/IdeaProjects/my_project/node_modules/@graphql-tools/prisma-loader/esm/prisma-yml/Cluster.js:2:25
      Error 11: Cannot query field "generateClusterToken" on type "Mutation".
      at /Users/user1/IdeaProjects/my_project/node_modules/@graphql-tools/prisma-loader/esm/prisma-yml/Cluster.js:3:9
      Error 12: This anonymous operation must be the only defined operation.
      at /Users/user1/IdeaProjects/my_project/node_modules/@graphql-tools/prisma-loader/esm/prisma-yml/Cluster.js:2:7
      Error 13: Unknown type "GenerateClusterTokenRequest".
      at /Users/user1/IdeaProjects/my_project/node_modules/@graphql-tools/prisma-loader/esm/prisma-yml/Cluster.js:2:25
      Error 14: Cannot query field "addServiceToCloudDBIfMissing" on type "Mutation".
      at /Users/user1/IdeaProjects/my_project/node_modules/@graphql-tools/prisma-loader/esm/prisma-yml/Cluster.js:3:9

Could you advice please?

"@shopify/admin-api-client": "0.2.3",
"@shopify/api-codegen-preset": "0.0.2",
"@shopify/graphql-client": "0.9.3",
"@shopify/shopify-api": "9.2.0",
"@shopify/storefront-api-client": "0.2.3",
"graphql-codegen": "0.4.0",
  • Node version: v20.10.0
  • Operating system: Darwin y-macbook.default 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000 arm64

Expected behavior

Types present.

Actual behavior

Error, not types.

Steps to reproduce the problem

Follow the guide - https://github.com/Shopify/shopify-api-js/blob/main/packages/shopify-api/docs/guides/graphql-types.md

bushev avatar Feb 10 '24 18:02 bushev