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(
|
||||
res,
|
||||
`Error loading data for outfit ${outfitId}: ${e.message}`,
|
||||
500
|
||||
500,
|
||||
);
|
||||
}
|
||||
} else if (req.query.id) {
|
||||
|
@ -101,7 +101,7 @@ async function handle(req, res) {
|
|||
return reject(
|
||||
res,
|
||||
`Error loading data for outfit ${outfitId}: ${e.message}`,
|
||||
500
|
||||
500,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ async function loadLayerUrlsForSavedOutfit(outfitId, size) {
|
|||
|
||||
if (errors && errors.length > 0) {
|
||||
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 visibleLayers = getVisibleLayers(petAppearance, itemAppearances);
|
||||
|
||||
const visibleLayers = getVisibleLayers(petAppearance, itemAppearances);
|
||||
visibleLayers.sort((a, b) => a.depth - b.depth);
|
||||
|
||||
const imageUrls = [];
|
||||
for (const layer of visibleLayers) {
|
||||
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
|
||||
.sort((a, b) => a.depth - b.depth)
|
||||
.map((layer) => layer.imageUrl);
|
||||
return imageUrls;
|
||||
}
|
||||
|
||||
async function loadUpdatedAtForSavedOutfit(outfitId) {
|
||||
|
@ -230,7 +233,7 @@ function reject(res, message, status = 400) {
|
|||
async function handleWithBeeline(req, res) {
|
||||
beeline.withTrace(
|
||||
{ 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}) {
|
||||
"""
|
||||
NOTE: In the case of an alt style, this won't match petStateId!
|
||||
"""
|
||||
id: ID!
|
||||
|
||||
species: Species!
|
||||
color: Color!
|
||||
pose: Pose!
|
||||
|
@ -269,6 +273,12 @@ const resolvers = {
|
|||
},
|
||||
|
||||
PetAppearance: {
|
||||
id: ({ id, altStyleId }) => {
|
||||
if (altStyleId != null) {
|
||||
return `${id}-with-alt-style-${altStyleId}`;
|
||||
}
|
||||
return id;
|
||||
},
|
||||
color: async ({ id }, _, { petStateLoader, petTypeLoader }) => {
|
||||
const petState = await petStateLoader.load(id);
|
||||
const petType = await petTypeLoader.load(petState.petTypeId);
|
||||
|
|
Loading…
Reference in a new issue