From 1dce12e79268466b90f8fa4612a1a8512e94e7ff Mon Sep 17 00:00:00 2001 From: Matchu Date: Mon, 15 Mar 2021 08:22:11 -0700 Subject: [PATCH] Oops, fix item previews with bodyId=0! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The other day, I deleted what was apparently a load-bearing glitch row, lol 😂 We had a row in pet_types that somehow had `body_id = 0`. And I guess that was causing this query to return some species, even though that body has no species. Here, I'm adding support for the special `representsAllBodies` body's species to be null. The client seems chill with it, we weren't using that property in that situation anyway! --- src/server/types/Item.js | 7 +++++-- src/server/types/PetAppearance.js | 15 ++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/server/types/Item.js b/src/server/types/Item.js index 9eff8ae..52dbc61 100644 --- a/src/server/types/Item.js +++ b/src/server/types/Item.js @@ -457,12 +457,15 @@ const resolvers = { GROUP BY swf_assets.body_id -- We have some invalid data where the asset has a body ID that -- matches no pet type. Huh! Well, ignore those bodies! - HAVING speciesId IS NOT NULL; + HAVING speciesId IS NOT NULL OR bodyId = 0; `, [id] ); return rows.map((row) => ({ - body: { id: row.bodyId, species: { id: row.speciesId } }, + body: { + id: row.bodyId, + species: row.speciesId ? { id: row.speciesId } : null, + }, zones: row.zoneIds.split(",").map((zoneId) => ({ id: zoneId })), })); }, diff --git a/src/server/types/PetAppearance.js b/src/server/types/PetAppearance.js index b41d539..7e23704 100644 --- a/src/server/types/PetAppearance.js +++ b/src/server/types/PetAppearance.js @@ -49,14 +49,16 @@ const typeDefs = gql` type Body @cacheControl(maxAge: ${oneDay}, staleWhileRevalidate: ${oneWeek}) { id: ID! - species: Species! + + # Whether this is the special body type that represents fitting _all_ pets. + representsAllBodies: Boolean! + + # The species this body belongs to. Null if representsAllBodies is true. + species: Species # A PetAppearance that has this body. Prefers Blue (or the optional # preferredColorId), and happy poses. canonicalAppearance(preferredColorId: ID): PetAppearance - - # Whether this is the special body type that represents fitting _all_ pets. - representsAllBodies: Boolean! } type PetAppearance @cacheControl(maxAge: ${oneHour}, staleWhileRevalidate: ${oneWeek}) { @@ -188,7 +190,10 @@ const resolvers = { }, Body: { - species: ({ species }) => { + species: ({ id, species }) => { + if (id == "0") { + return null; + } if (species) { return species; }