我在 Angular 应用程序上使用graphQL 代码生成器,并尝试从本地 Nestjs 应用程序加载我的架构。
这是 codegen.yml 文件:
schema: http://localhost:3000/graphql
documents: ./src/app/graphql/**/*.graphql
generates:
./src/app/graphql/types.ts:
plugins:
- typescript
- typescript-operations
- typescript-apollo-angular
Run Code Online (Sandbox Code Playgroud)
当我运行 graphql-codegen 时,出现以下错误:
Failed to load schema from http://localhost:3000/graphql:
invalid json response body at http://localhost:3000/graphql reason: Unexpected token < in JSON at position 0
FetchError: invalid json response body at http://localhost:3000/graphql reason: Unexpected token < in JSON at position 0
at C:\ngWishList2\node_modules\node-fetch\lib\index.js:271:32
at processTicksAndRejections (internal/process/task_queues.js:94:5)
at async UrlLoader.load (C:\ngWishList2\node_modules\@graphql-toolkit\url-loader\index.cjs.js:87:22)
at async C:\ngWishList2\node_modules\@graphql-toolkit\core\index.cjs.js:682:25
at async Promise.all (index …Run Code Online (Sandbox Code Playgroud)