You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After defining a schema, I can create a provider for my module for example:
import { Injectable, Scope } from 'graphql-modules';
import { MyModel } from '../models/my-model';
@Injectable({ scope: Scope.Operation })
export class MyProvider {
public async getAll(): Promise<Foo[]> {
return await MyModel.find({}).sort({ order: 1 });
}
}
Now, this is spotless when running the app, but I cant test it because the connection timeout.
Using testkit I can instantiate modules but obviously not the entire app, so executing query in tests always fail.
I think I need to have the database at module level, not instantiated at server level to run test. I don't know how tho: What's the best way to have mongodb available across various modules without instantiating it from the server?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm building a new application with graphql-modules, this time with tests in mind (shame on me for not doing it before).
I'm using the fastify ecosystem and mongoose to connect to my MongoDB database.
Defining the entry point of the app, I instantiate mongoose like this:
After defining a schema, I can create a provider for my module for example:
Now, this is spotless when running the app, but I cant test it because the connection timeout.
Using testkit I can instantiate modules but obviously not the entire app, so executing query in tests always fail.
I think I need to have the database at module level, not instantiated at server level to run test. I don't know how tho: What's the best way to have mongodb available across various modules without instantiating it from the server?
Beta Was this translation helpful? Give feedback.
All reactions