Merge branch 'fix-graphql-cache-errors' into 'master'

Fix GraphQL cache errors because of missing id on some queries

Closes #387

See merge request framasoft/mobilizon!629
This commit is contained in:
Thomas Citharel 2020-10-21 12:32:26 +02:00
commit 3864d6306a
11 changed files with 29 additions and 41 deletions

View File

@ -23,6 +23,7 @@ export const FETCH_PERSON = gql`
organizedEvents {
total
elements {
id
uuid
title
beginsOn
@ -120,18 +121,6 @@ export const LIST_PROFILES = gql`
}
`;
export const LOGGED_PERSON = gql`
query {
loggedPerson {
id
avatar {
url
}
preferredUsername
}
}
`;
export const UPDATE_DEFAULT_ACTOR = gql`
mutation ChangeDefaultActor($preferredUsername: String!) {
changeDefaultActor(preferredUsername: $preferredUsername) {
@ -180,6 +169,7 @@ export const LOGGED_USER_PARTICIPATIONS = gql`
$limit: Int
) {
loggedUser {
id
participations(
afterDatetime: $afterDateTime
beforeDatetime: $beforeDateTime
@ -240,6 +230,7 @@ export const LOGGED_USER_PARTICIPATIONS = gql`
export const LOGGED_USER_DRAFTS = gql`
query LoggedUserDrafts($page: Int, $limit: Int) {
loggedUser {
id
drafts(page: $page, limit: $limit) {
id
uuid
@ -276,6 +267,7 @@ export const LOGGED_USER_DRAFTS = gql`
export const LOGGED_USER_MEMBERSHIPS = gql`
query LoggedUserMemberships($page: Int, $limit: Int) {
loggedUser {
id
memberships(page: $page, limit: $limit) {
total
elements {

View File

@ -13,6 +13,7 @@ export const DISCUSSION_BASIC_FIELDS_FRAGMENT = gql`
actor {
id
preferredUsername
domain
avatar {
url
}
@ -35,6 +36,7 @@ export const DISCUSSION_FIELDS_FOR_REPLY_FRAGMENT = gql`
actor {
id
preferredUsername
domain
avatar {
url
}
@ -43,10 +45,12 @@ export const DISCUSSION_FIELDS_FOR_REPLY_FRAGMENT = gql`
actor {
id
preferredUsername
domain
}
creator {
id
preferredUsername
domain
}
}
`;

View File

@ -142,6 +142,7 @@ export const FETCH_EVENT = gql`
${tagsQuery}
},
relatedEvents {
id
uuid,
title,
beginsOn,
@ -150,9 +151,11 @@ export const FETCH_EVENT = gql`
url
}
physicalAddress {
id
description
},
organizerActor {
id
avatar {
url,
},

View File

@ -1,17 +1,5 @@
import gql from "graphql-tag";
export const LOGGED_PERSON = gql`
query {
loggedPerson {
id
avatar {
url
}
preferredUsername
}
}
`;
export const CREATE_FEED_TOKEN_ACTOR = gql`
mutation createFeedToken($actor_id: ID!) {
createFeedToken(actorId: $actor_id) {

View File

@ -38,6 +38,7 @@ export const LIST_GROUPS = gql`
}
organizedEvents {
elements {
id
uuid
title
beginsOn

View File

@ -161,6 +161,7 @@ export const LOGS = gql`
actor {
id
preferredUsername
domain
avatar {
url
}

View File

@ -23,6 +23,7 @@ export const SEARCH_EVENTS = gql`
) {
total
elements {
id
title
uuid
beginsOn
@ -44,6 +45,7 @@ export const SEARCH_GROUPS = gql`
searchGroups(term: $term, location: $location, radius: $radius, page: $page, limit: $limit) {
total
elements {
id
avatar {
url
}

View File

@ -109,7 +109,7 @@ import Subtitle from "../../components/Utils/Subtitle.vue";
apollo: {
futureParticipations: {
query: LOGGED_USER_PARTICIPATIONS,
fetchPolicy: "network-only",
fetchPolicy: "cache-and-network",
variables: {
page: 1,
limit: 10,
@ -122,7 +122,7 @@ import Subtitle from "../../components/Utils/Subtitle.vue";
},
drafts: {
query: LOGGED_USER_DRAFTS,
fetchPolicy: "network-only",
fetchPolicy: "cache-and-network",
variables: {
page: 1,
limit: 10,
@ -131,7 +131,7 @@ import Subtitle from "../../components/Utils/Subtitle.vue";
},
pastParticipations: {
query: LOGGED_USER_PARTICIPATIONS,
fetchPolicy: "network-only",
fetchPolicy: "cache-and-network",
variables: {
page: 1,
limit: 10,

View File

@ -185,12 +185,10 @@
<script lang="ts">
import { Component, Prop, Vue, Watch, Ref } from "vue-property-decorator";
import { DataProxy } from "apollo-cache";
import {
IEvent,
IEventParticipantStats,
IParticipant,
Participant,
ParticipantRole,
} from "../../types/event.model";
import { PARTICIPANTS, UPDATE_PARTICIPANT } from "../../graphql/event";
@ -198,7 +196,6 @@ import { CURRENT_ACTOR_CLIENT } from "../../graphql/actor";
import { IPerson, usernameWithDomain } from "../../types/actor";
import { CONFIG } from "../../graphql/config";
import { IConfig } from "../../types/config.model";
import { Paginate } from "../../types/paginate";
import { nl2br } from "../../utils/html";
import { asyncForEach } from "../../utils/asyncForEach";
import RouteName from "../../router/name";
@ -214,7 +211,7 @@ const MESSAGE_ELLIPSIS_LENGTH = 130;
config: CONFIG,
event: {
query: PARTICIPANTS,
fetchPolicy: "network-only",
fetchPolicy: "cache-and-network",
variables() {
return {
uuid: this.eventId,
@ -260,7 +257,7 @@ export default class Participants extends Vue {
@Ref("queueTable") readonly queueTable!: any;
mounted() {
mounted(): void {
const roleQuery = this.$route.query.role as string;
if (Object.values(ParticipantRole).includes(roleQuery as ParticipantRole)) {
this.roles = roleQuery as ParticipantRole;
@ -273,7 +270,7 @@ export default class Participants extends Vue {
}
@Watch("page")
loadMoreParticipants() {
loadMoreParticipants(): void {
this.$apollo.queries.event.fetchMore({
// New variables
variables: {
@ -299,9 +296,9 @@ export default class Participants extends Vue {
});
}
async acceptParticipant(participant: IParticipant) {
async acceptParticipant(participant: IParticipant): Promise<void> {
try {
const { data } = await this.$apollo.mutate({
await this.$apollo.mutate({
mutation: UPDATE_PARTICIPANT,
variables: {
id: participant.id,
@ -314,9 +311,9 @@ export default class Participants extends Vue {
}
}
async refuseParticipant(participant: IParticipant) {
async refuseParticipant(participant: IParticipant): Promise<void> {
try {
const { data } = await this.$apollo.mutate({
await this.$apollo.mutate({
mutation: UPDATE_PARTICIPANT,
variables: {
id: participant.id,
@ -329,14 +326,14 @@ export default class Participants extends Vue {
}
}
async acceptParticipants(participants: IParticipant[]) {
async acceptParticipants(participants: IParticipant[]): Promise<void> {
await asyncForEach(participants, async (participant: IParticipant) => {
await this.acceptParticipant(participant);
});
this.checkedRows = [];
}
async refuseParticipants(participants: IParticipant[]) {
async refuseParticipants(participants: IParticipant[]): Promise<void> {
await asyncForEach(participants, async (participant: IParticipant) => {
await this.refuseParticipant(participant);
});

View File

@ -53,7 +53,7 @@ import RouteName from "../../router/name";
apollo: {
membershipsPages: {
query: LOGGED_USER_MEMBERSHIPS,
fetchPolicy: "network-only",
fetchPolicy: "cache-and-network",
variables: {
page: 1,
limit: 10,

View File

@ -163,7 +163,7 @@ import Subtitle from "../components/Utils/Subtitle.vue";
config: CONFIG,
currentUserParticipations: {
query: LOGGED_USER_PARTICIPATIONS,
fetchPolicy: "network-only",
fetchPolicy: "cache-and-network",
variables() {
const lastWeek = new Date();
lastWeek.setDate(new Date().getDate() - 7);