Skip to content

Commit

Permalink
Fix InMemoryCache configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
sandercamp committed Aug 17, 2023
1 parent 0b4e1e9 commit 8308498
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
17 changes: 16 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,22 @@ const apolloClientLink = from([

const client = new ApolloClient({
link: apolloClientLink,
cache: new InMemoryCache(),
cache: new InMemoryCache({
typePolicies: {
Query: {
fields: {
teamById: {
read(_, { args, toReference }) {
return toReference({
__typename: 'Team',
id: args?.id,
});
}
}
}
}
}
}),
});

export default client;
7 changes: 6 additions & 1 deletion src/modules/feed/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface FragmentPostResult {
export const GET_POSTS = gql`
query postsConnection($team_id: ID!, $end: String) {
teamById(id: $team_id) {
id
posts(first: 10, after: $end, orderBy: "created_at desc") {
edges {
cursor
Expand All @@ -62,6 +63,7 @@ export const GET_POSTS = gql`

export interface GetPostsResult {
teamById: {
id: number;
posts: {
edges: {
cursor: number;
Expand All @@ -76,8 +78,9 @@ export interface GetPostsResult {
}

export const GET_USERS = gql`
query Users($team_id: ID!) {
query getUsers($team_id: ID!) {
teamById(id: $team_id) {
id
users {
id
name
Expand All @@ -89,13 +92,15 @@ export const GET_USERS = gql`

export interface GetUsersResult {
teamById: {
id: number;
users: User[];
};
}

export const GET_GOAL_PERCENTAGE = gql`
query getGoalPercentage($team_id: ID!) {
teamById(id: $team_id) {
id
activeKudosMeter {
amount
}
Expand Down
3 changes: 2 additions & 1 deletion src/modules/statistics/Statistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { GoalSection } from "./GoalSection";
export const GET_GOAL_PERCENTAGE = gql`
query getGoals($team_id: ID!) {
teamById(id: $team_id) {
id
activeGoals {
id
name
Expand Down Expand Up @@ -67,7 +68,7 @@ const Statistics = () => (
);
}
const currentKudos = data.teamById.activeKudosMeter.amount;
const goals = data.teamById.activeGoals.sort(
const goals = [...data.teamById.activeGoals].sort(
(goal1, goal2) => goal1.amount - goal2.amount
);

Expand Down

0 comments on commit 8308498

Please sign in to comment.