oops, fix isNc and stop loading items early!

This commit is contained in:
Emi Matchu 2020-07-02 20:06:04 -07:00
parent 3c4354d14b
commit ac12f6bb55
2 changed files with 10 additions and 11 deletions

View file

@ -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());

View file

@ -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",
],