https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
apollo-kotlin
  • n

    Neal Sanche

    12/15/2021, 10:01 PM
    We have a use case where we want to watch for changes to four GraphQL queries, and when any of them change, we want to create and return parameters to use to make another query. In most cases adding GraphQL watch() to these works great. But there are a few cases where the cache doesn't have anything in it yet, and so I guess since there's nothing to watch() the code for making the parameters never fires. I'm stubborn, and want this to work. Any ideas on how to ensure at least one query gets made when initiating a watch()?
    • 1
    • 1
  • s

    Stylianos Gakis

    12/17/2021, 2:54 PM
    Hey got a question about testing. Suppose I have a simple UseCase, that receives an apolloClient in its constructor.It has one method that calls one query, and does some business logic with it and returns something. Is there no way to simply mock the ApolloClient to just return a specific object? I’ve read this article for example but it feels quite involved for what I want to do. Optimally I’d like to be able to do inside a test class something like:
    private 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.
    m
    • 2
    • 6
  • j

    John O'Reilly

    12/19/2021, 3:11 PM
    It's not resolving
    watch
    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 ->
                }
    m
    • 2
    • 3
  • j

    John O'Reilly

    12/21/2021, 11:53 AM
    Are there any particular recommended patterns/approaches when using
    watch
    with endpoint that supports paging?
    b
    p
    • 3
    • 11
  • a

    Aaron Pramana

    12/22/2021, 4:41 AM
    APQ should only be attempted for queries, right? It seems as though the interceptor gets applied to mutations as well.
    b
    • 2
    • 3
  • e

    Eduard Boloș

    12/28/2021, 1:42 AM
    Hello! I am very excited about the new Apollo Kotlin, and I was looking at what it would take to upgrade the project from work from v2 to v3, but unfortunately it seems like a migration would be extremely difficult, from what I could tell so far. Even if using
    codegenModels
    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.)
    m
    • 2
    • 5
  • j

    John O'Reilly

    12/28/2021, 3:50 PM
    I'm using
    SqlNormalizedCacheFactory
    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?
    m
    • 2
    • 3
  • j

    John O'Reilly

    12/29/2021, 12:09 PM
    Are there any examples of unit test that mocks out Apollo client?
    m
    • 2
    • 13
  • j

    John O'Reilly

    12/29/2021, 1:56 PM
    Somewhat related (and this is very likely issue on my side but just in case anything jumps out)....I have a unit test in
    commonTest
    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 .🧵
    m
    • 2
    • 10
  • j

    John O'Reilly

    12/30/2021, 9:27 PM
    Should call like following be "main-safe"....or is expectation that client is on background thread when invoking it?
    apolloClient.query(query).execute()
    m
    • 2
    • 2
  • b

    Brian Donovan

    01/02/2022, 1:53 PM
    b
    • 2
    • 1
  • n

    Nick

    01/05/2022, 9:24 PM
    Is it possible to handle network connection issues when using a
    watch
    ? You said they watchers never throw here. Is it possible to emit network connection issues?
    m
    • 2
    • 4
  • s

    Stylianos Gakis

    01/11/2022, 9:25 AM
    Could any guidance be added for interceptors, but not for Http ones as described here, but adding a section about ApolloInterceptor too. More in Thread 🧵
    b
    m
    • 3
    • 10
  • s

    Stylianos Gakis

    01/11/2022, 11:45 AM
    A random curiosity question about the gradle plugin 🧵
    b
    • 2
    • 2
  • s

    Stylianos Gakis

    01/11/2022, 1:59 PM
    Is it not possible to use the test builders in non-test code? It is now generated in the test resources only. For our app we basically have a module called testdata where we have a ton of convenience builders (basically what test builders do, but we had to write them by hand which would be great if we could skip that from now on) which we use to make fake data when we test our app in some sort of “dev” mode. I was hoping we could use this functionality instead. Is there a way to generate them not only for the test sources?
    m
    • 2
    • 5
  • j

    Jessica Stone

    01/13/2022, 9:16 PM
    Hello all! I have been updating a project to use Apollo and really liking it so far. I have a few questions about the test builders which are available in v3: 1. Is there an eta on when test builders will be out of experimental? 2. Do I always need to start from Query.Data when using test builders? In the example usage provided, it looks like you have to start with
    HeroForEpisodeQuery.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?
    m
    • 2
    • 2
  • s

    Stylianos Gakis

    01/14/2022, 12:34 PM
    Dealing with File uploading migration 2.0->3.0 tl;dr -> Before we were passing in a path string to FileUpload(mimeType, path) but now I’m not sure what’s the functionally equivalent thing to do. We used to do:
    // 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?
    m
    • 2
    • 8
  • w

    wasyl

    01/17/2022, 12:07 PM
    Hello 👋 Is it possible to attach an arbitrary object as a
    tag
    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?
    m
    s
    m
    • 4
    • 10
  • r

    rudolf.hladik

    01/18/2022, 9:48 AM
    Hello, do subscriptions work in multiplatform environment? Especially on iOS? Is there any public GQL server that supports subscription to test that out?
    m
    j
    • 3
    • 11
  • s

    Stylianos Gakis

    01/20/2022, 11:27 AM
    A question about more about coroutines and cancellations in combination with Apollo. More in thread 🧵
    w
    b
    e
    • 4
    • 7
  • j

    John O'Reilly

    01/20/2022, 9:39 PM
    Using Apollo subscriptions for first time so could easily be issue on my side but am getting
    java.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....
    b
    • 2
    • 15
  • j

    John O'Reilly

    01/21/2022, 2:47 PM
    Is the normalized cache supported when using Kotlin/JS?
    :yes: 1
    b
    c
    • 3
    • 22
  • f

    Fabio

    01/24/2022, 1:17 AM
    Hi folks, I'm the one who opened this ticket: https://github.com/apollographql/apollo-kotlin/issues/3756 cc : hi @bod
    👋 2
    m
    • 2
    • 15
  • g

    gmaciel

    01/24/2022, 12:49 PM
    Hey, i’m trying to modularise the apollo queries within a mono-repo but getting duplicated class issue, currently this the structure i have:
    monorepo
      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.9
    b
    • 2
    • 19
  • s

    Sam Michael

    01/28/2022, 6:32 AM
    Hi, I received the following duplication error for Apollo generated types, wondering where to add the 'alwaysGenerateTypesMatching' config?
    Execution 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
    m
    • 2
    • 86
  • f

    Fabio

    01/31/2022, 1:29 AM
    Did you guys run into any considerations for dropped connection and recovering from errors when doing sus over websockets? Specially but not limited to handover from mobile to wifi ?
    m
    • 2
    • 4
  • f

    Fabio

    01/31/2022, 11:32 PM
    I'm coming closer to the point of starting to write code on
    apollo-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.
    b
    • 2
    • 4
  • n

    Nick

    02/11/2022, 4:34 PM
    Is it possible to add a header on the introspection? We need to add an auth token for ours to work.
    m
    • 2
    • 6
  • m

    maxgdn

    02/12/2022, 7:41 PM
    How might custom exceptions be thrown from an okhttp interceptor? I would like the exceptions to surface past all of the interceptors so that they can be handled elsewhere. More in thread ->
    m
    • 2
    • 7
  • s

    Stylianos Gakis

    02/14/2022, 5:31 PM
    More of a project structure and IDE question I guess, but is there a way for me to share my .graphqlconfig without gitignoring it yet still have fields inside there that are hidden somehow? I just don’t quite know how to do that and any pointers would be appreciated!
    m
    f
    • 3
    • 7
Powered by Linen
Title
s

Stylianos Gakis

02/14/2022, 5:31 PM
More of a project structure and IDE question I guess, but is there a way for me to share my .graphqlconfig without gitignoring it yet still have fields inside there that are hidden somehow? I just don’t quite know how to do that and any pointers would be appreciated!
Hmm went with the approach I saw here instead where I’m doing something like:
tasks.register("downloadSchema", com.apollographql.apollo3.gradle.internal.ApolloDownloadSchemaTask::class.java) {
  endpoint.set(...can use normal gradle techniques to hide stuff)
  schema.set("shared/src/commonMain/graphql/xyz/stylianosgakis/pawfinder/schema.graphqls")
}
m

mbonnin

02/14/2022, 7:39 PM
What do you mean by "hide" ? If it's shared, it's not really hidden?
s

Stylianos Gakis

02/15/2022, 10:00 AM
Sorry, meant hide from the github repository as it’s public. I just wanted to have some API-keys that I didn’t want to show in GitHub. So basically have a .graphqlconfig that is version controlled but doesn’t have these API keys in plain text. In the end I ended up not using a .graphqlconfig anyway since the task suggestion by you suffices. Now I can share my repository and simply have the local.properties variables be shared outside of git with whoever needs to have access. I do want to keep it available for all modules. My wording on this was a mess wasn’t it 😂 Sorry 😄
👍 1
m

mbonnin

02/15/2022, 3:05 PM
Gotcha 👍 Thanks for the details!
f

Fabio

02/16/2022, 5:25 AM
we use this in our proj
"Authorization": "Bearer ${env:SHOP_API_AUTH_TOKEN}"
so when you click refresh or tries to run a query, android studio pops up a dialog asking for the value
🤩 1
my only struggle is that we have 2
.graphqlconfig
files in our proj (for 2 different servers/schemas) and I haven't figured out how to solve some of the conflicts it brings. And I haven't had the time to look into this.
s

Stylianos Gakis

02/16/2022, 8:36 AM
Oh nice, that’s interesting! Might play around with this as well, thanks for sharing! 😄
View count: 5