I'm trying to use this boilerplate project.
My codegen.yml file defines the schema as:
schema: http://localhost:5555/graphql
When I try to generate the graphql code-gen, I get an error that says:
> yarn run v1.22.18 $ DEBUG=true graphql-codegen ✔ Parse configuration
> ❯ Generate outputs
> ❯ Generate src/lib/graphql.tsx
> ⠙ Load GraphQL schemas
> Load GraphQL documents
> Generate TypeError: fetch failed
> at Object.processResponse (/test/node_modules/cross-undici-fetch/node_modules/undici/lib/fetch/index.js:200:23)
> at /test/node_modules/cross-undici-fetch/node_modules/undici/lib/fetch/index.js:941:38
> at node:internal/process/task_queues:141:7
> at AsyncResource.runInAsyncScope (node:async_hooks:201:9)
> at AsyncResource.runMicrotask (node:internal/process/task_queues:138:8)
> at processTicksAndRejections (node:internal/process/task_queues:96:5) { cause: Error: connect
> ECONNREFUSED 127.0.0.1:5555
> at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16) {
> errno: -61, ✔ Parse configuration ❯ Generate outputs
> ❯ Generate src/lib/graphql.tsx
> ✖ Load GraphQL schemas
> → Failed to load schema
> Load GraphQL documents
> Generate
>
>
> Found 1 error
>
> ✖ src/lib/graphql.tsx
> Failed to load schema from http://localhost:5555/graphql:
>
> fetch failed
> TypeError: fetch failed
> at Object.processResponse (/test/node_modules/cross-undici-fetch/node_modules/undici/lib/fetch/index.js:200:23)
> at /test/node_modules/cross-undici-fetch/node_modules/undici/lib/fetch/index.js:941:38
> at node:internal/process/task_queues:141:7
> at AsyncResource.runInAsyncScope (node:async_hooks:201:9)
> at AsyncResource.runMicrotask (node:internal/process/task_queues:138:8)
> at processTicksAndRejections (node:internal/process/task_queues:96:5)
>
> 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.
> Error: Failed to load schema
> at loadSchema (/test/node_modules/@graphql-codegen/cli/bin.js:509:15)
> at processTicksAndRejections (node:internal/process/task_queues:96:5)
> at async /test/node_modules/@graphql-codegen/cli/bin.js:1039:65
> at async /test/node_modules/@graphql-codegen/cli/bin.js:1038:52
> at async /test/node_modules/@graphql-codegen/cli/bin.js:925:21
> Error: Failed to load schema
> at loadSchema (/test/node_modules/@graphql-codegen/cli/bin.js:509:15)
> at processTicksAndRejections (node:internal/process/task_queues:96:5)
> at async /test/node_modules/@graphql-codegen/cli/bin.js:1039:65
> at async /test/node_modules/@graphql-codegen/cli/bin.js:1038:52
> at async /test/node_modules/@graphql-codegen/cli/bin.js:925:21
>
>
> Running lifecycle hook "afterStart" scripts... [CLI] Loading Schemas
> [CLI] Exited with an error DetailedError: Failed to load schema
> at loadSchema (/test/node_modules/@graphql-codegen/cli/bin.js:509:15)
> at processTicksAndRejections (node:internal/process/task_queues:96:5)
> at async /test/node_modules/@graphql-codegen/cli/bin.js:1039:65
> at async /test/node_modules/@graphql-codegen/cli/bin.js:1038:52
> at async /test/node_modules/@graphql-codegen/cli/bin.js:925:21 { details: '\n' +
> ' Failed to load schema from http://localhost:5555/graphql:\n' +
> '\n' +
> ' fetch failed\n' +
> ' TypeError: fetch failed\n' +
> ' at Object.processResponse (/test/node_modules/cross-undici-fetch/node_modules/undici/lib/fetch/index.js:200:23)\n'
> +
> ' at /test/node_modules/cross-undici-fetch/node_modules/undici/lib/fetch/index.js:941:38\n'
> +
> ' at node:internal/process/task_queues:141:7\n' +
> ' at AsyncResource.runInAsyncScope (node:async_hooks:201:9)\n' +
> ' at AsyncResource.runMicrotask (node:internal/process/task_queues:138:8)\n' +
> ' at processTicksAndRejections (node:internal/process/task_queues:96:5)\n' +
> ' \n' +
> ' GraphQL Code Generator supports:\n' +
> ' - ES Modules and CommonJS exports (export as default or named export "schema")\n' +
> ' - Introspection JSON File\n' +
> ' - URL of GraphQL endpoint\n' +
> ' - Multiple files with type definitions (glob expression)\n' +
> ' - String in config file\n' +
> ' \n' +
> ' Try to use one of above options and run codegen again.\n' +
> ' \n' +
> ' ', source: 'src/lib/graphql.tsx', context: [Object: null prototype] {} } Something went wrong Failed to load schema for
> "src/lib/graphql.tsx"
> Failed to load schema from http://localhost:5555/graphql:
>
> fetch failed
> TypeError: fetch failed
> at Object.processResponse (/test/node_modules/cross-undici-fetch/node_modules/undici/lib/fetch/index.js:200:23)
> at /test/node_modules/cross-undici-fetch/node_modules/undici/lib/fetch/index.js:941:38
> at node:internal/process/task_queues:141:7
> at AsyncResource.runInAsyncScope (node:async_hooks:201:9)
> at AsyncResource.runMicrotask (node:internal/process/task_queues:138:8)
> at processTicksAndRejections (node:internal/process/task_queues:96:5)
>
> 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.
I have seen this github issue which indicates that some people with this problem found a resolution by deleting their yarn.lock file and re-running yarn. I have tried this twice (the second time I also deleted the node modules folder at the root directory level) and still get the same issue.
I don't know what to try next. I don't understand what is failing or why. Can anyone suggest the next thing to try to solve this connection issue?
When I try to run the local version, the front end loads at localhost3000, but at localhost:5555/graphql, I get a response that says:
GET query missing.
When I inspect the console on that page, it says 'bad request'