Stylianos Gakis
03/07/2023, 11:05 AM.httpServerUrl()
for each ApolloClient.Builder() right? And also make sure I use the right client for the right queries?
Basically the story is that the company is starting to get into having a supergraph, but we have 1 service right now which doesn’t go through there, so we want to also depend on this supergraph now and while slowly everything is moved in there we gotta deal with both those services.
Anything I am missing to make my life easier for this?bod
03/07/2023, 11:08 AMI still then need to make a new ApolloClient for each one of them, where I pass a different✅ Right! (technically you could have several services that point to the same server, but not sure what use-case that would be)for each ApolloClient.Builder() right?.httpServerUrl()
Stylianos Gakis
03/07/2023, 11:12 AMApolloClient
, so I guess gotta make our own types on top of these so that DI knows which one to provide for each case, and we need to be careful to call the right thing in the right place.
I wonder if making a new module for the new service is the right approach, so that hopefully in smaller feature modules we just won’t depend on the other service which exposes the generated code which targets the “old” service.mbonnin
03/07/2023, 11:13 AMbod
03/07/2023, 11:14 AMour own types on top of these so that DI knows which one to provideit's been a while since I've "_daggerred"_ but you should be able to give a name to things to distinguish between them when they have the same type
Stylianos Gakis
03/07/2023, 11:16 AMit’s been a while since I’ve “_daggerred”_Me too, cause we are “koinering” instead 😂 But yeah we could go with a qualifier too, and not introduce a new type. Will check out what makes the most sense 😊
bod
03/07/2023, 11:18 AMexecuteOnAbc(operation)
vs executeOnXyz(operation)
)agrosner
03/07/2023, 11:39 AMStylianos Gakis
03/13/2023, 12:48 PMOh we definitely will have a module which will depend on both, that would be our “:app” module which is the “spaghetti” module as a lot of people refer to it 😅 But for there we will just bite the bullet and be more carefulI lied. Just added a
apollo:di
module, which brings in apollo:giraffe
and apollo:octopus
, and only exposes a Koin module which :app
hooks into the Koin dep graph. Now no module is depending on both :giraffe and :octopus. Therefore no way for a module to misuse this, since those modules contain the koin qualifier (It’s a normal object instead of an annotation of Dagger, but same exact story), so one can not bring in the wrong qualifier, hooray for making mistakes impossible (almost).
Now if only Koin did not throw a RUNTIME 🥵 crash if someone tried to run get<ApolloClient>()
without adding a qualifier like get<ApolloClient>(giraffeClientQualifier)
:face_with_peeking_eye:
Thanks again Andrew for giving me the confidence that this is a fine approach that someone else had tried before too. Helped me a lot to just jump straight to fixing this instead of overthinking it 🤗agrosner
03/13/2023, 1:35 PMStylianos Gakis
03/13/2023, 1:53 PM