Skip to content

Commit

Permalink
Remove deprecated modules and move tests to the root level (#3274)
Browse files Browse the repository at this point in the history
* remove deprecated modules and move tests to the root level

* remove NoOpApolloStore

* remove the nytime Cache dependency

* silence/fix a bunch of warnings

* remove deprecated mock queries
  • Loading branch information
martinbonnin authored Jul 26, 2021
1 parent 73e1e12 commit 2ca7d9b
Show file tree
Hide file tree
Showing 481 changed files with 156 additions and 80,296 deletions.
2 changes: 1 addition & 1 deletion Contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Project Setup

This project is developed using either IntelliJ IDEA or Android Studio. To build multiplatform projects, you need MacOS and the Xcode developer tools.

To build the samples and integration tests, use the `composite` build. It's a composite build that includes the main build so that it's possible to use `apollo-gradle-plugin` with dependency substitution.
To build the integration tests, use the `tests` build. It's a composite build that includes the main build so that it's possible to use `apollo-gradle-plugin` with dependency substitution.

DOs and DON'Ts
--------------
Expand Down
116 changes: 0 additions & 116 deletions README.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ class ApolloResponse<out D : Operation.Data>(
extensions: Map<String, Any?> = this.extensions,
executionContext: ExecutionContext = this.executionContext
): ApolloResponse<D> {
return ApolloResponse(
requestUuid,
operation,
data as D?,
errors,
extensions,
executionContext
)
@Suppress("UNCHECKED_CAST")
return ApolloResponse(
requestUuid,
operation,
data as D?,
errors,
extensions,
executionContext
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ class CustomScalarAdapters(val customScalarAdapters: Map<String, Adapter<*>>): C
fun <T : Any> responseAdapterFor(customScalar: CustomScalarType): Adapter<T> {
return when {
customScalarAdapters[customScalar.name] != null -> {
@Suppress("UNCHECKED_CAST")
customScalarAdapters[customScalar.name] as Adapter<T>
}
customScalar.className == "com.apollographql.apollo3.api.Upload" -> {
// Shortcut to save users a call to `registerCustomScalarAdapter`
@Suppress("UNCHECKED_CAST")
UploadAdapter as Adapter<T>
}
else -> error("Can't map GraphQL type: `${customScalar.name}` to: `${customScalar.className}`. Did you forget to add a CustomScalarAdapter?")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ internal fun String.urlEncode(
}

private fun Char.percentEncode(): String {
return "%${toInt().toString(16)}".uppercase()
return "%${code.toString(16)}".uppercase()
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ object ResponseBodyParser {
var errors: List<Error>? = null
var extensions: Map<String, Any?>? = null
while (jsonReader.hasNext()) {
@Suppress("UNCHECKED_CAST")
when (jsonReader.nextName()) {
"data" -> data = operation.adapter().nullable().fromJson(jsonReader, customScalarAdapters)
"errors" -> errors = jsonReader.readErrors()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class BufferedSinkJsonWriter(private val sink: BufferedSink) : JsonWriter {
*
* Note: the implementation is modified from the Moshi implementation to:
* - Remove the leading "$."
* - Remove square brackets in lists. This isn't great because it doesn't allow to distinguish lists from "0" keys but
* - Remove square brackets in lists. This isn't great because it doesn't allow distinguishing lists from "0" keys but
* this is how File Upload works: https://github.com/jaydenseric/graphql-multipart-request-spec
*/
override val path: String
Expand Down Expand Up @@ -239,7 +239,7 @@ class BufferedSinkJsonWriter(private val sink: BufferedSink) : JsonWriter {
if (indent == null) {
return
}
sink.writeByte('\n'.toInt())
sink.writeByte('\n'.code)
var i = 1
val size = stackSize
while (i < size) {
Expand All @@ -255,7 +255,7 @@ class BufferedSinkJsonWriter(private val sink: BufferedSink) : JsonWriter {
private fun beforeName() {
val context = peekScope()
if (context == JsonScope.NONEMPTY_OBJECT) { // first in object
sink.writeByte(','.toInt())
sink.writeByte(','.code)
} else check(context == JsonScope.EMPTY_OBJECT) {
// not in an object!
"Nesting problem."
Expand All @@ -281,7 +281,7 @@ class BufferedSinkJsonWriter(private val sink: BufferedSink) : JsonWriter {
newline()
}
JsonScope.NONEMPTY_ARRAY -> {
sink.writeByte(','.toInt())
sink.writeByte(','.code)
newline()
}
JsonScope.DANGLING_NAME -> {
Expand Down Expand Up @@ -333,12 +333,12 @@ class BufferedSinkJsonWriter(private val sink: BufferedSink) : JsonWriter {
for (i in 0..0x1f) {
this[i] = "\\u00${i.toByte().hexString()}"
}
this['"'.toInt()] = "\\\""
this['\\'.toInt()] = "\\\\"
this['\t'.toInt()] = "\\t"
this['\b'.toInt()] = "\\b"
this['\n'.toInt()] = "\\n"
this['\r'.toInt()] = "\\r"
this['"'.code] = "\\\""
this['\\'.code] = "\\\\"
this['\t'.code] = "\\t"
this['\b'.code] = "\\b"
this['\n'.code] = "\\n"
this['\r'.code] = "\\r"
}

/**
Expand All @@ -347,14 +347,14 @@ class BufferedSinkJsonWriter(private val sink: BufferedSink) : JsonWriter {
@Throws(IOException::class)
fun string(sink: BufferedSink, value: String) {
val replacements = REPLACEMENT_CHARS
sink.writeByte('"'.toInt())
sink.writeByte('"'.code)
var last = 0
val length = value.length
for (i in 0 until length) {
val c = value[i]
var replacement: String?
if (c.toInt() < 128) {
replacement = replacements[c.toInt()]
if (c.code < 128) {
replacement = replacements[c.code]
if (replacement == null) {
continue
}
Expand All @@ -374,7 +374,7 @@ class BufferedSinkJsonWriter(private val sink: BufferedSink) : JsonWriter {
if (last < length) {
sink.writeUtf8(value, last, length)
}
sink.writeByte('"'.toInt())
sink.writeByte('"'.code)
}
}
}
Loading

0 comments on commit 2ca7d9b

Please sign in to comment.