-
Notifications
You must be signed in to change notification settings - Fork 7
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
Get nextToken working with GET_LIST API call, pagination #11
Comments
Struggling with this. When I pass the |
Hey, @mayteio great project! It's helping our team scaffold out our project quickly but we are really stuck on this one. Can you help point to where we can look into this one and help? Or is this more of a problem with RA working in with Amplify graphql? |
👋 hey @senorgeno, glad you've found it helpful so far. I'd be happy to point you in the right direction. Firstly, there's a reducer that catches the import { nextTokenReducer } from 'ra-aws-amplify';
export const App = () => (
<Admin ... customReducers={{ nextToken: nextTokenReducer }} />
) Note: In future release I'd like the API to be Then, in your list page we have an Amplify Pagination component we can pass in for next/prev instead of having numbers (as DynamoDB doesn't support total records out of the box). Here's where I'm stuck: I wanted to use permanent filters to pass the import { AmplifyPagination } from 'ra-aws-amplify'
export const PostList = props => {
const nextToken = useSelector(state => state.nextToken);
return <List {...props} pagination={<AmplifyPagination />} filter={{nextToken}} />
} Note: the use selector could be abstracted into a hook like Problem is, when you actually pass the ra-aws-amplify/src/buildAmplifyProvider/buildVariables.ts Lines 136 to 140 in 112dd87
The query ListPosts(
$filter: ModelPostFilterInput
$limit: Int
$nextToken: String
) {
listPosts(filter: $filter, limit: $limit, nextToken: $nextToken) {
id
...
}
} ra-aws-amplify/src/buildAmplifyProvider/buildQuery.ts Lines 36 to 41 in 112dd87
I don't have time to look at it this week but I am 100% open to collaborating here if you manage to fix it and want to submit a PR for it! Let me know if I can help or if you have any questions. |
import { AmplifyPagination } from 'ra-aws-amplify'
export const PostList = props => {
const nextToken = useSelector(state => state.nextToken);
return <List {...props} pagination={<AmplifyPagination />} filter={{nextToken}} />
} The What is desired is to insert |
Unreal, thanks for the info. Have you fixed this in a PR or should I jump in and do it? |
I'm using a quick workaround by doing this: import { AmplifyPagination } from 'ra-aws-amplify'
export const PostList = props => {
const [nextToken, setNextToken] = useState(null);
return <List {...props} pagination={<AmplifyPagination onNext={(nextToken) => setNextToken(nextToken)} />} filter={{nextToken}} />
} I also overrided And I think there's also a lot more to be done in |
Currently the infrastructure is in place, though the pagination doesn't actually work - just refetches the first 10.
Now
nextToken
is stored in redux, it needs to be pulled out inbuildVariablesImp
and included in the final variables that get sent to GraphQL.The text was updated successfully, but these errors were encountered: