Fix apollo cache issue when registrering first profile

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-08-03 14:58:42 +02:00
parent bd71dd6cf1
commit b53d8d54ef
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -129,6 +129,7 @@ import RouteName from "../../router/name";
import { changeIdentity } from "../../utils/auth";
import identityEditionMixin from "../../mixins/identityEdition";
import { ApolloCache, FetchResult } from "@apollo/client/core";
import { ActorType } from "@/types/enums";
@Component({
apollo: {
@ -180,8 +181,18 @@ export default class Register extends mixins(identityEditionMixin) {
});
if (identitiesData && localData) {
identitiesData.identities.push(localData.registerPerson);
store.writeQuery({ query: IDENTITIES, data: identitiesData });
const newPersonData = {
...localData.registerPerson,
type: ActorType.PERSON,
};
store.writeQuery({
query: IDENTITIES,
data: {
...identitiesData,
identities: [...identitiesData.identities, newPersonData],
},
});
}
}
},