我拥有最简单的代码来检查$lookup
:
react-admin
但是在控制台中我总是遇到相同的错误:无法读取null的属性'name'
我的依赖是:
import React, { Component } from "react";
import buildGraphQLProvider from "ra-data-graphql-simple";
import { Admin, Resource } from "react-admin";
import posts from "./routes/posts";
class App extends Component {
constructor() {
super();
this.state = { dataProvider: null };
}
componentDidMount() {
buildGraphQLProvider({
clientOptions: { uri: "https://countries.trevorblades.com" }
})
.then(dataProvider => this.setState({ dataProvider }))
.catch(e => console.log(e.message));
}
render() {
const { dataProvider } = this.state;
if (!dataProvider) {
return <div>Loading</div>;
}
return (
<Admin dataProvider={dataProvider}>
<Resource name="posts" {...posts} />
</Admin>
);
//or, directly return <Admin dataProvider={dataProvider} />
}
}
export default App;
我做错了什么?
答案 0 :(得分:1)
我有同样的问题。
问题是我在我的graphql模式中缺少Mutation
类型,因此检查了
type.name !== schema.mutationType.name
抛出错误,因为schema.mutationType
未定义
即使模式为空,也要确保模式中有Mutation
类型
答案 1 :(得分:0)