From ac12f6bb559d38a14d3baa2cce4638290bc35559 Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 2 Jul 2020 20:06:04 -0700 Subject: [PATCH] oops, fix isNc and stop loading items early! --- src/server/index.js | 9 ++++----- src/server/query-tests/Item.test.js | 12 ++++++------ 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/server/index.js b/src/server/index.js index d53f8097..616ad48f 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -182,8 +182,8 @@ const resolvers = { return item.rarityIndex; }, isNc: async ({ id, rarityIndex }, _, { itemLoader }) => { - if (rarityIndex) return rarityIndex === 500 || rarityIndex === 0; - const item = await itemLoader.load({ id }); + if (rarityIndex != null) return rarityIndex === 500 || rarityIndex === 0; + const item = await itemLoader.load(id); return item.rarityIndex === 500 || item.rarityIndex === 0; }, appearanceOn: async ( @@ -370,9 +370,8 @@ const resolvers = { })); return allPairs; }, - items: async (_, { ids }, { itemLoader }) => { - const items = await itemLoader.loadMany(ids); - return items; + items: (_, { ids }) => { + return ids.map(id => ({ id })); }, itemSearch: async (_, { query }, { itemSearchLoader }) => { const items = await itemSearchLoader.load(query.trim()); diff --git a/src/server/query-tests/Item.test.js b/src/server/query-tests/Item.test.js index 72cc2167..7e4bdb40 100644 --- a/src/server/query-tests/Item.test.js +++ b/src/server/query-tests/Item.test.js @@ -23,7 +23,7 @@ describe("Item", () => { expect(getDbCalls()).toMatchInlineSnapshot(` Array [ Array [ - "SELECT * FROM items WHERE id IN (?,?,?,?)", + "SELECT * FROM item_translations WHERE item_id IN (?,?,?,?) AND locale = \\"en\\"", Array [ "38913", "38911", @@ -32,7 +32,7 @@ describe("Item", () => { ], ], Array [ - "SELECT * FROM item_translations WHERE item_id IN (?,?,?,?) AND locale = \\"en\\"", + "SELECT * FROM items WHERE id IN (?,?,?,?)", Array [ "38913", "38911", @@ -78,7 +78,7 @@ describe("Item", () => { expect(getDbCalls()).toMatchInlineSnapshot(` Array [ Array [ - "SELECT * FROM items WHERE id IN (?,?,?)", + "SELECT * FROM item_translations WHERE item_id IN (?,?,?) AND locale = \\"en\\"", Array [ "38912", "38911", @@ -86,7 +86,7 @@ describe("Item", () => { ], ], Array [ - "SELECT * FROM item_translations WHERE item_id IN (?,?,?) AND locale = \\"en\\"", + "SELECT * FROM items WHERE id IN (?,?,?)", Array [ "38912", "38911", @@ -173,13 +173,13 @@ describe("Item", () => { expect(getDbCalls()).toMatchInlineSnapshot(` Array [ Array [ - "SELECT * FROM items WHERE id IN (?)", + "SELECT * FROM item_translations WHERE item_id IN (?) AND locale = \\"en\\"", Array [ "42829", ], ], Array [ - "SELECT * FROM item_translations WHERE item_id IN (?) AND locale = \\"en\\"", + "SELECT * FROM items WHERE id IN (?)", Array [ "42829", ],