dotansimha / dotansimha/graphql-code-generator
yarn gen works only if server runs on port 4000
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
### Describe the bug
Hello!
I have my api, who runs locally on port 6000... If i run "yarn gen" i get this:
```
Generate outputs
❯ Generate src/generated/graphql.tsx
✖ Failed to load schema
◼ Load GraphQL documents
◼ Generate
Failed to load schema for "src/generated/graphql.tsx"
Failed to load schema from http://localhost:6000/graphql:
fetch failed
TypeError: fetch failed
at Object.processResponse (E:\Startup\haircut\node_modules\undici\lib\fetch\index.js:198:23)
at E:\Startup\haircut\node_modules\undici\lib\fetch\index.js:929:38
at node:internal/process/task_queues:141:7
at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
at AsyncResource.runMicrotask (node:internal/process/task_queues:138:8)
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.
```
If i change the server port on 4000 and change this codegen.yaml schema url to 4000, this works fine.
I TRIED TO INIALIZE THIS AGAIN with "yarn graphql-codegen init" and change the url with port 6000, but doesn't work.
Thanks!
### Your Example Website or App
RN_Client: https://github.com/Wilted98/Haircut-client.git
API: https://github.com/Wilted98/haircut-api.git
### Steps to Reproduce the Bug or Issue
1) Start the client;
2) type yarn run gen
3) Get the error
### Expected behavior
To Work on any port.
### Platform
- OS: Windows
- NodeJS: 16.18
- `graphql` version: ^16.5.0
- `@graphql-codegen/cli` : "2.13.9",
- `@graphql-codegen/typescript` : "2.8.1",
- `@graphql-codegen/typescript-operations` : "2.5.6",
- `@graphql-codegen/typescript-urql` : "^3.6.2",
### Codegen Config File
```
overwrite: true
schema: 'http://localhost:6000/graphql'
documents: 'src/graphql/**/*.graphql'
generates:
src/generated/graphql.tsx:
plugins:
- 'typescript'
- 'typescript-operations'
- 'typescript-react-apollo'
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.