Neal Sanche
12/15/2021, 10:01 PMStylianos Gakis
12/17/2021, 2:54 PMprivate val mockedApolloClient = mockk<ApolloClient>().apply {
val apolloClient = this
coEvery { apolloClient.query(MyCustomQuery()/* or even omit this if possible?*/) } coAnswers {
MyObject()
}
}
private val useCase = MyUseCase(mockedApolloClient)
@Test
fun someTest() {
assert(useCase(input) == SomeResult)
}
I tried looking into the documentation and I didn’t find anything out unfortunately. Note that we’re still on 2.x.x but if a better solution exists for 3.0.0 I’d be happy to hear that as we’ll migrate to it soon anyway.John O'Reilly
12/19/2021, 3:11 PMwatch
below for some reason....is there some other dependency that needs to be pulled in for that? (basing code on what's in https://www.apollographql.com/docs/kotlin/caching/query-watchers/)
apolloClient.query(GetSessionsQuery())
.watch()
.collect { response ->
}
John O'Reilly
12/21/2021, 11:53 AMwatch
with endpoint that supports paging?Aaron Pramana
12/22/2021, 4:41 AMEduard Boloș
12/28/2021, 1:42 AMcodegenModels
set to compat
, or with `useVersion2Compat()`(which I think that it might do the same thing), there would be thousands of changes to go through in the project, the vast majority of them would be just removing function invocations from GQL fields, quite a few of them would be changing how polymorphic fragments are accessed, and a lot of mutation and query builders need to be changed too to constructor invocations. It would be a huuuuge time sink to do all of this changes in one go, so I was wondering, is it possible to have v2 and v3 running side by side in the same app, but using the same SQL cache? So that we can keep the old code using Apollo-Android, and slowly migrate to Apollo-Kotlin. (This would actually solve another issue for us, we have a lot of custom code that allows us to pass references to fragments from one activity to another and then observe for updates, and we would have to rewrite most of it, but again, it's hard to do it in one go. Thankfully, ApolloStore.readFragment()
from v3 does a lot of this already 😄.)
I imagine that even if it would be possible to have two instances writing to and reading from the same database, observing the cache for updates using .watch()
won't trigger any updates if the write was done by the other instance, isn't it?
Is there any hope to ease the migration for such a complex project? I want the new and fancy test builders, haha. (Sorry for the wall of text.)John O'Reilly
12/28/2021, 3:50 PMSqlNormalizedCacheFactory
and for JVM have following (injected using Koin)
single { SqlNormalizedCacheFactory("jdbc:sqlite:swapi.db") }
Running a main
function in JVM code and this works fine first time but on subsequent runs I get
Caused by: org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (table records already exists)
at org.sqlite.core.DB.newSQLException(DB.java:1012)
Is there some other init/config needed for case of JVM?John O'Reilly
12/29/2021, 12:09 PMJohn O'Reilly
12/29/2021, 1:56 PMcommonTest
in KMM module using new runTest
provided in Kotlinx Coroutines 1.6 to test some code that uses apollo...it runs fine for android, jvm but get issue when running for iOS .🧵John O'Reilly
12/30/2021, 9:27 PMapolloClient.query(query).execute()
Brian Donovan
01/02/2022, 1:53 PMNick
01/05/2022, 9:24 PMwatch
? You said they watchers never throw here. Is it possible to emit network connection issues?Stylianos Gakis
01/11/2022, 9:25 AMStylianos Gakis
01/11/2022, 11:45 AMStylianos Gakis
01/11/2022, 1:59 PMJessica Stone
01/13/2022, 9:16 PMHeroForEpisodeQuery.Data
, but it would be nice to be able to reference hero
directly, especially in cases where we have more nested models.
3. Related to the previous question, how do I mock fields which are lists if I want to set some values of the list items but not all? Would I need to use real models?Stylianos Gakis
01/14/2022, 12:34 PM// graphqls
mutation UploadFile($file: Upload!){
uploadFile(file: $file) { //stuff }
}
uploadFile(file: Upload!): File!
type File { // stuff }
// kt
private suspend fun uploadFile(path: String, mimeType: String): Response<UploadFileMutation.Data> {
val uploadFileMutation = UploadFileMutation(
file = FileUpload(mimeType, path)
)
return apolloClient.mutation(uploadFileMutation).execute()
}
and it’d work. Mind you, we were calling this method once with a file that we did .path
on it, and once on a Uri
that we did .path
on it too. (so not all of our cases can be fixed with the
Now with the new documentation mentioning “okioSource” as someone who has never worked with okio it’s not obvious what I should do to not break this. Maybe worth a mention in the migration logs? At least a link to okio documentation on this?wasyl
01/17/2022, 12:07 PMtag
to an Apollo call, so that the tag can be read in an okhttp3.Interceptor
class? The goal is to pass an object when triggering an Apollo call, and read it later from okhttp3.Request#tag()
in the interceptor.
There’s https://github.com/apollographql/apollo-kotlin/issues/2527 so I assume there isn’t (though maybe something appeared in v3?) and that the only way to do that now is to set a request header, read it in the interceptor, and strip before sending to the server?rudolf.hladik
01/18/2022, 9:48 AMStylianos Gakis
01/20/2022, 11:27 AMJohn O'Reilly
01/20/2022, 9:39 PMjava.net.ProtocolException: Expected HTTP 101 response but was '404 Not Found
for some reason even though subscription seems to work in playground....more in thread....John O'Reilly
01/21/2022, 2:47 PMFabio
01/24/2022, 1:17 AMgmaciel
01/24/2022, 12:49 PMmonorepo
app-a module
apollo-a module
app-b module
apollo-b module
Currently what i get is:
Cause: duplicate Type XXX generated in modules: apollo-b,apollo-a
What i have tried is this:
within app-a:
dependencies {
implementation(project(":apollo-a"))
apolloMetadata(project(":apollo-a"))
}
With apollo-a module:
apollo {
generateApolloMetadata.set(true)
generateKotlinModels.set(true)
}
Any suggestions on this?
Apollo version: 2.5.9Sam Michael
01/28/2022, 6:32 AMExecution failed for task ':checkServiceApolloDuplicates'.
duplicate Type 'ResolverKey(kind=SchemaType, id=Query)' generated in modules: Somthing,SomethingElse
Use 'alwaysGenerateTypesMatching' in a parent module to generate the type only once
Fabio
01/31/2022, 1:29 AMFabio
01/31/2022, 11:32 PMapollo-kotlin
, though I have some server code that not sure where to put. At this point I'd prefer the server to run standalone, so that excludes putting all its code into src/test
. Maybe a new module in apollo-kotlin
, like apollo-server
? But at the same time I don't have the goal of having a fully fledged server that actually handles true queries/mutations in a nice API (though that would be handy for my own goals if it were easy). Thoughts?
Btw I'd like to have a quick voice chat during your office hours, where are you located? If US West Coast I can do something in my early hours, if Europe I can do it in late hours.Nick
02/11/2022, 4:34 PMmaxgdn
02/12/2022, 7:41 PMStylianos Gakis
02/14/2022, 5:31 PM