Skip to content

Commit

Permalink
docs(graphql): update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
BatuhanW committed Oct 10, 2024
1 parent 7581b9a commit fdb6e59
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions documentation/docs/data/packages/graphql/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const App = () => <Refine dataProvider={dataProvider}>{/* ... */}</Refine>;

### Options

It's also possible to pas a 2nd parameter to GraphQL data provider. 2nd parameter is an object that consist of builder pieces for each data provider method such as getList, updateMany, etc...
It's also possible to pass a 2nd parameter to GraphQL data provider. 2nd parameter is an object that consist of builder pieces for each data provider method such as getList, updateMany, etc...
All fields in this options config are optional and fields that are provided will be deep merged into default options. So you can just pass certain methods you want to override, and the rest will fallback to default.

Let's say you have the following query:

Expand Down Expand Up @@ -93,10 +94,12 @@ type ActionMethod = {
};
```

We have ActionMethod type for each of the data provider actions. Additionally, `getOne` has `convertMutationToQuery` and `getList` has `countMapper`, `buildSorters`, `buildFilters`, `buildPagination` methods.
We have ActionMethod type for each of the data provider actions. Additionally, `getOne` has `convertMutationToQuery` and `getList` has `getTotalCount` methods.

`convertMutationToQuery` method on `getOne` might be needed because `useForm` hook also uses it. `useForm` hook has an optional gqlQuery field, we may only get `gqlMutation`. For this reason, we need to convert mutation to query to get initial data on edit, if needed.

`getTotalCount` can be used to extract total count of the list query from the response.

<details>
<summary>See all options</summary>

Expand Down Expand Up @@ -138,7 +141,7 @@ export const defaultOptions = {
getList: {
dataMapper: (response: OperationResult<any>, params: GetListParams) =>
response,
countMapper: (response: OperationResult<any>, params: GetListParams) => 0,
getTotalCount: (response: OperationResult<any>, params: GetListParams) => 0,
buildSorters: (params: GetListParams) => buildSorters(params.sorters),
buildFilters: (params: GetListParams) => buildFilters(params.filters),
buildPagination: (params: GetListParams) =>
Expand Down

0 comments on commit fdb6e59

Please sign in to comment.