We are trying to upgrade to mongoDB 5.0 and have updated mongoose to 6.0.12. (Using mongodb driver 4.1.3) In running the batch tests (jest), we are stuck on the error message “Final argument to executeLegacyOperation
must be a callback”
One example of a test that is failing:
test('should update existing items and return UPDATED status', async () => {
const {
data: { upsertBatchRole },
} = await gqlClient.fetch<{ upsertBatchRole: GQLUpsertBatchRoleOutput }>(upsertBatchRoleMutation, {
condition: {},
input: [
{
name: 'new',
id: '57b418b8d03e63b856d86538',
},
],
});
expect(upsertBatchRole).not.toBeNull();
const { status, data } = upsertBatchRole as GQLUpsertBatchRoleOutput;
const unitedData = uniteCategorizedArrays<GQLRole>({ ...data });
expect(status).toBe(ms.UPDATED);
expect(unitedData.length).toBe(1);
expect(unitedData[0]).toHaveProperty('name');
expect(unitedData[0]?.name).toBe('new');
_.forEach(unitedData, (item) => {
expect(item).toHaveProperty('id');
expect(item).toHaveProperty('name');
});
const {
data: { roleList },
} = await gqlClient.fetch(`
roleList {
name
}
`);
const orderedList = _.sortBy(roleList, 'name');
expect(orderedList).toHaveLength(1);
expect(orderedList[0].name).toBe('new');
});
Currently, graphql is at 15.5.1. Tried to upgrade graphql and got as far as 15.8.0 as higher versions produced a different error. Current node version is 14.21.3
Not sure if graphql is the issue here so looking for any ideas on how to resolve the issue. Someone also suggested it might be the mutation code that calls Mongo as the likely source of the error.