Skip to content

Commit

Permalink
Invalidate org GQL cache when project added
Browse files Browse the repository at this point in the history
This ensures that navigating to the org will show the new project.
  • Loading branch information
rmunn committed Jul 23, 2024
1 parent 1539fbb commit 1d70785
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions frontend/src/lib/gql/gql-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
type BulkAddOrgMembersMutationVariables,
type ChangeOrgMemberRoleMutationVariables,
type AddOrgMemberMutationVariables,
type CreateProjectMutationVariables,
} from './types';
import type {Readable, Unsubscriber} from 'svelte/store';
import {derived} from 'svelte/store';
Expand All @@ -56,6 +57,11 @@ function createGqlClient(_gqlEndpoint?: string): Client {
},
updates: {
Mutation: {
createProject: (result, args: CreateProjectMutationVariables, cache, _info) => {
if (args.input.orgId) {
cache.invalidate({__typename: 'OrgById', id: args.input.orgId});
}
},
softDeleteProject: (result, args: SoftDeleteProjectMutationVariables, cache, _info) => {
cache.invalidate({__typename: 'Project', id: args.input.projectId});
},
Expand Down Expand Up @@ -87,6 +93,7 @@ function createGqlClient(_gqlEndpoint?: string): Client {
},
addProjectToOrg: (result, args: MutationAddProjectToOrgArgs, cache, _info) => {
cache.invalidate({__typename: 'Project', id: args.input.projectId});
cache.invalidate({__typename: 'OrgById', id: args.input.orgId});
}
}
}
Expand Down

0 comments on commit 1d70785

Please sign in to comment.