lol fix cached zone names
Ahaha I fucked up a bit! I was indexing into the array of cached zones, instead of looking up by ID. This meant that all zone names were wrong, and some search results weren't loading bc there was no zone data! I made a fix here, and also added some fallback values, so that if there's an issue in the future we can at least fall back more gracefully than the infinite-spinner case we had here.
This commit is contained in:
parent
47d22ad25c
commit
f6c228b17e
1 changed files with 5 additions and 2 deletions
|
@ -2,6 +2,7 @@ import { ApolloClient, createHttpLink, InMemoryCache } from "@apollo/client";
|
||||||
import { createPersistedQueryLink } from "apollo-link-persisted-queries";
|
import { createPersistedQueryLink } from "apollo-link-persisted-queries";
|
||||||
|
|
||||||
const cachedZones = require("./cached-data/zones.json");
|
const cachedZones = require("./cached-data/zones.json");
|
||||||
|
const cachedZonesById = new Map(cachedZones.map((z) => [z.id, z]));
|
||||||
|
|
||||||
const typePolicies = {
|
const typePolicies = {
|
||||||
Query: {
|
Query: {
|
||||||
|
@ -30,11 +31,13 @@ const typePolicies = {
|
||||||
Zone: {
|
Zone: {
|
||||||
fields: {
|
fields: {
|
||||||
depth: (depth, { readField }) => {
|
depth: (depth, { readField }) => {
|
||||||
return depth || cachedZones[readField("id")].depth;
|
const id = readField("id");
|
||||||
|
return depth || cachedZonesById.get(id)?.depth || 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
label: (label, { readField }) => {
|
label: (label, { readField }) => {
|
||||||
return label || cachedZones[readField("id")].label;
|
const id = readField("id");
|
||||||
|
return label || cachedZonesById.get(id)?.label || `Zone #${id}`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue