From 02c959a8375e656228c5663962584cdcfc5aec3f Mon Sep 17 00:00:00 2001 From: Matchu Date: Fri, 14 Aug 2020 21:12:13 -0700 Subject: [PATCH] add explicitlyBodySpecific to Item GQL for the upcoming Support feature! --- src/server/index.js | 12 ++++++++++++ src/server/query-tests/Item.test.js | 9 ++++++--- .../query-tests/__snapshots__/Item.test.js.snap | 15 +++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/server/index.js b/src/server/index.js index 7862ba4..50b39d2 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -72,6 +72,14 @@ const typeDefs = gql` # this for the Support UI; it's not very helpful for most users, because it # can be empty even if the item _has_ an auto-detected special color. manualSpecialColor: Color + + # This is set manually by Support users, when the item _seems_ to fit all + # pets the same because of its zones, but it actually doesn't - e.g., + # the Dug Up Dirt Foreground actually looks different for each body. We + # provide this for the Support UI; it's not very helpful for most users, + # because it's only used at modeling time. This value does not change how + # layer data from this API should be interpreted! + explicitlyBodySpecific: Boolean! } # Cache for 1 week (unlikely to change) @@ -275,6 +283,10 @@ const resolvers = { ? { id: item.manualSpecialColorId } : null; }, + explicitlyBodySpecific: async ({ id }, _, { itemLoader }) => { + const item = await itemLoader.load(id); + return item.explicitlyBodySpecific; + }, }, PetAppearance: { id: async ({ petStateId }, _, { petStateLoader, petTypeLoader }) => { diff --git a/src/server/query-tests/Item.test.js b/src/server/query-tests/Item.test.js index 16cea9b..be6ed62 100644 --- a/src/server/query-tests/Item.test.js +++ b/src/server/query-tests/Item.test.js @@ -6,7 +6,7 @@ describe("Item", () => { const res = await query({ query: gql` query { - items(ids: ["38913", "38911", "38912", "77530", "78104"]) { + items(ids: ["38913", "38911", "38912", "55788", "77530", "78104"]) { id name description @@ -17,6 +17,7 @@ describe("Item", () => { id name } + explicitlyBodySpecific } } `, @@ -27,21 +28,23 @@ describe("Item", () => { expect(getDbCalls()).toMatchInlineSnapshot(` Array [ Array [ - "SELECT * FROM item_translations WHERE item_id IN (?,?,?,?,?) AND locale = \\"en\\"", + "SELECT * FROM item_translations WHERE item_id IN (?,?,?,?,?,?) AND locale = \\"en\\"", Array [ "38913", "38911", "38912", + "55788", "77530", "78104", ], ], Array [ - "SELECT * FROM items WHERE id IN (?,?,?,?,?)", + "SELECT * FROM items WHERE id IN (?,?,?,?,?,?)", Array [ "38913", "38911", "38912", + "55788", "77530", "78104", ], diff --git a/src/server/query-tests/__snapshots__/Item.test.js.snap b/src/server/query-tests/__snapshots__/Item.test.js.snap index 63bf3cb..dd27282 100644 --- a/src/server/query-tests/__snapshots__/Item.test.js.snap +++ b/src/server/query-tests/__snapshots__/Item.test.js.snap @@ -83,6 +83,7 @@ Object { "items": Array [ Object { "description": "Dont leave any trace that you were there with these gloves.", + "explicitlyBodySpecific": false, "id": "38913", "isNc": false, "manualSpecialColor": null, @@ -92,6 +93,7 @@ Object { }, Object { "description": "Hide your face and hair so no one can recognise you.", + "explicitlyBodySpecific": false, "id": "38911", "isNc": false, "manualSpecialColor": null, @@ -101,6 +103,7 @@ Object { }, Object { "description": "This robe is great for being stealthy.", + "explicitlyBodySpecific": false, "id": "38912", "isNc": false, "manualSpecialColor": null, @@ -108,8 +111,19 @@ Object { "rarityIndex": 90, "thumbnailUrl": "http://images.neopets.com/items/clo_zafara_agent_robe.gif", }, + Object { + "description": "Maybe youll be discovered by some Neopets from the future and thawed out!", + "explicitlyBodySpecific": true, + "id": "55788", + "isNc": true, + "manualSpecialColor": null, + "name": "Encased in Ice", + "rarityIndex": 500, + "thumbnailUrl": "http://images.neopets.com/items/mall_petinice.gif", + }, Object { "description": "Made with the finest jewels of the sea!", + "explicitlyBodySpecific": false, "id": "77530", "isNc": true, "manualSpecialColor": Object { @@ -122,6 +136,7 @@ Object { }, Object { "description": "You truly are the number one fan of Altador Cup, and your room reflects this!", + "explicitlyBodySpecific": false, "id": "78104", "isNc": true, "manualSpecialColor": null,