Skip to content

Commit

Permalink
Fixes on ObjectIdScalar and depreciated warning
Browse files Browse the repository at this point in the history
  • Loading branch information
EricKit committed Oct 21, 2019
1 parent 3f5ac7d commit 4d37d39
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { ConfigService } from './config/config.service';
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true,
};

if (configService.mongoAuthEnabled) {
Expand Down
4 changes: 2 additions & 2 deletions src/graphql.classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class User {
updatedAt: Date;
lastSeenAt: Date;
enabled: boolean;
_id: MongoObjectId;
_id: ObjectId;
}

export type MongoObjectId = any;
export type ObjectId = any;
2 changes: 1 addition & 1 deletion src/scalars/object-id.scalar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Types } from 'mongoose';

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

parseValue(value: string) {
return new Types.ObjectId(value); // value from the client
Expand Down
4 changes: 2 additions & 2 deletions src/users/users.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import { UserResolver } from './users.resolvers';
import { DateScalar } from '../scalars/date.scalar';
import { ConfigModule } from '../config/config.module';
import { AuthModule } from '../auth/auth.module';
import { ObjectIdScalar } from '../scalars/object-id.scalar';

@Module({
imports: [
MongooseModule.forFeature([{ name: 'User', schema: UserSchema }]),
UsersModule,
ConfigModule,
forwardRef(() => AuthModule),
],
exports: [UsersService],
controllers: [],
providers: [UsersService, UserResolver, DateScalar],
providers: [UsersService, UserResolver, DateScalar, ObjectIdScalar],
})
export class UsersModule {}
4 changes: 2 additions & 2 deletions src/users/users.types.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
scalar Date
scalar MongoObjectId
scalar ObjectId

type Query {
users: [User!]!
Expand All @@ -23,7 +23,7 @@ type User {
updatedAt: Date!
lastSeenAt: Date!
enabled: Boolean!
_id: MongoObjectId!
_id: ObjectId!
}

input CreateUserInput {
Expand Down

0 comments on commit 4d37d39

Please sign in to comment.