react-admin ra-data-graphql-simple 示例和 json-graphql-server

react-admin ra-data-graphql-simple example and json-graphql-server

我按照说明使用此处的帮助设置了 react-admin + graphql 概念验证 - https://www.npmjs.com/package/ra-data-graphql-simple and here - https://github.com/marmelab/json-graphql-server

我正在 运行 安装 json-graphql-server db.js

我似乎 运行 遇到了让它工作的问题 -

$ create-react-app test-admin
$ cd test-admin
$ yarn add react-admin
$ yarn add graphql ra-data-graphql-simple

然后我使用 ra-data-graphql-simple 示例中所示的代码更新 App.js,并从 react-admin tutotial 创建 posts.js。

在运行宁yarn start我得到-

./src/App.js
 Line 7:  'ApolloClient' is not defined  no-undef

有谁知道如何让示例运行?

这适用于示例 -

import buildGraphQLProvider from 'ra-data-graphql-simple';
import { Admin, Resource, Delete } from 'react-admin';
import { PostCreate, PostEdit, PostList } from './posts';

class App extends Component {
    constructor() {
        super();
        this.state = { dataProvider: null };
    }

    componentDidMount() {
        buildGraphQLProvider({ clientOptions: { uri: 'http://localhost:3000' }})
            .then(dataProvider => this.setState({ dataProvider }));
    }

    render() {
        const { dataProvider } = this.state;

        if (!dataProvider) {
            return <div>Loading</div>;
        }

        return (
            <Admin dataProvider={dataProvider}>
                <Resource name="Post" list={PostList} edit={PostEdit} create={PostCreate} remove={Delete} />
            </Admin>
        );
    }
}

export default App;