【发布时间】:2022-03-09 22:15:38
【问题描述】:
多年来,我一直在尝试为运行 Apollo 服务器的项目获取 api 类型。但是现在当我运行命令 apollo client:codegen api-types --includes=src/**/*.tsx --endpoint=http://localhost:4000/graphql --target=typescript --globalTypesFile=src/api-types/globalTypes.ts 时,出现以下错误:
Warning: apollo update available from 2.33.4 to 2.33.9.
⠸ Loading Apollo Project
Generating query files
CLIError: Error in "Loading schema for Unnamed Project": Error: ServerError: Response not successful: Received status code 500
at Object.error (/workApp/node_modules/@oclif/errors/lib/index.js:26:15)
at Generate.error (/workApp/node_modules/@oclif/command/lib/command.js:60:23)
at OclifLoadingHandler.showError (/workApp/node_modules/apollo/lib/OclifLoadingHandler.js:29:22)
at OclifLoadingHandler.handle (/workApp/node_modules/apollo/lib/OclifLoadingHandler.js:14:18)
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
oclif: { exit: 2 },
✖ Loading Apollo Project
→ Error initializing Apollo GraphQL project "Unnamed Project": Error:
…
Generating query files
› Error: Error initializing Apollo GraphQL project "Unnamed Project":
› Error: Error in "Loading schema for Unnamed Project": Error:
› ServerError: Response not successful: Received status code 500
我查看了一些 Stackoveflow 帖子并尝试了这个命令:apollo schema:download --endpoint=http://localhost:4000/graphql schema.json
但这也给了我以下错误:
✔ Loading Apollo Project
✖ Saving schema to schema.json
→ ServerError: Response not successful: Received status code 500
Error: ServerError: Response not successful: Received status code
500
有解决此错误的建议吗?
【问题讨论】:
标签: graphql apollo apollo-client react-apollo apollo-server