From caefc6610c05590d0aa98d4d81558e8a9b2e3d0e Mon Sep 17 00:00:00 2001 From: Matt Dunn-Rankin Date: Sun, 31 May 2020 16:00:59 -0700 Subject: [PATCH] fix bug loading species/color translation on pet --- src/server/loaders.js | 4 ++-- src/server/query-tests/Pet.test.js | 21 ++++++++++++++++++- .../__snapshots__/Pet.test.js.snap | 2 ++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/server/loaders.js b/src/server/loaders.js index 68c6919..cb8832f 100644 --- a/src/server/loaders.js +++ b/src/server/loaders.js @@ -21,7 +21,7 @@ const buildColorTranslationLoader = (db) => return colorIds.map( (colorId) => - entitiesByColorId.get(colorId) || + entitiesByColorId.get(String(colorId)) || new Error(`could not find translation for species ${colorId}`) ); }); @@ -46,7 +46,7 @@ const buildSpeciesTranslationLoader = (db) => return speciesIds.map( (speciesId) => - entitiesBySpeciesId.get(speciesId) || + entitiesBySpeciesId.get(String(speciesId)) || new Error(`could not find translation for species ${speciesId}`) ); }); diff --git a/src/server/query-tests/Pet.test.js b/src/server/query-tests/Pet.test.js index 0ebd664..1465c9b 100644 --- a/src/server/query-tests/Pet.test.js +++ b/src/server/query-tests/Pet.test.js @@ -9,9 +9,11 @@ describe("Pet", () => { petOnNeopetsDotCom(petName: "roopal27") { species { id + name } color { id + name } pose items { @@ -24,6 +26,23 @@ describe("Pet", () => { expect(res).toHaveNoErrors(); expect(res.data).toMatchSnapshot(); - expect(getDbCalls()).toMatchInlineSnapshot(`Array []`); + expect(getDbCalls()).toMatchInlineSnapshot(` + Array [ + Array [ + "SELECT * FROM species_translations + WHERE species_id IN (?) AND locale = \\"en\\"", + Array [ + 54, + ], + ], + Array [ + "SELECT * FROM color_translations + WHERE color_id IN (?) AND locale = \\"en\\"", + Array [ + 75, + ], + ], + ] + `); }); }); diff --git a/src/server/query-tests/__snapshots__/Pet.test.js.snap b/src/server/query-tests/__snapshots__/Pet.test.js.snap index 1816ff1..876fc77 100644 --- a/src/server/query-tests/__snapshots__/Pet.test.js.snap +++ b/src/server/query-tests/__snapshots__/Pet.test.js.snap @@ -5,6 +5,7 @@ Object { "petOnNeopetsDotCom": Object { "color": Object { "id": "75", + "name": "Starry", }, "items": Array [ Object { @@ -35,6 +36,7 @@ Object { "pose": "SAD_MASC", "species": Object { "id": "54", + "name": "Zafara", }, }, }