Options
All
  • Public
  • Public/Protected
  • All
Menu

Module graphql/utils/collection

Provides utility functions to work with collections of items within a GraphQL resolver.

Index

Type aliases

CollectionOptions

CollectionOptions: { paging?: PaginationOptions; sorting?: SortingOptions }

Type declaration

PaginationOptions

PaginationOptions: { limit?: number; offset?: number }

Type declaration

  • Optional limit?: number

    Skip last N items (defaults to Number.MAX_SAFE_INTEGER).

  • Optional offset?: number

    Skip first N items (defaults to 0).

SortingOptions

SortingOptions: { key: string; reversed?: boolean }

Type declaration

  • key: string

    Key to sort against.

  • Optional reversed?: boolean

    Sort in ascending or descending order (defaults to false).

Functions

Const collection

  • Apollo resolver for to sort and paginate a collection of items.

    Parameters

    • parent: any

      Parent object containing the collection of items.

    • options: CollectionOptions

      Pagination and Sorting options.

    Returns any[]

    Slice of sorted items from a collection.

Const pagination

  • Returns a slice from a collection of items.

    Parameters

    Returns any[]

    Slice of collection.

Const sort

  • Sort a collection of items.

    Parameters

    • items: any[]

      Collection to sort.

    • options: SortingOptions

      Sorting options.

    Returns any[]

    Sorted collection.

Generated using TypeDoc