Hi all, fairly new to KM, doing some GraphQL which requires an authorization header. The token is an...
n
Hi all, fairly new to KM, doing some GraphQL which requires an authorization header. The token is an ID token, basic JWT, nothing too fancy. Now, having trouble getting everything all initialized. We're going old-school and not using Koin or any DI, just making a top-level Kotlin object for the GraphQL apolloClient. I'll throw code in the thread.
The problem is, how can we pass in a TokenProvider to this, from the iOS side? Is that something we should even attempt to do? If I mark the Graph object as
@ThreadLocal
the code compiles and runs on iOS, but the TokenProvider interface's methods are never called. I'm a bit confused here.
So, didn't know about Stately, and was able to solve this nicely using IsolateState. So, nevermind. Thanks @kpgalligan for blogging about and making that library. Very handy.
👍 3
k
I just pushed a new version (1.1.6). Nothing you likely need, though.
n
Works with 1.1.4-a1, and I'll update when the push is visible to us mortals.
k
The last couple of releases have been very minor, so probably not much need.
🙇‍♂️ 1
c
Ooo this is great. I think I'm going to update my project to do it like this. Thanks for sharing, @Neal Sanche!
n
Updated code here @clark but of course I already plan to change the mutable map to something more generic, and set up an 'Inputs' builder so that we can get all of the things we need for the library over time, and have flexibility to add things later. But this is just a proof of concept that works. I'm also going to explore just using the TokenProvider interface from Apollo instead, but you get the idea.
🙏 1
❤️ 1
On the SwiftUI side it ends up looking like this.