Skip to content

Commit

Permalink
Fix/iac deployment issue (#41)
Browse files Browse the repository at this point in the history
* add: transfer filter to transfer resource

- Added helper functions to generate dynamic where condition based on filter input.
- Added filter to transfer resource
- Rename query name transfers and getAllTransfers to transfer and transfers

* update: transfer summary query

* update: transfers pagination default limit

* Fix: integration test

* Fix: integration test error

* Fix: bug int cannot represent non-integer value

-Use scalar type [dateTimeFlex,BigInt]

* update: transfer query to add events fields

-Added quoteEvents field to transfer resource
-Added transferEvents field to transfer resource
-Added partyLookupEventsfield to transfer resource
-Added settlementEvents to transfer resource

* fix: transfer filter bug

transfers query was returning less no of transfers documents than it was existing

* update: transaction schema and query according to new schema

* fix: conversion state filter

* fix: transfers object conversion error when no data returned for query

* create: resolver for fxTransferEvents and fxQuoteEvents lookup

* create: settlement resource prisma model

* create: settlement resource query

* add: conversionSettlementBatchId and transferSettlementBatchId lookup to transfer

* fix: lint errors

* Update two packages with high severity: body-parser  <1.20.3 & path-to-regexp  <0.1.10
They will need to be updated.

* Fix: unit test , remove unnecessary import

* update: set transferSettlementWindowId nullable

-- set transferSettlementBatchId null when transferSettlementWindowId is null
-- set conversionSettlementBatchId null when conversionSettlementWindowId is null

* update: resolver for events lookup

* update: events resolver to use dataloaders

* add: helper function for event resolver

* remove: unused graphql schema and queries

* update: remove unused mongoclient

* refactor: dataloaders

* chore:add ts-ignore to context.ts and index.ts

* fix: lint issues

---------

Co-authored-by: Akhilesh Rawat <[email protected]>
Co-authored-by: v3-Panwar-Ujjwal <[email protected]>
Co-authored-by: nguni52 <[email protected]>
  • Loading branch information
4 people authored Dec 18, 2024
1 parent 29ef506 commit 0af349a
Show file tree
Hide file tree
Showing 23 changed files with 399 additions and 393 deletions.
9 changes: 9 additions & 0 deletions prisma/base/eventStore.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,12 @@ model ReportingData {
@@map("reporting")
}

type MetaData {
reporting Reporting
}

type Reporting {
eventType String
transactionId String
}
33 changes: 17 additions & 16 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import {
createEventStoreClient,
createTransactionClient,
createSettlementClient,
getMongoClient,
Collection,
getRequestFields,
// createCacheMiddleware,
} from './lib';
Expand Down Expand Up @@ -43,6 +41,8 @@ transaction.$on('query', async (e) => {
console.log(`${e.query} ${e.params}`);
});

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
settlement.$on('query', async (e) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand All @@ -56,7 +56,6 @@ export interface Context {
settlement: typeof settlement;
config: typeof Config;
loaders: Map<any, any>;
eventStoreMongo: Collection;
participants: string[] | undefined;
getRequestFields: typeof getRequestFields;
}
Expand All @@ -70,16 +69,18 @@ csMongoDBObj.setDefaults({
path: [Config.EVENT_STORE_DB.DATABASE],
});

export const createContext = async (ctx: any): Promise<Context> => ({
...ctx,
config: Config,
log: Logger,
eventStore,
transaction,
settlement,
loaders: new Map(),
eventStoreMongo: await getMongoClient(csMongoDBObj.toString(), 'reporting'),
transactionMongo: await getMongoClient(csMongoDBObj.toString(), 'transaction'),
settlementMongo: await getMongoClient(csMongoDBObj.toString(), 'settlement'),
getRequestFields,
});
export const createContext = async (ctx: any): Promise<Context> => {
// Perform actual context creation
const context = {
...ctx,
config: Config,
log: Logger,
eventStore,
transaction,
settlement,
loaders: new Map(),
getRequestFields,
};

return context;
};
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const loggerPlugin = {
};

const startServer = async () => {
// @ts-ignore
const server = new ApolloServer<Context>({
schema: applyMiddleware(schema, authMiddleware),
plugins: [
Expand All @@ -54,6 +55,7 @@ const startServer = async () => {
],
// healthCheckPath: '/health',
});
// @ts-ignore
await server.start();
const corsOptions = {
origin: Config.CORS_WHITELIST,
Expand Down
5 changes: 3 additions & 2 deletions src/lib/mongo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@
import { Collection, MongoClient } from 'mongodb';

let collection: Collection;
let client: MongoClient;
let client: MongoClient | null = null;

// Not being used anywhere right now
const getMongoClient = async (uri: string, collectionName: string): Promise<Collection> => {
if (!collection) {
client = new MongoClient(uri);
await client.connect();
collection = client.db().collection(collectionName);
}
// console.log('Connected to client', client)
return collection;
};

const closeMongoClientConnection = async (): Promise<void> => {
if (client) {
await client.close();
client = null;
}
};

Expand Down
21 changes: 0 additions & 21 deletions src/schema/EventStore/Event.ts

This file was deleted.

54 changes: 0 additions & 54 deletions src/schema/EventStore/Query.ts

This file was deleted.

56 changes: 0 additions & 56 deletions src/schema/Settlement/Query.ts

This file was deleted.

31 changes: 0 additions & 31 deletions src/schema/Settlement/Settlement.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/schema/Settlement/index.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/schema/Transfer/Query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Query = extendType({
args: {
transferId: nonNull(stringArg()),
},
resolve: async (parent, args, ctx): Promise<any> => {
resolve: async (_, args, ctx): Promise<any> => {
try {
// Fetch a single transaction by transferId
const transaction = await ctx.transaction.transaction.findUnique({
Expand Down Expand Up @@ -76,9 +76,9 @@ const Query = extendType({
limit: intArg(),
offset: intArg(),
},
resolve: async (parent, args, ctx): Promise<any> => {
resolve: async (_, args, ctx): Promise<any> => {
try {
const { limit = 100, offset = 0, filter = {} } = args;
const { limit = 20, offset = 0, filter = {} } = args;
// Create where condition based on filter
const whereCondition = createWhereCondition(filter);
// Fetch multiple transactions with pagination and filtering
Expand Down
Loading

0 comments on commit 0af349a

Please sign in to comment.