当我执行“yarn graphql-codegen”命令时,我得到了以下错误...我不知道该怎么修。
% 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.
做了一些命令
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条答案
按热度按时间icomxhvb1#
您尝试连接的主机(
localhost:4000
)似乎不存在,因此graphql-codegen
无法加载架构(根据错误日志Failed to load schema from http://localhost:4000:
)尝试更正graphql-codegen配置中的主机,然后再次运行该命令。