首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有角阿波罗密码Gen的热巧克力图形

带有角阿波罗密码Gen的热巧克力图形
EN

Stack Overflow用户
提问于 2022-05-22 05:41:18
回答 1查看 362关注 0票数 0

我在试着测试阿波罗图形‘m的角度编码。

因此,我创建了一个NET5服务器,它在https://localhost:8081/api/graphql/上托管Grapqhl端点。

它装得很好,不用担心。

然后,我创建了一个包含阿波罗图形as的虚拟角度项目,并按照这两个指南安装了代码gen:

  1. https://www.graphql-code-generator.com/docs/getting-started/installation
  2. https://www.graphql-code-generator.com/docs/guides/angular

这就产生了码元yml,具体如下:

代码语言:javascript
复制
overwrite: true
schema: "https://localhost:8080/api/graphql"
documents: "src/**/*.graphql"
generates:
  src/generated/graphql.ts:
    plugins:
      - "typescript"
      - "typescript-operations"
      - "typescript-apollo-angular"
  ./graphql.schema.json:
    plugins:
      - "introspection"

按照指令,我已经运行了generate命令,但是它失败了,如下所示:

代码语言:javascript
复制
> apollo-test@0.0.0 codegen
> graphql-codegen --config codegen.yml

  √ Parse configuration
  > Generate outputs
    > Generate src/generated/graphql.ts
      × Load GraphQL schemas
        → Failed to load schema
        Load GraphQL documents
        Generate
    > Generate ./graphql.schema.json
      × Load GraphQL schemas
        → Failed to load schema
        Load GraphQL documents
        Generate


 Found 2 errors

  ✖ ./graphql.schema.json
    Failed to load schema from https://localhost:8081/api/graphql:

        fetch failed
        TypeError: fetch failed
    at Object.processResponse (D:\CodeRepos\dummyTest\apollo-test\node_modules\undici\lib\fetch\index.js:200:23)
    at D:\CodeRepos\dummyTest\apollo-test\node_modules\undici\lib\fetch\index.js:941:38
    at node:internal/process/task_queues:141:7
    at AsyncResource.runInAsyncScope (node:async_hooks:201:9)
    at AsyncResource.runMicrotask (node:internal/process/task_queues:138:8)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

        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.

编辑1- Package.JSON

代码语言:javascript
复制
{
  "name": "apollo-test",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "codegen": "graphql-codegen --config codegen.yml"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~13.3.0",
    "@angular/common": "~13.3.0",
    "@angular/compiler": "~13.3.0",
    "@angular/core": "~13.3.0",
    "@angular/forms": "~13.3.0",
    "@angular/platform-browser": "~13.3.0",
    "@angular/platform-browser-dynamic": "~13.3.0",
    "@angular/router": "~13.3.0",
    "@apollo/client": "^3.0.0",
    "@graphql-codegen/cli": "^2.6.2",
    "@graphql-codegen/typescript": "^2.4.11",
    "@graphql-codegen/typescript-apollo-angular": "^3.4.10",
    "@graphql-codegen/typescript-operations": "^2.4.0",
    "apollo-angular": "^3.0.1",
    "graphql": "^16.5.0",
    "rxjs": "~7.5.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.3.1",
    "@angular/cli": "~13.3.1",
    "@angular/compiler-cli": "~13.3.0",
    "@types/jasmine": "~3.10.0",
    "@types/node": "^12.11.1",
    "jasmine-core": "~4.0.0",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.1.0",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "typescript": "~4.6.2",
    "@graphql-codegen/typescript-operations": "2.4.0",
    "@graphql-codegen/typescript": "2.4.11",
    "@graphql-codegen/typescript-apollo-angular": "3.4.10",
    "@graphql-codegen/introspection": "2.1.1",
    "@graphql-codegen/cli": "2.6.2"
  }
}
EN

回答 1

Stack Overflow用户

发布于 2022-06-02 19:13:49

我也遇到了同样的问题,并通过将NODE_TLS_REJECT_UNAUTHORIZED=0添加到package.json中的generate脚本来修复它。

请参阅:https://github.com/dotansimha/graphql-code-generator/issues/1785#issuecomment-493976501

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72335067

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档