Skip to content

Commit

Permalink
Add KtorHttpUrlAdapter (apollographql#5915)
Browse files Browse the repository at this point in the history
* Add KtorHttpUrlAdapter

* update apiDump

---------

Co-authored-by: Martin Bonnin <[email protected]>
  • Loading branch information
2 people authored and BoD committed Jul 1, 2024
1 parent 90f64d9 commit e0989ea
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
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 |
8 changes: 8 additions & 0 deletions libraries/apollo-engine-ktor/api/apollo-engine-ktor.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
public final class com/apollographql/apollo3/network/adapter/KtorHttpUrlAdapter : com/apollographql/apollo3/api/Adapter {
public static final field INSTANCE Lcom/apollographql/apollo3/network/adapter/KtorHttpUrlAdapter;
public fun fromJson (Lcom/apollographql/apollo3/api/json/JsonReader;Lcom/apollographql/apollo3/api/CustomScalarAdapters;)Lio/ktor/http/Url;
public synthetic fun fromJson (Lcom/apollographql/apollo3/api/json/JsonReader;Lcom/apollographql/apollo3/api/CustomScalarAdapters;)Ljava/lang/Object;
public fun toJson (Lcom/apollographql/apollo3/api/json/JsonWriter;Lcom/apollographql/apollo3/api/CustomScalarAdapters;Lio/ktor/http/Url;)V
public synthetic fun toJson (Lcom/apollographql/apollo3/api/json/JsonWriter;Lcom/apollographql/apollo3/api/CustomScalarAdapters;Ljava/lang/Object;)V
}

4 changes: 4 additions & 0 deletions libraries/apollo-engine-ktor/api/apollo-engine-ktor.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
// - Show declarations: true

// Library unique name: <com.apollographql.apollo3:apollo-engine-ktor>
final object com.apollographql.apollo3.network.adapter/KtorHttpUrlAdapter : com.apollographql.apollo3.api/Adapter<io.ktor.http/Url> { // com.apollographql.apollo3.network.adapter/KtorHttpUrlAdapter|null[0]
final fun fromJson(com.apollographql.apollo3.api.json/JsonReader, com.apollographql.apollo3.api/CustomScalarAdapters): io.ktor.http/Url // com.apollographql.apollo3.network.adapter/KtorHttpUrlAdapter.fromJson|fromJson(com.apollographql.apollo3.api.json.JsonReader;com.apollographql.apollo3.api.CustomScalarAdapters){}[0]
final fun toJson(com.apollographql.apollo3.api.json/JsonWriter, com.apollographql.apollo3.api/CustomScalarAdapters, io.ktor.http/Url) // com.apollographql.apollo3.network.adapter/KtorHttpUrlAdapter.toJson|toJson(com.apollographql.apollo3.api.json.JsonWriter;com.apollographql.apollo3.api.CustomScalarAdapters;io.ktor.http.Url){}[0]
}
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())
}
}

0 comments on commit e0989ea

Please sign in to comment.