This video is available to students only

Module 8 Summary

This lesson is a summary of the work we've done in Module 8.0.

📝 This module's quiz can be found - here.
🗒️ Solutions for this module's quiz can be found - here.

In this module, we build the functionality to have the client be able to query for a list of listings.

Server Project#

src/graphql/typeDefs.ts#

We created a single root-level listings field that can be queried from the client to receive the information for a list of listings. The listing query field returns a collection of listings that satisfies three input arguments:

  • limit: The amount of listing objects to be returned for a single page.

  • page: The page (i.e. subset) of listing objects to be returned from the "listings" collection.

  • filter: The filter (i.e. sort) to be applied to the list of listings returned.

The ListingsFilter Enum determines the different filter values that can be applied to the listings query field. We've established two separate filter values:

  • PRICE_LOW_TO_HIGH: To sort the listings from the lowest price to the highest price.

  • PRICE_HIGH_TO_LOW: To sort the listings from the highest price to the lowest price.

src/graphql/resolvers/Listing/index.ts#

In the listingResolvers map in the src/graphql/resolvers/Listing/index.ts file, we created the root-level query listings() resolver function to find a paginated list of listings from the "listings" collection based on the argument values provided.

Start a new discussion. All notification go to the author.