This video is available to students only

Module 8 Summary

📝 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.
server/src/graphql/typeDefs.ts
  type Query {
    authUrl: String!
    user(id: ID!): User!
    listing(id: ID!): Listing!
    listings(filter: ListingsFilter!, limit: Int!, page: Int!): Listings!
  }

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