Preprocess#
Helper functions and classes used by Subgrounds' own pagination strategies.
- class subgrounds.pagination.preprocess.PaginationNode(node_idx, filter_field, first_value, skip_value, filter_value, filter_value_type, key_path, inner=<factory>)#
Class representing the pagination config for a single GraphQL list field.
- filter_field#
Name of the node's filter field, e.g.: if
filter_name
istimestamp_gt
, thenfilter_field
istimestamp
- Type:
- filter_value#
Initial value of the filter argument (i.e.:
where: {filter: FILTER_VALUE}
)- Type:
Any
- filter_value_type#
Type of the filter value
- Type:
subgrounds.schema.TypeRef.T
- key_path#
Location in the list field to which this pagination node refers to in the initial query
- inner#
Nested pagination nodes (if any).
- get_vardefs()#
Returns a list of variable definitions corresponding to this pagination node's pagination arguments as well as the variable definitions related to any nested pagination nodes.
- Returns:
_description_
- Return type:
- subgrounds.pagination.preprocess.normalize(schema, document, pagination_nodes)#
Inject various graphql components to "normalize" the query for pagination.
When we paginate a query, we inject custom filtering based on the order by values. We also add GraphQL variables so that PaginationStrategy only need to change those
to perform pagination.
- The main process for normalization begins by recursively adjusting Selection nodes
within the Query tree. We only apply the following steps if the node needs to be paginated.
- > Note, these steps always check the current selection and will merge new values
and selections onto whats currently there.
Ensure id is on the Selection
Replace first argument value by $firstX
Replace skip argument value by $skipX
With the orderBy (default being id), generate where filtering arguments
These are used to filter out values when paginating
Set where filtering values (deep union / merge)