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

yarn gen works only if server runs on port 4000 #8557

Open
Wilted98 opened this issue Nov 1, 2022 · 5 comments
Open

yarn gen works only if server runs on port 4000 #8557

Wilted98 opened this issue Nov 1, 2022 · 5 comments
Labels
core Related to codegen core/cli

Comments

@Wilted98
Copy link

Wilted98 commented Nov 1, 2022

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'

@ardatan
Copy link
Collaborator

ardatan commented Nov 1, 2022

Please share a clear reproduction by using our template on CodeSandbox or StackBlitz since we cannot access your localhost :)

@Wilted98
Copy link
Author

Wilted98 commented Nov 1, 2022

@ardatan Sorry. Edited.

@charlypoly charlypoly added the core Related to codegen core/cli label Nov 3, 2022
@Flowko
Copy link

Flowko commented Dec 14, 2022

any news about this ?

@Flowko
Copy link

Flowko commented Dec 14, 2022

so i just used 0.0.0.0:1337 and it seems to work fine, for anyone wondering

@saihaj
Copy link
Collaborator

saihaj commented Dec 15, 2022

This is very weird 🤔 there is no process in codegen that runs or uses that port. When you visit your server on port 6000 locally you it works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to codegen core/cli
Projects
None yet
Development

No branches or pull requests

5 participants