Skip to content

Commit

Permalink
chore: update mongoose 8
Browse files Browse the repository at this point in the history
  • Loading branch information
meabed committed Nov 1, 2023
1 parent a70b592 commit 3e8fa9c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/composeMongoose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export type GenerateResolverType<TDoc extends Document, TContext = any> = {

export type ObjectTypeComposerWithMongooseResolvers<
TDoc extends Document,
TContext = any
TContext = any,
> = ObjectTypeComposer<TDoc, TContext> & {
mongooseResolvers: GenerateResolverType<TDoc, TContext>;
};
Expand Down
35 changes: 19 additions & 16 deletions src/fieldsConverter.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint-disable no-use-before-define */

import type { Model, Schema } from 'mongoose';
import mongoose, { Document } from 'mongoose';
import type { Schema, Model } from 'mongoose';
import type {
SchemaComposer,
ObjectTypeComposer,
EnumTypeComposer,
ComposeOutputTypeDefinition,
EnumTypeComposer,
ObjectTypeComposer,
ObjectTypeComposerFieldConfigAsObjectDefinition,
SchemaComposer,
} from 'graphql-compose';
import { upperFirst } from 'graphql-compose';
import type { GraphQLScalarType } from 'graphql-compose/lib/graphql';
Expand Down Expand Up @@ -386,18 +386,21 @@ export function enumToGraphQL(
const desc = _getFieldDescription(field);
if (desc) etc.setDescription(desc);

const fields = valueList.reduce((result, value) => {
let key;
if (value === null) {
key = 'NULL';
} else if (value === '') {
key = 'EMPTY_STRING';
} else {
key = value.replace(/[^_a-zA-Z0-9]/g, '_').replace(/(^[0-9])(.*)/g, 'a_$1$2');
}
result[key] = { value };
return result;
}, {} as Record<string, { value: any }>);
const fields = valueList.reduce(
(result, value) => {
let key;
if (value === null) {
key = 'NULL';
} else if (value === '') {
key = 'EMPTY_STRING';
} else {
key = value.replace(/[^_a-zA-Z0-9]/g, '_').replace(/(^[0-9])(.*)/g, 'a_$1$2');
}
result[key] = { value };
return result;
},
{} as Record<string, { value: any }>
);
etc.setFields(fields);
});
}
Expand Down
5 changes: 2 additions & 3 deletions src/resolvers/helpers/__tests__/sort-test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { EnumTypeComposer, schemaComposer, ObjectTypeComposer } from 'graphql-compose';
import { sortHelperArgs, sortHelper, getSortTypeFromModel } from '../sort';
import { EnumTypeComposer, ObjectTypeComposer, schemaComposer } from 'graphql-compose';
import { getSortTypeFromModel, sortHelper, sortHelperArgs } from '../sort';
import { UserModel } from '../../../__mocks__/userModel';
import { convertModelToGraphQL } from '../../../fieldsConverter';
import { getIndexesFromModel } from '../../../utils';
import * as console from 'console';

describe('Resolver helper `sort` ->', () => {
let UserTC: ObjectTypeComposer<any, any>;
Expand Down

0 comments on commit 3e8fa9c

Please sign in to comment.