Skip to content

Instantly share code, notes, and snippets.

@alfari16
Created September 7, 2020 04:46
Show Gist options
  • Select an option

  • Save alfari16/3fe7676f3aed8fafae4764ad849ff736 to your computer and use it in GitHub Desktop.

Select an option

Save alfari16/3fe7676f3aed8fafae4764ad849ff736 to your computer and use it in GitHub Desktop.
// resolvers.ts
// ...other codes
export default {
// ...other codes
Merchant: {
products({id: merchantId}: Merchant, {pagination: input}: {pagination: IPagination}, {loaders}: IGraphQLSchemaContext) {
const paginationCollector = {
limit: input?.limit || 10,
offset: input?.offset || 0,
sortBy: input?.sortBy || PaginationSortByEnum.ASC,
orderBy: input?.orderBy || "createdAt",
search: input?.search || ''
}
return loaders.getProductsByMerchantId(paginationCollector).load(merchantId);
},
// ...other codes
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment