Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose ExecutionContext to HttpEngine and add OkHttp helpers #5383

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

martinbonnin
Copy link
Contributor

@martinbonnin martinbonnin commented Nov 20, 2023

Makes it easier to create custom HttpEngine implementations and tag OkHttp requests. Makes it possible to do things like this:

internal class MyHttpEngine: HttpEngine {
  private val okHttpClient = OkHttpClient()

  override suspend fun execute(request: HttpRequest): HttpResponse {
    val taggedRequest = request
        .toOkHttpRequest()
        .newBuilder()
        .tag(MyExecutionContext::class.java, request.executionContext[MyExecutionContext])
        .build()
    return okHttpClient.execute(taggedRequest).toApolloHttpResponse()
  }

  override fun dispose() {

  }
}

Copy link

netlify bot commented Nov 20, 2023

Deploy Preview for apollo-android-docs canceled.

Name Link
🔨 Latest commit 280429e
🔍 Latest deploy log https://app.netlify.com/sites/apollo-android-docs/deploys/655b332082294e000810395c

Copy link
Contributor

@BoD BoD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@martinbonnin martinbonnin merged commit 4396dc5 into main Nov 20, 2023
9 checks passed
@martinbonnin martinbonnin deleted the http-execution-request branch November 20, 2023 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants