我正在设置 Api平台(已启用graphql)服务器和 react-admin 客户端。 我在api平台(名称为Domain)上创建资源。如果我查询GraphQL Playground应用程序,我会得到预期的结果。 在使用ra-data-graphql-simple软件包安装react-admin之后,客户端尝试连接,并且客户端返回错误“未知资源域。请确保已在服务器端模式上声明了该错误”
这是我的App.js代码
import React, { Component } from 'react';
import { Admin, Resource, Delete } from 'react-admin';
import buildGraphQLProvider from 'ra-data-graphql-simple';
import myBuildQuery from './dataProvider';
import { DomainShow, DomainEdit, DomainCreate, DomainList } from './domain';
class App extends Component {
constructor() {
super();
this.state = { dataProvider: null };
}
componentDidMount() {
const introspectionOptions = {
include: ['Domains', 'Purchases'],
};
buildGraphQLProvider({
//buildQuery: myBuildQuery,
clientOptions: { uri: 'http://127.0.0.1:8000/api/graphql' },
introspection: introspectionOptions
})
.then(dataProvider => this.setState({ dataProvider }));
}
render() {
const { dataProvider } = this.state;
if (!dataProvider) {
return <div>Loading</div>;
}
return (
<Admin dataProvider={dataProvider}>
<Resource name="domains" list={ DomainList } create={ DomainCreate } show={ DomainShow } edit={ DomainEdit } title="Domains"/>
</Admin>
);
}
}
export default App;