From 3537ef9a6f0387ac8bbe8c31e8c83546f1f3a3f0 Mon Sep 17 00:00:00 2001 From: Matchu Date: Mon, 21 Jun 2021 10:37:54 -0700 Subject: [PATCH] Use itemSearchV2 in wardrobe too That's the last itemSearch call site! I'll probably keep it up for other clients for a while though, esp since it doesn't depend on any additional loaders or anything, it's pretty small overall Updated the comments to reflect this, and also remembered to make them real docstrings lol! --- src/app/WardrobePage/SearchPanel.js | 6 ++-- src/server/types/Item.js | 44 ++++++++++++++++++----------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/app/WardrobePage/SearchPanel.js b/src/app/WardrobePage/SearchPanel.js index 2b8f3f0..184d916 100644 --- a/src/app/WardrobePage/SearchPanel.js +++ b/src/app/WardrobePage/SearchPanel.js @@ -295,20 +295,18 @@ function useSearchResults(query, outfitState) { $colorId: ID! $offset: Int! ) { - itemSearch( + itemSearch: itemSearchV2( query: $query fitsPet: $fitsPet itemKind: $itemKind currentUserOwnsOrWants: $currentUserOwnsOrWants zoneIds: $zoneIds - offset: $offset - limit: 50 ) { query zones { id } - items { + items(offset: $offset, limit: 50) { # TODO: De-dupe this from useOutfitState? id name diff --git a/src/server/types/Item.js b/src/server/types/Item.js index 25d35af..5034626 100644 --- a/src/server/types/Item.js +++ b/src/server/types/Item.js @@ -194,16 +194,20 @@ const typeDefs = gql` item(id: ID!): Item items(ids: [ID!]!): [Item!]! - # Find items by name. Exact match, except for some tweaks, like - # case-insensitivity and trimming extra whitespace. Null if not found. - # - # NOTE: These aren't used in DTI at time of writing; they're a courtesy API - # for the /r/Neopets Discord bot's outfit preview command! + """ + Find items by name. Exact match, except for some tweaks, like + case-insensitivity and trimming extra whitespace. Null if not found. + + NOTE: These aren't used in DTI at time of writing; they're a courtesy API + for the /r/Neopets Discord bot's outfit preview command! + """ itemByName(name: String!): Item itemsByName(names: [String!]!): [Item]! - # Search for items with fuzzy matching. - # Deprecated: Prefer itemSearchV2 instead! (A lot is not yet ported tho!) + """ + Search for items with fuzzy matching. + Deprecated: Prefer itemSearchV2 instead! + """ itemSearch( query: String! fitsPet: FitsPetSearchFilter @@ -214,7 +218,9 @@ const typeDefs = gql` limit: Int ): ItemSearchResult! - # Search for items with fuzzy matching. + """ + Search for items with fuzzy matching. + """ itemSearchV2( query: String! fitsPet: FitsPetSearchFilter @@ -223,8 +229,10 @@ const typeDefs = gql` zoneIds: [ID!] ): ItemSearchResultV2! - # Deprecated: an alias for itemSearch, but with speciesId and colorId - # required, serving the same purpose as fitsPet in itemSearch. + """ + Deprecated: an alias for itemSearch, but with speciesId and colorId + required, serving the same purpose as fitsPet in itemSearch. + """ itemSearchToFit( query: String! itemKind: ItemKindSearchFilter @@ -236,14 +244,18 @@ const typeDefs = gql` limit: Int ): ItemSearchResult! - # Get the 20 items most recently added to our database. + """ + Get the 20 items most recently added to our database. + """ newestItems: [Item!]! @cacheControl(maxAge: ${oneHour}, staleWhileRevalidate: ${oneDay}) - # Get items that need models for the given color. - # - # NOTE: Most color IDs won't be accepted here. Either pass the ID of a - # major special color like Baby (#6), or leave it blank for standard - # bodies like Blue, Green, Red, etc. + """ + Get items that need models for the given color. + + NOTE: Most color IDs won't be accepted here. Either pass the ID of a + major special color like Baby (#6), or leave it blank for standard + bodies like Blue, Green, Red, etc. + """ itemsThatNeedModels(colorId: ID): [Item!]! @cacheControl(maxAge: 1, staleWhileRevalidate: ${oneHour}) }