update PetAppearance id to match petStateId

Previously, we were using a custom-y `id` field to help Apollo cross-reference `petAppearance` queries with the results from bulk `petAppearances` queries. Now, instead, we deprecate `petStateId`, and start using `id` to have the same stable value!

This is in anticipation of pet appearance support tools: a stable ID will make it easier to edit them, esp changing their pose (which would otherwise have changed the ID!)
This commit is contained in:
Emi Matchu 2020-08-27 21:32:22 -07:00
parent bf21716db0
commit 59ffc86481
2 changed files with 16 additions and 22 deletions

View file

@ -297,7 +297,7 @@ function PoseOption({ poseInfo, onChange, inputRef }) {
? // A lil debug output, so that we can quickly identify glitched
// PetStates and manually mark them as glitched!
window.location.hostname.includes("localhost") &&
`#${poseInfo.petStateId}`
`#${poseInfo.id}`
: "Not modeled yet"
}
position="relative"
@ -422,7 +422,6 @@ function usePoses(speciesId, colorId, selectedPose) {
fragment PetAppearanceForPosePicker on PetAppearance {
id
petStateId
bodyId
pose
...PetAppearanceForOutfitPreview

View file

@ -97,7 +97,7 @@ const typeDefs = gql`
bodyId: ID!
layers: [AppearanceLayer!]!
petStateId: ID! # Convenience field for developers
petStateId: ID! # Deprecated, an alias for id
}
type ItemAppearance {
@ -319,35 +319,30 @@ const resolvers = {
},
},
PetAppearance: {
id: async ({ petStateId }, _, { petStateLoader, petTypeLoader }) => {
const petState = await petStateLoader.load(petStateId);
const petType = await petTypeLoader.load(petState.petTypeId);
const pose = getPoseFromPetState(petState);
return `${petType.speciesId}-${petType.colorId}-${pose}`;
},
color: async ({ petStateId }, _, { petStateLoader, petTypeLoader }) => {
const petState = await petStateLoader.load(petStateId);
color: async ({ id }, _, { petStateLoader, petTypeLoader }) => {
const petState = await petStateLoader.load(id);
const petType = await petTypeLoader.load(petState.petTypeId);
return { id: petType.colorId };
},
species: async ({ petStateId }, _, { petStateLoader, petTypeLoader }) => {
const petState = await petStateLoader.load(petStateId);
species: async ({ id }, _, { petStateLoader, petTypeLoader }) => {
const petState = await petStateLoader.load(id);
const petType = await petTypeLoader.load(petState.petTypeId);
return { id: petType.speciesId };
},
bodyId: async ({ petStateId }, _, { petStateLoader, petTypeLoader }) => {
const petState = await petStateLoader.load(petStateId);
bodyId: async ({ id }, _, { petStateLoader, petTypeLoader }) => {
const petState = await petStateLoader.load(id);
const petType = await petTypeLoader.load(petState.petTypeId);
return petType.bodyId;
},
pose: async ({ petStateId }, _, { petStateLoader }) => {
const petState = await petStateLoader.load(petStateId);
pose: async ({ id }, _, { petStateLoader }) => {
const petState = await petStateLoader.load(id);
return getPoseFromPetState(petState);
},
layers: async ({ petStateId }, _, { petSwfAssetLoader }) => {
const swfAssets = await petSwfAssetLoader.load(petStateId);
layers: async ({ id }, _, { petSwfAssetLoader }) => {
const swfAssets = await petSwfAssetLoader.load(id);
return swfAssets;
},
petStateId: ({ id }) => id,
},
AppearanceLayer: {
bodyId: async ({ id }, _, { swfAssetLoader }) => {
@ -501,7 +496,7 @@ const resolvers = {
},
petAppearance: async ({ id }, _, { outfitLoader }) => {
const outfit = await outfitLoader.load(id);
return { petStateId: outfit.petStateId };
return { id: outfit.petStateId };
},
wornItems: async ({ id }, _, { itemOutfitRelationshipsLoader }) => {
const relationships = await itemOutfitRelationshipsLoader.load(id);
@ -576,7 +571,7 @@ const resolvers = {
return null;
}
return { petStateId: petState.id };
return { id: petState.id };
},
petAppearances: async (
_,
@ -589,7 +584,7 @@ const resolvers = {
});
const petStates = await petStatesForPetTypeLoader.load(petType.id);
petStates.sort((a, b) => a.id - b.id);
return petStates.map((petState) => ({ petStateId: petState.id }));
return petStates.map((petState) => ({ id: petState.id }));
},
outfit: (_, { id }) => ({ id }),
petOnNeopetsDotCom: async (_, { petName }) => {