Hey all, wondering if anyone can provide a little ...
# graphql-kotlin
m
Hey all, wondering if anyone can provide a little guidance re: adding single headers to apollo graphql calls in Kotlin? Don't really want this to be a global header so trying to avoid the interceptor pattern.
Copy code
interface TourService {
    @POST("/")
    suspend fun toursQuery(
        @Header("Authorization") auth: String,
        @Header("Content-Type") content: String = "application/json",
        @Body body: String): List<Tour>
}

object ApolloBuilder {
    private const val BASE_URL = "<https://somewhere.com>"
    private fun getApollo(): ApolloClient {
        return ApolloClient.builder()
            .serverUrl(BASE_URL)
            .build()
    }
}
I assumed that the
@Header
annotation would magik things in 😄
s
I don’t think this is a
graphql-kotlin
question, but isn’t the annotation
RequestHeader
?
Actually not quite sure what you’re doing 😅
m
🤷 Ha ya I'm new to this framework and Kotlin even but the
@Header
annotation works for Retrofit.
But I'm trying to add a header to my graphql request while using Apollo.
s
Perhaps #graphql? This channel is for graphql-kotlin so not sure how helpful it will be about using the Apollo client
1
m
Sounds good, thanks. 🙂
s
Or #apollo-android if that is the client library you are using
☝️ 1