I'm using graphQL API to make request to my Database in case MongoDB. i'm actually using Typescript and NodeJS. Since a moment, i get one error in my GraphqL Playground click to see the error message
here is my script for connection to database :
Mongo-helper.ts
export const MongodbHelper = {
client: (null as unknown) as MongoClient,
uri: (null as unknown) as string,
async connect(uri: string): Promise<void> {
this.uri = uri;
this.client = await MongoClient.connect(uri, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
},
async disconnect(): Promise<void> {
await this.client.close();
},
async getCollection(name: string): Promise<Collection> {
if (!this.client?.isConnected()) {
await this.connect(this.uri);
}
return this.client.db().collection(name);
},
};
Someone can help me please ?
question from:
https://stackoverflow.com/questions/65939723/graphql-typescript-mongodb 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…