Add altStyleId to PetAppearance type and resolvers

This commit is contained in:
Steve C 2026-01-03 22:44:45 -05:00
parent 067da33025
commit a0a7cfba01
2 changed files with 12 additions and 3 deletions

View file

@ -33,6 +33,9 @@ const resolvers = {
return null;
}
// Neopets may omit this field entirely; treat "missing" as null.
const altStyleId = customPetData.custom_pet.alt_style ?? null;
const petType = await petTypeBySpeciesAndColorLoader.load({
speciesId: customPetData.custom_pet.species_id,
colorId: customPetData.custom_pet.color_id,
@ -53,7 +56,7 @@ const resolvers = {
.join(",");
petState = petStates.find((ps) => ps.swfAssetIds === swfAssetIdsString);
if (petState) {
return { id: petState.id };
return { id: petState.id, altStyleId };
}
// Next, look for a pet state matching the same pose. (This can happen if
@ -71,7 +74,7 @@ const resolvers = {
`because it matches pose ${pose}. Actual pet state for these ` +
`assets not found: ${swfAssetIdsString}`,
);
return { id: petState.id };
return { id: petState.id, altStyleId };
}
}
@ -85,7 +88,7 @@ const resolvers = {
`as an UNKNOWN fallback pose. Actual pet state for these ` +
`assets not found: ${swfAssetIdsString}`,
);
return { id: petState.id };
return { id: petState.id, altStyleId };
}
// If we still don't have a pet state, raise an error. (This can happen

View file

@ -78,6 +78,12 @@ const typeDefs = gql`
"""
id: ID!
"""
The ID of the alt style used to render this appearance, if any.
Null when this appearance is not using an alt style.
"""
altStyleId: ID
species: Species!
color: Color!
pose: Pose!