Skip to content

Commit 4d37d39

Browse files
committed
Fixes on ObjectIdScalar and depreciated warning
1 parent 3f5ac7d commit 4d37d39

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

src/app.module.ts

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { ConfigService } from './config/config.service';
1717
useNewUrlParser: true,
1818
useCreateIndex: true,
1919
useFindAndModify: false,
20+
useUnifiedTopology: true,
2021
};
2122

2223
if (configService.mongoAuthEnabled) {

src/graphql.classes.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class User {
6666
updatedAt: Date;
6767
lastSeenAt: Date;
6868
enabled: boolean;
69-
_id: MongoObjectId;
69+
_id: ObjectId;
7070
}
7171

72-
export type MongoObjectId = any;
72+
export type ObjectId = any;

src/scalars/object-id.scalar.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Types } from 'mongoose';
44

55
@Scalar('ObjectId')
66
export class ObjectIdScalar {
7-
description = 'Mongo ObjectId scalar type';
7+
description = 'MongoDB ObjectId scalar type, sent as 24 byte Hex String';
88

99
parseValue(value: string) {
1010
return new Types.ObjectId(value); // value from the client

src/users/users.module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ import { UserResolver } from './users.resolvers';
66
import { DateScalar } from '../scalars/date.scalar';
77
import { ConfigModule } from '../config/config.module';
88
import { AuthModule } from '../auth/auth.module';
9+
import { ObjectIdScalar } from '../scalars/object-id.scalar';
910

1011
@Module({
1112
imports: [
1213
MongooseModule.forFeature([{ name: 'User', schema: UserSchema }]),
13-
UsersModule,
1414
ConfigModule,
1515
forwardRef(() => AuthModule),
1616
],
1717
exports: [UsersService],
1818
controllers: [],
19-
providers: [UsersService, UserResolver, DateScalar],
19+
providers: [UsersService, UserResolver, DateScalar, ObjectIdScalar],
2020
})
2121
export class UsersModule {}

src/users/users.types.graphql

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
scalar Date
2-
scalar MongoObjectId
2+
scalar ObjectId
33

44
type Query {
55
users: [User!]!
@@ -23,7 +23,7 @@ type User {
2323
updatedAt: Date!
2424
lastSeenAt: Date!
2525
enabled: Boolean!
26-
_id: MongoObjectId!
26+
_id: ObjectId!
2727
}
2828

2929
input CreateUserInput {

0 commit comments

Comments
 (0)