英文:
how fix of the error about graphql codegen
问题
When I do the "yarn graphql-codegen" command, I got the following error:
% yarn graphql-codegen
yarn run v1.22.4
warning package.json: No license field
$ /Users/xxx/node_modules/.bin/graphql-codegen
✔ Parse Configuration
⚠ Generate outputs
❯ Generate to src/gql/
✖
Failed to load schema from http://localhost:4000:
connect ECONNREFUSED 127.0.0.1:4000
Error: connect ECONNREFUSED 127.0.0.1:4000
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)
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.
◼ Load GraphQL documents
◼ Generate
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I don't have an idea how to fix it.
英文:
When I do "yarn graphql-codegen" command
I got the following error...
I don't have an idea how to fix it.
% yarn graphql-codegen
yarn run v1.22.4
warning package.json: No license field
$ /Users/xxx/node_modules/.bin/graphql-codegen
✔ Parse Configuration
⚠ Generate outputs
❯ Generate to src/gql/
✖
Failed to load schema from http://localhost:4000:
connect ECONNREFUSED 127.0.0.1:4000
Error: connect ECONNREFUSED 127.0.0.1:4000
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16)
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.
◼ Load GraphQL documents
◼ Generate
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
did some commands like
yarn add @graphql-codegen/cli @graphql-codegen/typescript @graphql-codegen/typescript-operations
npm install --save-dev @graphql-codegen/cli @graphql-codegen/typescript @graphql-codegen/typescript-operations @graphql-codegen/client
/Users/xxx/node_modules/.bin/graphql-codegen
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const cli_js_1 = require("./cli.js");
const cli_error_js_1 = require("./utils/cli-error.js");
const [, , cmd] = process.argv;
(0, cli_js_1.runCli)(cmd)
.then(returnCode => {
process.exit(returnCode);
})
.catch(error => {
(0, cli_error_js_1.cliError)(error);
});
答案1
得分: 1
尝试更正你的 graphql-codegen 配置中的主机信息,然后再次运行命令。
英文:
It seemed like the host which you tried to connect to (localhost:4000
) doesn't exist so graphql-codegen
cant load the schema (per error log Failed to load schema from http://localhost:4000:
)
Try to correct the host in your graphql-codegen config and run the command again.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论