diff --git a/src/client.ts b/src/client.ts index 7676cf35..e419fc7b 100644 --- a/src/client.ts +++ b/src/client.ts @@ -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; diff --git a/src/modules/feed/queries.ts b/src/modules/feed/queries.ts index db515d1e..6eb5f2b6 100644 --- a/src/modules/feed/queries.ts +++ b/src/modules/feed/queries.ts @@ -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 @@ -62,6 +63,7 @@ export const GET_POSTS = gql` export interface GetPostsResult { teamById: { + id: number; posts: { edges: { cursor: number; @@ -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 @@ -89,6 +92,7 @@ export const GET_USERS = gql` export interface GetUsersResult { teamById: { + id: number; users: User[]; }; } @@ -96,6 +100,7 @@ export interface GetUsersResult { export const GET_GOAL_PERCENTAGE = gql` query getGoalPercentage($team_id: ID!) { teamById(id: $team_id) { + id activeKudosMeter { amount } diff --git a/src/modules/statistics/Statistics.tsx b/src/modules/statistics/Statistics.tsx index e82ddf94..7dc48de9 100644 --- a/src/modules/statistics/Statistics.tsx +++ b/src/modules/statistics/Statistics.tsx @@ -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 @@ -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 );