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

Failed to load schema - TypeError: crossUndiciFetch.fetch is not a function (cont) #7396

Closed
doron-cohen opened this issue Jan 24, 2022 · 8 comments

Comments

@doron-cohen
Copy link

doron-cohen commented Jan 24, 2022

This is a continuation of #7388 . I don't understand why such a severe bug which breaks the the application and is reported by so many users in just a few hours is being closed. The ability to comment was also blocked which is something I don't understand the reason for. I understand it is very hard to maintain such a popular tool but this bug is important to solve. At the very least keep the ticket open for us to have a place to discuss it and debug as a group.

I suggest using a label like requires-reproduction instead of closing and locking.

About reproducing: Is there a public schema url we can try to reproduce this on?

Describe the bug

When running the generate command I get this error:

Found 1 error

  ✖ ./src/user.tsx
    Failed to load schema from http://localhost:8080/v1/graphql:

        crossUndiciFetch.fetch is not a function
        TypeError: crossUndiciFetch.fetch is not a function
    at defaultAsyncFetch (/home/doron/dev/supplize/application/application/node_modul
es/@graphql-tools/url-loader/index.js:44:29)
    at /home/doron/dev/supplize/application/application/node_modules/@graphql-tools/u
rl-loader/index.js:474:36
    at new ValueOrPromise (/home/doron/dev/supplize/application/application/node_modu
les/value-or-promise/build/main/ValueOrPromise.js:14:21)
    at executor (/home/doron/dev/supplize/application/application/node_modules/@graph
ql-tools/url-loader/index.js:442:20)
    at /home/doron/dev/supplize/application/application/node_modules/@graphql-tools/u
rl-loader/index.js:646:20
    at /home/doron/dev/supplize/application/application/node_modules/@graphql-tools/w
rap/index.js:1697:52
    at new ValueOrPromise (/home/doron/dev/supplize/application/application/node_modu
les/value-or-promise/build/main/ValueOrPromise.js:14:21)
    at Object.introspectSchema (/home/doron/dev/supplize/application/application/node
_modules/@graphql-tools/wrap/index.js:1697:12)
    at UrlLoader.load (/home/doron/dev/supplize/application/application/node_modules/
@graphql-tools/url-loader/index.js:687:40)
    at async /home/doron/dev/supplize/application/application/node_modules/@graphql-t
ools/load/index.js:75:39

        GraphQL Code Generator supports:
          - ES Modules and CommonJS exports (export as default or named export "schem
a")
          - 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.
    Error: Failed to load schema
        at loadSchema (/home/doron/dev/supplize/application/application/node_modules/
@graphql-codegen/cli/bin.js:503:15)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
        at async /home/doron/dev/supplize/application/application/node_modules/@graph
ql-codegen/cli/bin.js:857:33
        at async /home/doron/dev/supplize/application/application/node_modules/@graph
ql-codegen/cli/bin.js:972:52
        at async Task.task (/home/doron/dev/supplize/application/application/node_mod
ules/@graphql-codegen/cli/bin.js:811:17)
    Error: Failed to load schema
        at loadSchema (/home/doron/dev/supplize/application/application/node_modules/
@graphql-codegen/cli/bin.js:503:15)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
        at async /home/doron/dev/supplize/application/application/node_modules/@graph
ql-codegen/cli/bin.js:857:33
        at async /home/doron/dev/supplize/application/application/node_modules/@graph
ql-codegen/cli/bin.js:972:52
        at async Task.task (/home/doron/dev/supplize/application/application/node_mod
ules/@graphql-codegen/cli/bin.js:811:17)

Running this command works so I believe it's a dependency issue:

curl -X POST -H "Content-Type: application/json" -H "x-hasura-role: user" -H "x-hasura-admin-secret: secret" --data '{"query": "query IntrospectionQuery { __schema { queryType { name } mutationType { name } subscriptionType { name } types { ...FullType } directives { name description locations args { ...InputValue } } } } fragment FullType on __Type { kind name description fields(includeDeprecated: true) { name description args { ...InputValue } type { ...TypeRef } isDeprecated deprecationReason } inputFields { ...InputValue } interfaces { ...TypeRef } enumValues(includeDeprecated: true) { name description isDeprecated deprecationReason } possibleTypes { ...TypeRef } } fragment InputValue on __InputValue { name description type { ...TypeRef } defaultValue } fragment TypeRef on __Type { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } } } }"}' "http://localhost:8080/v1/graphql"

To Reproduce
Steps to reproduce the behavior:

  1. My codegen.json config file:
{
  "overwrite": true,
  "generates": {
    "./src/user.tsx": {
      "schema": [
        {
          "http://localhost:8080/v1/graphql": {
            "headers": {
              "x-hasura-role": "user",
              "x-hasura-admin-secret": "secret"
            }
          }
        }
      ],
      "documents": ["./src/user/**/*.graphql"],
      "plugins": ["typescript", "typescript-operations", "typescript-react-apollo"],
      "config": {
        "preResolveTypes": true,
        "skipTypename": false,
        "withHooks": true,
        "withHOC": false,
        "withComponent": false,
        "enumsAsTypes": true,
        "constEnums": true,
        "reactApolloVersion": 3
      }
    }
  }
}

Expected behavior

Environment:

OS: linux
React

    "@graphql-codegen/cli": "^2.4.0",
    "@graphql-codegen/introspection": "^2.1.1",
    "@graphql-codegen/typescript": "^2.4.2",
    "@graphql-codegen/typescript-operations": "^2.2.2",
    "@graphql-codegen/typescript-react-apollo": "^3.2.4",

Additional context

@ardatan
Copy link
Collaborator

ardatan commented Jan 24, 2022

I don't understand why such a severe bug which breaks the the application and is reported by so many users in just a few hours is being closed after doing some stuff

Nobody has created a reproduction and then they said the issue has been gone after reinstalling etc.

The ability to comment was also blocked which is something I don't understand the reason for.

Nobody is creating a reproduction but writing the same comments. So the issue was too heated and it is impossible to move on without a reproduction for us.

About reproducing: Is there a public schema url we can try to reproduce this on?

There are bunch of GraphQL APIs here.
https://github.com/APIs-guru/graphql-apis

@naquiroz
Copy link

Hi, I made a reproduction here
Feel free to test (to make it work please add a .env following example.env)

@doron-cohen
Copy link
Author

doron-cohen commented Jan 24, 2022

I don't understand why such a severe bug which breaks the the application and is reported by so many users in just a few hours is being closed after doing some stuff

Nobody has created a reproduction and then they said the issue has been gone after reinstalling etc.

The ability to comment was also blocked which is something I don't understand the reason for.

Nobody is creating a reproduction but writing the same comments. So the issue was too heated and it is impossible to move on without a reproduction for us.

I don't think it was too heated. More users were reporting the issue. I was only open for a few hours. You could give it more time for us to reproduce. I truly appreciate the effort you guys put in maintaining these tools but closing bugs (and locking them) too soon will deter users from reporting them in the first place.

Thanks @naquiroz for reproducing the issue.

@naquiroz
Copy link

I would also like to add that, I just deleted node_modules package-lock.json and it worked.

@ardatan
Copy link
Collaborator

ardatan commented Jan 24, 2022

Ok it seems like a broken release in one of the dependencies.
Deleting lock file seems to work in here;
https://codesandbox.io/s/course-site-frontend-forked-ob5w7?file=/package.json
@doron-cohen When do you think you can create your reproduction?

@doron-cohen
Copy link
Author

Ok, I resolved the issue by removing the lockfile and reinstalling dependencies. So I guess this is fixed?

@ardatan ardatan closed this as completed Jan 26, 2022
@stereosteve
Copy link

I ran into this and fixed it by replacing localhost with 127.0.0.1.

I think it has something to do with undici's dns resolution, based on reading nodejs/undici#1248 (comment)

Also relevant for: #7388

@0xPasho
Copy link

0xPasho commented Aug 15, 2022

Sheesh, @stereosteve workaround worked.

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

No branches or pull requests

5 participants