This is an adapter library that converts DynamoDB-style pagination to GraphQL Connection-style pagination.
import {
paginationToParams,
dataToConnection
} from 'graphql-dynamodb-connections';
const userConnections = {
type: userConnection,
args: connectionArgs,
resolve: ((_, args) => {
return promisifiedDocumentClient.scan({
TableName: 'users',
...paginationToParams(args)
})
.then(dataToConnection);
})
};
You can find more examples in the examples folder.
paginationToParams(connectionArgs)
-- adapts connection-args to DynamoDB paramsdataToConnection(data)
-- converts the data returned by DynamoDB into a Connection type