@common-stack/mobile-stack-react 6.0.6-alpha.20 → 6.0.6-alpha.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config/base-apollo-cache.js +35 -0
- package/lib/config/base-apollo-client.d.ts +3 -5
- package/lib/config/base-apollo-client.js +54 -82
- package/lib/config/base-redux-config.js +2 -12
- package/lib/config/client.service.d.ts +2 -2
- package/lib/config/client.service.js +1 -1
- package/lib/config/mobile-env-config.js +2 -2
- package/lib/config/redux-config.d.ts +14 -20
- package/lib/config/redux-config.js +18 -15
- package/lib/load-context.mobile.d.ts +2 -2
- package/lib/load-context.mobile.js +2 -2
- package/package.json +6 -4
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {InMemoryCache}from'@apollo/client/cache/index.js';// cache.ts
|
|
2
|
+
const createCache = ({ getDataIdFromObject, clientState }) => {
|
|
3
|
+
const cache = new InMemoryCache({
|
|
4
|
+
dataIdFromObject: getDataIdFromObject,
|
|
5
|
+
possibleTypes: clientState.possibleTypes,
|
|
6
|
+
typePolicies: clientState.typePolicies,
|
|
7
|
+
});
|
|
8
|
+
return cache;
|
|
9
|
+
};
|
|
10
|
+
const initializeCache = ({ cache, initialState, clientState, logger, }) => {
|
|
11
|
+
if (initialState) {
|
|
12
|
+
try {
|
|
13
|
+
cache.restore(initialState);
|
|
14
|
+
logger.debug('Cache restored with initial state');
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
logger.error(err, 'Error restoring cache');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
clientState.defaults?.forEach((x) => {
|
|
22
|
+
try {
|
|
23
|
+
if (x.type === 'query') {
|
|
24
|
+
cache.writeQuery({ query: x.query, data: x.data });
|
|
25
|
+
}
|
|
26
|
+
else if (x.type === 'fragment') {
|
|
27
|
+
cache.writeFragment({ id: x.id, fragment: x.fragment, data: x.data });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
logger.error(err, 'Error writing to cache');
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};export{createCache,initializeCache};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { ApolloClient } from '@apollo/client';
|
|
2
|
-
import { InMemoryCache } from '@apollo/client/cache';
|
|
3
|
-
import { IClientState } from '@common-stack/client-core';
|
|
1
|
+
import { ApolloClient, NormalizedCacheObject, InMemoryCache } from '@apollo/client/index.js';
|
|
4
2
|
import { CdmLogger } from '@cdm-logger/core';
|
|
5
3
|
interface IApolloClientParams {
|
|
6
4
|
initialState?: any;
|
|
7
5
|
scope: 'browser' | 'server' | 'native';
|
|
8
6
|
getDataIdFromObject: (x?: any) => string;
|
|
9
|
-
clientState:
|
|
7
|
+
clientState: any;
|
|
10
8
|
isDebug: boolean;
|
|
11
9
|
isDev: boolean;
|
|
12
10
|
isSSR: boolean;
|
|
@@ -15,7 +13,7 @@ interface IApolloClientParams {
|
|
|
15
13
|
logger: CdmLogger.ILogger;
|
|
16
14
|
}
|
|
17
15
|
export declare const createApolloClient: ({ scope, isDev, isDebug, isSSR, getDataIdFromObject, clientState, httpGraphqlURL, httpLocalGraphqlURL, initialState, logger, }: IApolloClientParams) => {
|
|
18
|
-
apolloClient: ApolloClient<
|
|
16
|
+
apolloClient: ApolloClient<NormalizedCacheObject>;
|
|
19
17
|
cache: InMemoryCache;
|
|
20
18
|
};
|
|
21
19
|
export {};
|
|
@@ -1,65 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/* eslint-disable import/no-extraneous-dependencies */
|
|
3
|
-
/* eslint-disable no-underscore-dangle */
|
|
4
|
-
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
1
|
+
import {isBoolean,merge}from'lodash-es';import {ApolloLink,ApolloClient}from'@apollo/client/index.js';import {HttpLink}from'@apollo/client/link/http/index.js';import {BatchHttpLink}from'@apollo/client/link/batch-http/index.js';import {onError}from'@apollo/client/link/error/index.js';import {GraphQLWsLink}from'@apollo/client/link/subscriptions/index.js';import {getOperationAST}from'graphql';import {invariant}from'ts-invariant';import {RetryLink}from'@apollo/client/link/retry/index.js';import {createClient}from'graphql-ws';import fetch from'cross-fetch';import {createCache,initializeCache}from'./base-apollo-cache.js';// apolloClient.ts
|
|
5
2
|
const schema = `
|
|
6
|
-
|
|
3
|
+
# Add your schema here
|
|
7
4
|
`;
|
|
8
5
|
const errorLink = onError(({ graphQLErrors, networkError }) => {
|
|
9
6
|
if (graphQLErrors) {
|
|
10
|
-
graphQLErrors.map(({ message, locations, path }) =>
|
|
11
|
-
// tslint:disable-next-line
|
|
12
|
-
invariant.warn(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`));
|
|
7
|
+
graphQLErrors.map(({ message, locations, path }) => invariant.warn(`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`));
|
|
13
8
|
}
|
|
14
9
|
if (networkError) {
|
|
15
|
-
// tslint:disable-next-line
|
|
16
10
|
invariant.warn(`[Network error]: ${networkError}`);
|
|
17
11
|
}
|
|
18
12
|
});
|
|
19
|
-
let _apolloClient;
|
|
20
|
-
let _memoryCache;
|
|
21
13
|
const createApolloClient = ({ scope, isDev, isDebug, isSSR, getDataIdFromObject, clientState, httpGraphqlURL, httpLocalGraphqlURL, initialState, logger, }) => {
|
|
14
|
+
logger.debug('Initializing Apollo Client with parameters, {%o}', {
|
|
15
|
+
scope,
|
|
16
|
+
isDev,
|
|
17
|
+
isDebug,
|
|
18
|
+
isSSR,
|
|
19
|
+
httpGraphqlURL,
|
|
20
|
+
httpLocalGraphqlURL,
|
|
21
|
+
});
|
|
22
22
|
const isBrowser = scope === 'browser';
|
|
23
23
|
const isServer = scope === 'server';
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
logger.trace('Error occured in retryLink Attempt condition', e);
|
|
40
|
-
throw e;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const retrylink = new RetryLink({
|
|
44
|
-
attempts: attemptConditions,
|
|
24
|
+
const cache = createCache({ getDataIdFromObject, clientState, logger });
|
|
25
|
+
logger.debug('Created new Apollo memory cache');
|
|
26
|
+
const retryLink = new RetryLink({
|
|
27
|
+
attempts: async (count, operation, error) => {
|
|
28
|
+
logger.debug('Retrying link attempt', { count, operation, error });
|
|
29
|
+
const promises = (clientState.retryLinkAttemptFuncs || []).map((func) => func(count, operation, error));
|
|
30
|
+
try {
|
|
31
|
+
const result = await Promise.all(promises);
|
|
32
|
+
return !!result.find((item) => item && isBoolean(item));
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
logger.error(e, 'Error occurred in retryLink attempt condition');
|
|
36
|
+
throw e;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
45
39
|
});
|
|
46
|
-
|
|
47
|
-
// return quickly if client is already created.
|
|
48
|
-
return {
|
|
49
|
-
apolloClient: _apolloClient,
|
|
50
|
-
cache: _memoryCache,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
_memoryCache = cache;
|
|
40
|
+
let link;
|
|
54
41
|
if (isBrowser) {
|
|
55
42
|
const connectionParams = async () => {
|
|
43
|
+
logger.debug('Getting WebSocket connection parameters');
|
|
56
44
|
const param = {};
|
|
57
45
|
for (const connectionParam of clientState.connectionParams) {
|
|
58
|
-
|
|
46
|
+
const result = await connectionParam();
|
|
47
|
+
merge(param, await result());
|
|
59
48
|
}
|
|
60
49
|
return param;
|
|
61
50
|
};
|
|
62
|
-
let timedOut;
|
|
63
51
|
const wsLink = new GraphQLWsLink(createClient({
|
|
64
52
|
url: httpGraphqlURL.replace(/^http/, 'ws'),
|
|
65
53
|
retryAttempts: 10,
|
|
@@ -68,29 +56,20 @@ const createApolloClient = ({ scope, isDev, isDebug, isSSR, getDataIdFromObject,
|
|
|
68
56
|
keepAlive: 10000,
|
|
69
57
|
connectionParams,
|
|
70
58
|
on: {
|
|
71
|
-
connected: (socket) =>
|
|
72
|
-
},
|
|
59
|
+
connected: (socket) => logger.debug('WebSocket connected'),
|
|
73
60
|
error: async (error) => {
|
|
74
|
-
logger.error(error, '
|
|
61
|
+
logger.error(error, 'WebSocket connection error');
|
|
75
62
|
const promises = (clientState.connectionCallbackFuncs || []).map((func) => func(wsLink, error, {}));
|
|
76
63
|
try {
|
|
77
|
-
await promises;
|
|
64
|
+
await Promise.all(promises);
|
|
78
65
|
}
|
|
79
66
|
catch (err) {
|
|
80
|
-
logger.trace('Error occurred in
|
|
67
|
+
logger.trace('Error occurred in WebSocket connection callback', err);
|
|
81
68
|
throw err;
|
|
82
69
|
}
|
|
83
70
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
logger.trace('Pinged Server');
|
|
87
|
-
},
|
|
88
|
-
pong: (received) => {
|
|
89
|
-
logger.trace('Pong received');
|
|
90
|
-
if (received)
|
|
91
|
-
clearTimeout(timedOut); // pong is received, clear connection close timeout
|
|
92
|
-
},
|
|
93
|
-
// inactivityTimeout: 10000,
|
|
71
|
+
ping: () => logger.trace('Ping server'),
|
|
72
|
+
pong: () => logger.trace('Pong received'),
|
|
94
73
|
},
|
|
95
74
|
}));
|
|
96
75
|
link = ApolloLink.split(({ query, operationName }) => {
|
|
@@ -99,49 +78,42 @@ const createApolloClient = ({ scope, isDev, isDebug, isSSR, getDataIdFromObject,
|
|
|
99
78
|
}
|
|
100
79
|
const operationAST = getOperationAST(query, operationName);
|
|
101
80
|
return !!operationAST && operationAST.operation === 'subscription';
|
|
102
|
-
}, wsLink, new HttpLink({
|
|
103
|
-
uri: httpGraphqlURL,
|
|
104
|
-
}));
|
|
81
|
+
}, wsLink, new HttpLink({ uri: httpGraphqlURL, credentials: 'include', fetch }));
|
|
105
82
|
}
|
|
106
83
|
else if (isServer) {
|
|
107
|
-
|
|
84
|
+
logger.debug('Creating BatchHttpLink for server');
|
|
85
|
+
link = new BatchHttpLink({
|
|
86
|
+
uri: httpLocalGraphqlURL,
|
|
87
|
+
fetch,
|
|
88
|
+
batchInterval: 200,
|
|
89
|
+
batchMax: 100,
|
|
90
|
+
credentials: 'include',
|
|
91
|
+
});
|
|
108
92
|
}
|
|
109
93
|
else {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const links = [errorLink, retrylink, ...(clientState.preLinks || []), link];
|
|
113
|
-
// Add apollo logger during development only
|
|
114
|
-
if (isBrowser && (isDev || isDebug)) {
|
|
115
|
-
const apolloLogger = require('apollo-link-logger');
|
|
116
|
-
links.unshift(apolloLogger.default);
|
|
94
|
+
logger.debug('Creating HttpLink for native');
|
|
95
|
+
link = new HttpLink({ uri: httpLocalGraphqlURL, fetch, credentials: 'include' });
|
|
117
96
|
}
|
|
97
|
+
const links = [errorLink, retryLink, ...(clientState.preLinks || []), link].filter(Boolean);
|
|
118
98
|
const params = {
|
|
119
99
|
queryDeduplication: true,
|
|
120
|
-
typeDefs: schema.concat(clientState.typeDefs),
|
|
100
|
+
typeDefs: schema.concat(clientState.typeDefs || ''),
|
|
121
101
|
resolvers: clientState.resolvers,
|
|
122
102
|
link: ApolloLink.from(links),
|
|
123
103
|
cache,
|
|
104
|
+
credentials: 'include',
|
|
124
105
|
connectToDevTools: isBrowser && (isDev || isDebug),
|
|
125
106
|
};
|
|
126
107
|
if (isSSR) {
|
|
127
108
|
if (isBrowser) {
|
|
128
|
-
if (initialState) {
|
|
129
|
-
cache.restore(initialState);
|
|
130
|
-
}
|
|
131
109
|
params.ssrForceFetchDelay = 100;
|
|
132
110
|
}
|
|
133
111
|
else if (isServer) {
|
|
134
112
|
params.ssrMode = true;
|
|
135
113
|
}
|
|
136
114
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
else if (x.type === 'fragment') {
|
|
143
|
-
cache.writeFragment(x);
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
return { apolloClient: _apolloClient, cache };
|
|
115
|
+
const apolloClient = new ApolloClient(params);
|
|
116
|
+
logger.debug('Created new Apollo client');
|
|
117
|
+
initializeCache({ cache, initialState, clientState, logger });
|
|
118
|
+
return { apolloClient, cache };
|
|
147
119
|
};export{createApolloClient};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {combineReducers,configureStore}from'@reduxjs/toolkit';import {persistReducer
|
|
1
|
+
import {combineReducers,configureStore}from'@reduxjs/toolkit';import {persistReducer}from'redux-persist';// version 11/12/2021
|
|
2
2
|
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
@@ -26,17 +26,7 @@ const createReduxStore = ({ scope, isDebug, isDev, reducers, rootEpic, enhancers
|
|
|
26
26
|
const store = configureStore({
|
|
27
27
|
reducer: persistedReducer,
|
|
28
28
|
middleware: (getDefaultMiddleware) => getDefaultMiddleware({
|
|
29
|
-
serializableCheck:
|
|
30
|
-
ignoredActions: [
|
|
31
|
-
FLUSH,
|
|
32
|
-
REHYDRATE,
|
|
33
|
-
PAUSE,
|
|
34
|
-
PERSIST,
|
|
35
|
-
PURGE,
|
|
36
|
-
REGISTER,
|
|
37
|
-
...(reduxConfig?.ignoredActions || []),
|
|
38
|
-
],
|
|
39
|
-
},
|
|
29
|
+
serializableCheck: false,
|
|
40
30
|
}).concat(...middlewares),
|
|
41
31
|
devTools: isDev || isDebug,
|
|
42
32
|
preloadedState: initialState,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { Container } from 'inversify';
|
|
3
|
-
import { ApolloClient } from '@apollo/client/index.js';
|
|
3
|
+
import { ApolloClient, NormalizedCacheObject } from '@apollo/client/index.js';
|
|
4
4
|
export declare const createClientContainer: (req?: any, res?: any) => {
|
|
5
5
|
container: Container;
|
|
6
|
-
apolloClient: ApolloClient<
|
|
6
|
+
apolloClient: ApolloClient<NormalizedCacheObject>;
|
|
7
7
|
serviceFunc: () => any;
|
|
8
8
|
logger: import("@cdm-logger/core/lib/interface").ILogger;
|
|
9
9
|
};
|
|
@@ -35,7 +35,7 @@ const createClientContainer = (req, res) => {
|
|
|
35
35
|
scope: typeof window !== 'undefined' ? 'browser' : 'server',
|
|
36
36
|
clientState,
|
|
37
37
|
getDataIdFromObject: (result) => features.getDataIdFromObject(result),
|
|
38
|
-
initialState:
|
|
38
|
+
initialState: undefined,
|
|
39
39
|
logger,
|
|
40
40
|
});
|
|
41
41
|
if (!container.isBound(ClientTypes.InMemoryCache)) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {cleanEnv,str}from'envalid';import {getEnvironment}from'@common-stack/core';const env = getEnvironment();
|
|
2
2
|
const config = cleanEnv(env, {
|
|
3
3
|
GA_ID: str({ devDefault: 'G-xxxxxxx' }),
|
|
4
|
-
GRAPHQL_URL: str({}),
|
|
5
|
-
LOCAL_GRAPHQL_URL: str({}),
|
|
4
|
+
GRAPHQL_URL: str({ default: env?.GRAPHQL_URL }),
|
|
5
|
+
LOCAL_GRAPHQL_URL: str({ default: env?.GRAPHQL_URL }),
|
|
6
6
|
GRAPHQL_SUBSCRIPTION_URL: str({ default: env?.GRAPHQL_URL?.replace(/^http/, 'ws') }),
|
|
7
7
|
LOG_LEVEL: str({ devDefault: 'debug' }),
|
|
8
8
|
});export{config};
|
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { EpicMiddleware } from 'redux-observable';
|
|
3
|
+
import { PersistConfig } from 'redux-persist';
|
|
4
|
+
import modules from '../modules';
|
|
2
5
|
import history from './router-history';
|
|
6
|
+
import { logger } from '../utils';
|
|
3
7
|
export { history };
|
|
4
|
-
|
|
8
|
+
interface Dependencies {
|
|
5
9
|
apolloClient: any;
|
|
6
|
-
routes:
|
|
10
|
+
routes: ReturnType<typeof modules.getConfiguredRoutes>;
|
|
7
11
|
services: any;
|
|
8
12
|
container: any;
|
|
9
|
-
logger:
|
|
10
|
-
config
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare const
|
|
15
|
-
|
|
16
|
-
storage: import("@react-native-async-storage/async-storage").AsyncStorageStatic;
|
|
17
|
-
stateReconciler: typeof autoMergeLevel2;
|
|
18
|
-
transforms: any[];
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Add any reducers required for this app dirctly in to
|
|
22
|
-
* `combineReducers`
|
|
23
|
-
*/
|
|
24
|
-
export declare const createReduxStore: (history: any, apolloClient: any, services: any, container: any) => {
|
|
25
|
-
store: import("redux").Store<any, import("redux").UnknownAction, unknown>;
|
|
13
|
+
logger: typeof logger;
|
|
14
|
+
config?: any;
|
|
15
|
+
}
|
|
16
|
+
export declare const epicMiddlewareFunc: (apolloClient: any, services: any, container: any) => EpicMiddleware<any, any, any, Dependencies>;
|
|
17
|
+
export declare const persistConfig: PersistConfig<any>;
|
|
18
|
+
export declare const createReduxStore: (apolloClient: any, services: any, container: any) => {
|
|
19
|
+
store: any;
|
|
26
20
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import storage from'@react-native-async-storage/async-storage';import autoMergeLevel2 from'redux-persist/lib/stateReconciler/autoMergeLevel2';import {createEpicMiddleware}from'redux-observable';import {REDUX_PERSIST_KEY}from'@common-stack/client-core';import {createReduxStore as createReduxStore$1}from'./base-redux-config.js';import features from'../modules.js';import {rootEpic}from'./epic-config.js';export{default as history}from'./router-history.js';import {logger}from'../utils/index.js';const epicMiddlewareFunc = (apolloClient, services, container) => createEpicMiddleware({
|
|
1
|
+
import'reflect-metadata';import storage from'@react-native-async-storage/async-storage';import autoMergeLevel2 from'redux-persist/lib/stateReconciler/autoMergeLevel2';import {createEpicMiddleware}from'redux-observable';import {REDUX_PERSIST_KEY,ClientTypes}from'@common-stack/client-core';import {createReduxStore as createReduxStore$1}from'./base-redux-config.js';import features from'../modules.js';import {rootEpic}from'./epic-config.js';export{default as history}from'./router-history.js';import {logger}from'../utils/index.js';const epicMiddlewareFunc = (apolloClient, services, container) => createEpicMiddleware({
|
|
2
2
|
dependencies: {
|
|
3
3
|
apolloClient,
|
|
4
4
|
routes: features.getConfiguredRoutes(),
|
|
@@ -6,6 +6,7 @@ import storage from'@react-native-async-storage/async-storage';import autoMergeL
|
|
|
6
6
|
container,
|
|
7
7
|
logger,
|
|
8
8
|
config: {
|
|
9
|
+
loadRoot: true,
|
|
9
10
|
isMobile: true,
|
|
10
11
|
},
|
|
11
12
|
},
|
|
@@ -16,34 +17,36 @@ const persistConfig = {
|
|
|
16
17
|
stateReconciler: autoMergeLevel2,
|
|
17
18
|
transforms: features.reduxPersistStateTransformers,
|
|
18
19
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
scope: 'browser',
|
|
27
|
-
isDebug: false,
|
|
20
|
+
const createReduxStore = (apolloClient, services, container) => {
|
|
21
|
+
let store;
|
|
22
|
+
let initialState = {};
|
|
23
|
+
let middlewares = [];
|
|
24
|
+
store = createReduxStore$1({
|
|
25
|
+
scope: typeof window !== 'undefined' ? 'browser' : 'server',
|
|
26
|
+
isDebug: true,
|
|
28
27
|
isDev: process.env.NODE_ENV === 'development',
|
|
29
|
-
initialState
|
|
28
|
+
initialState,
|
|
30
29
|
persistConfig,
|
|
31
|
-
middleware:
|
|
30
|
+
middleware: middlewares,
|
|
32
31
|
epicMiddleware: epicMiddlewareFunc(apolloClient, services, container),
|
|
33
32
|
rootEpic: rootEpic,
|
|
34
33
|
reducers: { ...features.reducers },
|
|
34
|
+
reduxConfig: features.getReduxConfig(),
|
|
35
35
|
});
|
|
36
|
-
|
|
36
|
+
logger.debug('Created new Redux store');
|
|
37
|
+
if (container.isBound(ClientTypes.ReduxStore)) {
|
|
37
38
|
container
|
|
38
|
-
.rebind(
|
|
39
|
+
.rebind(ClientTypes.ReduxStore)
|
|
39
40
|
.toDynamicValue(() => store)
|
|
40
41
|
.inRequestScope();
|
|
42
|
+
logger.debug('Rebound ReduxStore in container');
|
|
41
43
|
}
|
|
42
44
|
else {
|
|
43
45
|
container
|
|
44
|
-
.bind(
|
|
46
|
+
.bind(ClientTypes.ReduxStore)
|
|
45
47
|
.toDynamicValue(() => store)
|
|
46
48
|
.inRequestScope();
|
|
49
|
+
logger.debug('Bound ReduxStore in container');
|
|
47
50
|
}
|
|
48
51
|
return { store };
|
|
49
52
|
};export{createReduxStore,epicMiddlewareFunc,persistConfig};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
export declare const loadContext: () => {
|
|
3
3
|
modules: import("packages/common-client-react/lib").Feature;
|
|
4
|
-
store:
|
|
4
|
+
store: any;
|
|
5
5
|
container: import("inversify").Container;
|
|
6
|
-
apolloClient: import("@apollo/client").ApolloClient<
|
|
6
|
+
apolloClient: import("@apollo/client").ApolloClient<import("@apollo/client").NormalizedCacheObject>;
|
|
7
7
|
persistor: import("redux-persist").Persistor;
|
|
8
8
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import'reflect-metadata';import {persistStore}from'redux-persist';import features from'./modules.js';import {createReduxStore}from'./config/redux-config.js';import {createClientContainer}from'./config/client.service.js'
|
|
1
|
+
import'reflect-metadata';import {persistStore}from'redux-persist';import features from'./modules.js';import {createReduxStore}from'./config/redux-config.js';import {createClientContainer}from'./config/client.service.js';/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
3
3
|
const loadContext = () => {
|
|
4
4
|
const { apolloClient: client, container, serviceFunc } = createClientContainer();
|
|
5
|
-
const { store } = createReduxStore(
|
|
5
|
+
const { store } = createReduxStore(client, serviceFunc(), container);
|
|
6
6
|
const persistor = persistStore(store);
|
|
7
7
|
return {
|
|
8
8
|
modules: features,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/mobile-stack-react",
|
|
3
|
-
"version": "6.0.6-alpha.
|
|
3
|
+
"version": "6.0.6-alpha.29",
|
|
4
4
|
"description": "Client Module for mobile app",
|
|
5
5
|
"homepage": "https://github.com/cdmbase/fullstack-pro#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@apollo/client": "^3.9.0",
|
|
33
33
|
"@cdm-logger/client": "^9.0.3",
|
|
34
34
|
"@common-stack/client-core": "6.0.6-alpha.5",
|
|
35
|
-
"@common-stack/client-react": "6.0.6-alpha.
|
|
35
|
+
"@common-stack/client-react": "6.0.6-alpha.29",
|
|
36
36
|
"@common-stack/components-pro": "6.0.6-alpha.5",
|
|
37
37
|
"@common-stack/core": "6.0.6-alpha.5",
|
|
38
38
|
"@expo/vector-icons": "~13.0.0",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"expo-status-bar": "~1.6.0",
|
|
72
72
|
"expo-updates": "~0.18.19",
|
|
73
73
|
"expo-web-browser": "~12.3.2",
|
|
74
|
+
"graphql": "^16.0.0",
|
|
74
75
|
"graphql-ws": "^5.11.2",
|
|
75
76
|
"history": "^4.10.1",
|
|
76
77
|
"immutability-helper": "^3.0.1",
|
|
@@ -117,7 +118,8 @@
|
|
|
117
118
|
"rxjs-hooks": "^0.5.2",
|
|
118
119
|
"sentry-expo": "~7.1.0",
|
|
119
120
|
"subscriptions-transport-ws": "0.9.18",
|
|
120
|
-
"text-encoding-polyfill": "^0.6.7"
|
|
121
|
+
"text-encoding-polyfill": "^0.6.7",
|
|
122
|
+
"ts-invariant": "^0.10.3"
|
|
121
123
|
},
|
|
122
124
|
"peerDependencies": {
|
|
123
125
|
"@apollo/client": ">=3.0.0",
|
|
@@ -131,5 +133,5 @@
|
|
|
131
133
|
"typescript": {
|
|
132
134
|
"definition": "lib/index.d.ts"
|
|
133
135
|
},
|
|
134
|
-
"gitHead": "
|
|
136
|
+
"gitHead": "aa66043992d4bf6bf28cc00791945d04909e56c2"
|
|
135
137
|
}
|