【问题标题】:How do I solve this Apollo Control Cache error?如何解决此 Apollo Control Cache 错误?
【发布时间】:2021-10-24 11:42:42
【问题描述】:

我正在尝试设置我的服务器端后端,但遇到了这个错误:

node_modules/apollo-cache-control/dist/index.d.ts:24:9 - error TS2717: Subsequent property declarations must have the same type.  Property 'cacheControl' must be of type 'ResolveInfoCacheControl', but here has type '{ setCacheHint: (hint: CacheHint) => void; cacheHint: CacheHint; }'.

24         cacheControl: {
           ~~~~~~~~~~~~

  node_modules/@nestjs/graphql/node_modules/apollo-server-types/dist/index.d.ts:140:9
    140         cacheControl: ResolveInfoCacheControl;
                ~~~~~~~~~~~~
    'cacheControl' was also declared here.

【问题讨论】:

    标签: apollo apollo-server


    【解决方案1】:

    我刚刚找到了解决方法,您必须将其添加到您的 tsconfig.json 文件中:

    "skipLibCheck": true
    

    我的 tsconfig.json 看起来像:

    {
      "compilerOptions": {
        "module": "commonjs",
        "esModuleInterop": true,
        "target": "es2015",
        "noImplicitAny": false,
        "moduleResolution": "node",
        "sourceMap": true,
        "outDir": "lib",
        "baseUrl": "./",
        "lib": ["es6", "esnext.asynciterable"],
        "types": ["node"],
        "skipLibCheck": true
      },
      "include": ["src/**/*"]
    }
    

    【讨论】:

    • 有这个解决方法很好,但我不确定这是一个好的长期解决方案,因为这会影响所有库。我想知道是否有什么可以针对有问题的图书馆做更多的事情?
    • @David 现在我正在继续这个 hack。我完全同意你的看法。
    【解决方案2】:

    确保所有 apollo 软件包(apollo-serverapollo-server-expressapollo-server-core)具有完全相同的版本

    【讨论】:

      猜你喜欢
      • 2017-09-30
      • 1970-01-01
      • 2016-10-22
      • 2017-07-25
      • 2017-12-12
      • 2012-02-14
      • 2015-04-12
      • 2016-06-21
      相关资源
      最近更新 更多