Skip to content

Commit

Permalink
Merge pull request #2999 from marmelab/fix-ra-data-graphql-doc
Browse files Browse the repository at this point in the history
Fix missing mention of compulsory buildQuery param in ra-data-graphql
  • Loading branch information
Gildas Garcia committed Mar 14, 2019
2 parents 88a2b19 + 1fb2f90 commit 171442a
Showing 1 changed file with 5 additions and 4 deletions.
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

0 comments on commit 171442a

Please sign in to comment.