forked from apollographql/apollo-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add KtorHttpUrlAdapter (apollographql#5915)
* Add KtorHttpUrlAdapter * update apiDump --------- Co-authored-by: Martin Bonnin <[email protected]>
- Loading branch information
Showing
4 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
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
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
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 | ||
} | ||
|
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
21 changes: 21 additions & 0 deletions
21
...tor/src/commonMain/kotlin/com/apollographql/apollo3/network/adapter/KtorHttpUrlAdapter.kt
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
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()) | ||
} | ||
} | ||
|