Skip to content

Commit

Permalink
turbo logging trying to track down a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gnarf committed May 30, 2024
1 parent 8311258 commit a7bbe82
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 11 deletions.
2 changes: 1 addition & 1 deletion server/graphql-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const getGraphQLContext = ({ req }) => {

const atLoader = AtLoader();
const browserLoader = BrowserLoader();

console.log('gql context', transaction?.id);

Check failure on line 13 in server/graphql-context.js

View workflow job for this annotation

GitHub Actions / Using NodeJS and Postgres 12

Unexpected console statement
return { user, atLoader, browserLoader, transaction };
};

Expand Down
6 changes: 4 additions & 2 deletions server/models/services/CollectionJobService.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ const getCollectionJobById = async ({
browserAttributes
)
],
transaction
transaction,
logging: console.log

Check failure on line 331 in server/models/services/CollectionJobService.js

View workflow job for this annotation

GitHub Actions / Using NodeJS and Postgres 12

Unexpected console statement
});
};

Expand Down Expand Up @@ -388,7 +389,8 @@ const getCollectionJobs = async ({
)
],
pagination,
transaction
transaction,
logging: console.log

Check failure on line 393 in server/models/services/CollectionJobService.js

View workflow job for this annotation

GitHub Actions / Using NodeJS and Postgres 12

Unexpected console statement
});
};

Expand Down
11 changes: 7 additions & 4 deletions server/models/services/ModelService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -56,7 +56,8 @@ const getById = async (
where: { id },
attributes,
include,
transaction
transaction,
logging
});
};

Expand Down Expand Up @@ -113,7 +114,8 @@ const get = async (
attributes = [],
include = [],
pagination = {},
transaction
transaction,
logging
}
) => {
if (!model) throw new Error('Model not defined');
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion server/resolvers/collectionJobResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {

const collectionJobResolver = async (_, { id }, context) => {
const { transaction } = context;

console.log('collection job resolver', transaction.id);

Check failure on line 7 in server/resolvers/collectionJobResolver.js

View workflow job for this annotation

GitHub Actions / Using NodeJS and Postgres 12

Unexpected console statement
const collectionJob = await getCollectionJobById({ id, transaction });

return collectionJob;
Expand Down
2 changes: 1 addition & 1 deletion server/resolvers/collectionJobsResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const {

const collectionJobsResolver = async (_, __, context) => {
const { transaction } = context;

console.log('collectionJobs', transaction?.id);

Check failure on line 7 in server/resolvers/collectionJobsResolver.js

View workflow job for this annotation

GitHub Actions / Using NodeJS and Postgres 12

Unexpected console statement
const collectionJobs = await getCollectionJobs({ transaction });

return collectionJobs;
Expand Down
30 changes: 29 additions & 1 deletion server/tests/util/graphql-test-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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;
};
Expand Down
2 changes: 1 addition & 1 deletion server/tests/util/mock-automation-scheduler-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down

0 comments on commit a7bbe82

Please sign in to comment.