Browse Source

fix(admin-ui): Fix Apollo cache errors when switching Channels

Fixes #496
Michael Bromley 5 years ago
parent
commit
ca2c1b6da5

+ 3 - 3
packages/admin-ui/src/lib/core/src/data/client-state/client-resolvers.ts

@@ -86,15 +86,15 @@ export const clientResolvers: ResolverDefinition = {
                 throw new Error('setActiveChannel: Could not find Channel with ID ' + args.channelId);
             }
             const permissions = activeChannel.permissions;
-            const data: { userStatus: Partial<UserStatus> } = {
+            const data: { userStatus: UserStatus } = {
                 userStatus: {
-                    __typename: 'UserStatus',
+                    ...previous.userStatus,
                     permissions,
                     activeChannelId: activeChannel.id,
                 },
             };
             cache.writeQuery({ query: GET_USER_STATUS, data });
-            return { ...previous.userStatus, ...data.userStatus };
+            return data.userStatus;
         },
         updateUserChannels: (_, args: UpdateUserChannels.Variables, { cache }): UserStatus => {
             // tslint:disable-next-line:no-non-null-assertion

+ 2 - 0
packages/admin-ui/src/lib/core/src/data/definitions/settings-definitions.ts

@@ -419,6 +419,7 @@ export const UPDATE_PAYMENT_METHOD = gql`
 
 export const GLOBAL_SETTINGS_FRAGMENT = gql`
     fragment GlobalSettings on GlobalSettings {
+        id
         availableLanguages
         trackInventory
     }
@@ -548,6 +549,7 @@ export const ALL_CUSTOM_FIELDS_FRAGMENT = gql`
 export const GET_SERVER_CONFIG = gql`
     query GetServerConfig {
         globalSettings {
+            id
             serverConfig {
                 orderProcess {
                     name