From 25c1fba235175e0273d789365587769812c959ac Mon Sep 17 00:00:00 2001 From: Matheus Wichman Date: Sun, 14 Jul 2019 22:30:12 -0300 Subject: [PATCH] Add pagination and sorting params to GET_MANY_REFERENCE --- packages/ra-data-graphql-simple/src/buildVariables.js | 4 ++++ packages/ra-data-graphql-simple/src/buildVariables.test.js | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/packages/ra-data-graphql-simple/src/buildVariables.js b/packages/ra-data-graphql-simple/src/buildVariables.js index fa390caf63d..c88280e62c2 100644 --- a/packages/ra-data-graphql-simple/src/buildVariables.js +++ b/packages/ra-data-graphql-simple/src/buildVariables.js @@ -248,6 +248,10 @@ export default introspectionResults => ( case GET_MANY_REFERENCE: { const parts = preparedParams.target.split('.'); return { + page: parseInt(preparedParams.pagination.page, 10) - 1, + perPage: parseInt(preparedParams.pagination.perPage, 10), + sortField: preparedParams.sort.field, + sortOrder: preparedParams.sort.order, filter: { [`${parts[0]}Id`]: preparedParams.id }, }; } diff --git a/packages/ra-data-graphql-simple/src/buildVariables.test.js b/packages/ra-data-graphql-simple/src/buildVariables.test.js index eccaf59d180..1cc525b143d 100644 --- a/packages/ra-data-graphql-simple/src/buildVariables.test.js +++ b/packages/ra-data-graphql-simple/src/buildVariables.test.js @@ -132,6 +132,8 @@ describe('buildVariables', () => { const params = { target: 'author.id', id: 'author1', + pagination: { page: 1, perPage: 10 }, + sort: { field: 'name', order: 'ASC' }, }; expect( @@ -143,6 +145,10 @@ describe('buildVariables', () => { ) ).toEqual({ filter: { authorId: 'author1' }, + page: 0, + perPage: 10, + sortField: 'name', + sortOrder: 'ASC', }); }); });