This PR implements the refactoring of the readAll and readAllCursor functions in sql, sql-adapter and generic models (#142 ). Furthermore it implements the necessary changes to make pagination a required argument in the readMany functions mentioned above.
limit-offset: paginationInput and limit are required by the schema.
cbp: paginationCursorInput required by schema. Either first or last has to be given. This is checked in the resolver. Error if invalid.
resolver checks record limit, model-layer does not care
checkAndAdjustRecordLimit resolver function removed, pagination arguments used instead. If exceeded error is thrown. This is now also the case in DDMs
views/includes/record-limit-helpers.ejs removed as deprecated
in case of to_one end of an association pagination with LIMIT 1 (either limit or first) is given to the root-resolver call.
in case of one_to_one end of assoc without the foreignKey pagination with LIMIT 2 is used in the root resolver, to check if a record is associated to more than 1 record. Appropriate benignError is added.
readAll and readAllCursor refactored:
neither does need to count.
neither will use a limit, if no limit is given. (e.g. when requiring a model manually inside node)
readAllCursor validity check of paginiation args moved to resolver.
To avoid calculating the OFFSET needed for backward-pagination, instead the resulting records will be reversed post-fetching to get the desired order.
To calculate the pageInfo (hasNextPage | hasPreviousPage) the query limit (if needed) will be increased by 1 (Extra check needed for the special case someone uses pagination:{first: -1}), to get information about possible succeeding records.
Additionaly a second query with reversed Operators (<,<=,>,>=) with no ORDER and LIMIT 1 will be run to get possible preceding records.
Functionalities outsourced to helper functions.
changed error message for invalid response from remote zendro-server.
* rename `checkCountAndReduceRecordLimitHelper` to `checkCountAndReduceRecordsLimit`
### documentation
* added documentation on cursor-based-pagination argument
* added mandatory pagination argument to all places in the docu where needed
Issues
Closes #142 Closes #145
Description
This PR implements the refactoring of the
readAll
andreadAllCursor
functions in sql, sql-adapter and generic models (#142 ). Furthermore it implements the necessary changes to make pagination a required argument in the readMany functions mentioned above.related PRs
Blocks
None
Changelog
codegen
pagination is mandatory!.
paginationInput
andlimit
are required by the schema.paginationCursorInput
required by schema. Eitherfirst
orlast
has to be given. This is checked in the resolver. Error if invalid.resolver checks record limit, model-layer does not care
checkAndAdjustRecordLimit
resolver function removed, pagination arguments used instead. If exceeded error is thrown. This is now also the case in DDMsviews/includes/record-limit-helpers.ejs
removed as deprecatedto_one
end of an association pagination withLIMIT 1
(eitherlimit
orfirst
) is given to the root-resolver call.one_to_one
end of assoc without the foreignKey pagination withLIMIT 2
is used in the root resolver, to check if a record is associated to more than 1 record. AppropriatebenignError
is added.readAll
andreadAllCursor
refactored:node
)readAllCursor
validity check of paginiation args moved to resolver.OFFSET
needed for backward-pagination, instead the resulting records will be reversed post-fetching to get the desired order.hasNextPage | hasPreviousPage
) the query limit (if needed) will be increased by 1 (Extra check needed for the special case someone usespagination:{first: -1}
), to get information about possible succeeding records.ORDER
andLIMIT 1
will be run to get possible preceding records.changed error message for invalid response from remote zendro-server.
Tests
21. Limit check
" refactoredreadAllCursor
skeleton
readAll
&readAllCursor
:// Generic cursorPaginationArgumentsToGeneric(search, pagination, orderOptions, idAttribute) buildCursorBasedGenericOptions(search, order, pagination, idAttribute) buildOppositeSearchGeneric(search, order, pagination, idAttribute)