Skip to content

Instantly share code, notes, and snippets.

@FilipeLipan
Created April 18, 2018 14:14
Show Gist options
  • Save FilipeLipan/5d3e5eed3ec9ad343bc3b41793e7482b to your computer and use it in GitHub Desktop.
Save FilipeLipan/5d3e5eed3ec9ad343bc3b41793e7482b to your computer and use it in GitHub Desktop.
class App : Application() {
private val BASE_URL = "https://api.github.com/graphql"
//TODO: put your token here man!!!
private val GITHUB_AUTH_TOKEN = ""
private lateinit var apolloClient: ApolloClient
override fun onCreate() {
super.onCreate()
val okHttpClient = OkHttpClient.Builder()
.addInterceptor {
val original = it.request()
val builder = original.newBuilder().method(original.method(), original.body())
builder.header("Authorization", "Bearer $GITHUB_AUTH_TOKEN")
it.proceed(builder.build())
}
.build()
apolloClient = ApolloClient.builder()
.serverUrl(BASE_URL)
.okHttpClient(okHttpClient)
.build()
}
fun apolloClient(): ApolloClient {
return this.apolloClient;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment