Closed thearabbit closed 4 years ago
For model methods, feel free to just import Model2. For data source methods (like data2.findOneById()
), I'm not sure! Haven't seen an established best practice for this. The two solutions that come to mind are:
data1
and data2
data2
as an argument to a data1
method, like in the resolver: data1.getData1('rabbit', data2)
Thanks for your reply. Excuse me, which one better for ???
1- Use Logic API
directly on the resolver (Import ....)
2- Use Logic API
from data source (Apollo Server
Of the two solutions I mentioned, I'm not sure which is better.
You might be able to use context inside the getData method in the Data1 class.
class Data1 extends DataSource {
getData(x) {
this.context.dataSources.data2.getData(x)
}
}
Oh yeah! That seems better ☺️
Very thanks again 👍
I tried to use
mongoose
How to use
Model2
in DataSource1 (Data1)?