首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeScript,Apollo GraphQL yield assignable“节点获取错误

TypeScript,Apollo GraphQL yield assignable“节点获取错误
EN

Stack Overflow用户
提问于 2020-03-17 18:05:59
回答 1查看 141关注 0票数 0

我正致力于在NodeJS/Apollo/GraphQL项目中实现schema stitching。它是用TypeScript编写的。

代码是

代码语言:javascript
复制
import {
    makeRemoteExecutableSchema,
    introspectSchema,
    mergeSchemas
} from 'graphql-tools';
import { HttpLink } from 'apollo-link-http';
import fetch from 'node-fetch';


export default  async () => {
    const link = new HttpLink({
        uri:'http://localhost:4545',
        fetch
    })
    const remoteSchema = await introspectSchema(link);
    // Make remote executable schema
    return makeRemoteExecutableSchema({
        schema: remoteSchema,
        link
    });

}

它抱怨说

类型文件的引用部分是

代码语言:javascript
复制
export interface HttpOptions {
    uri?: string | UriFunction;
    includeExtensions?: boolean;
    fetch?: WindowOrWorkerGlobalScope['fetch'];
    headers?: any;
    credentials?: string;
    fetchOptions?: any;
}

这似乎是一个bug that has been fixed,但它似乎没有在这里修复,尽管我使用的是最新版本和行

fetch?: WindowOrWorkerGlobalScope['fetch'];

这似乎是对其中一个解决方法的建议,因此,它应该得到修复。

无论如何,我的package.json

代码语言:javascript
复制
{
  "dependencies": {

    "apollo-datasource-graphql": "^1.3.2",
    "apollo-datasource-rest": "^0.7.0",
    "apollo-link-http": "^1.5.16",
    "apollo-server": "^2.10.1",
    "axios": "^0.19.2",
    "dotenv": "^8.2.0",
    "graphql": "^14.6.0",
    "graphql-tools": "^4.0.7",
    "https-proxy-agent": "^5.0.0",
    "node-fetch": "^2.6.0",
    "uuid": "^7.0.1"
  },
  "devDependencies": {
    "@types/node": "^13.9.1",
    "@types/ramda": "^0.26.43",
    "babel-eslint": "^10.0.3",
    "eslint": "^6.8.0",
    "eslint-config-airbnb-base": "^14.0.0",
    "eslint-config-prettier": "^6.10.0",
    "eslint-plugin-prettier": "^3.1.2",
    "pino": "^5.16.0",
    "prettier": "^1.19.1",
    "ramda": "^0.26.1",
    "typescript": "^3.8.3"
  },
  "scripts": {
    "dev": "tsc && node dist/index.js"
  }
}

任何线索都非常感谢!

EN

回答 1

Stack Overflow用户

发布于 2020-04-30 11:24:43

使用cross-fetch可以解决这个问题。

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

https://stackoverflow.com/questions/60720099

复制
相关文章

相似问题

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