diff --git a/src/server/index.js b/src/server/index.js index b3482d2..4525414 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -63,6 +63,8 @@ const typeDefs = gql` name: String! description: String! thumbnailUrl: String! + rarityIndex: Int! + isNc: Boolean! appearanceOn(speciesId: ID!, colorId: ID!): ItemAppearance } @@ -73,7 +75,7 @@ const typeDefs = gql` pose: Pose! genderPresentation: GenderPresentation # deprecated emotion: Emotion # deprecated - approximateThumbnailUrl: String! + approximateThumbnailUrl: String! # deprecated layers: [AppearanceLayer!]! } @@ -162,6 +164,7 @@ const resolvers = { const translation = await itemTranslationLoader.load(item.id); return translation.description; }, + isNc: (item) => item.rarityIndex === 500 || item.rarityIndex === 0, appearanceOn: async ( item, { speciesId, colorId }, diff --git a/src/server/query-tests/Item.test.js b/src/server/query-tests/Item.test.js index fdcb6db..72cc216 100644 --- a/src/server/query-tests/Item.test.js +++ b/src/server/query-tests/Item.test.js @@ -6,11 +6,13 @@ describe("Item", () => { const res = await query({ query: gql` query { - items(ids: ["38913", "38911", "38912"]) { + items(ids: ["38913", "38911", "38912", "78104"]) { id name description thumbnailUrl + rarityIndex + isNc } } `, @@ -21,19 +23,21 @@ describe("Item", () => { expect(getDbCalls()).toMatchInlineSnapshot(` Array [ Array [ - "SELECT * FROM items WHERE id IN (?,?,?)", + "SELECT * FROM items WHERE id IN (?,?,?,?)", Array [ "38913", "38911", "38912", + "78104", ], ], 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", + "78104", ], ], ] diff --git a/src/server/query-tests/__snapshots__/Item.test.js.snap b/src/server/query-tests/__snapshots__/Item.test.js.snap index e92e633..d804ebf 100644 --- a/src/server/query-tests/__snapshots__/Item.test.js.snap +++ b/src/server/query-tests/__snapshots__/Item.test.js.snap @@ -84,21 +84,35 @@ Object { Object { "description": "Dont leave any trace that you were there with these gloves.", "id": "38913", + "isNc": false, "name": "Zafara Agent Gloves", + "rarityIndex": 88, "thumbnailUrl": "http://images.neopets.com/items/clo_zafara_agent_gloves.gif", }, Object { "description": "Hide your face and hair so no one can recognise you.", "id": "38911", + "isNc": false, "name": "Zafara Agent Hood", + "rarityIndex": 92, "thumbnailUrl": "http://images.neopets.com/items/clo_zafara_agent_hood.gif", }, Object { "description": "This robe is great for being stealthy.", "id": "38912", + "isNc": false, "name": "Zafara Agent Robe", + "rarityIndex": 90, "thumbnailUrl": "http://images.neopets.com/items/clo_zafara_agent_robe.gif", }, + Object { + "description": "You truly are the number one fan of Altador Cup, and your room reflects this!", + "id": "78104", + "isNc": true, + "name": "#1 Fan Room Background", + "rarityIndex": 500, + "thumbnailUrl": "http://images.neopets.com/items/mall_bg_numberonefanbg.gif", + }, ], } `;