Fix GraphQL cache errors because of missing id on some queries
Also moves some queries to cache-and-network policy and improve typescript a bit Closes #387 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
f05e26e28a
commit
ae027b4e39
|
@ -23,6 +23,7 @@ export const FETCH_PERSON = gql`
|
||||||
organizedEvents {
|
organizedEvents {
|
||||||
total
|
total
|
||||||
elements {
|
elements {
|
||||||
|
id
|
||||||
uuid
|
uuid
|
||||||
title
|
title
|
||||||
beginsOn
|
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`
|
export const UPDATE_DEFAULT_ACTOR = gql`
|
||||||
mutation ChangeDefaultActor($preferredUsername: String!) {
|
mutation ChangeDefaultActor($preferredUsername: String!) {
|
||||||
changeDefaultActor(preferredUsername: $preferredUsername) {
|
changeDefaultActor(preferredUsername: $preferredUsername) {
|
||||||
|
@ -180,6 +169,7 @@ export const LOGGED_USER_PARTICIPATIONS = gql`
|
||||||
$limit: Int
|
$limit: Int
|
||||||
) {
|
) {
|
||||||
loggedUser {
|
loggedUser {
|
||||||
|
id
|
||||||
participations(
|
participations(
|
||||||
afterDatetime: $afterDateTime
|
afterDatetime: $afterDateTime
|
||||||
beforeDatetime: $beforeDateTime
|
beforeDatetime: $beforeDateTime
|
||||||
|
@ -240,6 +230,7 @@ export const LOGGED_USER_PARTICIPATIONS = gql`
|
||||||
export const LOGGED_USER_DRAFTS = gql`
|
export const LOGGED_USER_DRAFTS = gql`
|
||||||
query LoggedUserDrafts($page: Int, $limit: Int) {
|
query LoggedUserDrafts($page: Int, $limit: Int) {
|
||||||
loggedUser {
|
loggedUser {
|
||||||
|
id
|
||||||
drafts(page: $page, limit: $limit) {
|
drafts(page: $page, limit: $limit) {
|
||||||
id
|
id
|
||||||
uuid
|
uuid
|
||||||
|
@ -276,6 +267,7 @@ export const LOGGED_USER_DRAFTS = gql`
|
||||||
export const LOGGED_USER_MEMBERSHIPS = gql`
|
export const LOGGED_USER_MEMBERSHIPS = gql`
|
||||||
query LoggedUserMemberships($page: Int, $limit: Int) {
|
query LoggedUserMemberships($page: Int, $limit: Int) {
|
||||||
loggedUser {
|
loggedUser {
|
||||||
|
id
|
||||||
memberships(page: $page, limit: $limit) {
|
memberships(page: $page, limit: $limit) {
|
||||||
total
|
total
|
||||||
elements {
|
elements {
|
||||||
|
|
|
@ -13,6 +13,7 @@ export const DISCUSSION_BASIC_FIELDS_FRAGMENT = gql`
|
||||||
actor {
|
actor {
|
||||||
id
|
id
|
||||||
preferredUsername
|
preferredUsername
|
||||||
|
domain
|
||||||
avatar {
|
avatar {
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
|
@ -35,6 +36,7 @@ export const DISCUSSION_FIELDS_FOR_REPLY_FRAGMENT = gql`
|
||||||
actor {
|
actor {
|
||||||
id
|
id
|
||||||
preferredUsername
|
preferredUsername
|
||||||
|
domain
|
||||||
avatar {
|
avatar {
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
|
@ -43,10 +45,12 @@ export const DISCUSSION_FIELDS_FOR_REPLY_FRAGMENT = gql`
|
||||||
actor {
|
actor {
|
||||||
id
|
id
|
||||||
preferredUsername
|
preferredUsername
|
||||||
|
domain
|
||||||
}
|
}
|
||||||
creator {
|
creator {
|
||||||
id
|
id
|
||||||
preferredUsername
|
preferredUsername
|
||||||
|
domain
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -142,6 +142,7 @@ export const FETCH_EVENT = gql`
|
||||||
${tagsQuery}
|
${tagsQuery}
|
||||||
},
|
},
|
||||||
relatedEvents {
|
relatedEvents {
|
||||||
|
id
|
||||||
uuid,
|
uuid,
|
||||||
title,
|
title,
|
||||||
beginsOn,
|
beginsOn,
|
||||||
|
@ -150,9 +151,11 @@ export const FETCH_EVENT = gql`
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
physicalAddress {
|
physicalAddress {
|
||||||
|
id
|
||||||
description
|
description
|
||||||
},
|
},
|
||||||
organizerActor {
|
organizerActor {
|
||||||
|
id
|
||||||
avatar {
|
avatar {
|
||||||
url,
|
url,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,17 +1,5 @@
|
||||||
import gql from "graphql-tag";
|
import gql from "graphql-tag";
|
||||||
|
|
||||||
export const LOGGED_PERSON = gql`
|
|
||||||
query {
|
|
||||||
loggedPerson {
|
|
||||||
id
|
|
||||||
avatar {
|
|
||||||
url
|
|
||||||
}
|
|
||||||
preferredUsername
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const CREATE_FEED_TOKEN_ACTOR = gql`
|
export const CREATE_FEED_TOKEN_ACTOR = gql`
|
||||||
mutation createFeedToken($actor_id: ID!) {
|
mutation createFeedToken($actor_id: ID!) {
|
||||||
createFeedToken(actorId: $actor_id) {
|
createFeedToken(actorId: $actor_id) {
|
||||||
|
|
|
@ -38,6 +38,7 @@ export const LIST_GROUPS = gql`
|
||||||
}
|
}
|
||||||
organizedEvents {
|
organizedEvents {
|
||||||
elements {
|
elements {
|
||||||
|
id
|
||||||
uuid
|
uuid
|
||||||
title
|
title
|
||||||
beginsOn
|
beginsOn
|
||||||
|
|
|
@ -161,6 +161,7 @@ export const LOGS = gql`
|
||||||
actor {
|
actor {
|
||||||
id
|
id
|
||||||
preferredUsername
|
preferredUsername
|
||||||
|
domain
|
||||||
avatar {
|
avatar {
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ export const SEARCH_EVENTS = gql`
|
||||||
) {
|
) {
|
||||||
total
|
total
|
||||||
elements {
|
elements {
|
||||||
|
id
|
||||||
title
|
title
|
||||||
uuid
|
uuid
|
||||||
beginsOn
|
beginsOn
|
||||||
|
@ -44,6 +45,7 @@ export const SEARCH_GROUPS = gql`
|
||||||
searchGroups(term: $term, location: $location, radius: $radius, page: $page, limit: $limit) {
|
searchGroups(term: $term, location: $location, radius: $radius, page: $page, limit: $limit) {
|
||||||
total
|
total
|
||||||
elements {
|
elements {
|
||||||
|
id
|
||||||
avatar {
|
avatar {
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ import Subtitle from "../../components/Utils/Subtitle.vue";
|
||||||
apollo: {
|
apollo: {
|
||||||
futureParticipations: {
|
futureParticipations: {
|
||||||
query: LOGGED_USER_PARTICIPATIONS,
|
query: LOGGED_USER_PARTICIPATIONS,
|
||||||
fetchPolicy: "network-only",
|
fetchPolicy: "cache-and-network",
|
||||||
variables: {
|
variables: {
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
|
@ -122,7 +122,7 @@ import Subtitle from "../../components/Utils/Subtitle.vue";
|
||||||
},
|
},
|
||||||
drafts: {
|
drafts: {
|
||||||
query: LOGGED_USER_DRAFTS,
|
query: LOGGED_USER_DRAFTS,
|
||||||
fetchPolicy: "network-only",
|
fetchPolicy: "cache-and-network",
|
||||||
variables: {
|
variables: {
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
|
@ -131,7 +131,7 @@ import Subtitle from "../../components/Utils/Subtitle.vue";
|
||||||
},
|
},
|
||||||
pastParticipations: {
|
pastParticipations: {
|
||||||
query: LOGGED_USER_PARTICIPATIONS,
|
query: LOGGED_USER_PARTICIPATIONS,
|
||||||
fetchPolicy: "network-only",
|
fetchPolicy: "cache-and-network",
|
||||||
variables: {
|
variables: {
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
|
|
|
@ -185,12 +185,10 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { Component, Prop, Vue, Watch, Ref } from "vue-property-decorator";
|
import { Component, Prop, Vue, Watch, Ref } from "vue-property-decorator";
|
||||||
import { DataProxy } from "apollo-cache";
|
|
||||||
import {
|
import {
|
||||||
IEvent,
|
IEvent,
|
||||||
IEventParticipantStats,
|
IEventParticipantStats,
|
||||||
IParticipant,
|
IParticipant,
|
||||||
Participant,
|
|
||||||
ParticipantRole,
|
ParticipantRole,
|
||||||
} from "../../types/event.model";
|
} from "../../types/event.model";
|
||||||
import { PARTICIPANTS, UPDATE_PARTICIPANT } from "../../graphql/event";
|
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 { IPerson, usernameWithDomain } from "../../types/actor";
|
||||||
import { CONFIG } from "../../graphql/config";
|
import { CONFIG } from "../../graphql/config";
|
||||||
import { IConfig } from "../../types/config.model";
|
import { IConfig } from "../../types/config.model";
|
||||||
import { Paginate } from "../../types/paginate";
|
|
||||||
import { nl2br } from "../../utils/html";
|
import { nl2br } from "../../utils/html";
|
||||||
import { asyncForEach } from "../../utils/asyncForEach";
|
import { asyncForEach } from "../../utils/asyncForEach";
|
||||||
import RouteName from "../../router/name";
|
import RouteName from "../../router/name";
|
||||||
|
@ -214,7 +211,7 @@ const MESSAGE_ELLIPSIS_LENGTH = 130;
|
||||||
config: CONFIG,
|
config: CONFIG,
|
||||||
event: {
|
event: {
|
||||||
query: PARTICIPANTS,
|
query: PARTICIPANTS,
|
||||||
fetchPolicy: "network-only",
|
fetchPolicy: "cache-and-network",
|
||||||
variables() {
|
variables() {
|
||||||
return {
|
return {
|
||||||
uuid: this.eventId,
|
uuid: this.eventId,
|
||||||
|
@ -260,7 +257,7 @@ export default class Participants extends Vue {
|
||||||
|
|
||||||
@Ref("queueTable") readonly queueTable!: any;
|
@Ref("queueTable") readonly queueTable!: any;
|
||||||
|
|
||||||
mounted() {
|
mounted(): void {
|
||||||
const roleQuery = this.$route.query.role as string;
|
const roleQuery = this.$route.query.role as string;
|
||||||
if (Object.values(ParticipantRole).includes(roleQuery as ParticipantRole)) {
|
if (Object.values(ParticipantRole).includes(roleQuery as ParticipantRole)) {
|
||||||
this.roles = roleQuery as ParticipantRole;
|
this.roles = roleQuery as ParticipantRole;
|
||||||
|
@ -273,7 +270,7 @@ export default class Participants extends Vue {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Watch("page")
|
@Watch("page")
|
||||||
loadMoreParticipants() {
|
loadMoreParticipants(): void {
|
||||||
this.$apollo.queries.event.fetchMore({
|
this.$apollo.queries.event.fetchMore({
|
||||||
// New variables
|
// New variables
|
||||||
variables: {
|
variables: {
|
||||||
|
@ -299,9 +296,9 @@ export default class Participants extends Vue {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async acceptParticipant(participant: IParticipant) {
|
async acceptParticipant(participant: IParticipant): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const { data } = await this.$apollo.mutate({
|
await this.$apollo.mutate({
|
||||||
mutation: UPDATE_PARTICIPANT,
|
mutation: UPDATE_PARTICIPANT,
|
||||||
variables: {
|
variables: {
|
||||||
id: participant.id,
|
id: participant.id,
|
||||||
|
@ -314,9 +311,9 @@ export default class Participants extends Vue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async refuseParticipant(participant: IParticipant) {
|
async refuseParticipant(participant: IParticipant): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const { data } = await this.$apollo.mutate({
|
await this.$apollo.mutate({
|
||||||
mutation: UPDATE_PARTICIPANT,
|
mutation: UPDATE_PARTICIPANT,
|
||||||
variables: {
|
variables: {
|
||||||
id: participant.id,
|
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 asyncForEach(participants, async (participant: IParticipant) => {
|
||||||
await this.acceptParticipant(participant);
|
await this.acceptParticipant(participant);
|
||||||
});
|
});
|
||||||
this.checkedRows = [];
|
this.checkedRows = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
async refuseParticipants(participants: IParticipant[]) {
|
async refuseParticipants(participants: IParticipant[]): Promise<void> {
|
||||||
await asyncForEach(participants, async (participant: IParticipant) => {
|
await asyncForEach(participants, async (participant: IParticipant) => {
|
||||||
await this.refuseParticipant(participant);
|
await this.refuseParticipant(participant);
|
||||||
});
|
});
|
||||||
|
|
|
@ -53,7 +53,7 @@ import RouteName from "../../router/name";
|
||||||
apollo: {
|
apollo: {
|
||||||
membershipsPages: {
|
membershipsPages: {
|
||||||
query: LOGGED_USER_MEMBERSHIPS,
|
query: LOGGED_USER_MEMBERSHIPS,
|
||||||
fetchPolicy: "network-only",
|
fetchPolicy: "cache-and-network",
|
||||||
variables: {
|
variables: {
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
|
|
|
@ -163,7 +163,7 @@ import Subtitle from "../components/Utils/Subtitle.vue";
|
||||||
config: CONFIG,
|
config: CONFIG,
|
||||||
currentUserParticipations: {
|
currentUserParticipations: {
|
||||||
query: LOGGED_USER_PARTICIPATIONS,
|
query: LOGGED_USER_PARTICIPATIONS,
|
||||||
fetchPolicy: "network-only",
|
fetchPolicy: "cache-and-network",
|
||||||
variables() {
|
variables() {
|
||||||
const lastWeek = new Date();
|
const lastWeek = new Date();
|
||||||
lastWeek.setDate(new Date().getDate() - 7);
|
lastWeek.setDate(new Date().getDate() - 7);
|
||||||
|
|
Loading…
Reference in a new issue