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

Add KtorHttpUrlAdapter #5915

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libraries/apollo-adapters/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ apollo-adapters contains adapters for common date and big decimal GraphQL scalar
| `com.apollographql.apollo3.adapter.JavaOffsetDateTimeAdapter` | For `java.time.OffsetDateTime` ISO8601 dates |
| `com.apollographql.apollo3.adapter.DateAdapter` | For `java.util.Date` ISO8601 dates |
| `com.apollographql.apollo3.adapter.BigDecimalAdapter` | For a Multiplatform `com.apollographql.apollo3.adapter.BigDecimal` class holding big decimal values |
| `com.apollographql.apollo3.adapter.network.KtorHttpUrlAdapter` | For `io.ktor.http.Url` class holding url values |
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.apollographql.apollo3.network.adapter

import com.apollographql.apollo3.api.Adapter
import com.apollographql.apollo3.api.CustomScalarAdapters
import com.apollographql.apollo3.api.json.JsonReader
import com.apollographql.apollo3.api.json.JsonWriter
import io.ktor.http.Url

/**
* An [Adapter] that converts to/from [io.ktor.http.Url]
*/
object KtorHttpUrlAdapter: Adapter<Url> {
override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): Url {
return Url(reader.nextString()!!)
}

override fun toJson(writer: JsonWriter, customScalarAdapters: CustomScalarAdapters, value: Url) {
writer.value(value.toString())
}
}

Loading