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

Webshop example schema error with graphql-code-generator #449

Closed
rpham-eog opened this issue Jul 6, 2023 · 6 comments
Closed

Webshop example schema error with graphql-code-generator #449

rpham-eog opened this issue Jul 6, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@rpham-eog
Copy link

What version of GraphJin are you using?

Latest master branch, v3.0.12 docker image

Have you tried reproducing the issue with the latest release?

Yes

What is the hardware spec (RAM, OS)?

64 GB, macOS Monterey

Steps to reproduce the issue (config used to run GraphJin).

  1. Download https://github.com/dosco/graphjin/tree/f47065f9856ac1c81aef82dd78c557a53f4b0429/examples/webshop (latest example commit to master as of 7/6/2023 6:25 PM CDT)
  2. cd examples/webshop
  3. docker-compose run api db reset (Note: latest is used, which is currently equivalent to v3.0.12)
  4. docker-compose up
  5. Download this repo and run yarn codegen

Expected behaviour and actual result.

Code generation fails while loading schema. Expected to succeed without error.

Outputs the below error

rpham@hourpham-mb9DKD code-gen-test % yarn codegen
yarn run v1.22.19
$ graphql-codegen --config codegen.ts
✔ Parse Configuration
⚠ Generate outputs
  ❯ Generate to src/graphql/generated.ts
    ✖
      Failed to load schema from http://localhost:8080/api/v1/graphql:
      Schema must contain uniquely named types but contains multiple types named "rolesEnum".
      Error: Schema must contain uniquely named types but contains multiple types named "rolesEnum".
      at new GraphQLSchema (/Users/rpham/Documents/repos/code-gen-test/node_modules/graphql/type/schema.js:219:15)
      at mapSchema (/Users/rpham/Documents/repos/code-gen-test/node_modules/@graphql-tools/utils/cjs/mapSchema.js:14:12)
      at createWrappingSchema (/Users/rpham/Documents/repos/code-gen-test/node_modules/@graphql-tools/wrap/cjs/wrapSchema.js:16:34)
      at wrapSchema (/Users/rpham/Documents/repos/code-gen-test/node_modules/@graphql-tools/wrap/cjs/wrapSchema.js:11:20)
      at memoized (/Users/rpham/Documents/repos/code-gen-test/node_modules/@graphql-tools/utils/cjs/memoize.js:9:30)
      at UrlLoader.load (/Users/rpham/Documents/repos/code-gen-test/node_modules/@graphql-tools/url-loader/cjs/index.js:228:51)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async /Users/rpham/Documents/repos/code-gen-test/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:15:39
      at async Promise.all (index 5)
      at async loadFile (/Users/rpham/Documents/repos/code-gen-test/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:13:9)
      GraphQL Code Generator supports:
      - ES Modules and CommonJS exports (export as default or named export "schema")
      - Introspection JSON File
      - URL of GraphQL endpoint
      - Multiple files with type definitions (glob expression)
      - String in config file
      Try to use one of above options and run codegen again.
    ◼ Load GraphQL documents
    ◼ Generate
  ❯ Generate to src/graphql/graphql.schema.json
    ✖
      Failed to load schema from http://localhost:8080/api/v1/graphql:
      Schema must contain uniquely named types but contains multiple types named "rolesEnum".
      Error: Schema must contain uniquely named types but contains multiple types named "rolesEnum".
      at new GraphQLSchema (/Users/rpham/Documents/repos/code-gen-test/node_modules/graphql/type/schema.js:219:15)
      at mapSchema (/Users/rpham/Documents/repos/code-gen-test/node_modules/@graphql-tools/utils/cjs/mapSchema.js:14:12)
      at createWrappingSchema (/Users/rpham/Documents/repos/code-gen-test/node_modules/@graphql-tools/wrap/cjs/wrapSchema.js:16:34)
      at wrapSchema (/Users/rpham/Documents/repos/code-gen-test/node_modules/@graphql-tools/wrap/cjs/wrapSchema.js:11:20)
      at memoized (/Users/rpham/Documents/repos/code-gen-test/node_modules/@graphql-tools/utils/cjs/memoize.js:9:30)
      at UrlLoader.load (/Users/rpham/Documents/repos/code-gen-test/node_modules/@graphql-tools/url-loader/cjs/index.js:228:51)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async /Users/rpham/Documents/repos/code-gen-test/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:15:39
      at async Promise.all (index 5)
      at async loadFile (/Users/rpham/Documents/repos/code-gen-test/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:13:9)
      GraphQL Code Generator supports:
      - ES Modules and CommonJS exports (export as default or named export "schema")
      - Introspection JSON File
      - URL of GraphQL endpoint
      - Multiple files with type definitions (glob expression)
      - String in config file
      Try to use one of above options and run codegen again.
    ◼ Load GraphQL documents
    ◼ Generate
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@rpham-eog rpham-eog added the bug Something isn't working label Jul 6, 2023
@nathanstitt
Copy link

I also received this error when using the /api/v1/graphql url with graphql-codegen but the intro.json file that's output by the enable_introspection: true config option worked for me.

https://graphjin.com/posts/cheatsheet#introspection-query

@dosco
Copy link
Owner

dosco commented Sep 23, 2023

I don't know much about graphql-codegen but this is wierd the intro.json is the same as whats sent via /api/v1/graphql so if one worked so should the other.

     Error: Schema must contain uniquely named types but contains multiple types named "rolesEnum".
     ```

@rkrishnasanka
Copy link
Contributor

@dosco Yeah I have this error too, however if I point it to the generated intro.json it seems to work correctly. I think we need to figure out if the data thats being sent out is 100% the same. I'll look at this in a bit once I'm done building out the current MVP.

@dosco
Copy link
Owner

dosco commented Dec 14, 2023

bBest option is to save the two and do a diff on it. would love some help with this. The function used by both is gj.getIntroResult() it also caches the query so it should be the same. however just to be sure I'm moving the initial generation call lower in the init stack to be sure it's working with a fully initialized state.

@rkrishnasanka
Copy link
Contributor

@dosco I'll check on this and give you an update. I'm just trying to get my prototype working this week.

@rkrishnasanka
Copy link
Contributor

@dosco looking at how the responses are coming out, it seems like the only difference between the responses are: having the extra "data" wrappering the graph query response. But when I run the same wrappered json via the file schema option, it works. This is an issue with the codegen tool and not graphjin.

Screen Shot 2023-12-15 at 4 21 32 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants