Compare commits
2 commits
98eb14853c
...
0e1b1eded3
Author | SHA1 | Date | |
---|---|---|---|
0e1b1eded3 | |||
8fb561338a |
2 changed files with 22 additions and 9 deletions
|
@ -84,7 +84,7 @@ async function handle(req, res) {
|
||||||
return reject(
|
return reject(
|
||||||
res,
|
res,
|
||||||
`Error loading data for outfit ${outfitId}: ${e.message}`,
|
`Error loading data for outfit ${outfitId}: ${e.message}`,
|
||||||
500
|
500,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (req.query.id) {
|
} else if (req.query.id) {
|
||||||
|
@ -101,7 +101,7 @@ async function handle(req, res) {
|
||||||
return reject(
|
return reject(
|
||||||
res,
|
res,
|
||||||
`Error loading data for outfit ${outfitId}: ${e.message}`,
|
`Error loading data for outfit ${outfitId}: ${e.message}`,
|
||||||
500
|
500,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ async function loadLayerUrlsForSavedOutfit(outfitId, size) {
|
||||||
|
|
||||||
if (errors && errors.length > 0) {
|
if (errors && errors.length > 0) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`GraphQL Error: ${errors.map((e) => e.message).join(", ")}`
|
`GraphQL Error: ${errors.map((e) => e.message).join(", ")}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,17 +197,20 @@ async function loadLayerUrlsForSavedOutfit(outfitId, size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { petAppearance, itemAppearances } = data.outfit;
|
const { petAppearance, itemAppearances } = data.outfit;
|
||||||
const visibleLayers = getVisibleLayers(petAppearance, itemAppearances);
|
|
||||||
|
|
||||||
|
const visibleLayers = getVisibleLayers(petAppearance, itemAppearances);
|
||||||
|
visibleLayers.sort((a, b) => a.depth - b.depth);
|
||||||
|
|
||||||
|
const imageUrls = [];
|
||||||
for (const layer of visibleLayers) {
|
for (const layer of visibleLayers) {
|
||||||
if (!layer.imageUrl) {
|
if (!layer.imageUrl) {
|
||||||
throw new Error(`layer ${layer.id} has no imageUrl for size ${size}`);
|
console.warn(`layer ${layer.id} has no imageUrl for size ${size}`);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
imageUrls.push(layer.imageUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
return visibleLayers
|
return imageUrls;
|
||||||
.sort((a, b) => a.depth - b.depth)
|
|
||||||
.map((layer) => layer.imageUrl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadUpdatedAtForSavedOutfit(outfitId) {
|
async function loadUpdatedAtForSavedOutfit(outfitId) {
|
||||||
|
@ -230,7 +233,7 @@ function reject(res, message, status = 400) {
|
||||||
async function handleWithBeeline(req, res) {
|
async function handleWithBeeline(req, res) {
|
||||||
beeline.withTrace(
|
beeline.withTrace(
|
||||||
{ name: "api/outfitImage", operation_name: "api/outfitImage" },
|
{ name: "api/outfitImage", operation_name: "api/outfitImage" },
|
||||||
() => handle(req, res)
|
() => handle(req, res),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,11 @@ const typeDefs = gql`
|
||||||
}
|
}
|
||||||
|
|
||||||
type PetAppearance @cacheControl(maxAge: ${oneHour}, staleWhileRevalidate: ${oneWeek}) {
|
type PetAppearance @cacheControl(maxAge: ${oneHour}, staleWhileRevalidate: ${oneWeek}) {
|
||||||
|
"""
|
||||||
|
NOTE: In the case of an alt style, this won't match petStateId!
|
||||||
|
"""
|
||||||
id: ID!
|
id: ID!
|
||||||
|
|
||||||
species: Species!
|
species: Species!
|
||||||
color: Color!
|
color: Color!
|
||||||
pose: Pose!
|
pose: Pose!
|
||||||
|
@ -269,6 +273,12 @@ const resolvers = {
|
||||||
},
|
},
|
||||||
|
|
||||||
PetAppearance: {
|
PetAppearance: {
|
||||||
|
id: ({ id, altStyleId }) => {
|
||||||
|
if (altStyleId != null) {
|
||||||
|
return `${id}-with-alt-style-${altStyleId}`;
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
},
|
||||||
color: async ({ id }, _, { petStateLoader, petTypeLoader }) => {
|
color: async ({ id }, _, { petStateLoader, petTypeLoader }) => {
|
||||||
const petState = await petStateLoader.load(id);
|
const petState = await petStateLoader.load(id);
|
||||||
const petType = await petTypeLoader.load(petState.petTypeId);
|
const petType = await petTypeLoader.load(petState.petTypeId);
|
||||||
|
|
Loading…
Reference in a new issue