Created
April 18, 2018 14:14
-
-
Save FilipeLipan/5d3e5eed3ec9ad343bc3b41793e7482b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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