add rarityIndex, isNc to API

This commit is contained in:
Matt Dunn-Rankin 2020-05-31 15:56:40 -07:00
parent 6f5e03da9c
commit ce81543957
3 changed files with 25 additions and 4 deletions

View file

@ -63,6 +63,8 @@ const typeDefs = gql`
name: String! name: String!
description: String! description: String!
thumbnailUrl: String! thumbnailUrl: String!
rarityIndex: Int!
isNc: Boolean!
appearanceOn(speciesId: ID!, colorId: ID!): ItemAppearance appearanceOn(speciesId: ID!, colorId: ID!): ItemAppearance
} }
@ -73,7 +75,7 @@ const typeDefs = gql`
pose: Pose! pose: Pose!
genderPresentation: GenderPresentation # deprecated genderPresentation: GenderPresentation # deprecated
emotion: Emotion # deprecated emotion: Emotion # deprecated
approximateThumbnailUrl: String! approximateThumbnailUrl: String! # deprecated
layers: [AppearanceLayer!]! layers: [AppearanceLayer!]!
} }
@ -162,6 +164,7 @@ const resolvers = {
const translation = await itemTranslationLoader.load(item.id); const translation = await itemTranslationLoader.load(item.id);
return translation.description; return translation.description;
}, },
isNc: (item) => item.rarityIndex === 500 || item.rarityIndex === 0,
appearanceOn: async ( appearanceOn: async (
item, item,
{ speciesId, colorId }, { speciesId, colorId },

View file

@ -6,11 +6,13 @@ describe("Item", () => {
const res = await query({ const res = await query({
query: gql` query: gql`
query { query {
items(ids: ["38913", "38911", "38912"]) { items(ids: ["38913", "38911", "38912", "78104"]) {
id id
name name
description description
thumbnailUrl thumbnailUrl
rarityIndex
isNc
} }
} }
`, `,
@ -21,19 +23,21 @@ describe("Item", () => {
expect(getDbCalls()).toMatchInlineSnapshot(` expect(getDbCalls()).toMatchInlineSnapshot(`
Array [ Array [
Array [ Array [
"SELECT * FROM items WHERE id IN (?,?,?)", "SELECT * FROM items WHERE id IN (?,?,?,?)",
Array [ Array [
"38913", "38913",
"38911", "38911",
"38912", "38912",
"78104",
], ],
], ],
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 [ Array [
"38913", "38913",
"38911", "38911",
"38912", "38912",
"78104",
], ],
], ],
] ]

View file

@ -84,21 +84,35 @@ Object {
Object { Object {
"description": "Dont leave any trace that you were there with these gloves.", "description": "Dont leave any trace that you were there with these gloves.",
"id": "38913", "id": "38913",
"isNc": false,
"name": "Zafara Agent Gloves", "name": "Zafara Agent Gloves",
"rarityIndex": 88,
"thumbnailUrl": "http://images.neopets.com/items/clo_zafara_agent_gloves.gif", "thumbnailUrl": "http://images.neopets.com/items/clo_zafara_agent_gloves.gif",
}, },
Object { Object {
"description": "Hide your face and hair so no one can recognise you.", "description": "Hide your face and hair so no one can recognise you.",
"id": "38911", "id": "38911",
"isNc": false,
"name": "Zafara Agent Hood", "name": "Zafara Agent Hood",
"rarityIndex": 92,
"thumbnailUrl": "http://images.neopets.com/items/clo_zafara_agent_hood.gif", "thumbnailUrl": "http://images.neopets.com/items/clo_zafara_agent_hood.gif",
}, },
Object { Object {
"description": "This robe is great for being stealthy.", "description": "This robe is great for being stealthy.",
"id": "38912", "id": "38912",
"isNc": false,
"name": "Zafara Agent Robe", "name": "Zafara Agent Robe",
"rarityIndex": 90,
"thumbnailUrl": "http://images.neopets.com/items/clo_zafara_agent_robe.gif", "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",
},
], ],
} }
`; `;