dotansimha / dotansimha/graphql-code-generator

@graphql-mesh/cli Unauthorized Error After Reinstalling Dependencies

Open
#10,119 1 comment 0 reactions 1 assignee Claimed by @eddeee888 View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Which packages are impacted by your issue?

@graphql-codegen/cli

### Describe the bug

At the beginning of the month, I created an application using @graphql-mesh/cli version 5.0.2. I used the following command to generate my code, and everything worked fine:
```
dotenv -e .env -- graphql-codegen --config codegen.yaml
```
Today, I started working on a very similar project, where I’m also using @graphql-mesh/cli in the exact same way:
```
dotenv -e .env -- graphql-codegen --config codegen.yaml
```
However, in this new project, I started receiving the following error:
```
✔ Parse Configuration
⚠ Generate outputs
❯ Generate to .hasura/generated.ts

Failed to load schema from (here is my correct link):
unauthorized
GraphQLError: unauthorized
at createGraphQLError (/Users/adamsmichal/Projects/devticon/backend-rest/node_modules/@graphql-tools/utils/cjs/errors.js:31:12)
at /Users/adamsmichal/Projects/devticon/backend-rest/node_modules/@graphql-tools/wrap/cjs/introspect.js:12:102
at Array.map ()
at getSchemaFromIntrospection (/Users/adamsmichal/Projects/devticon/backend-rest/node_modules/@graphql-tools/wrap/cjs/introspect.js:12:58)
at /Users/adamsmichal/Projects/devticon/backend-rest/node_modules/@graphql-tools/wrap/cjs/introspect.js:35:32)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async UrlLoader.load (/Users/adamsmichal/Projects/devticon/backend-rest/node_modules/@graphql-tools/url-loader/cjs/index.js:221:29)
at async /Users/adamsmichal/Projects/devticon/backend-rest/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:14:39)
at async Promise.all (index 5)
at async loadFile (/Users/adamsmichal/Projects/devticon/backend-rest/node_modules/@graphql-tools/load/cjs/load-typedefs/load-file.js:12: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
```
To test, I went back to the working project, deleted node_modules and package-lock.json, and then reinstalled the dependencies. Unfortunately, the same error started appearing in the previously working project as well.

This suggests that the issue might be related to deep dependencies that are now causing authorization issues after a fresh install.

Environment:
• @graphql-mesh/cli version: 5.0.2
• Node.js version: 21.5.0
• npm version: 10.2.4

### Your Example Website or App

Private

### Steps to Reproduce the Bug or Issue

It's hard for me to write how to reproduce the code because it doesn't work when I do it from scratch

### Expected behavior

The code generation should work as it did originally without throwing unauthorized errors.

### Screenshots or Videos

_No response_

### Platform

@graphql-mesh/cli version: 5.0.2
Node.js version: 21.5.0
npm version: 10.2.4

### Codegen Config File

_No response_

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.