【发布时间】:2020-11-17 02:43:28
【问题描述】:
这是我的代码。
import { ApolloClient, ApolloProvider, InMemoryCache } from "@apollo/client";
import { createHttpLink } from "apollo-link-http";
import { render } from "react-dom";
import React from "react";
import RouteCollector from "./routeCollector";
import "./index.css";
import possibleTypes from "./tools/graphqlCodeGenerator/possibleTypes.json";
const cache = new InMemoryCache({
possibleTypes,
});
const link = createHttpLink({
uri: "http://localhost:8000/graphql",
credentials: "include",
});
const client = new ApolloClient({
cache,
link,
});
render(
<ApolloProvider client={client}>
<RouteCollector />
</ApolloProvider>,
document.getElementById("root")
);
我正在使用包" @ apollo / client ":" ^ 3.0.2 ", "apollo-link-http": "^1.5.17", "graphql": "^15.3.0","react": "^16.13.1",
当我运行程序时出现错误
TypeError: possibleTypes[supertype].forEach 不是函数
如何修复错误?
【问题讨论】:
-
代码的哪一行抛出了这个错误?
-
@RezaBehzadpour
const cache = new InMemoryCache({possibleTypes,})
标签: reactjs graphql apollo apollo-client