Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/development/CodeContribution/Project_Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cd fullstack-pro

e. Insall and build packages using following command. Run from the root folder of this project.
```
yarn global add lerna
yarn global add lerna@6
yarn bootstrap
```

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"db:seed": "yarn db:migrate && knex seed:run --cwd . --knexfile ./servers/backend-server/knexfile.js",
"setBranchEnv": "cross-env REPOSITORY_BRANCH=${1:-$REPOSITORY_BRANCH} PUBLISH_BRANCH=${2:-$PUBLISH_BRANCH}",
"predevpublish": "if ! git show-ref --verify --quiet refs/remotes/origin/$PUBLISH_BRANCH; then git checkout -b $PUBLISH_BRANCH && git push -u origin $PUBLISH_BRANCH; fi && git fetch origin $PUBLISH_BRANCH && git checkout $PUBLISH_BRANCH && git pull origin $PUBLISH_BRANCH && git merge -s recursive -X theirs $REPOSITORY_BRANCH -m \"merge from $REPOSITORY_BRANCH\" && yarn gitcommit && node tools/update-dependency-version.js && yarn gitcommit",
"devpublish": "lerna publish prerelease --ignore-scripts --exact",
"devpublish": "lerna publish prerelease --ignore-scripts --exact",
"postdevpublish": "git checkout $REPOSITORY_BRANCH",
"devpublish:auto": "yarn devpublish -- --yes",
"devpublish:force": "yarn devpublish -- --force-publish=* --yes",
Expand Down Expand Up @@ -120,7 +120,7 @@
},
"dependencies": {
"dataloader": "^2.1.0",
"graphql": "^15.0.0",
"graphql": "^16.8.1",
"graphql-tag": "^2.12.6"
},
"devDependencies": {
Expand Down Expand Up @@ -354,4 +354,4 @@
"cacheDirectories": [
".cache"
]
}
}
12 changes: 6 additions & 6 deletions packages-modules/counter/browser/src/generated-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,24 +247,24 @@ export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs

/** Mapping between all available schema types and the resolvers types */
export type ResolversTypes = {
Query: ResolverTypeWrapper<{}>;
Counter: ResolverTypeWrapper<Counter>;
Int: ResolverTypeWrapper<Scalars['Int']>;
ClientCounter: ResolverTypeWrapper<ClientCounter>;
Int: ResolverTypeWrapper<Scalars['Int']>;
Counter: ResolverTypeWrapper<Counter>;
Mutation: ResolverTypeWrapper<{}>;
Boolean: ResolverTypeWrapper<Scalars['Boolean']>;
Query: ResolverTypeWrapper<{}>;
Subscription: ResolverTypeWrapper<{}>;
String: ResolverTypeWrapper<Scalars['String']>;
};

/** Mapping between all available schema types and the resolvers parents */
export type ResolversParentTypes = {
Query: {};
Counter: Counter;
Int: Scalars['Int'];
ClientCounter: ClientCounter;
Int: Scalars['Int'];
Counter: Counter;
Mutation: {};
Boolean: Scalars['Boolean'];
Query: {};
Subscription: {};
String: Scalars['String'];
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ContainerModule, interfaces } from 'inversify';
import { CounterMockService, CounterMockProxyService } from '../services';
import { CounterMockProxyService, CounterMockService } from '../services';
import { TYPES } from '../constants';
import { ICounterService } from '../interfaces';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
import { DataSource, DataSourceConfig } from 'apollo-datasource';
import { Container } from 'inversify';
import type { KeyValueCache } from '@apollo/utils.keyvaluecache';
import { ApolloError } from 'apollo-server-errors';
import { InMemoryLRUCache } from 'apollo-server-caching';
// import { setupCaching } from './cache';
import { KeyValueCache } from 'apollo-server-caching';
import { IService, IContext, ICounterService } from '../interfaces';
import { ICounterService } from '../interfaces';
import { setupCaching } from './cache';
import { Counter } from '../generated-models';
import { TYPES } from '../constants';

export interface CacheOptions {
ttl?: number;
}

export class CounterDataSource extends DataSource<IService> implements ICounterService {
private context!: IContext;
type Options = {
cache: KeyValueCache;
context: {
container: Container;
};
};

private cacheCounterService: ICounterService;

constructor() {
super();
export class CounterDataSource implements ICounterService {
// eslint-disable-next-line no-useless-constructor
constructor(private readonly options: Options) {
this.initialize();
}

private cacheCounterService: ICounterService;

public counterQuery(): Counter | Promise<Counter> | PromiseLike<Counter> {
return this.cacheCounterService.counterQuery();
}
Expand All @@ -28,14 +33,14 @@ export class CounterDataSource extends DataSource<IService> implements ICounterS
return this.cacheCounterService.addCounter();
}

public initialize(config: DataSourceConfig<IContext>) {
this.context = config.context;
if (!this.context.counterMockService) {
public initialize() {
const { context, cache } = this.options;
const counterService = context.container.getNamed<ICounterService>(TYPES.CounterMockService, 'proxy');
if (!counterService) {
throw new ApolloError('Missing TextFileService in the context!');
}
try {
const cache = config.cache || new InMemoryLRUCache<string>();
this.cacheCounterService = setupCaching({ counterService: config.context.counterMockService, cache });
this.cacheCounterService = setupCaching({ counterService, cache });
} catch (err) {
throw new ApolloError(`Setting up cache in the FilesDataSource failed due to ${err}`);
}
Expand Down
22 changes: 7 additions & 15 deletions packages-modules/counter/server/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,24 @@ import { interfaces } from 'inversify';
import schema from './schema/schema.graphql';
import { ICounterService, IService } from './interfaces';
import { resolver } from './resolvers';
import { localCounterModule, externalCounterModule } from './containers';
import { externalCounterModule, localCounterModule } from './containers';
import { CounterMockMoleculerService } from './services';
import { TYPES } from './constants';
import { CounterDataSource } from './dataloader';

const counterServiceGen = (container: interfaces.Container): IService => {
return {
counterMockService: container.getNamed<ICounterService>(TYPES.CounterMockService, 'proxy'),
};
};

const dataSources: (container: interfaces.Container) => any = () => {
return {
counterCache: new CounterDataSource(),
};
};
const counterServiceGen = (container: interfaces.Container): IService => ({
counterMockService: container.getNamed<ICounterService>(TYPES.CounterMockService, 'proxy'),
});

export default new Feature({
schema,
createContainerFunc: [localCounterModule],
createResolversFunc: resolver,
createServiceFunc: counterServiceGen,
// createContextFunc: () => ({ counterMock: counterMock }), // note anything set here should be singleton.
createDataSourceFunc: dataSources,
createDataSourceFunc: (options) => ({
counterCache: new CounterDataSource(options),
}),
createHemeraContainerFunc: [externalCounterModule],
addBrokerClientServiceClass: [CounterMockMoleculerService],
addBrokerMainServiceClass: [],
});

1 change: 1 addition & 0 deletions packages-modules/counter/server/src/resolvers/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const resolver: (options: any) => IResolvers<IContext> = (options) => ({
},
Mutation: {
async addCounter(obj, { amount }, context) {
console.log(context);
await context.counterMockService.addCounter(amount);
const counter = await context.counterMockService.counterQuery();

Expand Down
10 changes: 5 additions & 5 deletions portable-devices/browser-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
"@apollo/client": "~3.7.1",
"@apollo/react-common": "^3.1.4",
"@cdm-logger/client": "^7.0.12",
"@common-stack/client-core": "0.2.33",
"@common-stack/client-react": "0.2.33",
"@common-stack/components-pro": "^0.3.1-alpha.1",
"@common-stack/core": "0.2.32",
"@common-stack/env-list-loader": "0.5.1-alpha.1",
"@common-stack/client-core": "0.5.34",
"@common-stack/client-react": "0.5.36",
"@common-stack/components-pro": "^0.5.34",
"@common-stack/core": "0.5.34",
"@common-stack/env-list-loader": "0.6.1-alpha.4",
"@workbench-stack/components": "^2.2.1-alpha.3",
"antd": "~4.24.1",
"apollo-link-debounce": "^2.1.0",
Expand Down
12 changes: 6 additions & 6 deletions portable-devices/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@
"@cdm-logger/client": "^7.0.12",
"@cdm-logger/electron": "^7.0.12",
"@cdm-logger/server": "^7.0.12",
"@common-stack/client-core": "0.5.1",
"@common-stack/client-react": "0.5.6",
"@common-stack/core": "0.5.1",
"@common-stack/server-core": "0.5.1",
"@common-stack/client-core": "0.5.34",
"@common-stack/client-react": "0.5.36",
"@common-stack/core": "0.5.34",
"@common-stack/server-core": "0.5.35",
"@sample-stack/core": "0.0.1",
"@sample-stack/counter-module-browser": "0.0.1",
"@sample-stack/counter-module-electron": "0.0.1",
Expand All @@ -68,7 +68,7 @@
"electron-updater": "4.3.9",
"envalid": "~7.2.2",
"esm": "^3.2.25",
"graphql": "^15.0.0",
"graphql": "^16.8.1",
"graphql-tag": "^2.11.0",
"graphql-ws": "^5.11.2",
"history": "^4.10.1",
Expand Down Expand Up @@ -123,4 +123,4 @@
"appName": "Fullstack-Pro",
"apiApp": "https://time-tracker-api.herokuapp.com/"
}
}
}
6 changes: 3 additions & 3 deletions portable-devices/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
"dependencies": {
"@apollo/client": "~3.7.1",
"@cdm-logger/client": "^7.0.12",
"@common-stack/client-core": "^0.5.1",
"@common-stack/client-react": "^0.5.6",
"@common-stack/core": "^0.5.1",
"@common-stack/client-core": "^0.5.34",
"@common-stack/client-react": "^0.5.36",
"@common-stack/core": "^0.5.34",
"@expo/vector-icons": "~13.0.0",
"@react-native-async-storage/async-storage": "~1.17.3",
"@react-native-community/cameraroll": "~4.1.2",
Expand Down
20 changes: 11 additions & 9 deletions servers/backend-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
"dependencies": {
"@apollo/client": "~3.7.1",
"@cdm-logger/server": "^7.0.12",
"@common-stack/core": "0.5.1",
"@common-stack/server-core": "0.5.1",
"@common-stack/store-mongo": "0.5.3",
"@common-stack/core": "0.5.34",
"@common-stack/server-core": "0.5.35",
"@common-stack/store-mongo": "0.5.34",
"@babel/runtime": "^7.20.1",
"@graphql-tools/links": "^8.3.21",
"@graphql-tools/utils": "^8.0.0",
Expand All @@ -78,15 +78,15 @@
"@sample-stack/platform-server": "0.0.1",
"@sample-stack/store": "0.0.1",
"apollo-datasource": "^3.3.1",
"apollo-datasource-rest": "^3.3.1",
"@apollo/datasource-rest": "^6.2.2",
"apollo-errors": "^1.9.0",
"apollo-server-cache-memcached": "^3.3.1",
"apollo-server-cache-redis": "^3.3.1",
"apollo-server-caching": "^3.3.0",
"apollo-server-core": "^3.11.1",
"apollo-server-errors": "^3.3.1",
"apollo-server-express": "^3.11.1",
"apollo-server-plugin-response-cache": "^3.8.1",
"@apollo/server": "^4.10.4",
"@apollo/server-plugin-response-cache": "^4.1.3",
"app-root-path": "^3.0.0",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
Expand All @@ -95,7 +95,7 @@
"envalid": "~7.2.2",
"esm": "^3.2.25",
"express": "^4.17.1",
"graphql": "^15.0.0",
"graphql": "^16.8.1",
"graphql-ws": "^5.11.2",
"graphql-bigint": "^1.0.0",
"graphql-nats-subscriptions": "^1.5.0",
Expand All @@ -117,7 +117,9 @@
"rxjs-compat": "^6.5.3",
"subscriptions-transport-ws": "^0.11.0",
"universal-cookie-express": "^4.0.1",
"ws": "^8.11.0"
"ws": "^8.11.0",
"@keyv/redis": "^2.8.4",
"@apollo/utils.keyvadapter": "^3.1.0"
},
"devDependencies": {
"cross-env": "^7.0.3",
Expand All @@ -130,4 +132,4 @@
"typescript": {
"definition": "dist/main.d.ts"
}
}
}
Loading