Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing mention of compulsory buildQuery param in ra-data-graphql #2999

Merged
merged 1 commit into from
Mar 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/ra-data-graphql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import React, { Component } from 'react';
import buildGraphQLProvider from 'ra-data-graphql';
import { Admin, Resource, Delete } from 'react-admin';

import builqQuery from './buildQuery'; // see Specify your queries and mutations section below
import { PostCreate, PostEdit, PostList } from '../components/admin/posts';

class App extends Component {
Expand All @@ -58,7 +59,7 @@ class App extends Component {
this.state = { dataProvider: null };
}
componentDidMount() {
buildGraphQLProvider()
buildGraphQLProvider({ buildQuery })
.then(dataProvider => this.setState({ dataProvider }));
}

Expand Down Expand Up @@ -124,7 +125,7 @@ The `./schema` file is a `schema.json` in `./scr` retrieved with [`get-graphql-s

## Specify your queries and mutations

For the provider to know how to map react-admin request to apollo queries and mutations, you must provide a `queryBuilder` option. The `queryBuilder` is a factory function which will be called with the introspection query result.
For the provider to know how to map react-admin request to apollo queries and mutations, you must provide a `buildQuery` option. The `buildQuery` is a factory function which will be called with the introspection query result.

The introspection result is an object with 4 properties:

Expand Down Expand Up @@ -184,9 +185,9 @@ For example:
}
```

The `queryBuilder` function must return a function which will be called with the same parameters as the react-admin data provider but must return an object matching the `options` of the ApolloClient [query](http://dev.apollodata.com/core/apollo-client-api.html#ApolloClient.query) method with an additional `parseResponse` function.
The `buildQuery` function must return a function which will be called with the same parameters as the react-admin data provider, but must return an object matching the `options` of the ApolloClient [query](http://dev.apollodata.com/core/apollo-client-api.html#ApolloClient.query) method with an additional `parseResponse` function.

This `parseResponse` function will be called with an [ApolloQueryResult](http://dev.apollodata.com/core/apollo-client-api.html#ApolloQueryResult) and must returns the data expected by react-admin.
This `parseResponse` function will be called with an [ApolloQueryResult](http://dev.apollodata.com/core/apollo-client-api.html#ApolloQueryResult) and must return the data expected by react-admin.

For example:

Expand Down