diff --git a/src/composition/apollo/discussions.ts b/src/composition/apollo/discussions.ts index c98a35978..b406682b1 100644 --- a/src/composition/apollo/discussions.ts +++ b/src/composition/apollo/discussions.ts @@ -4,6 +4,7 @@ import { useCurrentUserClient } from "./user"; import type { Ref } from "vue"; import { IGroup } from "@/types/actor"; import { GROUP_DISCUSSIONS_LIST } from "@/graphql/discussion"; +import { useCurrentActorClient } from "./actor"; export function useGroupDiscussionsList( name: string | undefined | Ref, @@ -13,6 +14,8 @@ export function useGroupDiscussionsList( } ) { const { currentUser } = useCurrentUserClient(); + const { currentActor } = useCurrentActorClient(); + const { result, error, loading, onResult, onError, refetch } = useQuery< { group: Pick< @@ -29,6 +32,12 @@ export function useGroupDiscussionsList( GROUP_DISCUSSIONS_LIST, () => ({ name: unref(name), + // To ensure the request is re-executed when the actor changes, + // we include a dummy `_actor` parameter that's ignored by the server. + // This function does not depend on the actor, the server identifies them by the token. + // So without this dummy parameter, the GraphQL call is not automatically reloaded + // when the actor changes. + _actor: currentActor?.value?.id, ...options, }), () => ({ diff --git a/src/composition/apollo/resources.ts b/src/composition/apollo/resources.ts index 1f60281a6..f28f1fd10 100644 --- a/src/composition/apollo/resources.ts +++ b/src/composition/apollo/resources.ts @@ -4,6 +4,7 @@ import { useCurrentUserClient } from "./user"; import type { Ref } from "vue"; import { IGroup } from "@/types/actor"; import { GROUP_RESOURCES_LIST } from "@/graphql/resources"; +import { useCurrentActorClient } from "./actor"; export function useGroupResourcesList( name: string | undefined | Ref, @@ -13,6 +14,8 @@ export function useGroupResourcesList( } ) { const { currentUser } = useCurrentUserClient(); + const { currentActor } = useCurrentActorClient(); + const { result, error, loading, onResult, onError, refetch } = useQuery< { group: Pick< @@ -29,6 +32,12 @@ export function useGroupResourcesList( GROUP_RESOURCES_LIST, () => ({ name: unref(name), + // To ensure the request is re-executed when the actor changes, + // we include a dummy `_actor` parameter that's ignored by the server. + // This function does not depend on the actor, the server identifies them by the token. + // So without this dummy parameter, the GraphQL call is not automatically reloaded + // when the actor changes. + _actor: currentActor?.value?.id, ...options, }), () => ({