小编AtA*_*ark的帖子

GraphQL 代码生成器 - 无法从 Nestjs 服务器端点加载我的 GQL 架构

我在 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)

graphql nestjs graphql-codegen

6
推荐指数
1
解决办法
8607
查看次数

标签 统计

graphql ×1

graphql-codegen ×1

nestjs ×1