首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >http://localhost:5555/graphql: GraphQL -从GraphQL提取加载架构失败

http://localhost:5555/graphql: GraphQL -从GraphQL提取加载架构失败
EN

Stack Overflow用户
提问于 2022-05-03 00:41:28
回答 1查看 2.3K关注 0票数 2

我正在尝试使用这个样板工程

我的codegen.yml文件将模式定义为:

代码语言:javascript
复制
schema: http://localhost:5555/graphql

当我试图生成graphql代码-gen时,我得到一个错误,上面写着:

代码语言:javascript
复制
> 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.

我看过这个github问题,它表明一些有这个问题的人通过删除他们的yarn.lock文件并重新运行纱线找到了一个解决方案。我已经尝试过两次了(第二次我还删除了根目录级别的节点模块文件夹),但问题仍然存在。

我不知道下一步该做什么。我不明白是什么失败了,或者是为什么。有人能建议下一件事来解决这个连接问题吗?

当我尝试运行本地版本时,前端将在localhost3000加载,但在localhost:5555/graphql上,我会得到这样的响应:

查询丢失。

当我检查页面上的控制台时,它会说“糟糕的请求”。

EN

回答 1

Stack Overflow用户

发布于 2022-05-03 21:59:28

我没有意识到我必须让服务器运行才能运行代码。它起作用了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72093753

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档