From a7bbe8270f8daaca2357f9df2d168355d927577b Mon Sep 17 00:00:00 2001 From: "Mx. Corey Frang" Date: Thu, 30 May 2024 11:59:02 -0400 Subject: [PATCH] turbo logging trying to track down a bug --- server/graphql-context.js | 2 +- .../models/services/CollectionJobService.js | 6 ++-- server/models/services/ModelService.js | 11 ++++--- server/resolvers/collectionJobResolver.js | 2 +- server/resolvers/collectionJobsResolver.js | 2 +- server/tests/util/graphql-test-utilities.js | 30 ++++++++++++++++++- .../util/mock-automation-scheduler-server.js | 2 +- 7 files changed, 44 insertions(+), 11 deletions(-) diff --git a/server/graphql-context.js b/server/graphql-context.js index 86c6434d1..9085048da 100644 --- a/server/graphql-context.js +++ b/server/graphql-context.js @@ -10,7 +10,7 @@ const getGraphQLContext = ({ req }) => { const atLoader = AtLoader(); const browserLoader = BrowserLoader(); - + console.log('gql context', transaction?.id); return { user, atLoader, browserLoader, transaction }; }; diff --git a/server/models/services/CollectionJobService.js b/server/models/services/CollectionJobService.js index 957d48ccb..437c0d88b 100644 --- a/server/models/services/CollectionJobService.js +++ b/server/models/services/CollectionJobService.js @@ -327,7 +327,8 @@ const getCollectionJobById = async ({ browserAttributes ) ], - transaction + transaction, + logging: console.log }); }; @@ -388,7 +389,8 @@ const getCollectionJobs = async ({ ) ], pagination, - transaction + transaction, + logging: console.log }); }; diff --git a/server/models/services/ModelService.js b/server/models/services/ModelService.js index 9ebc3c037..a0af93717 100644 --- a/server/models/services/ModelService.js +++ b/server/models/services/ModelService.js @@ -39,7 +39,7 @@ const { sequelize } = require('..'); */ const getById = async ( model, - { id, attributes = [], include = [], transaction } + { id, attributes = [], include = [], transaction, logging } ) => { if (!model) throw new Error('Model not defined'); @@ -56,7 +56,8 @@ const getById = async ( where: { id }, attributes, include, - transaction + transaction, + logging }); }; @@ -113,7 +114,8 @@ const get = async ( attributes = [], include = [], pagination = {}, - transaction + transaction, + logging } ) => { if (!model) throw new Error('Model not defined'); @@ -143,7 +145,8 @@ const get = async ( order, attributes, include, // included fields being marked as 'required' will affect overall count for pagination - transaction + transaction, + logging }; // enablePagination paginated result structure and related values diff --git a/server/resolvers/collectionJobResolver.js b/server/resolvers/collectionJobResolver.js index 208bdfbb3..4c3dd43a3 100644 --- a/server/resolvers/collectionJobResolver.js +++ b/server/resolvers/collectionJobResolver.js @@ -4,7 +4,7 @@ const { const collectionJobResolver = async (_, { id }, context) => { const { transaction } = context; - + console.log('collection job resolver', transaction.id); const collectionJob = await getCollectionJobById({ id, transaction }); return collectionJob; diff --git a/server/resolvers/collectionJobsResolver.js b/server/resolvers/collectionJobsResolver.js index 1dab28b7c..4ad36e62d 100644 --- a/server/resolvers/collectionJobsResolver.js +++ b/server/resolvers/collectionJobsResolver.js @@ -4,7 +4,7 @@ const { const collectionJobsResolver = async (_, __, context) => { const { transaction } = context; - + console.log('collectionJobs', transaction?.id); const collectionJobs = await getCollectionJobs({ transaction }); return collectionJobs; diff --git a/server/tests/util/graphql-test-utilities.js b/server/tests/util/graphql-test-utilities.js index 5588b2da7..1fcd42a72 100644 --- a/server/tests/util/graphql-test-utilities.js +++ b/server/tests/util/graphql-test-utilities.js @@ -9,7 +9,33 @@ let mockReq; const server = new ApolloServer({ typeDefs, context: () => getGraphQLContext({ req: mockReq }), - resolvers + resolvers, + plugins: [ + { + async requestDidStart(arg) { + arg.logger.log = arg.logger.info; + console.log('requestDidStart', arg.context, arg.query); + return { + async didResolveSource(arg) { + console.log('didResolveSource', arg.source); + }, + async parsingDidStart(arg) { + console.log('parsing did start'); + return async (err) => console.error(err); + }, + async didResolveOperation(arg) { + console.log('didResolveOperation', require('util').inspect(arg.operation, false, 10, true)); + }, + async didEncounterErrors(arg) { + console.error('didEncounterErrors', arg); + }, + async willSendResponse(arg) { + console.log('willSendResponse', arg.response); + } + }; + } + } + ] }); const failWithErrors = errors => { @@ -61,10 +87,12 @@ const query = async ( { transaction, user = defaultUser, ...queryOptions } = {} ) => { mockReq = { session: { user }, transaction }; + console.log('setup mock req', transaction?.id, gql); const { data, errors } = await server.executeOperation({ query: gql, ...queryOptions }); + console.log(data, errors); if (errors) failWithErrors(errors); return data; }; diff --git a/server/tests/util/mock-automation-scheduler-server.js b/server/tests/util/mock-automation-scheduler-server.js index 82ced42be..b656043fa 100644 --- a/server/tests/util/mock-automation-scheduler-server.js +++ b/server/tests/util/mock-automation-scheduler-server.js @@ -136,7 +136,7 @@ const startCollectionJobSimulation = async (job, transaction) => { // stub behavior in test suite return { status: COLLECTION_JOB_STATUS.QUEUED }; } else { - await timeout(100000); + // await timeout(100000); console.log('query job', transaction.id, job.id); const data = await query( gql`