diff --git a/README.md b/README.md index 93a522a5426..846bddaae2e 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ [![Join Spectrum](https://img.shields.io/badge/spectrum-join-orange?logo=spectrum)](https://spectrum.chat/apollo/apollo-android) [![Slack](https://img.shields.io/static/v1?label=kotlinlang&message=apollo-android&color=15a2f5&logo=slack)](https://app.slack.com/client/T09229ZC6/C01A6KM1SBZ) [![CI](https://github.com/apollographql/apollo-android/workflows/CI/badge.svg)](https://github.com/apollographql/apollo-android/actions) -[![Maven Central](https://img.shields.io/maven-central/v/com.apollographql.apollo/apollo-api)](https://repo1.maven.org/maven2/com/apollographql/apollo/) -[![OSS Snapshots](https://img.shields.io/nexus/s/com.apollographql.apollo/apollo-api?server=https%3A%2F%2Foss.sonatype.org&label=oss-snapshots)](https://oss.sonatype.org/content/repositories/snapshots/com/apollographql/apollo/) +[![Maven Central](https://img.shields.io/maven-central/v/com.homer.apollographql.apollo/apollo-api)](https://repo1.maven.org/maven2/com/apollographql/apollo/) +[![OSS Snapshots](https://img.shields.io/nexus/s/com.homer.apollographql.apollo/apollo-api?server=https%3A%2F%2Foss.sonatype.org&label=oss-snapshots)](https://oss.sonatype.org/content/repositories/snapshots/com/apollographql/apollo/) Apollo Android is a GraphQL client that generates Java and Kotlin models from GraphQL queries. These models give you a type-safe API to work with GraphQL servers. Apollo helps you keep your GraphQL query statements together, organized, and easy to access. @@ -44,16 +44,16 @@ The [JS Graphql IntelliJ Plugin](https://jimkyndemeyer.github.io/js-graphql-inte ## Releases -The latest version is [![Maven Central](https://img.shields.io/maven-central/v/com.apollographql.apollo/apollo-api)](https://repo1.maven.org/maven2/com/apollographql/apollo/) +The latest version is [![Maven Central](https://img.shields.io/maven-central/v/com.homer.apollographql.apollo/apollo-api)](https://repo1.maven.org/maven2/com/apollographql/apollo/) Check the [changelog](https://github.com/apollographql/apollo-android/releases) for the release history. -Releases are hosted on [Jcenter](https://jcenter.bintray.com/com/apollographql/apollo/) and [Maven Central](https://repo1.maven.org/maven2/com/apollographql/apollo/). The plugin is additionally hosted on the [Gradle Plugin Portal](https://plugins.gradle.org/plugin/com.apollographql.apollo) +Releases are hosted on [Jcenter](https://jcenter.bintray.com/com/apollographql/apollo/) and [Maven Central](https://repo1.maven.org/maven2/com/apollographql/apollo/). The plugin is additionally hosted on the [Gradle Plugin Portal](https://plugins.gradle.org/plugin/com.homer.apollographql.apollo) ```groovy:title=build.gradle.kts plugins { - id("com.apollographql.apollo").version("x.y.z") + id("com.homer.apollographql.apollo").version("x.y.z") } repositories { @@ -61,19 +61,19 @@ repositories { } dependencies { - implementation("com.apollographql.apollo:apollo-runtime:x.y.z") + implementation("com.homer.apollographql.apollo:apollo-runtime:x.y.z") // optional: if you want to use the normalized cache - implementation("com.apollographql.apollo:apollo-normalized-cache-sqlite:x.y.z") + implementation("com.homer.apollographql.apollo:apollo-normalized-cache-sqlite:x.y.z") // optional: for coroutines support - implementation("com.apollographql.apollo:apollo-coroutines-support:x.y.z") + implementation("com.homer.apollographql.apollo:apollo-coroutines-support:x.y.z") // optional: for RxJava3 support - implementation("com.apollographql.apollo:apollo-rx3-support:x.y.z") + implementation("com.homer.apollographql.apollo:apollo-rx3-support:x.y.z") // optional: Most of apollo-android does not depend on Android in practice and runs on any JVM or on Kotlin native. apollo-android-support contains a few Android-only helper classes. For an example to send logs to logcat or run callbacks on the main thread. - implementation("com.apollographql.apollo:apollo-android-support:x.y.z") + implementation("com.homer.apollographql.apollo:apollo-android-support:x.y.z") // optional: if you just want the generated models and parsers and write your own HTTP code/cache code, you can remove apollo-runtime // and use apollo-api instead - implementation("com.apollographql.apollo:apollo-api:x.y.z") + implementation("com.homer.apollographql.apollo:apollo-api:x.y.z") } ``` diff --git a/apollo-android-support/api.txt b/apollo-android-support/api.txt index c9ed23f12a7..d1e77a89f06 100644 --- a/apollo-android-support/api.txt +++ b/apollo-android-support/api.txt @@ -1,23 +1,23 @@ // Signature format: 3.0 -package com.apollographql.apollo { +package com.homer.apollographql.apollo { - public final class ApolloAndroidLogger implements com.apollographql.apollo.Logger { + public final class ApolloAndroidLogger implements com.homer.apollographql.apollo.Logger { ctor public ApolloAndroidLogger(); method public void log(int priority, String message, Throwable? t, java.lang.Object... args); } - public final class ApolloCallback extends com.apollographql.apollo.ApolloCall.Callback { - ctor public ApolloCallback(com.apollographql.apollo.ApolloCall.Callback, android.os.Handler); - method public void onFailure(com.apollographql.apollo.exception.ApolloException); - method public void onResponse(com.apollographql.apollo.api.Response); - method public static com.apollographql.apollo.ApolloCallback! wrap(com.apollographql.apollo.ApolloCall.Callback, android.os.Handler); + public final class ApolloCallback extends com.homer.apollographql.apollo.ApolloCall.Callback { + ctor public ApolloCallback(com.homer.apollographql.apollo.ApolloCall.Callback, android.os.Handler); + method public void onFailure(com.homer.apollographql.apollo.exception.ApolloException); + method public void onResponse(com.homer.apollographql.apollo.api.Response); + method public static com.homer.apollographql.apollo.ApolloCallback! wrap(com.homer.apollographql.apollo.ApolloCall.Callback, android.os.Handler); } - public final class ApolloPrefetchCallback extends com.apollographql.apollo.ApolloPrefetch.Callback { - ctor public ApolloPrefetchCallback(com.apollographql.apollo.ApolloPrefetch.Callback, android.os.Handler); - method public void onFailure(com.apollographql.apollo.exception.ApolloException); + public final class ApolloPrefetchCallback extends com.homer.apollographql.apollo.ApolloPrefetch.Callback { + ctor public ApolloPrefetchCallback(com.homer.apollographql.apollo.ApolloPrefetch.Callback, android.os.Handler); + method public void onFailure(com.homer.apollographql.apollo.exception.ApolloException); method public void onSuccess(); - method public static com.apollographql.apollo.ApolloPrefetchCallback! wrap(com.apollographql.apollo.ApolloPrefetch.Callback, android.os.Handler); + method public static com.homer.apollographql.apollo.ApolloPrefetchCallback! wrap(com.homer.apollographql.apollo.ApolloPrefetch.Callback, android.os.Handler); } } diff --git a/apollo-android-support/src/main/AndroidManifest.xml b/apollo-android-support/src/main/AndroidManifest.xml index 3c9387144a0..841851d92d2 100644 --- a/apollo-android-support/src/main/AndroidManifest.xml +++ b/apollo-android-support/src/main/AndroidManifest.xml @@ -1,4 +1,4 @@ + package="com.homer.apollographql.apollo.android.support"> diff --git a/apollo-android-support/src/main/java/com/apollographql/apollo/ApolloAndroidLogger.kt b/apollo-android-support/src/main/java/com/homer/apollographql/apollo/ApolloAndroidLogger.kt similarity index 76% rename from apollo-android-support/src/main/java/com/apollographql/apollo/ApolloAndroidLogger.kt rename to apollo-android-support/src/main/java/com/homer/apollographql/apollo/ApolloAndroidLogger.kt index c84a3c94fb7..cb21d636910 100644 --- a/apollo-android-support/src/main/java/com/apollographql/apollo/ApolloAndroidLogger.kt +++ b/apollo-android-support/src/main/java/com/homer/apollographql/apollo/ApolloAndroidLogger.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo +package com.homer.apollographql.apollo import android.util.Log -import com.apollographql.apollo.Logger +import com.homer.apollographql.apollo.Logger /** * This is an Android wrapper around [Logger] that will take any messages Apollo wants @@ -11,7 +11,7 @@ class ApolloAndroidLogger : Logger { override fun log(priority: Int, message: String, t: Throwable?, vararg args: Any) { val formattedMessage = message.format(*args) - val tag = ApolloAndroidLogger::class.java.simpleName + val tag = com.homer.apollographql.apollo.ApolloAndroidLogger::class.java.simpleName when (priority) { Logger.DEBUG -> Log.d(tag, formattedMessage) diff --git a/apollo-android-support/src/main/java/com/apollographql/apollo/ApolloCallback.java b/apollo-android-support/src/main/java/com/homer/apollographql/apollo/ApolloCallback.java similarity index 86% rename from apollo-android-support/src/main/java/com/apollographql/apollo/ApolloCallback.java rename to apollo-android-support/src/main/java/com/homer/apollographql/apollo/ApolloCallback.java index c46cf51d041..d9c76dca771 100644 --- a/apollo-android-support/src/main/java/com/apollographql/apollo/ApolloCallback.java +++ b/apollo-android-support/src/main/java/com/homer/apollographql/apollo/ApolloCallback.java @@ -1,17 +1,17 @@ -package com.apollographql.apollo; +package com.homer.apollographql.apollo; import android.os.Handler; import android.os.Looper; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.exception.ApolloHttpException; -import com.apollographql.apollo.exception.ApolloNetworkException; -import com.apollographql.apollo.exception.ApolloParseException; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.exception.ApolloHttpException; +import com.homer.apollographql.apollo.exception.ApolloNetworkException; +import com.homer.apollographql.apollo.exception.ApolloParseException; import org.jetbrains.annotations.NotNull; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; /** *

Android wrapper for {@link ApolloCall.Callback} to be operated on specified {@link Handler}

diff --git a/apollo-android-support/src/main/java/com/apollographql/apollo/ApolloPrefetchCallback.java b/apollo-android-support/src/main/java/com/homer/apollographql/apollo/ApolloPrefetchCallback.java similarity index 85% rename from apollo-android-support/src/main/java/com/apollographql/apollo/ApolloPrefetchCallback.java rename to apollo-android-support/src/main/java/com/homer/apollographql/apollo/ApolloPrefetchCallback.java index be0dfa2e102..1a5ae0f9b71 100644 --- a/apollo-android-support/src/main/java/com/apollographql/apollo/ApolloPrefetchCallback.java +++ b/apollo-android-support/src/main/java/com/homer/apollographql/apollo/ApolloPrefetchCallback.java @@ -1,14 +1,14 @@ -package com.apollographql.apollo; +package com.homer.apollographql.apollo; import android.os.Handler; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.exception.ApolloHttpException; -import com.apollographql.apollo.exception.ApolloNetworkException; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.exception.ApolloHttpException; +import com.homer.apollographql.apollo.exception.ApolloNetworkException; import org.jetbrains.annotations.NotNull; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; /** * Android wrapper for {@link ApolloPrefetch.Callback} to be operated on specified {@link Handler} diff --git a/apollo-api/api.txt b/apollo-api/api.txt index a82f2eb00ea..843c15e73e5 100644 --- a/apollo-api/api.txt +++ b/apollo-api/api.txt @@ -1,9 +1,9 @@ // Signature format: 3.0 -package com.apollographql.apollo { +package com.homer.apollographql.apollo { public interface Logger { method public void log(int priority, String message, Throwable? t, java.lang.Object... args); - field public static final com.apollographql.apollo.Logger.Companion Companion; + field public static final com.homer.apollographql.apollo.Logger.Companion Companion; field public static final int DEBUG = 3; // 0x3 field public static final int ERROR = 6; // 0x6 field public static final int WARN = 5; // 0x5 @@ -17,7 +17,7 @@ package com.apollographql.apollo { } -package com.apollographql.apollo.api { +package com.homer.apollographql.apollo.api { @kotlin.RequiresOptIn(level=RequiresOptIn.Level.WARNING) @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(AnnotationRetention.BINARY) public @interface ApolloExperimental { } @@ -27,14 +27,14 @@ package com.apollographql.apollo.api { ctor public BigDecimal(double doubleVal); ctor public BigDecimal(int intVal); ctor public BigDecimal(long longVal); - method public com.apollographql.apollo.api.BigDecimal add(com.apollographql.apollo.api.BigDecimal augend); - method public com.apollographql.apollo.api.BigDecimal divide(com.apollographql.apollo.api.BigDecimal divisor); + method public com.homer.apollographql.apollo.api.BigDecimal add(com.homer.apollographql.apollo.api.BigDecimal augend); + method public com.homer.apollographql.apollo.api.BigDecimal divide(com.homer.apollographql.apollo.api.BigDecimal divisor); method public boolean equals(Object? other); method public int hashCode(); - method public com.apollographql.apollo.api.BigDecimal multiply(com.apollographql.apollo.api.BigDecimal multiplicand); - method public com.apollographql.apollo.api.BigDecimal negate(); + method public com.homer.apollographql.apollo.api.BigDecimal multiply(com.homer.apollographql.apollo.api.BigDecimal multiplicand); + method public com.homer.apollographql.apollo.api.BigDecimal negate(); method public int signum(); - method public com.apollographql.apollo.api.BigDecimal subtract(com.apollographql.apollo.api.BigDecimal subtrahend); + method public com.homer.apollographql.apollo.api.BigDecimal subtract(com.homer.apollographql.apollo.api.BigDecimal subtrahend); method public byte toByte(); method public char toChar(); method public double toDouble(); @@ -51,14 +51,14 @@ package com.apollographql.apollo.api { ctor public BigDecimal(double doubleVal); ctor public BigDecimal(int intVal); ctor public BigDecimal(long longVal); - method public com.apollographql.apollo.api.BigDecimal add(com.apollographql.apollo.api.BigDecimal augend); - method public com.apollographql.apollo.api.BigDecimal divide(com.apollographql.apollo.api.BigDecimal divisor); + method public com.homer.apollographql.apollo.api.BigDecimal add(com.homer.apollographql.apollo.api.BigDecimal augend); + method public com.homer.apollographql.apollo.api.BigDecimal divide(com.homer.apollographql.apollo.api.BigDecimal divisor); method public boolean equals(Object? other); method public int hashCode(); - method public com.apollographql.apollo.api.BigDecimal multiply(com.apollographql.apollo.api.BigDecimal multiplicand); - method public com.apollographql.apollo.api.BigDecimal negate(); + method public com.homer.apollographql.apollo.api.BigDecimal multiply(com.homer.apollographql.apollo.api.BigDecimal multiplicand); + method public com.homer.apollographql.apollo.api.BigDecimal negate(); method public int signum(); - method public com.apollographql.apollo.api.BigDecimal subtract(com.apollographql.apollo.api.BigDecimal subtrahend); + method public com.homer.apollographql.apollo.api.BigDecimal subtract(com.homer.apollographql.apollo.api.BigDecimal subtrahend); method public byte toByte(); method public char toChar(); method public double toDouble(); @@ -70,61 +70,61 @@ package com.apollographql.apollo.api { } public final class BigDecimalKt { - method public static Number toNumber(com.apollographql.apollo.api.BigDecimal); + method public static Number toNumber(com.homer.apollographql.apollo.api.BigDecimal); } public final class BigDecimalKt { - method public static Number toNumber(com.apollographql.apollo.api.BigDecimal); + method public static Number toNumber(com.homer.apollographql.apollo.api.BigDecimal); } public final class BigDecimalKt { - method public static Number toNumber(com.apollographql.apollo.api.BigDecimal); + method public static Number toNumber(com.homer.apollographql.apollo.api.BigDecimal); } public interface CustomTypeAdapter { - method public T! decode(com.apollographql.apollo.api.CustomTypeValue value); - method public com.apollographql.apollo.api.CustomTypeValue encode(T? value); + method public T! decode(com.homer.apollographql.apollo.api.CustomTypeValue value); + method public com.homer.apollographql.apollo.api.CustomTypeValue encode(T? value); } public abstract sealed class CustomTypeValue { - method public static final com.apollographql.apollo.api.CustomTypeValue fromRawValue(Object value); - field public static final com.apollographql.apollo.api.CustomTypeValue.Companion Companion; + method public static final com.homer.apollographql.apollo.api.CustomTypeValue fromRawValue(Object value); + field public static final com.homer.apollographql.apollo.api.CustomTypeValue.Companion Companion; field public final T? value; } public static final class CustomTypeValue.Companion { - method public com.apollographql.apollo.api.CustomTypeValue fromRawValue(Object value); + method public com.homer.apollographql.apollo.api.CustomTypeValue fromRawValue(Object value); } - public static final class CustomTypeValue.GraphQLBoolean extends com.apollographql.apollo.api.CustomTypeValue { + public static final class CustomTypeValue.GraphQLBoolean extends com.homer.apollographql.apollo.api.CustomTypeValue { ctor public CustomTypeValue.GraphQLBoolean(boolean value); method public boolean equals(Object? other); method public int hashCode(); } - public static final class CustomTypeValue.GraphQLJsonList extends com.apollographql.apollo.api.CustomTypeValue> { + public static final class CustomTypeValue.GraphQLJsonList extends com.homer.apollographql.apollo.api.CustomTypeValue> { ctor public CustomTypeValue.GraphQLJsonList(java.util.List value); method public boolean equals(Object? other); method public int hashCode(); } - public static final class CustomTypeValue.GraphQLJsonObject extends com.apollographql.apollo.api.CustomTypeValue> { + public static final class CustomTypeValue.GraphQLJsonObject extends com.homer.apollographql.apollo.api.CustomTypeValue> { ctor public CustomTypeValue.GraphQLJsonObject(java.util.Map value); method public boolean equals(Object? other); method public int hashCode(); } - public static final class CustomTypeValue.GraphQLNull extends com.apollographql.apollo.api.CustomTypeValue { - field public static final com.apollographql.apollo.api.CustomTypeValue.GraphQLNull INSTANCE; + public static final class CustomTypeValue.GraphQLNull extends com.homer.apollographql.apollo.api.CustomTypeValue { + field public static final com.homer.apollographql.apollo.api.CustomTypeValue.GraphQLNull INSTANCE; } - public static final class CustomTypeValue.GraphQLNumber extends com.apollographql.apollo.api.CustomTypeValue { + public static final class CustomTypeValue.GraphQLNumber extends com.homer.apollographql.apollo.api.CustomTypeValue { ctor public CustomTypeValue.GraphQLNumber(Number value); method public boolean equals(Object? other); method public int hashCode(); } - public static final class CustomTypeValue.GraphQLString extends com.apollographql.apollo.api.CustomTypeValue { + public static final class CustomTypeValue.GraphQLString extends com.homer.apollographql.apollo.api.CustomTypeValue { ctor public CustomTypeValue.GraphQLString(String value); method public boolean equals(Object? other); method public int hashCode(); @@ -136,14 +136,14 @@ package com.apollographql.apollo.api { } public final class Error { - ctor public Error(String message, java.util.List locations, java.util.Map customAttributes); + ctor public Error(String message, java.util.List locations, java.util.Map customAttributes); method @Deprecated public java.util.Map customAttributes(); method public boolean equals(Object? other); method public java.util.Map getCustomAttributes(); - method public java.util.List getLocations(); + method public java.util.List getLocations(); method public String getMessage(); method public int hashCode(); - method @Deprecated public java.util.List locations(); + method @Deprecated public java.util.List locations(); method @Deprecated public String? message(); } @@ -157,27 +157,27 @@ package com.apollographql.apollo.api { method @Deprecated public long line(); } - @com.apollographql.apollo.api.ApolloExperimental public interface ExecutionContext { - method public R! fold(R? initial, kotlin.jvm.functions.Function2 operation); - method public operator E? get(com.apollographql.apollo.api.ExecutionContext.Key key); - method public com.apollographql.apollo.api.ExecutionContext minusKey(com.apollographql.apollo.api.ExecutionContext.Key key); - method public default operator com.apollographql.apollo.api.ExecutionContext plus(com.apollographql.apollo.api.ExecutionContext context); - field public static final com.apollographql.apollo.api.ExecutionContext.Companion Companion; - field public static final com.apollographql.apollo.api.ExecutionContext Empty; + @com.homer.apollographql.apollo.api.ApolloExperimental public interface ExecutionContext { + method public R! fold(R? initial, kotlin.jvm.functions.Function2 operation); + method public operator E? get(com.homer.apollographql.apollo.api.ExecutionContext.Key key); + method public com.homer.apollographql.apollo.api.ExecutionContext minusKey(com.homer.apollographql.apollo.api.ExecutionContext.Key key); + method public default operator com.homer.apollographql.apollo.api.ExecutionContext plus(com.homer.apollographql.apollo.api.ExecutionContext context); + field public static final com.homer.apollographql.apollo.api.ExecutionContext.Companion Companion; + field public static final com.homer.apollographql.apollo.api.ExecutionContext Empty; } public static final class ExecutionContext.Companion { } - public static interface ExecutionContext.Element extends com.apollographql.apollo.api.ExecutionContext { - method public default R! fold(R? initial, kotlin.jvm.functions.Function2 operation); - method public default operator E? get(com.apollographql.apollo.api.ExecutionContext.Key key); - method public com.apollographql.apollo.api.ExecutionContext.Key getKey(); - method public default com.apollographql.apollo.api.ExecutionContext minusKey(com.apollographql.apollo.api.ExecutionContext.Key key); - property public abstract com.apollographql.apollo.api.ExecutionContext.Key key; + public static interface ExecutionContext.Element extends com.homer.apollographql.apollo.api.ExecutionContext { + method public default R! fold(R? initial, kotlin.jvm.functions.Function2 operation); + method public default operator E? get(com.homer.apollographql.apollo.api.ExecutionContext.Key key); + method public com.homer.apollographql.apollo.api.ExecutionContext.Key getKey(); + method public default com.homer.apollographql.apollo.api.ExecutionContext minusKey(com.homer.apollographql.apollo.api.ExecutionContext.Key key); + property public abstract com.homer..apollo.api.ExecutionContext.Key key; } - public static interface ExecutionContext.Key { + public static interface ExecutionContext.Key { } public class FileUpload { @@ -187,174 +187,174 @@ package com.apollographql.apollo.api { method public final String? getFilePath(); method public final String getMimetype(); method public void writeTo(okio.BufferedSink sink); - field public static final com.apollographql.apollo.api.FileUpload.Companion Companion; + field public static final com.homer.apollographql.apollo.api.FileUpload.Companion Companion; } public static final class FileUpload.Companion { } public final class FileuploadKt { - method public static com.apollographql.apollo.api.FileUpload create(com.apollographql.apollo.api.FileUpload.Companion, String mimetype, String filePath); + method public static com.homer..apollo.api.FileUpload create(com.homer.apollographql.apollo.api.FileUpload.Companion, String mimetype, String filePath); } public interface GraphqlFragment { - method public com.apollographql.apollo.api.internal.ResponseFieldMarshaller marshaller(); + method public com.homer.apollographql.apollo.api.internal.ResponseFieldMarshaller marshaller(); } public final class Input { - method public static com.apollographql.apollo.api.Input absent(); + method public static com.homer.apollographql.apollo.api.Input absent(); method public boolean equals(Object? other); - method public static com.apollographql.apollo.api.Input fromNullable(V? value); + method public static com.homer.apollographql.apollo.api.Input fromNullable(V? value); method public int hashCode(); - method public static com.apollographql.apollo.api.Input optional(V? value); - field public static final com.apollographql.apollo.api.Input.Companion Companion; + method public static com.homer.apollographql.apollo.api.Input optional(V? value); + field public static final com.homer.apollographql.apollo.api.Input.Companion Companion; field public final boolean defined; field public final V? value; } public static final class Input.Companion { - method public com.apollographql.apollo.api.Input absent(); - method public com.apollographql.apollo.api.Input fromNullable(V? value); - method public com.apollographql.apollo.api.Input optional(V? value); + method public com.homer.apollographql.apollo.api.Input absent(); + method public com.homer.apollographql.apollo.api.Input fromNullable(V? value); + method public com.homer.apollographql.apollo.api.Input optional(V? value); } public interface InputType { - method public com.apollographql.apollo.api.internal.InputFieldMarshaller marshaller(); + method public com.homer.apollographql.apollo.api.internal.InputFieldMarshaller marshaller(); } public final class KotlinExtensions { } - public interface Mutation extends com.apollographql.apollo.api.Operation { + public interface Mutation extends com.homer.apollographql.apollo.api.Operation { } - public interface Operation { - method public okio.ByteString composeRequestBody(boolean autoPersistQueries, boolean withQueryDocument, com.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters); - method public okio.ByteString composeRequestBody(com.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters); + public interface Operation { + method public okio.ByteString composeRequestBody(boolean autoPersistQueries, boolean withQueryDocument, com.homer.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters); + method public okio.ByteString composeRequestBody(com.homer.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters); method public okio.ByteString composeRequestBody(); - method public com.apollographql.apollo.api.OperationName name(); + method public com.homer.apollographql.apollo.api.OperationName name(); method public String operationId(); - method public com.apollographql.apollo.api.Response parse(okio.BufferedSource source, com.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters); - method public com.apollographql.apollo.api.Response parse(okio.ByteString byteString, com.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters); - method public com.apollographql.apollo.api.Response parse(okio.BufferedSource source); - method public com.apollographql.apollo.api.Response parse(okio.ByteString byteString); + method public com.homer.apollographql.apollo.api.Response parse(okio.BufferedSource source, com.homer.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters); + method public com.homer.apollographql.apollo.api.Response parse(okio.ByteString byteString, com.homer.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters); + method public com.homer.apollographql.apollo.api.Response parse(okio.BufferedSource source); + method public com.homer.apollographql.apollo.api.Response parse(okio.ByteString byteString); method public String queryDocument(); - method public com.apollographql.apollo.api.internal.ResponseFieldMapper responseFieldMapper(); + method public com.homer.apollographql.apollo.api.internal.ResponseFieldMapper responseFieldMapper(); method public V variables(); method public T? wrapData(D? data); - field public static final com.apollographql.apollo.api.Operation.Companion Companion; - field public static final com.apollographql.apollo.api.Operation.Variables EMPTY_VARIABLES; + field public static final com.homer.apollographql.apollo.api.Operation.Companion Companion; + field public static final com.homer.apollographql.apollo.api.Operation.Variables EMPTY_VARIABLES; } public static final class Operation.Companion { } public static interface Operation.Data { - method public com.apollographql.apollo.api.internal.ResponseFieldMarshaller marshaller(); + method public com.homer.apollographql.apollo.api.internal.ResponseFieldMarshaller marshaller(); } public static class Operation.Variables { ctor public Operation.Variables(); method public final String marshal(); - method public final String marshal(com.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters); - method public com.apollographql.apollo.api.internal.InputFieldMarshaller marshaller(); + method public final String marshal(com.homer.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters); + method public com.homer.apollographql.apollo.api.internal.InputFieldMarshaller marshaller(); method public java.util.Map valueMap(); } public final class OperationDataJsonSerializer { - method public static String serialize(com.apollographql.apollo.api.Operation.Data, String indent = "", com.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters = com.apollographql.apollo.api.ScalarTypeAdapters.DEFAULT); - method public static String serialize(com.apollographql.apollo.api.Operation.Data, String indent = ""); - method public static String serialize(com.apollographql.apollo.api.Operation.Data); + method public static String serialize(com.homer.apollographql.apollo.api.Operation.Data, String indent = "", com.homer.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters = com.homer.apollo.api.ScalarTypeAdapters.DEFAULT); + method public static String serialize(com.homer.apollographql.apollo.api.Operation.Data, String indent = ""); + method public static String serialize(com.homer.apollographql.apollo.api.Operation.Data); } public interface OperationName { method public String name(); } - public interface Query extends com.apollographql.apollo.api.Operation { + public interface Query extends com.homer.apollographql.apollo.api.Operation { } public final class Response { - ctor public Response(com.apollographql.apollo.api.Operation operation, T? data, java.util.List? errors, java.util.Set dependentKeys, boolean isFromCache, java.util.Map extensions, com.apollographql.apollo.api.ExecutionContext executionContext); - ctor public Response(com.apollographql.apollo.api.Response.Builder builder); - method public static com.apollographql.apollo.api.Response.Builder builder(com.apollographql.apollo.api.Operation operation); - method public com.apollographql.apollo.api.Operation component1(); + ctor public Response(com.homer.apollographql.apollo.api.Operation operation, T? data, java.util.List? errors, java.util.Set dependentKeys, boolean isFromCache, java.util.Map extensions, com.homer.apollographql.apollo.api.ExecutionContext executionContext); + ctor public Response(com.homer.apollographql.apollo.api.Response.Builder builder); + method public static com.homer.apollographql.apollo.api.Response.Builder builder(com.homer.apollographql.apollo.api.Operation operation); + method public com.homer..apollo.api.Operation component1(); method public T? component2(); - method public java.util.List? component3(); + method public java.util.List? component3(); method public java.util.Set component4(); method public boolean component5(); method public java.util.Map component6(); - method public com.apollographql.apollo.api.ExecutionContext component7(); - method public com.apollographql.apollo.api.Response copy(com.apollographql.apollo.api.Operation operation, T? data, java.util.List? errors, java.util.Set dependentKeys, boolean isFromCache, java.util.Map extensions, com.apollographql.apollo.api.ExecutionContext executionContext); + method public com.homer.apollographql.apollo.api.ExecutionContext component7(); + method public com.homer.apollographql.apollo.api.Response copy(com.homer.apollographql.apollo.api.Operation operation, T? data, java.util.List? errors, java.util.Set dependentKeys, boolean isFromCache, java.util.Map extensions, com.homer.apollographql.apollo.api.ExecutionContext executionContext); method @Deprecated public T? data(); method @Deprecated public java.util.Set dependentKeys(); method public boolean equals(Object? other); - method @Deprecated public java.util.List? errors(); + method @Deprecated public java.util.List? errors(); method @Deprecated public java.util.Map extensions(); method @Deprecated public boolean fromCache(); method public T? getData(); method public java.util.Set getDependentKeys(); - method public java.util.List? getErrors(); - method public com.apollographql.apollo.api.ExecutionContext getExecutionContext(); + method public java.util.List? getErrors(); + method public com.homer.apollographql.apollo.api.ExecutionContext getExecutionContext(); method public java.util.Map getExtensions(); method @Deprecated public boolean getFromCache(); - method public com.apollographql.apollo.api.Operation getOperation(); + method public com.homer.apollographql.apollo.api.Operation getOperation(); method public boolean hasErrors(); method public int hashCode(); method public boolean isFromCache(); - method @Deprecated public com.apollographql.apollo.api.Operation operation(); - method public com.apollographql.apollo.api.Response.Builder toBuilder(); + method @Deprecated public com.homer.apollographql.apollo.api.Operation operation(); + method public com.homer.apollographql.apollo.api.Response.Builder toBuilder(); method public String toString(); property @Deprecated public final boolean fromCache; - field public static final com.apollographql.apollo.api.Response.Companion Companion; + field public static final com.homer.apollographql.apollo.api.Response.Companion Companion; } public static final class Response.Builder { - method public com.apollographql.apollo.api.Response build(); - method public com.apollographql.apollo.api.Response.Builder data(T? data); - method public com.apollographql.apollo.api.Response.Builder dependentKeys(java.util.Set? dependentKeys); - method public com.apollographql.apollo.api.Response.Builder errors(java.util.List? errors); - method public com.apollographql.apollo.api.Response.Builder executionContext(com.apollographql.apollo.api.ExecutionContext executionContext); - method public com.apollographql.apollo.api.Response.Builder extensions(java.util.Map? extensions); - method public com.apollographql.apollo.api.Response.Builder fromCache(boolean fromCache); + method public com.homer.apollographql.apollo.api.Response build(); + method public com.homer.apollographql.apollo.api.Response.Builder data(T? data); + method public com.homer.apollographql.apollo.api.Response.Builder dependentKeys(java.util.Set? dependentKeys); + method public com.homer.apollographql.apollo.api.Response.Builder errors(java.util.List? errors); + method public com.homer.apollographql.apollo.api.Response.Builder executionContext(com.homer.apollographql.apollo.api.ExecutionContext executionContext); + method public com.homer.apollographql.apollo.api.Response.Builder extensions(java.util.Map? extensions); + method public com.homer.apollographql.apollo.api.Response.Builder fromCache(boolean fromCache); } public static final class Response.Companion { - method public com.apollographql.apollo.api.Response.Builder builder(com.apollographql.apollo.api.Operation operation); + method public com.homer.apollographql.apollo.api.Response.Builder builder(com.homer.apollographql.apollo.api.Operation operation); } public class ResponseField { method @Deprecated public final java.util.Map arguments(); - method @Deprecated public final java.util.List conditions(); + method @Deprecated public final java.util.List conditions(); method public boolean equals(Object? other); method @Deprecated public final String fieldName(); - method public static final com.apollographql.apollo.api.ResponseField forBoolean(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); - method public static final com.apollographql.apollo.api.ResponseField.CustomTypeField forCustomType(String responseName, String fieldName, java.util.Map? arguments, boolean optional, com.apollographql.apollo.api.ScalarType scalarType, java.util.List? conditions); - method public static final com.apollographql.apollo.api.ResponseField forDouble(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); - method public static final com.apollographql.apollo.api.ResponseField forEnum(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); - method public static final com.apollographql.apollo.api.ResponseField forFragment(String responseName, String fieldName, java.util.List? conditions); - method public static final com.apollographql.apollo.api.ResponseField forInt(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); - method public static final com.apollographql.apollo.api.ResponseField forList(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); - method public static final com.apollographql.apollo.api.ResponseField forLong(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); - method public static final com.apollographql.apollo.api.ResponseField forObject(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); - method public static final com.apollographql.apollo.api.ResponseField forString(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public static final com.homer.apollographql.apollo.api.ResponseField forBoolean(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public static final com.homer.apollographql.apollo.api.ResponseField.CustomTypeField forCustomType(String responseName, String fieldName, java.util.Map? arguments, boolean optional, com.homer.apollographql.apollo.api.ScalarType scalarType, java.util.List? conditions); + method public static final com.homer.apollographql.apollo.api.ResponseField forDouble(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public static final com.homer.apollographql.apollo.api.ResponseField forEnum(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public static final com.homer.apollographql.apollo.api.ResponseField forFragment(String responseName, String fieldName, java.util.List? conditions); + method public static final com.homer.apollographql.apollo.api.ResponseField forInt(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public static final com.homer.apollographql.apollo.api.ResponseField forList(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public static final com.homer.apollographql.apollo.api.ResponseField forLong(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public static final com.homer.apollographql.apollo.api.ResponseField forObject(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public static final com.homer.apollographql.apollo.api.ResponseField forString(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); method public final java.util.Map getArguments(); - method public final java.util.List getConditions(); + method public final java.util.List getConditions(); method public final String getFieldName(); method public final boolean getOptional(); method public final String getResponseName(); - method public final com.apollographql.apollo.api.ResponseField.Type getType(); + method public final com.homer.apollographql.apollo.api.ResponseField.Type getType(); method public int hashCode(); method public static final boolean isArgumentValueVariableType(java.util.Map objectMap); method @Deprecated public final boolean optional(); - method public final Object? resolveArgument(String name, com.apollographql.apollo.api.Operation.Variables variables); + method public final Object? resolveArgument(String name, com.homer.apollographql.apollo.api.Operation.Variables variables); method @Deprecated public final String responseName(); - method @Deprecated public final com.apollographql.apollo.api.ResponseField.Type type(); - field public static final com.apollographql.apollo.api.ResponseField.Companion Companion; + method @Deprecated public final com.homer.apollographql.apollo.api.ResponseField.Type type(); + field public static final com.homer.apollographql.apollo.api.ResponseField.Companion Companion; field public static final String VARIABLE_NAME_KEY = "variableName"; } - public static final class ResponseField.BooleanCondition extends com.apollographql.apollo.api.ResponseField.Condition { + public static final class ResponseField.BooleanCondition extends com.homer.apollographql.apollo.api.ResponseField.Condition { method public boolean equals(Object? other); method @Deprecated public boolean getInverted(); method public String getVariableName(); @@ -366,52 +366,52 @@ package com.apollographql.apollo.api { } public static final class ResponseField.Companion { - method public com.apollographql.apollo.api.ResponseField forBoolean(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); - method public com.apollographql.apollo.api.ResponseField.CustomTypeField forCustomType(String responseName, String fieldName, java.util.Map? arguments, boolean optional, com.apollographql.apollo.api.ScalarType scalarType, java.util.List? conditions); - method public com.apollographql.apollo.api.ResponseField forDouble(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); - method public com.apollographql.apollo.api.ResponseField forEnum(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); - method public com.apollographql.apollo.api.ResponseField forFragment(String responseName, String fieldName, java.util.List? conditions); - method public com.apollographql.apollo.api.ResponseField forInt(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); - method public com.apollographql.apollo.api.ResponseField forList(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); - method public com.apollographql.apollo.api.ResponseField forLong(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); - method public com.apollographql.apollo.api.ResponseField forObject(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); - method public com.apollographql.apollo.api.ResponseField forString(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public com.homer.apollographql.apollo.api.ResponseField forBoolean(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public com.homer.apollographql.apollo.api.ResponseField.CustomTypeField forCustomType(String responseName, String fieldName, java.util.Map? arguments, boolean optional, com.homer.apollographql.apollo.api.ScalarType scalarType, java.util.List? conditions); + method public com.homer.apollographql.apollo.api.ResponseField forDouble(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public com.homer.apollographql.apollo.api.ResponseField forEnum(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public com.homer.apollographql.apollo.api.ResponseField forFragment(String responseName, String fieldName, java.util.List? conditions); + method public com.homer.apollographql.apollo.api.ResponseField forInt(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public com.homer.apollographql.apollo.api.ResponseField forList(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public com.homer.apollographql.apollo.api.ResponseField forLong(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public com.homer.apollographql.apollo.api.ResponseField forObject(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); + method public com.homer.apollographql.apollo.api.ResponseField forString(String responseName, String fieldName, java.util.Map? arguments, boolean optional, java.util.List? conditions); method public boolean isArgumentValueVariableType(java.util.Map objectMap); } public static class ResponseField.Condition { - method public static final com.apollographql.apollo.api.ResponseField.BooleanCondition booleanCondition(String variableName, boolean inverted); - method public static final com.apollographql.apollo.api.ResponseField.TypeNameCondition typeCondition(String![] types); - field public static final com.apollographql.apollo.api.ResponseField.Condition.Companion Companion; + method public static final com.homer.apollographql.apollo.api.ResponseField.BooleanCondition booleanCondition(String variableName, boolean inverted); + method public static final com.homer.apollographql.apollo.api.ResponseField.TypeNameCondition typeCondition(String![] types); + field public static final com.homer.apollographql.apollo.api.ResponseField.Condition.Companion Companion; } public static final class ResponseField.Condition.Companion { - method public com.apollographql.apollo.api.ResponseField.BooleanCondition booleanCondition(String variableName, boolean inverted); - method public com.apollographql.apollo.api.ResponseField.TypeNameCondition typeCondition(String![] types); + method public com.homer.apollographql.apollo.api.ResponseField.BooleanCondition booleanCondition(String variableName, boolean inverted); + method public com.homer.apollographql.apollo.api.ResponseField.TypeNameCondition typeCondition(String![] types); } - public static final class ResponseField.CustomTypeField extends com.apollographql.apollo.api.ResponseField { - method public com.apollographql.apollo.api.ScalarType getScalarType(); - method @Deprecated public com.apollographql.apollo.api.ScalarType scalarType(); + public static final class ResponseField.CustomTypeField extends com.homer.apollographql.apollo.api.ResponseField { + method public com.homer.apollographql.apollo.api.ScalarType getScalarType(); + method @Deprecated public com.homer.apollographql.apollo.api.ScalarType scalarType(); } public enum ResponseField.Type { - method public static com.apollographql.apollo.api.ResponseField.Type valueOf(String name); - method public static com.apollographql.apollo.api.ResponseField.Type[] values(); - enum_constant public static final com.apollographql.apollo.api.ResponseField.Type BOOLEAN; - enum_constant public static final com.apollographql.apollo.api.ResponseField.Type CUSTOM; - enum_constant public static final com.apollographql.apollo.api.ResponseField.Type DOUBLE; - enum_constant public static final com.apollographql.apollo.api.ResponseField.Type ENUM; - enum_constant public static final com.apollographql.apollo.api.ResponseField.Type FRAGMENT; - enum_constant public static final com.apollographql.apollo.api.ResponseField.Type FRAGMENTS; - enum_constant public static final com.apollographql.apollo.api.ResponseField.Type INT; - enum_constant public static final com.apollographql.apollo.api.ResponseField.Type LIST; - enum_constant public static final com.apollographql.apollo.api.ResponseField.Type LONG; - enum_constant public static final com.apollographql.apollo.api.ResponseField.Type OBJECT; - enum_constant public static final com.apollographql.apollo.api.ResponseField.Type STRING; - } - - public static final class ResponseField.TypeNameCondition extends com.apollographql.apollo.api.ResponseField.Condition { + method public static com.homer.apollographql.apollo.api.ResponseField.Type valueOf(String name); + method public static com.homer.apollographql.apollo.api.ResponseField.Type[] values(); + enum_constant public static final com.homer.apollographql.apollo.api.ResponseField.Type BOOLEAN; + enum_constant public static final com.homer.apollographql.apollo.api.ResponseField.Type CUSTOM; + enum_constant public static final com.homer.apollographql.apollo.api.ResponseField.Type DOUBLE; + enum_constant public static final com.homer.apollographql.apollo.api.ResponseField.Type ENUM; + enum_constant public static final com.homer.apollographql.apollo.api.ResponseField.Type FRAGMENT; + enum_constant public static final com.homer.apollographql.apollo.api.ResponseField.Type FRAGMENTS; + enum_constant public static final com.homer.apollographql.apollo.api.ResponseField.Type INT; + enum_constant public static final com.homer.apollographql.apollo.api.ResponseField.Type LIST; + enum_constant public static final com.homer.apollographql.apollo.api.ResponseField.Type LONG; + enum_constant public static final com.homer.apollographql.apollo.api.ResponseField.Type OBJECT; + enum_constant public static final com.homer.apollographql.apollo.api.ResponseField.Type STRING; + } + + public static final class ResponseField.TypeNameCondition extends com.homer.apollographql.apollo.api.ResponseField.Condition { method public boolean equals(Object? other); method public java.util.List getTypeNames(); method public int hashCode(); @@ -424,22 +424,22 @@ package com.apollographql.apollo.api { } public final class ScalarTypeAdapters { - ctor public ScalarTypeAdapters(java.util.Map> customAdapters); - method public com.apollographql.apollo.api.CustomTypeAdapter adapterFor(com.apollographql.apollo.api.ScalarType scalarType); - method public java.util.Map> getCustomAdapters(); - field public static final com.apollographql.apollo.api.ScalarTypeAdapters.Companion Companion; - field public static final com.apollographql.apollo.api.ScalarTypeAdapters DEFAULT; + ctor public ScalarTypeAdapters(java.util.Map> customAdapters); + method public com.homer.apollographql.apollo.api.CustomTypeAdapter adapterFor(com.homer.apollographql.apollo.api.ScalarType scalarType); + method public java.util.Map> getCustomAdapters(); + field public static final com.homer.apollographql.apollo.api.ScalarTypeAdapters.Companion Companion; + field public static final com.homer.apollographql.apollo.api.ScalarTypeAdapters DEFAULT; } public static final class ScalarTypeAdapters.Companion { } - public interface Subscription extends com.apollographql.apollo.api.Operation { + public interface Subscription extends com.homer.apollographql.apollo.api.Operation { } } -package com.apollographql.apollo.exception { +package com.homer.apollographql.apollo.exception { public class ApolloException { ctor public ApolloException(String message); diff --git a/apollo-api/build.gradle.kts b/apollo-api/build.gradle.kts index 14618626899..575e817839e 100644 --- a/apollo-api/build.gradle.kts +++ b/apollo-api/build.gradle.kts @@ -4,32 +4,10 @@ plugins { } kotlin { - @Suppress("ClassName") - data class iOSTarget(val name: String, val preset: String, val id: String) - - val iosTargets = listOf( - iOSTarget("ios", "iosArm64", "ios-arm64"), - iOSTarget("iosSim", "iosX64", "ios-x64") - ) - - for ((targetName, presetName, id) in iosTargets) { - targetFromPreset(presets.getByName(presetName), targetName) { - mavenPublication { - artifactId = "${project.name}-$id" - } - } - } - jvm { withJava() } - js { - useCommonJs() - browser() - nodejs() - } - sourceSets { val commonMain by getting { dependencies { @@ -42,48 +20,11 @@ kotlin { dependencies { } } - - val iosMain by getting { - dependsOn(commonMain) - } - - val iosSimMain by getting { - dependsOn(iosMain) - } - - val jsMain by getting { - dependsOn(commonMain) - dependencies { - implementation(npm("big.js", "5.2.2")) - } - } - - val jsTest by getting { - dependencies { - implementation(kotlin("test-js")) - } - } - - val commonTest by getting { - dependencies { - implementation(kotlin("test-common")) - implementation(kotlin("test-annotations-common")) - } - } - - val jvmTest by getting { - dependsOn(jvmMain) - dependencies { - implementation(kotlin("test-junit")) - implementation(groovy.util.Eval.x(project, "x.dep.truth")) - implementation(groovy.util.Eval.x(project, "x.dep.okHttp.okHttp")) - } - } } } metalava { - hiddenPackages += setOf("com.apollographql.apollo.api.internal") + hiddenPackages += setOf("com.homer.apollographql.apollo.api.internal") } tasks.withType { diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/InputType.kt b/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/InputType.kt deleted file mode 100644 index bad8a713102..00000000000 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/InputType.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.apollographql.apollo.api - -import com.apollographql.apollo.api.internal.InputFieldMarshaller - -interface InputType { - - fun marshaller(): InputFieldMarshaller -} diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/FieldValueResolver.kt b/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/FieldValueResolver.kt deleted file mode 100644 index 4579e093422..00000000000 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/FieldValueResolver.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.apollographql.apollo.api.internal - -import com.apollographql.apollo.api.ResponseField - -interface FieldValueResolver { - fun valueFor(recordSet: R, field: ResponseField): T? -} diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/Closeable.kt b/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/Closeable.kt deleted file mode 100644 index 8e2ac8e5498..00000000000 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/Closeable.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.apollographql.apollo.api.internal.json - -expect interface Closeable { - fun close() -} diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/Flushable.kt b/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/Flushable.kt deleted file mode 100644 index 7625650d5a8..00000000000 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/Flushable.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.apollographql.apollo.api.internal.json - -expect interface Flushable { - fun flush() -} diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/Logger.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/Logger.kt similarity index 79% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/Logger.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/Logger.kt index 6a90f9784b5..89ada19aa95 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/Logger.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/Logger.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo +package com.homer.apollographql.apollo /** - * Logger to use for logging by the [com.apollographql.apollo.ApolloClient] + * Logger to use for logging by the [com.homer.apollographql.apollo.ApolloClient] */ interface Logger { /** diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/ApolloExperimental.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/ApolloExperimental.kt similarity index 87% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/ApolloExperimental.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/ApolloExperimental.kt index ddfd523286c..df54f8fa685 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/ApolloExperimental.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/ApolloExperimental.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api /** * Marks declarations that are still **experimental**. diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/BigDecimal.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/BigDecimal.kt similarity index 93% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/BigDecimal.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/BigDecimal.kt index 2b6408fed19..77bbb90154e 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/BigDecimal.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/BigDecimal.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api // BigDecimal cannot subclass `Number` in JS, as it will cause runtime trap in any compiled Kotlin/JS product in the module initialization // script. diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/CustomTypeAdapter.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/CustomTypeAdapter.kt similarity index 96% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/CustomTypeAdapter.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/CustomTypeAdapter.kt index f5118a0d904..b59e3b1acc8 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/CustomTypeAdapter.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/CustomTypeAdapter.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api /** * Class represents the adapter for mapping GraphQL custom scalar types to Java objects. diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/CustomTypeValue.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/CustomTypeValue.kt similarity index 98% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/CustomTypeValue.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/CustomTypeValue.kt index e815ece87a0..b711a85ad91 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/CustomTypeValue.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/CustomTypeValue.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api import kotlin.jvm.JvmField import kotlin.jvm.JvmStatic diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/EnumValue.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/EnumValue.kt similarity index 66% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/EnumValue.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/EnumValue.kt index 73737c573ea..4cdc14c13f2 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/EnumValue.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/EnumValue.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api /** * Represents an enum value diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Error.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Error.kt similarity index 98% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Error.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Error.kt index b81bb4dbc19..ea589ccf735 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Error.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Error.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api import kotlin.js.JsName diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/ExecutionContext.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/ExecutionContext.kt similarity index 95% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/ExecutionContext.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/ExecutionContext.kt index eac9a90b215..4e595e3ae88 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/ExecutionContext.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/ExecutionContext.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api -import com.apollographql.apollo.api.ExecutionContext.Element -import com.apollographql.apollo.api.ExecutionContext.Key +import com.homer.apollographql.apollo.api.ExecutionContext.Element +import com.homer.apollographql.apollo.api.ExecutionContext.Key import kotlin.jvm.JvmField /** diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/FileUpload.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/FileUpload.kt similarity index 95% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/FileUpload.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/FileUpload.kt index eac441b4181..b13a0ef103d 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/FileUpload.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/FileUpload.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api import okio.BufferedSink diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/GraphqlFragment.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/GraphqlFragment.kt similarity index 63% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/GraphqlFragment.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/GraphqlFragment.kt index b40f1034e01..61309353bba 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/GraphqlFragment.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/GraphqlFragment.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller +import com.homer.apollographql.apollo.api.internal.ResponseFieldMarshaller /** * Represents a GraphQL fragment diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Input.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Input.kt similarity index 97% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Input.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Input.kt index b9ed0e81c0b..04b773a8a1d 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Input.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Input.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api import kotlin.jvm.JvmField import kotlin.jvm.JvmStatic diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/InputExtensions.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/InputExtensions.kt similarity index 86% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/InputExtensions.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/InputExtensions.kt index c1841af40a3..c40d3871122 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/InputExtensions.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/InputExtensions.kt @@ -2,7 +2,7 @@ @file:JvmName("KotlinExtensions") @file:JvmMultifileClass -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api import kotlin.jvm.JvmMultifileClass import kotlin.jvm.JvmName diff --git a/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/InputType.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/InputType.kt new file mode 100644 index 00000000000..0a4c5a6aafb --- /dev/null +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/InputType.kt @@ -0,0 +1,8 @@ +package com.homer.apollographql.apollo.api + +import com.homer.apollographql.apollo.api.internal.InputFieldMarshaller + +interface InputType { + + fun marshaller(): InputFieldMarshaller +} diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Mutation.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Mutation.kt similarity index 80% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Mutation.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Mutation.kt index a4ceaaee576..a5ec5e8695d 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Mutation.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Mutation.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api /** * Represents a GraphQL mutation operation that will be sent to the server. diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Operation.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Operation.kt similarity index 90% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Operation.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Operation.kt index 0588c61b89d..f734dd4b7a0 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Operation.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Operation.kt @@ -1,13 +1,13 @@ -package com.apollographql.apollo.api - -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.InputFieldWriter -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.Throws -import com.apollographql.apollo.api.internal.json.InputFieldJsonWriter -import com.apollographql.apollo.api.internal.json.JsonWriter -import com.apollographql.apollo.api.internal.json.use +package com.homer.apollographql.apollo.api + +import com.homer.apollographql.apollo.api.internal.InputFieldMarshaller +import com.homer.apollographql.apollo.api.internal.InputFieldWriter +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper +import com.homer.apollographql.apollo.api.internal.ResponseFieldMarshaller +import com.homer.apollographql.apollo.api.internal.Throws +import com.homer.apollographql.apollo.api.internal.json.InputFieldJsonWriter +import com.homer.apollographql.apollo.api.internal.json.JsonWriter +import com.homer.apollographql.apollo.api.internal.json.use import okio.Buffer import okio.BufferedSource import okio.ByteString diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/OperationDataExtensions.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/OperationDataExtensions.kt similarity index 87% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/OperationDataExtensions.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/OperationDataExtensions.kt index 98b42138665..e54335b4bdd 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/OperationDataExtensions.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/OperationDataExtensions.kt @@ -1,9 +1,9 @@ @file:JvmName("OperationDataJsonSerializer") -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.SimpleResponseWriter +import com.homer.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT +import com.homer.apollographql.apollo.api.internal.SimpleResponseWriter import okio.IOException import kotlin.jvm.JvmName import kotlin.jvm.JvmOverloads diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/OperationName.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/OperationName.kt similarity index 74% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/OperationName.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/OperationName.kt index d85dae7a824..22ebbf700cf 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/OperationName.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/OperationName.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api /** * GraphQL operation name. diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Query.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Query.kt similarity index 80% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Query.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Query.kt index 96dfb9131a3..c092eb6a11e 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Query.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Query.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api import okio.ByteString diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Response.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Response.kt similarity index 99% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Response.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Response.kt index 2867daa058f..56a34cd9bfb 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Response.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Response.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api import kotlin.js.JsName import kotlin.jvm.JvmStatic diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/ResponseField.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/ResponseField.kt similarity index 99% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/ResponseField.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/ResponseField.kt index 76e6f6e7a9a..4de41a74dfc 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/ResponseField.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/ResponseField.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api import kotlin.js.JsName import kotlin.jvm.JvmStatic diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/ScalarType.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/ScalarType.kt similarity index 89% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/ScalarType.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/ScalarType.kt index e9fb4bc7343..6e92f973799 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/ScalarType.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/ScalarType.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api /** * Represents a custom GraphQL scalar type diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/ScalarTypeAdapters.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/ScalarTypeAdapters.kt similarity index 91% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/ScalarTypeAdapters.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/ScalarTypeAdapters.kt index f74d005dd1e..caa9b8cbf2d 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/ScalarTypeAdapters.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/ScalarTypeAdapters.kt @@ -1,10 +1,10 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api -import com.apollographql.apollo.api.CustomTypeValue.* -import com.apollographql.apollo.api.CustomTypeValue.Companion.fromRawValue -import com.apollographql.apollo.api.internal.json.JsonWriter -import com.apollographql.apollo.api.internal.json.Utils -import com.apollographql.apollo.api.internal.json.use +import com.homer.apollographql.apollo.api.CustomTypeValue.* +import com.homer.apollographql.apollo.api.CustomTypeValue.Companion.fromRawValue +import com.homer.apollographql.apollo.api.internal.json.JsonWriter +import com.homer.apollographql.apollo.api.internal.json.Utils +import com.homer.apollographql.apollo.api.internal.json.use import okio.Buffer import kotlin.jvm.JvmField @@ -82,7 +82,7 @@ class ScalarTypeAdapters(val customAdapters: Map throw IllegalArgumentException("Can't decode: $value into Double") } } + - mapOf("com.apollographql.apollo.api.FileUpload" to object : CustomTypeAdapter { + mapOf("com.homer.apollographql.apollo.api.FileUpload" to object : CustomTypeAdapter { override fun decode(value: CustomTypeValue<*>): FileUpload { // TODO: is there a valid use case for decoding a FileUpload or should we throw here? return FileUpload("", value.value?.toString() ?: "") diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Subscription.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Subscription.kt similarity index 76% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Subscription.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Subscription.kt index 4284749bbbd..8495305ef63 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/Subscription.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/Subscription.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api /** * Represents a GraphQL subscription. diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ApolloLogger.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ApolloLogger.kt similarity index 72% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ApolloLogger.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ApolloLogger.kt index 4f3bb954e43..395e113b229 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ApolloLogger.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ApolloLogger.kt @@ -1,9 +1,9 @@ -package com.apollographql.apollo.api.internal +package com.homer.apollographql.apollo.api.internal -import com.apollographql.apollo.Logger -import com.apollographql.apollo.Logger.Companion.DEBUG -import com.apollographql.apollo.Logger.Companion.ERROR -import com.apollographql.apollo.Logger.Companion.WARN +import com.homer.apollographql.apollo.Logger +import com.homer.apollographql.apollo.Logger.Companion.DEBUG +import com.homer.apollographql.apollo.Logger.Companion.ERROR +import com.homer.apollographql.apollo.Logger.Companion.WARN class ApolloLogger(val logger: Logger?) { diff --git a/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/FieldValueResolver.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/FieldValueResolver.kt new file mode 100644 index 00000000000..0d784cff463 --- /dev/null +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/FieldValueResolver.kt @@ -0,0 +1,7 @@ +package com.homer.apollographql.apollo.api.internal + +import com.homer.apollographql.apollo.api.ResponseField + +interface FieldValueResolver { + fun valueFor(recordSet: R, field: ResponseField): T? +} diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/InputFieldMarshaller.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/InputFieldMarshaller.kt similarity index 88% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/InputFieldMarshaller.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/InputFieldMarshaller.kt index bf2b3258b56..738020084da 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/InputFieldMarshaller.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/InputFieldMarshaller.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.internal +package com.homer.apollographql.apollo.api.internal import okio.IOException import kotlin.jvm.JvmSynthetic diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/InputFieldWriter.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/InputFieldWriter.kt similarity index 96% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/InputFieldWriter.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/InputFieldWriter.kt index d2cad8f11cf..e8681198278 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/InputFieldWriter.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/InputFieldWriter.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.api.internal +package com.homer.apollographql.apollo.api.internal -import com.apollographql.apollo.api.ScalarType +import com.homer.apollographql.apollo.api.ScalarType import okio.IOException import kotlin.jvm.JvmSynthetic diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/OperationRequestBodyComposer.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/OperationRequestBodyComposer.kt similarity index 78% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/OperationRequestBodyComposer.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/OperationRequestBodyComposer.kt index b86ee398f5b..e26d29c71c2 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/OperationRequestBodyComposer.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/OperationRequestBodyComposer.kt @@ -1,9 +1,9 @@ -package com.apollographql.apollo.api.internal +package com.homer.apollographql.apollo.api.internal -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.internal.json.JsonWriter -import com.apollographql.apollo.api.internal.json.use +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.ScalarTypeAdapters +import com.homer.apollographql.apollo.api.internal.json.JsonWriter +import com.homer.apollographql.apollo.api.internal.json.use import okio.Buffer import okio.ByteString import kotlin.jvm.JvmStatic diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/QueryDocumentMinifier.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/QueryDocumentMinifier.kt similarity index 77% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/QueryDocumentMinifier.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/QueryDocumentMinifier.kt index 1506a7dc22f..01aaa30be32 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/QueryDocumentMinifier.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/QueryDocumentMinifier.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.internal +package com.homer.apollographql.apollo.api.internal import kotlin.jvm.JvmStatic diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ResolveDelegate.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ResolveDelegate.kt similarity index 77% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ResolveDelegate.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ResolveDelegate.kt index f0624ddfc63..63a7fda1311 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ResolveDelegate.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ResolveDelegate.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.api.internal +package com.homer.apollographql.apollo.api.internal -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.ResponseField +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.ResponseField interface ResolveDelegate { fun willResolveRootQuery(operation: Operation<*, *, *>) diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ResponseFieldMapper.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ResponseFieldMapper.kt similarity index 90% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ResponseFieldMapper.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ResponseFieldMapper.kt index 074aa085ef8..3c7f3e28f26 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ResponseFieldMapper.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ResponseFieldMapper.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.internal +package com.homer.apollographql.apollo.api.internal import kotlin.jvm.JvmSynthetic diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ResponseFieldMarshaller.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ResponseFieldMarshaller.kt similarity index 87% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ResponseFieldMarshaller.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ResponseFieldMarshaller.kt index 2a42c3e66b6..a22197985ac 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ResponseFieldMarshaller.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ResponseFieldMarshaller.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.internal +package com.homer.apollographql.apollo.api.internal import kotlin.jvm.JvmSynthetic diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ResponseReader.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ResponseReader.kt similarity index 93% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ResponseReader.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ResponseReader.kt index fa4de6e069b..0fd2edad206 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ResponseReader.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ResponseReader.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.api.internal +package com.homer.apollographql.apollo.api.internal -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarType +import com.homer.apollographql.apollo.api.ResponseField +import com.homer.apollographql.apollo.api.ScalarType /* * ResponseReader is an abstraction for reading GraphQL fields. diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ResponseWriter.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ResponseWriter.kt similarity index 91% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ResponseWriter.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ResponseWriter.kt index a353fa2bf54..a0844dc238e 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/ResponseWriter.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/ResponseWriter.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.api.internal +package com.homer.apollographql.apollo.api.internal -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarType +import com.homer.apollographql.apollo.api.ResponseField +import com.homer.apollographql.apollo.api.ScalarType interface ResponseWriter { fun writeString(field: ResponseField, value: String?) diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/SimpleOperationResponseParser.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/SimpleOperationResponseParser.kt similarity index 83% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/SimpleOperationResponseParser.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/SimpleOperationResponseParser.kt index f5faff48dca..ade0c3379ee 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/SimpleOperationResponseParser.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/SimpleOperationResponseParser.kt @@ -1,12 +1,12 @@ -package com.apollographql.apollo.api.internal +package com.homer.apollographql.apollo.api.internal -import com.apollographql.apollo.api.Error -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.internal.json.BufferedSourceJsonReader -import com.apollographql.apollo.api.internal.json.ResponseJsonStreamReader -import com.apollographql.apollo.api.internal.json.use +import com.homer.apollographql.apollo.api.Error +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.Response +import com.homer.apollographql.apollo.api.ScalarTypeAdapters +import com.homer.apollographql.apollo.api.internal.json.BufferedSourceJsonReader +import com.homer.apollographql.apollo.api.internal.json.ResponseJsonStreamReader +import com.homer.apollographql.apollo.api.internal.json.use import okio.BufferedSource import okio.IOException import kotlin.jvm.JvmStatic diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/SimpleResponseReader.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/SimpleResponseReader.kt similarity index 93% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/SimpleResponseReader.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/SimpleResponseReader.kt index e2a1c27fb95..ab1f1828541 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/SimpleResponseReader.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/SimpleResponseReader.kt @@ -1,12 +1,12 @@ -package com.apollographql.apollo.api.internal - -import com.apollographql.apollo.api.BigDecimal -import com.apollographql.apollo.api.CustomTypeValue -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarType -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.toNumber +package com.homer.apollographql.apollo.api.internal + +import com.homer.apollographql.apollo.api.BigDecimal +import com.homer.apollographql.apollo.api.CustomTypeValue +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.ResponseField +import com.homer.apollographql.apollo.api.ScalarType +import com.homer.apollographql.apollo.api.ScalarTypeAdapters +import com.homer.apollographql.apollo.api.toNumber class SimpleResponseReader private constructor( private val recordSet: Map, diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/SimpleResponseWriter.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/SimpleResponseWriter.kt similarity index 89% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/SimpleResponseWriter.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/SimpleResponseWriter.kt index df480f3c3da..a76a02aaf14 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/SimpleResponseWriter.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/SimpleResponseWriter.kt @@ -1,11 +1,11 @@ -package com.apollographql.apollo.api.internal - -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarType -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.internal.json.JsonWriter -import com.apollographql.apollo.api.internal.json.Utils.writeToJson -import com.apollographql.apollo.api.internal.json.use +package com.homer.apollographql.apollo.api.internal + +import com.homer.apollographql.apollo.api.ResponseField +import com.homer.apollographql.apollo.api.ScalarType +import com.homer.apollographql.apollo.api.ScalarTypeAdapters +import com.homer.apollographql.apollo.api.internal.json.JsonWriter +import com.homer.apollographql.apollo.api.internal.json.Utils.writeToJson +import com.homer.apollographql.apollo.api.internal.json.use import okio.Buffer import okio.IOException diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/Throws.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/Throws.kt similarity index 68% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/Throws.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/Throws.kt index a0082f4eb54..39832c4f072 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/Throws.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/Throws.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.internal +package com.homer.apollographql.apollo.api.internal import kotlin.reflect.KClass diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/Utils.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/Utils.kt similarity index 96% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/Utils.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/Utils.kt index 3937c553542..1c757aa47ab 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/Utils.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/Utils.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.internal +package com.homer.apollographql.apollo.api.internal import kotlin.jvm.JvmName import kotlin.jvm.JvmStatic diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/BufferedSourceJsonReader.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/BufferedSourceJsonReader.kt similarity index 99% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/BufferedSourceJsonReader.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/BufferedSourceJsonReader.kt index 5d1bbf81425..ad37abcf076 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/BufferedSourceJsonReader.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/BufferedSourceJsonReader.kt @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.apollographql.apollo.api.internal.json +package com.homer.apollographql.apollo.api.internal.json -import com.apollographql.apollo.api.internal.Throws +import com.homer.apollographql.apollo.api.internal.Throws import okio.Buffer import okio.BufferedSource import okio.ByteString diff --git a/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/Closeable.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/Closeable.kt new file mode 100644 index 00000000000..06dafedffb8 --- /dev/null +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/Closeable.kt @@ -0,0 +1,5 @@ +package com.homer.apollographql.apollo.api.internal.json + +expect interface Closeable { + fun close() +} diff --git a/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/Flushable.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/Flushable.kt new file mode 100644 index 00000000000..7279ff9cb00 --- /dev/null +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/Flushable.kt @@ -0,0 +1,5 @@ +package com.homer.apollographql.apollo.api.internal.json + +expect interface Flushable { + fun flush() +} diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/InputFieldJsonWriter.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/InputFieldJsonWriter.kt similarity index 92% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/InputFieldJsonWriter.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/InputFieldJsonWriter.kt index 045f8fab6d2..13f8cb0636d 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/InputFieldJsonWriter.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/InputFieldJsonWriter.kt @@ -1,12 +1,12 @@ -package com.apollographql.apollo.api.internal.json - -import com.apollographql.apollo.api.CustomTypeValue.* -import com.apollographql.apollo.api.ScalarType -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.InputFieldWriter -import com.apollographql.apollo.api.internal.Throws -import com.apollographql.apollo.api.internal.json.Utils.writeToJson +package com.homer.apollographql.apollo.api.internal.json + +import com.homer.apollographql.apollo.api.CustomTypeValue.* +import com.homer.apollographql.apollo.api.ScalarType +import com.homer.apollographql.apollo.api.ScalarTypeAdapters +import com.homer.apollographql.apollo.api.internal.InputFieldMarshaller +import com.homer.apollographql.apollo.api.internal.InputFieldWriter +import com.homer.apollographql.apollo.api.internal.Throws +import com.homer.apollographql.apollo.api.internal.json.Utils.writeToJson import okio.IOException class InputFieldJsonWriter( diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonDataException.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonDataException.kt similarity index 95% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonDataException.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonDataException.kt index 722ea4b9b62..56fbe4e9ff9 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonDataException.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonDataException.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.apollographql.apollo.api.internal.json +package com.homer.apollographql.apollo.api.internal.json /** * Thrown when the data in a JSON document doesn't match the data expected by the caller. diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonEncodingException.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonEncodingException.kt similarity index 93% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonEncodingException.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonEncodingException.kt index fb70b58b37d..fa6cda5dd82 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonEncodingException.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonEncodingException.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.apollographql.apollo.api.internal.json +package com.homer.apollographql.apollo.api.internal.json import okio.IOException diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonReader.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonReader.kt similarity index 98% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonReader.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonReader.kt index 4ef7c379329..a90364e0b38 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonReader.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonReader.kt @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.apollographql.apollo.api.internal.json +package com.homer.apollographql.apollo.api.internal.json -import com.apollographql.apollo.api.internal.Throws +import com.homer.apollographql.apollo.api.internal.Throws import okio.IOException /** diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonScope.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonScope.kt similarity index 97% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonScope.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonScope.kt index a4d4a4056b0..62585d6fd17 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonScope.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonScope.kt @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.apollographql.apollo.api.internal.json +package com.homer.apollographql.apollo.api.internal.json /** Lexical scoping elements within a JSON reader or writer. */ object JsonScope { diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonUtf8Writer.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonUtf8Writer.kt similarity index 98% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonUtf8Writer.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonUtf8Writer.kt index 01964badcdf..1ffe6702915 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonUtf8Writer.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonUtf8Writer.kt @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.apollographql.apollo.api.internal.json +package com.homer.apollographql.apollo.api.internal.json -import com.apollographql.apollo.api.internal.Throws +import com.homer.apollographql.apollo.api.internal.Throws import okio.BufferedSink import okio.ByteString import okio.IOException diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonWriter.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonWriter.kt similarity index 96% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonWriter.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonWriter.kt index 25bc2a701b5..aa2f9c6a257 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonWriter.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonWriter.kt @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.apollographql.apollo.api.internal.json +package com.homer.apollographql.apollo.api.internal.json -import com.apollographql.apollo.api.internal.Throws -import com.apollographql.apollo.api.internal.json.JsonScope.getPath +import com.homer.apollographql.apollo.api.internal.Throws +import com.homer.apollographql.apollo.api.internal.json.JsonScope.getPath import okio.BufferedSink import okio.IOException import kotlin.jvm.JvmStatic diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonWriters.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonWriters.kt similarity index 80% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonWriters.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonWriters.kt index d3ecb03e8a2..34c43a9123d 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/JsonWriters.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/JsonWriters.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.internal.json +package com.homer.apollographql.apollo.api.internal.json inline fun JsonWriter.writeObject(crossinline block: JsonWriter.() -> Unit) { beginObject() diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/ResponseJsonStreamReader.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/ResponseJsonStreamReader.kt similarity index 96% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/ResponseJsonStreamReader.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/ResponseJsonStreamReader.kt index ff637ceb68c..8720f3d46cc 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/ResponseJsonStreamReader.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/ResponseJsonStreamReader.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.api.internal.json +package com.homer.apollographql.apollo.api.internal.json -import com.apollographql.apollo.api.BigDecimal -import com.apollographql.apollo.api.internal.Throws +import com.homer.apollographql.apollo.api.BigDecimal +import com.homer.apollographql.apollo.api.internal.Throws import okio.IOException open class ResponseJsonStreamReader( diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/Utils.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/Utils.kt similarity index 82% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/Utils.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/Utils.kt index 9267bbea36d..518488cb4ad 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/Utils.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/Utils.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.api.internal.json +package com.homer.apollographql.apollo.api.internal.json -import com.apollographql.apollo.api.EnumValue -import com.apollographql.apollo.api.internal.Throws +import com.homer.apollographql.apollo.api.EnumValue +import com.homer.apollographql.apollo.api.internal.Throws import okio.IOException import kotlin.jvm.JvmStatic diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/use.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/use.kt similarity index 89% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/use.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/use.kt index 2260d718a23..7ea7e6309fa 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/api/internal/json/use.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/api/internal/json/use.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.internal.json +package com.homer.apollographql.apollo.api.internal.json inline fun T.use(block: (T) -> R): R { var exception: Throwable? = null diff --git a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/exception/ApolloException.kt b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/exception/ApolloException.kt similarity index 77% rename from apollo-api/src/commonMain/kotlin/com/apollographql/apollo/exception/ApolloException.kt rename to apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/exception/ApolloException.kt index dfbf99e046c..011903a41b6 100644 --- a/apollo-api/src/commonMain/kotlin/com/apollographql/apollo/exception/ApolloException.kt +++ b/apollo-api/src/commonMain/kotlin/com/homer/apollographql/apollo/exception/ApolloException.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.exception +package com.homer.apollographql.apollo.exception open class ApolloException : RuntimeException { constructor(message: String) : super(message) diff --git a/apollo-api/src/commonTest/kotlin/com/apollographql/apollo/api/InputTest.kt b/apollo-api/src/commonTest/kotlin/com/apollographql/apollo/api/InputTest.kt deleted file mode 100644 index 6d1f5d3817a..00000000000 --- a/apollo-api/src/commonTest/kotlin/com/apollographql/apollo/api/InputTest.kt +++ /dev/null @@ -1,78 +0,0 @@ -package com.apollographql.apollo.api - -import com.apollographql.apollo.api.Input.Companion.fromNullable -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertNotEquals - -class InputTest { - @Test - fun testInputEqualsOnNotNullValue() { - val value = "Hello world!" - val stringInput = fromNullable(value) - val anotherStringInput = fromNullable(value) - assertEquals(stringInput, anotherStringInput) - } - - @Test - fun testInputNotEqualsOnDifferentValues() { - val value = "Hello world!" - val value2 = "Bye world!" - val stringInput = fromNullable(value) - val anotherStringInput = fromNullable(value2) - assertNotEquals(stringInput, anotherStringInput) - } - - @Test - fun testInputEqualsOnNullValue() { - val stringInput = fromNullable(null) - val anotherStringInput = fromNullable(null) - assertEquals(stringInput, anotherStringInput) - } - - @Test - fun testInputEqualsOnNotNullObjects() { - val `object` = TestObject("Hello world!") - val aInput = fromNullable(`object`) - val anotherInput = fromNullable(`object`) - assertEquals(aInput, anotherInput) - } - - @Test - fun testInputEqualsOnEqualObjectsWithDifferentReferences() { - val object1 = TestObject("Hello world!") - val object2 = TestObject("Hello world!") - val input1 = fromNullable(object1) - val input2 = fromNullable(object2) - assertEquals(input1, input2) - } - - @Test - fun testInputNotEqualsOnDifferentObjects() { - val `object` = TestObject("Hello world!") - val anotherObject = TestObject("Bye world!") - val aInput = fromNullable(`object`) - val anotherInput = fromNullable(anotherObject) - assertNotEquals(aInput, anotherInput) - } - - @Test - fun testInputEqualsOnObjectsWithNullValue() { - val `object` = TestObject(null) - val aInput = fromNullable(`object`) - val anotherInput = fromNullable(`object`) - assertEquals(aInput, anotherInput) - } - - @Test - fun testInputNotEqualsWhenAnObjectIsNull() { - val `object` = TestObject(null) - val aInput = fromNullable(`object`) - val anotherInput: Input = fromNullable(null) - assertNotEquals(aInput, anotherInput) - } - - //================================================================== - //================================================================== - internal data class TestObject(private val value: String?) -} diff --git a/apollo-api/src/commonTest/kotlin/com/apollographql/apollo/api/TestUtils.kt b/apollo-api/src/commonTest/kotlin/com/apollographql/apollo/api/TestUtils.kt deleted file mode 100644 index 43e995d0731..00000000000 --- a/apollo-api/src/commonTest/kotlin/com/apollographql/apollo/api/TestUtils.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.apollographql.apollo.api - -import okio.BufferedSource -import okio.ByteString - -val EMPTY_OPERATION: Operation<*, *, *> = object : Operation { - override fun variables(): Operation.Variables { - return Operation.EMPTY_VARIABLES - } - - override fun name(): OperationName = object : OperationName { - override fun name() = "test" - } - - override fun operationId() = "" - - override fun queryDocument() = throw UnsupportedOperationException() - override fun responseFieldMapper() = throw UnsupportedOperationException() - override fun wrapData(data: Operation.Data?) = throw UnsupportedOperationException() - override fun parse(source: BufferedSource) = throw UnsupportedOperationException() - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters) = throw UnsupportedOperationException() - override fun parse(byteString: ByteString) = throw UnsupportedOperationException() - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters) = throw UnsupportedOperationException() - override fun composeRequestBody() = throw UnsupportedOperationException() - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters) = throw UnsupportedOperationException() - override fun composeRequestBody(autoPersistQueries: Boolean, withQueryDocument: Boolean, scalarTypeAdapters: ScalarTypeAdapters) = throw UnsupportedOperationException() -} diff --git a/apollo-api/src/commonTest/kotlin/com/apollographql/apollo/api/internal/SimpleResponseReaderTest.kt b/apollo-api/src/commonTest/kotlin/com/apollographql/apollo/api/internal/SimpleResponseReaderTest.kt deleted file mode 100644 index 6e36d7ce4ca..00000000000 --- a/apollo-api/src/commonTest/kotlin/com/apollographql/apollo/api/internal/SimpleResponseReaderTest.kt +++ /dev/null @@ -1,552 +0,0 @@ -package com.apollographql.apollo.api.internal - -import com.apollographql.apollo.api.BigDecimal -import com.apollographql.apollo.api.CustomTypeAdapter -import com.apollographql.apollo.api.CustomTypeValue -import com.apollographql.apollo.api.EMPTY_OPERATION -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ResponseField.Condition.Companion.typeCondition -import com.apollographql.apollo.api.ScalarType -import com.apollographql.apollo.api.ScalarTypeAdapters -import kotlin.reflect.KClass -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertNull -import kotlin.test.assertTrue -import kotlin.test.fail - -class SimpleResponseReaderTest { - private val noConditions: List = emptyList() - - @Test - fun readString() { - val successField = ResponseField.forString("successFieldResponseName", "successFieldName", null, false, noConditions) - val classCastExceptionField = ResponseField.forString("classCastExceptionField", "classCastExceptionField", null, false, - noConditions) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = "response1" - recordSet["successFieldName"] = "response2" - recordSet["classCastExceptionField"] = 1 - val responseReader = responseReader(recordSet) - assertEquals(expected = "response1", actual = responseReader.readString(successField)) - try { - responseReader.readString(classCastExceptionField) - fail("expected ClassCastException") - } catch (expected: ClassCastException) { - // expected - } - } - - @Test - fun readInt() { - val successField = ResponseField.forInt("successFieldResponseName", "successFieldName", null, false, noConditions) - val classCastExceptionField = ResponseField.forInt("classCastExceptionField", "classCastExceptionField", null, false, - noConditions) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = BigDecimal(1) - recordSet["successFieldName"] = BigDecimal(2) - recordSet["classCastExceptionField"] = "anything" - val responseReader = responseReader(recordSet) - assertEquals(expected = 1, actual = responseReader.readInt(successField)) - try { - responseReader.readInt(classCastExceptionField) - fail("expected ClassCastException") - } catch (expected: ClassCastException) { - // expected - } - } - - @Test - fun readLong() { - val successField = ResponseField.forLong("successFieldResponseName", "successFieldName", null, false, noConditions) - val classCastExceptionField = ResponseField.forLong("classCastExceptionField", "classCastExceptionField", null, false, - noConditions) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = BigDecimal(1) - recordSet["successFieldName"] = BigDecimal(2) - recordSet["classCastExceptionField"] = "anything" - val responseReader = responseReader(recordSet) - assertEquals(expected = 1, actual = responseReader.readLong(successField) as Long) - try { - responseReader.readLong(classCastExceptionField) - fail("expected ClassCastException") - } catch (expected: ClassCastException) { - // expected - } - } - - @Test - fun readDouble() { - val successField = ResponseField.forDouble("successFieldResponseName", "successFieldName", null, false, noConditions) - val classCastExceptionField = ResponseField.forDouble("classCastExceptionField", "classCastExceptionField", null, false, - noConditions) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = BigDecimal(1.1) - recordSet["successFieldName"] = BigDecimal(2.2) - recordSet["classCastExceptionField"] = "anything" - val responseReader = responseReader(recordSet) - assertEquals(expected = 1.1, actual = responseReader.readDouble(successField)!!) - try { - responseReader.readDouble(classCastExceptionField) - fail("expected ClassCastException") - } catch (expected: ClassCastException) { - // expected - } - } - - @Test - fun readBoolean() { - val successField = ResponseField.forBoolean("successFieldResponseName", "successFieldName", null, false, noConditions) - val classCastExceptionField = ResponseField.forBoolean("classCastExceptionField", "classCastExceptionField", null, - false, noConditions) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = true - recordSet["successFieldName"] = false - recordSet["classCastExceptionField"] = "anything" - val responseReader = responseReader(recordSet) - assertTrue(responseReader.readBoolean(successField)!!) - try { - responseReader.readBoolean(classCastExceptionField) - fail("expected ClassCastException") - } catch (expected: ClassCastException) { - // expected - } - } - - @Test - fun readObject() { - val responseObject = Any() - val successField = ResponseField.forObject("successFieldResponseName", "successFieldName", null, false, noConditions) - val classCastExceptionField = ResponseField.forObject("classCastExceptionField", "classCastExceptionField", null, false, - noConditions) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = emptyMap() - recordSet["successFieldName"] = emptyMap() - recordSet["classCastExceptionField"] = "anything" - val responseReader = responseReader(recordSet) - assertEquals( - expected = responseObject, - actual = responseReader.readObject(successField, object : ResponseReader.ObjectReader { - override fun read(reader: ResponseReader): Any = responseObject - })) - try { - responseReader.readObject(classCastExceptionField, object : ResponseReader.ObjectReader { - override fun read(reader: ResponseReader): Any { - return reader.readString(ResponseField.forString("anything", "anything", null, true, noConditions))!! - } - }) - fail("expected ClassCastException") - } catch (expected: ClassCastException) { - // expected - } - } - - @Test - fun readFragment() { - val responseObject = Any() - val successFragmentField = ResponseField.forFragment("__typename", "__typename", listOf(typeCondition(arrayOf("Fragment1")))) - val skipFragmentField = ResponseField.forFragment("__typename", "__typename", listOf(typeCondition(arrayOf("Fragment2")))) - val recordSet: MutableMap = HashMap() - recordSet["__typename"] = "Fragment1" - val responseReader = responseReader(recordSet) - assertEquals( - expected = responseObject, - actual = responseReader.readFragment(successFragmentField, object : ResponseReader.ObjectReader { - override fun read(reader: ResponseReader): Any = responseObject - }) - ) - assertNull( - responseReader.readFragment(skipFragmentField, object : ResponseReader.ObjectReader { - override fun read(reader: ResponseReader): Any = responseObject - }) - ) - } - - @Test - fun readCustomObjectMap() { - val mapScalarType: ScalarType = object : ScalarType { - override fun typeName(): String { - return Map::class.simpleName!! - } - - override fun className(): String { - return "kotlin.collections.Map" - } - } - val successField = ResponseField.forCustomType("successFieldResponseName", "successFieldName", null, - false, mapScalarType, noConditions) - val objectMap = mutableMapOf() - objectMap["string"] = "string" - objectMap["boolean"] = true - objectMap["double"] = 1.99 - objectMap["float"] = 2.99f - objectMap["long"] = 3L - objectMap["int"] = 4 - objectMap["stringList"] = listOf("string1", "string2") - objectMap["booleanList"] = listOf("true", "false") - objectMap["doubleList"] = listOf(1.99, 2.99) - objectMap["floatList"] = listOf(3.99f, 4.99f, 5.99f) - objectMap["longList"] = listOf(5L, 7L) - objectMap["intList"] = listOf(8, 9, 10) - objectMap["object"] = HashMap(objectMap) - objectMap["objectList"] = listOf(HashMap(objectMap), HashMap(objectMap)) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = objectMap - recordSet["successFieldName"] = objectMap - val responseReader = responseReader(recordSet) - assertEquals(expected = objectMap, actual = responseReader.readCustomType>(successField)) - } - - @Test - fun readCustomObjectList() { - val listScalarType: ScalarType = object : ScalarType { - override fun typeName(): String { - return List::class.simpleName!! - } - - override fun className(): String { - return "kotlin.collections.List" - } - } - val successField = ResponseField.forCustomType("successFieldResponseName", "successFieldName", null, - false, listScalarType, noConditions) - val objectMap: MutableMap = HashMap() - objectMap["string"] = "string" - objectMap["boolean"] = true - val objectList = listOf>(objectMap, objectMap) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = objectList - recordSet["successFieldName"] = objectList - val responseReader = responseReader(recordSet) - assertEquals(expected = objectList, actual = responseReader.readCustomType>(successField)) - } - - @Test - fun readCustomWithDefaultAdapter() { - val stringField = ResponseField.forCustomType("stringField", "stringField", null, false, - scalarTypeFor(String::class, "kotlin.String"), noConditions) - val booleanField = ResponseField.forCustomType("booleanField", "booleanField", null, false, - scalarTypeFor(Boolean::class, "kotlin.Boolean"), noConditions) - val integerField = ResponseField.forCustomType("integerField", "integerField", null, false, - scalarTypeFor(Int::class, "kotlin.Int"), noConditions) - val longField = ResponseField.forCustomType("longField", "longField", null, false, - scalarTypeFor(Long::class, "kotlin.Long"), noConditions) - val floatField = ResponseField.forCustomType("floatField", "floatField", null, false, - scalarTypeFor(Float::class, "kotlin.Float"), noConditions) - val doubleField = ResponseField.forCustomType("doubleField", "doubleField", null, false, - scalarTypeFor(Double::class, "kotlin.Double"), noConditions) - val unsupportedField = ResponseField.forCustomType("unsupportedField", "unsupportedField", null, false, - scalarTypeFor(RuntimeException::class, "kotlin.RuntimeException"), noConditions) - val recordSet: MutableMap = HashMap() - recordSet[stringField.responseName] = "string" - recordSet[booleanField.responseName] = true - recordSet[integerField.responseName] = BigDecimal(1) - recordSet[longField.responseName] = BigDecimal(2) - recordSet[floatField.responseName] = BigDecimal("3.99") - recordSet[doubleField.responseName] = BigDecimal("4.99") - recordSet[unsupportedField.responseName] = "smth" - val responseReader = responseReader(recordSet) - assertEquals(expected = "string", actual = responseReader.readCustomType(stringField)!!) - assertEquals(expected = true, actual = responseReader.readCustomType(booleanField)!!) - assertEquals(expected = 1, actual = responseReader.readCustomType(integerField)!!) - assertEquals(expected = 2L, actual = responseReader.readCustomType(longField)!!) - assertEquals(expected = 3.99f, actual = responseReader.readCustomType(floatField)!!) - assertEquals(expected = 4.99, actual = responseReader.readCustomType(doubleField)!!) - try { - responseReader.readCustomType(unsupportedField) - fail("Expect IllegalArgumentException") - } catch (expected: IllegalArgumentException) { - // expected - } - } - - @Test - fun readStringList() { - val successField = ResponseField.forList("successFieldResponseName", "successFieldName", null, false, noConditions) - val classCastExceptionField = ResponseField.forList("classCastExceptionField", "classCastExceptionField", null, false, noConditions) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = listOf("value1", "value2", "value3") - recordSet["successFieldName"] = listOf("value4", "value5") - recordSet["classCastExceptionField"] = "anything" - val responseReader = responseReader(recordSet) - assertEquals( - expected = listOf("value1", "value2", "value3"), - actual = responseReader.readList(successField) { reader: ResponseReader.ListItemReader -> reader.readString() } - ) - try { - responseReader.readList(classCastExceptionField) { null!! } - fail("expected ClassCastException") - } catch (expected: ClassCastException) { - // expected - } - } - - @Test - fun readIntList() { - val successField = ResponseField.forList("successFieldResponseName", "successFieldName", null, false, noConditions) - val classCastExceptionField = ResponseField.forList("classCastExceptionField", "classCastExceptionField", null, false, noConditions) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = listOf(BigDecimal(1), BigDecimal(2), BigDecimal(3)) - recordSet["successFieldName"] = listOf(BigDecimal(4), BigDecimal(5)) - recordSet["classCastExceptionField"] = "anything" - val responseReader = responseReader(recordSet) - assertEquals( - expected = listOf(1, 2, 3), - actual = responseReader.readList(successField) { reader: ResponseReader.ListItemReader -> reader.readInt() } - ) - try { - responseReader.readList(classCastExceptionField) { null!! } - fail("expected ClassCastException") - } catch (expected: ClassCastException) { - // expected - } - } - - @Test - fun readLongList() { - val successField = ResponseField.forList("successFieldResponseName", "successFieldName", null, false, noConditions) - val classCastExceptionField = ResponseField.forList("classCastExceptionField", "classCastExceptionField", null, false, noConditions) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = listOf(BigDecimal(1), BigDecimal(2), BigDecimal(3)) - recordSet["successFieldName"] = listOf(BigDecimal(4), BigDecimal(5)) - recordSet["classCastExceptionField"] = "anything" - val responseReader = responseReader(recordSet) - assertEquals( - expected = listOf(1, 2, 3), - actual = responseReader.readList(successField) { reader: ResponseReader.ListItemReader -> reader.readInt() } - ) - try { - responseReader.readList(classCastExceptionField) { null!! } - fail("expected ClassCastException") - } catch (expected: ClassCastException) { - // expected - } - } - - @Test - fun readDoubleList() { - val successField = ResponseField.forList("successFieldResponseName", "successFieldName", null, false, noConditions) - val classCastExceptionField = ResponseField.forList("classCastExceptionField", "classCastExceptionField", null, false, noConditions) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = listOf(BigDecimal(1), BigDecimal(2), BigDecimal(3)) - recordSet["successFieldName"] = listOf(BigDecimal(4), BigDecimal(5)) - recordSet["classCastExceptionField"] = "anything" - val responseReader = responseReader(recordSet) - assertEquals( - expected = listOf(1.0, 2.0, 3.0), - actual = responseReader.readList(successField) { reader: ResponseReader.ListItemReader -> reader.readDouble() } - ) - try { - responseReader.readList(classCastExceptionField) { null!! } - fail("expected ClassCastException") - } catch (expected: ClassCastException) { - // expected - } - } - - @Test - fun readBooleanList() { - val successField = ResponseField.forList("successFieldResponseName", "successFieldName", null, false, noConditions) - val classCastExceptionField = ResponseField.forList("classCastExceptionField", "classCastExceptionField", null, false, noConditions) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = listOf(true, false, true) - recordSet["successFieldName"] = listOf(false, false) - recordSet["classCastExceptionField"] = "anything" - val responseReader = responseReader(recordSet) - assertEquals( - expected = listOf(true, false, true), - actual = responseReader.readList(successField) { reader: ResponseReader.ListItemReader -> reader.readBoolean() } - ) - try { - responseReader.readList(classCastExceptionField) { null!! } - fail("expected ClassCastException") - } catch (expected: ClassCastException) { - // expected - } - } - - @Test - fun readObjectList() { - val successField = ResponseField.forList("successFieldResponseName", "successFieldName", null, false, noConditions) - val classCastExceptionField = ResponseField.forList("classCastExceptionField", "classCastExceptionField", null, false, noConditions) - val responseObject1 = Any() - val responseObject2 = Any() - val responseObject3 = Any() - val objects = listOf(responseObject1, responseObject2, responseObject3) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = listOf(emptyMap(), emptyMap(), emptyMap()) - recordSet["successFieldName"] = listOf(emptyMap(), emptyMap(), emptyMap()) - recordSet["classCastExceptionField"] = "anything" - val responseReader = responseReader(recordSet) - - var index = 0 - assertEquals( - expected = objects, - actual = responseReader.readList(successField) { reader -> - reader.readObject { objects[index++] } - } - ) - try { - responseReader.readList(classCastExceptionField) { null!! } - fail("expected ClassCastException") - } catch (expected: ClassCastException) { - // expected - } - } - - @Test - fun readListOfScalarList() { - val successField = ResponseField.forList("successFieldResponseName", "successFieldName", null, false, noConditions) - val classCastExceptionField = ResponseField.forList("classCastExceptionField", "classCastExceptionField", null, false, noConditions) - val response1 = listOf(listOf("1", "2"), listOf("3", "4", "5")) - val response2 = listOf(listOf("6", "7", "8"), listOf("9", "0")) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = response1 - recordSet["successFieldName"] = response2 - recordSet["classCastExceptionField"] = "anything" - val responseReader = responseReader(recordSet) - assertEquals( - expected = listOf(listOf("1", "2"), listOf("3", "4", "5")), - actual = responseReader.readList(successField) { reader -> reader.readList(ResponseReader.ListItemReader::readString) } - ) - try { - responseReader.readList(classCastExceptionField) { null!! } - fail("expected ClassCastException") - } catch (expected: ClassCastException) { - // expected - } - } - - @Test - fun optionalFieldsIOException() { - val responseReader = responseReader(emptyMap()) - responseReader.readString(ResponseField.forString("stringField", "stringField", null, true, noConditions)) - responseReader.readInt(ResponseField.forInt("intField", "intField", null, true, noConditions)) - responseReader.readLong(ResponseField.forLong("longField", "longField", null, true, noConditions)) - responseReader.readDouble(ResponseField.forDouble("doubleField", "doubleField", null, true, noConditions)) - responseReader.readBoolean(ResponseField.forBoolean("booleanField", "booleanField", null, true, noConditions)) - responseReader.readObject(ResponseField.forObject("objectField", "objectField", null, true, noConditions)) { null!! } - responseReader.readList(ResponseField.forList("scalarListField", "scalarListField", null, true, noConditions)) { null!! } - } - - @Test - fun mandatoryFieldsIOException() { - val responseReader = responseReader(emptyMap()) - try { - responseReader.readString(ResponseField.forString("stringField", "stringField", null, false, noConditions)) - fail("expected NullPointerException") - } catch (expected: NullPointerException) { - //expected - } - try { - responseReader.readInt(ResponseField.forInt("intField", "intField", null, false, noConditions)) - fail("expected NullPointerException") - } catch (expected: NullPointerException) { - //expected - } - try { - responseReader.readLong(ResponseField.forLong("longField", "longField", null, false, noConditions)) - fail("expected NullPointerException") - } catch (expected: NullPointerException) { - //expected - } - try { - responseReader.readDouble(ResponseField.forDouble("doubleField", "doubleField", null, false, noConditions)) - fail("expected NullPointerException") - } catch (expected: NullPointerException) { - //expected - } - try { - responseReader.readBoolean(ResponseField.forBoolean("booleanField", "booleanField", null, false, noConditions)) - fail("expected NullPointerException") - } catch (expected: NullPointerException) { - //expected - } - try { - responseReader.readObject(ResponseField.forObject("objectField", "objectField", null, false, noConditions)) { null!! } - fail("expected NullPointerException") - } catch (expected: NullPointerException) { - //expected - } - try { - responseReader.readList(ResponseField.forList("scalarListField", "scalarListField", null, false, noConditions)) { null!! } - fail("expected NullPointerException") - } catch (expected: NullPointerException) { - //expected - } - } - - @Test - fun readScalarListWithNulls() { - val scalarList = ResponseField.forList("list", "list", null, false, noConditions) - val recordSet: MutableMap = HashMap() - recordSet["list"] = listOf(null, "item2", "item3", null, "item5", null) - val responseReader = responseReader(recordSet) - assertEquals( - expected = listOf(null, "item2", "item3", null, "item5", null), - actual = responseReader.readList(scalarList) { reader: ResponseReader.ListItemReader -> reader.readString() }) - } - - @Test - fun readObjectListWithNulls() { - val listField = ResponseField.forList("list", "list", null, false, noConditions) - val indexField = ResponseField.forList("index", "index", null, false, noConditions) - val responseObjects = listOf(null, Any(), Any(), null, Any(), null) - val recordSet: MutableMap = HashMap() - recordSet["list"] = listOf( - null, - mapOf("index" to "1"), - mapOf("index" to "2"), - null, - mapOf("index" to "4"), - null - ) - val responseReader = responseReader(recordSet) - assertEquals( - expected = responseObjects, - actual = responseReader.readList(listField) { listReader -> - listReader.readObject { reader -> - responseObjects[reader.readString(indexField)!!.toInt()]!! - } - } - ) - } - - companion object { - private fun responseReader(recordSet: Map): SimpleResponseReader { - val customTypeAdapters: MutableMap> = HashMap() - customTypeAdapters[OBJECT_CUSTOM_TYPE] = object : CustomTypeAdapter { - override fun decode(value: CustomTypeValue<*>): Any { - return value.value.toString() - } - - override fun encode(value: Any?): CustomTypeValue<*> { - throw UnsupportedOperationException() - } - } - return SimpleResponseReader(recordSet, EMPTY_OPERATION.variables(), ScalarTypeAdapters(customTypeAdapters)) - } - - private fun scalarTypeFor(clazz: KClass<*>, className: String): ScalarType { - return object : ScalarType { - override fun typeName(): String { - return clazz.simpleName!! - } - - override fun className(): String { - return className - } - } - } - - private val OBJECT_CUSTOM_TYPE: ScalarType = object : ScalarType { - override fun typeName(): String { - return String::class.simpleName!! - } - - override fun className(): String { - return "kotlin.String" - } - } - } -} diff --git a/apollo-api/src/commonTest/kotlin/com/apollographql/apollo/api/internal/json/InputFieldJsonWriterTest.kt b/apollo-api/src/commonTest/kotlin/com/apollographql/apollo/api/internal/json/InputFieldJsonWriterTest.kt deleted file mode 100644 index b96b98e4f90..00000000000 --- a/apollo-api/src/commonTest/kotlin/com/apollographql/apollo/api/internal/json/InputFieldJsonWriterTest.kt +++ /dev/null @@ -1,226 +0,0 @@ -package com.apollographql.apollo.api.internal.json - -import com.apollographql.apollo.api.BigDecimal -import com.apollographql.apollo.api.CustomTypeAdapter -import com.apollographql.apollo.api.CustomTypeValue -import com.apollographql.apollo.api.ScalarType -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.InputFieldWriter -import com.apollographql.apollo.api.toNumber -import okio.Buffer -import kotlin.reflect.KClass -import kotlin.test.Test -import kotlin.test.assertEquals - -class InputFieldJsonWriterTest { - private val jsonBuffer = Buffer() - private val jsonWriter = JsonWriter.of(jsonBuffer).apply { - serializeNulls = true - beginObject() - } - private val inputFieldJsonWriter = InputFieldJsonWriter(jsonWriter, ScalarTypeAdapters(emptyMap())) - - @Test - fun writeString() { - inputFieldJsonWriter.writeString("someField", "someValue") - inputFieldJsonWriter.writeString("someNullField", null) - assertEquals("{\"someField\":\"someValue\",\"someNullField\":null", jsonBuffer.readUtf8()) - } - - @Test - fun writeInt() { - inputFieldJsonWriter.writeInt("someField", 1) - inputFieldJsonWriter.writeInt("someNullField", null) - assertEquals("{\"someField\":1,\"someNullField\":null", jsonBuffer.readUtf8()) - } - - @Test - fun writeLong() { - inputFieldJsonWriter.writeLong("someField", 10L) - inputFieldJsonWriter.writeLong("someNullField", null) - assertEquals("{\"someField\":10,\"someNullField\":null", jsonBuffer.readUtf8()) - } - - @Test - fun writeDouble() { - inputFieldJsonWriter.writeDouble("someField", 1.01) - inputFieldJsonWriter.writeDouble("someNullField", null) - assertEquals("{\"someField\":1.01,\"someNullField\":null", jsonBuffer.readUtf8()) - } - - @Test - fun writeNumber() { - inputFieldJsonWriter.writeNumber("someField", BigDecimal("1.001").toNumber()) - inputFieldJsonWriter.writeNumber("someNullField", null) - kotlin.test.assertEquals("{\"someField\":1.001,\"someNullField\":null", jsonBuffer.readUtf8()) - } - - @Test - fun writeBoolean() { - inputFieldJsonWriter.writeBoolean("someField", true) - inputFieldJsonWriter.writeBoolean("someNullField", null) - assertEquals("{\"someField\":true,\"someNullField\":null", jsonBuffer.readUtf8()) - } - - @Test - fun writeObject() { - inputFieldJsonWriter.writeObject("someField", object : InputFieldMarshaller { - override fun marshal(writer: InputFieldWriter) { - writer.writeString("someField", "someValue") - } - }) - inputFieldJsonWriter.writeObject("someNullField", null) - assertEquals("{\"someField\":{\"someField\":\"someValue\"},\"someNullField\":null", jsonBuffer.readUtf8()) - } - - @Test - fun writeList() { - inputFieldJsonWriter.writeList("someField", object : InputFieldWriter.ListWriter { - override fun write(listItemWriter: InputFieldWriter.ListItemWriter) { - listItemWriter.writeString("someValue") - } - }) - inputFieldJsonWriter.writeList("someNullField", null) - assertEquals("{\"someField\":[\"someValue\"],\"someNullField\":null", jsonBuffer.readUtf8()) - } - - @Test - fun writeCustomBoolean() { - val customTypeAdapters: MutableMap> = HashMap() - val scalarType = MockCustomScalarType(CustomTypeValue.GraphQLBoolean::class, "com.apollographql.apollo.api.CustomTypeValue.GraphQLBoolean") - customTypeAdapters[scalarType] = object : MockCustomTypeAdapter() { - override fun encode(value: Any?): CustomTypeValue<*> { - return CustomTypeValue.GraphQLBoolean((value as Boolean)) - } - } - val inputFieldJsonWriter = InputFieldJsonWriter(jsonWriter, ScalarTypeAdapters(customTypeAdapters)) - inputFieldJsonWriter.writeCustom("someField", scalarType, true) - inputFieldJsonWriter.writeCustom("someNullField", scalarType, null) - assertEquals("{\"someField\":true,\"someNullField\":null", jsonBuffer.readUtf8()) - } - - @Test - fun writeCustomNumber() { - val customTypeAdapters: MutableMap> = HashMap() - val scalarType = MockCustomScalarType(CustomTypeValue.GraphQLNumber::class, "com.apollographql.apollo.api.CustomTypeValue.GraphQLNumber") - customTypeAdapters[scalarType] = object : MockCustomTypeAdapter() { - override fun encode(value: Any?): CustomTypeValue<*> { - return CustomTypeValue.GraphQLNumber((value as BigDecimal).toNumber()) - } - } - val inputFieldJsonWriter = InputFieldJsonWriter(jsonWriter, ScalarTypeAdapters(customTypeAdapters)) - inputFieldJsonWriter.writeCustom("someField", scalarType, BigDecimal("100.1")) - inputFieldJsonWriter.writeCustom("someNullField", scalarType, null) - assertEquals("{\"someField\":100.1,\"someNullField\":null", jsonBuffer.readUtf8()) - } - - @Test - fun writeCustomString() { - val customTypeAdapters: MutableMap> = HashMap() - val scalarType = MockCustomScalarType(CustomTypeValue.GraphQLString::class, "com.apollographql.apollo.api.CustomTypeValue.GraphQLString") - customTypeAdapters[scalarType] = object : MockCustomTypeAdapter() { - override fun encode(value: Any?): CustomTypeValue<*> { - return CustomTypeValue.GraphQLString((value as String)) - } - } - val inputFieldJsonWriter = InputFieldJsonWriter(jsonWriter, ScalarTypeAdapters(customTypeAdapters)) - inputFieldJsonWriter.writeCustom("someField", scalarType, "someValue") - inputFieldJsonWriter.writeCustom("someNullField", scalarType, null) - assertEquals("{\"someField\":\"someValue\",\"someNullField\":null", jsonBuffer.readUtf8()) - } - - @Test - fun writeCustomNull() { - val customTypeAdapters: MutableMap> = HashMap() - val scalarType = MockCustomScalarType(CustomTypeValue.GraphQLNumber::class, "com.apollographql.apollo.api.CustomTypeValue.GraphQLNull") - customTypeAdapters[scalarType] = object : MockCustomTypeAdapter() { - override fun encode(value: Any?): CustomTypeValue<*> { - return CustomTypeValue.GraphQLNull - } - } - val inputFieldJsonWriter = InputFieldJsonWriter(jsonWriter, ScalarTypeAdapters(customTypeAdapters)) - inputFieldJsonWriter.writeCustom("someField", scalarType, null) - assertEquals("{\"someField\":null", jsonBuffer.readUtf8()) - } - - @Test - fun writeCustomJsonObject() { - val value = mapOf( - "stringField" to "string", - "booleanField" to true, - "numberField" to 100, - "listField" to listOf( - "string", - true, - 100, - mapOf( - "stringField" to "string", - "numberField" to 100, - "booleanField" to true, - "listField" to listOf(1, 2, 3) - ) - ), - "objectField" to mapOf( - "stringField" to "string", - "numberField" to 100, - "booleanField" to true, - "listField" to listOf(1, 2, 3) - ) - ) - val scalarType = MockCustomScalarType(Map::class, "kotlin.collections.Map") - inputFieldJsonWriter.writeCustom("someField", scalarType, value) - inputFieldJsonWriter.writeCustom("someNullField", scalarType, null) - assertEquals("{\"someField\":{\"stringField\":\"string\",\"booleanField\":true,\"numberField\":100,\"listField\":[\"string\",true,100,{\"stringField\":\"string\",\"numberField\":100,\"booleanField\":true,\"listField\":[1,2,3]}],\"objectField\":{\"stringField\":\"string\",\"numberField\":100,\"booleanField\":true,\"listField\":[1,2,3]}},\"someNullField\":null", jsonBuffer.readUtf8()) - } - - @Test - fun writeCustomList() { - val value = listOf( - "string", - true, - 100, - mapOf( - "stringField" to "string", - "numberField" to 100, - "booleanField" to true, - "listField" to listOf(1, 2, 3) - ) - ) - val scalarType = MockCustomScalarType(List::class, "kotlin.collections.List") - inputFieldJsonWriter.writeCustom("someField", scalarType, value) - inputFieldJsonWriter.writeCustom("someNullField", scalarType, null) - assertEquals("{\"someField\":[\"string\",true,100,{\"stringField\":\"string\",\"numberField\":100,\"booleanField\":true,\"listField\":[1,2,3]}],\"someNullField\":null", jsonBuffer.readUtf8()) - } - - @Test - fun writeListOfList() { - inputFieldJsonWriter.writeList("someField", object : InputFieldWriter.ListWriter { - override fun write(listItemWriter: InputFieldWriter.ListItemWriter) { - listItemWriter.writeList(object : InputFieldWriter.ListWriter { - override fun write(listItemWriter: InputFieldWriter.ListItemWriter) { - listItemWriter.writeString("someValue") - } - }) - } - }) - inputFieldJsonWriter.writeList("someNullField", null) - assertEquals("{\"someField\":[[\"someValue\"]],\"someNullField\":null", jsonBuffer.readUtf8()) - } - - private data class MockCustomScalarType internal constructor(val clazz: KClass<*>, val qualifiedName: String) : ScalarType { - override fun typeName(): String { - return clazz.simpleName!! - } - - override fun className(): String { - return qualifiedName - } - } - - private abstract inner class MockCustomTypeAdapter : CustomTypeAdapter { - override fun decode(value: CustomTypeValue<*>): Any { - throw UnsupportedOperationException() - } - } -} diff --git a/apollo-api/src/iosMain/kotlin/com/apollographql/apollo/api/BigDecimal.kt b/apollo-api/src/iosMain/kotlin/com/apollographql/apollo/api/BigDecimal.kt deleted file mode 100644 index ed6b47aee4c..00000000000 --- a/apollo-api/src/iosMain/kotlin/com/apollographql/apollo/api/BigDecimal.kt +++ /dev/null @@ -1,73 +0,0 @@ -package com.apollographql.apollo.api - -import platform.Foundation.NSDecimalNumber - -actual class BigDecimal internal constructor(private val raw: NSDecimalNumber) : Number() { - - actual constructor(strVal: String) : this(NSDecimalNumber(strVal)) - - actual constructor(doubleVal: Double) : this(NSDecimalNumber(doubleVal)) - - actual constructor(intVal: Int) : this(NSDecimalNumber(intVal)) - - actual constructor(longVal: Long) : this(NSDecimalNumber(long = longVal)) - - actual fun add(augend: BigDecimal): BigDecimal = BigDecimal(raw.decimalNumberByAdding(augend.raw)) - - actual fun subtract(subtrahend: BigDecimal): BigDecimal = BigDecimal(raw.decimalNumberBySubtracting(subtrahend.raw)) - - actual fun multiply(multiplicand: BigDecimal): BigDecimal = BigDecimal(raw.decimalNumberByMultiplyingBy(multiplicand.raw)) - - actual fun divide(divisor: BigDecimal): BigDecimal = BigDecimal(raw.decimalNumberByDividingBy(divisor.raw)) - - actual fun negate(): BigDecimal = BigDecimal(NSDecimalNumber(0).decimalNumberBySubtracting(raw)) - - actual fun signum(): Int { - val result = raw.compare(NSDecimalNumber(0)).toInt() - return when { - result < 0 -> -1 - result > 0 -> 1 - else -> 0 - } - } - - override fun toInt(): Int { - return raw.intValue - } - - override fun toLong(): Long { - return raw.longValue - } - - override fun toShort(): Short { - return raw.shortValue - } - - override fun toByte(): Byte { - return raw.charValue - } - - override fun toChar(): Char { - // Convert to `Int` first and then `Char` (unsigned 16-bit integer). - // UShort is experimental, and stdlib does not provide direct UShort -> Char conversion. - return raw.intValue.toChar() - } - - override fun toDouble(): Double { - return raw.doubleValue - } - - override fun toFloat(): Float { - return raw.floatValue - } - - override fun equals(other: Any?): Boolean { - return (this === other) || raw == (other as? BigDecimal)?.raw - } - - override fun hashCode(): Int = raw.hashCode() - - override fun toString(): String = raw.stringValue -} - -actual fun BigDecimal.toNumber(): Number = this diff --git a/apollo-api/src/iosMain/kotlin/com/apollographql/apollo/api/internal/Throws.kt b/apollo-api/src/iosMain/kotlin/com/apollographql/apollo/api/internal/Throws.kt deleted file mode 100644 index 9c4c9c64ddb..00000000000 --- a/apollo-api/src/iosMain/kotlin/com/apollographql/apollo/api/internal/Throws.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.apollographql.apollo.api.internal - -import kotlin.reflect.KClass - -actual annotation class Throws actual constructor(actual vararg val exceptionClasses: KClass) diff --git a/apollo-api/src/iosMain/kotlin/com/apollographql/apollo/api/internal/json/Closeable.kt b/apollo-api/src/iosMain/kotlin/com/apollographql/apollo/api/internal/json/Closeable.kt deleted file mode 100644 index 70955c097b4..00000000000 --- a/apollo-api/src/iosMain/kotlin/com/apollographql/apollo/api/internal/json/Closeable.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.apollographql.apollo.api.internal.json - -actual interface Closeable { - actual fun close() -} diff --git a/apollo-api/src/iosMain/kotlin/com/apollographql/apollo/api/internal/json/Flushable.kt b/apollo-api/src/iosMain/kotlin/com/apollographql/apollo/api/internal/json/Flushable.kt deleted file mode 100644 index d2bafa45b9e..00000000000 --- a/apollo-api/src/iosMain/kotlin/com/apollographql/apollo/api/internal/json/Flushable.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.apollographql.apollo.api.internal.json - -actual interface Flushable { - actual fun flush() -} diff --git a/apollo-api/src/jsMain/kotlin/com/apollographql/apollo/api/internal/json/Closeable.kt b/apollo-api/src/jsMain/kotlin/com/apollographql/apollo/api/internal/json/Closeable.kt deleted file mode 100644 index 70955c097b4..00000000000 --- a/apollo-api/src/jsMain/kotlin/com/apollographql/apollo/api/internal/json/Closeable.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.apollographql.apollo.api.internal.json - -actual interface Closeable { - actual fun close() -} diff --git a/apollo-api/src/jsMain/kotlin/com/apollographql/apollo/api/internal/json/Flushable.kt b/apollo-api/src/jsMain/kotlin/com/apollographql/apollo/api/internal/json/Flushable.kt deleted file mode 100644 index d2bafa45b9e..00000000000 --- a/apollo-api/src/jsMain/kotlin/com/apollographql/apollo/api/internal/json/Flushable.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.apollographql.apollo.api.internal.json - -actual interface Flushable { - actual fun flush() -} diff --git a/apollo-api/src/jsMain/kotlin/com/apollographql/apollo/api/BigDecimal.kt b/apollo-api/src/jsMain/kotlin/com/homer/apollographql/apollo/api/BigDecimal.kt similarity index 98% rename from apollo-api/src/jsMain/kotlin/com/apollographql/apollo/api/BigDecimal.kt rename to apollo-api/src/jsMain/kotlin/com/homer/apollographql/apollo/api/BigDecimal.kt index 7d03b994e83..75a2a8d8cba 100644 --- a/apollo-api/src/jsMain/kotlin/com/apollographql/apollo/api/BigDecimal.kt +++ b/apollo-api/src/jsMain/kotlin/com/homer/apollographql/apollo/api/BigDecimal.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api @JsModule("big.js") @JsNonModule diff --git a/apollo-api/src/jsMain/kotlin/com/apollographql/apollo/api/internal/Throws.kt b/apollo-api/src/jsMain/kotlin/com/homer/apollographql/apollo/api/internal/Throws.kt similarity index 72% rename from apollo-api/src/jsMain/kotlin/com/apollographql/apollo/api/internal/Throws.kt rename to apollo-api/src/jsMain/kotlin/com/homer/apollographql/apollo/api/internal/Throws.kt index 9c4c9c64ddb..3500b5f0fff 100644 --- a/apollo-api/src/jsMain/kotlin/com/apollographql/apollo/api/internal/Throws.kt +++ b/apollo-api/src/jsMain/kotlin/com/homer/apollographql/apollo/api/internal/Throws.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.internal +package com.homer.apollographql.apollo.api.internal import kotlin.reflect.KClass diff --git a/apollo-api/src/jsMain/kotlin/com/homer/apollographql/apollo/api/internal/json/Closeable.kt b/apollo-api/src/jsMain/kotlin/com/homer/apollographql/apollo/api/internal/json/Closeable.kt new file mode 100644 index 00000000000..6f29e89ad55 --- /dev/null +++ b/apollo-api/src/jsMain/kotlin/com/homer/apollographql/apollo/api/internal/json/Closeable.kt @@ -0,0 +1,5 @@ +package com.homer.apollographql.apollo.api.internal.json + +actual interface Closeable { + actual fun close() +} diff --git a/apollo-api/src/jsMain/kotlin/com/homer/apollographql/apollo/api/internal/json/Flushable.kt b/apollo-api/src/jsMain/kotlin/com/homer/apollographql/apollo/api/internal/json/Flushable.kt new file mode 100644 index 00000000000..17be693c310 --- /dev/null +++ b/apollo-api/src/jsMain/kotlin/com/homer/apollographql/apollo/api/internal/json/Flushable.kt @@ -0,0 +1,5 @@ +package com.homer.apollographql.apollo.api.internal.json + +actual interface Flushable { + actual fun flush() +} diff --git a/apollo-api/src/jsTest/kotlin/com/apollographql/apollo/api/BigDecimalTests.kt b/apollo-api/src/jsTest/kotlin/com/apollographql/apollo/api/BigDecimalTests.kt deleted file mode 100644 index 41c0c7c6db3..00000000000 --- a/apollo-api/src/jsTest/kotlin/com/apollographql/apollo/api/BigDecimalTests.kt +++ /dev/null @@ -1,71 +0,0 @@ -package com.apollographql.apollo.api - -import kotlin.test.* - -class BigDecimalTests { - @Test - fun equality() { - assertEquals(BigDecimal("12345.12345678901234567890123"), BigDecimal("12345.12345678901234567890123")) - assertEquals(BigDecimal("987654321098765432109876543210"), BigDecimal("987654321098765432109876543210")) - assertEquals(BigDecimal("1024768"), BigDecimal("1024768")) - assertEquals(BigDecimal(-Double.MAX_VALUE), BigDecimal(-Double.MAX_VALUE)) - assertEquals(BigDecimal(Double.MAX_VALUE), BigDecimal(Double.MAX_VALUE)) - assertEquals(BigDecimal(-Long.MAX_VALUE - 1), BigDecimal(-Long.MAX_VALUE - 1)) - assertEquals(BigDecimal(Long.MAX_VALUE), BigDecimal(Long.MAX_VALUE)) - } - - @Test - fun overflow() { - assertFails { - BigDecimal("987654321098765432109876543210").toLong() - } - } - - @Test - fun truncating() { - - assertEquals( - BigDecimal("12345.12345678901234567890123").toDouble(), - 12345.123456789011 - ) - } - - @Test - fun roundTrip_Int() { - val bridged = BigDecimal(Int.MAX_VALUE) - assertEquals(bridged.toInt(), Int.MAX_VALUE) - - val bridgedNeg = BigDecimal( -Int.MAX_VALUE - 1) - assertEquals(bridgedNeg.toInt(), -Int.MAX_VALUE - 1) - } - - @Test - fun roundTrip_Long() { - val bridged = BigDecimal(Long.MAX_VALUE) - assertEquals(bridged.toLong(), Long.MAX_VALUE) - - val bridgedNeg = BigDecimal(-Long.MAX_VALUE - 1) - assertEquals(bridgedNeg.toLong(), -Long.MAX_VALUE - 1) - } - - @Test - fun roundTrip_Double() { - val bridged = BigDecimal(Double.MAX_VALUE) - assertEquals(bridged.toDouble(), Double.MAX_VALUE) - - val bridgedNeg = BigDecimal(-Double.MAX_VALUE) - assertEquals(bridgedNeg.toDouble(), -Double.MAX_VALUE) - - assertFails { - BigDecimal(Double.POSITIVE_INFINITY) - } - - assertFails { - BigDecimal(Double.NEGATIVE_INFINITY) - } - - assertFails { - BigDecimal(Double.NaN) - } - } -} diff --git a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Absent.java b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Absent.java similarity index 86% rename from apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Absent.java rename to apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Absent.java index 1cb917528a2..32996ab483b 100644 --- a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Absent.java +++ b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Absent.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.apollographql.apollo.api.internal; +package com.homer.apollographql.apollo.api.internal; import org.jetbrains.annotations.Nullable; @@ -22,8 +22,6 @@ import java.util.Collections; import java.util.Set; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; - /** * Implementation of an {@link Optional} not containing a reference. */ @@ -51,13 +49,13 @@ public T get() { @Override public T or(T defaultValue) { - return checkNotNull(defaultValue, "use Optional.orNull() instead of Optional.or(null)"); + return Utils.checkNotNull(defaultValue, "use Optional.orNull() instead of Optional.or(null)"); } @SuppressWarnings("unchecked") // safe covariant cast @Override public Optional or(Optional secondChoice) { - return (Optional) checkNotNull(secondChoice); + return (Optional) Utils.checkNotNull(secondChoice); } @Override @@ -68,22 +66,22 @@ public T orNull() { @Override public Optional transform(Function function) { - checkNotNull(function); + Utils.checkNotNull(function); return Optional.absent(); } @Override public Optional map(Function function) { - checkNotNull(function); + Utils.checkNotNull(function); return Optional.absent(); } @Override public Optional flatMap(Function> function) { - checkNotNull(function); + Utils.checkNotNull(function); return Optional.absent(); } @Override public Optional apply(Action action) { - checkNotNull(action); + Utils.checkNotNull(action); return Optional.absent(); } diff --git a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Action.java b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Action.java similarity index 66% rename from apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Action.java rename to apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Action.java index 23416690231..774f2ceae64 100644 --- a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Action.java +++ b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Action.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.internal; +package com.homer.apollographql.apollo.api.internal; import org.jetbrains.annotations.NotNull; diff --git a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Function.java b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Function.java similarity index 83% rename from apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Function.java rename to apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Function.java index adf78ba2950..10d32e14928 100644 --- a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Function.java +++ b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Function.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.internal; +package com.homer.apollographql.apollo.api.internal; import org.jetbrains.annotations.NotNull; diff --git a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Functions.java b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Functions.java similarity index 90% rename from apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Functions.java rename to apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Functions.java index 961dbbb00ee..be83f07e3f3 100644 --- a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Functions.java +++ b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Functions.java @@ -1,10 +1,8 @@ -package com.apollographql.apollo.api.internal; +package com.homer.apollographql.apollo.api.internal; import org.jetbrains.annotations.Nullable; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; - public class Functions { /** * Returns the identity function. @@ -48,7 +46,7 @@ private enum ToStringFunction implements Function { @Override public String apply(Object o) { - checkNotNull(o); // eager for GWT. + Utils.checkNotNull(o); // eager for GWT. return o.toString(); } diff --git a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Mutator.java b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Mutator.java similarity index 85% rename from apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Mutator.java rename to apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Mutator.java index 7e981afdb66..abe6f7b4456 100644 --- a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Mutator.java +++ b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Mutator.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.internal; +package com.homer.apollographql.apollo.api.internal; /** * Represents an operation that accepts a single input argument, mutate it and returns no result diff --git a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Optional.java b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Optional.java similarity index 98% rename from apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Optional.java rename to apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Optional.java index d09bbcc0cb6..9c3a307386d 100644 --- a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Optional.java +++ b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Optional.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.apollographql.apollo.api.internal; +package com.homer.apollographql.apollo.api.internal; import java.io.Serializable; @@ -22,8 +22,6 @@ import org.jetbrains.annotations.Nullable; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; - /** * An immutable object that may contain a non-null reference to another object. Each instance of this type either @@ -91,7 +89,7 @@ public static Optional absent() { * @throws NullPointerException if {@code reference} is null */ public static Optional of(T reference) { - return new Present(checkNotNull(reference)); + return new Present(Utils.checkNotNull(reference)); } /** diff --git a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Present.java b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Present.java similarity index 84% rename from apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Present.java rename to apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Present.java index 440faa868f6..93cc6b34d83 100644 --- a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/Present.java +++ b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/Present.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.apollographql.apollo.api.internal; +package com.homer.apollographql.apollo.api.internal; import java.util.Collections; @@ -23,8 +23,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; - /** * Implementation of an {@link Optional} containing a reference. */ @@ -45,33 +43,33 @@ final class Present extends Optional { } @Override public T or(T defaultValue) { - checkNotNull(defaultValue, "use Optional.orNull() instead of Optional.or(null)"); + Utils.checkNotNull(defaultValue, "use Optional.orNull() instead of Optional.or(null)"); return reference; } @Override public Optional or(Optional secondChoice) { - checkNotNull(secondChoice); + Utils.checkNotNull(secondChoice); return this; } @Override public Optional transform(Function function) { - return new Present(checkNotNull(function.apply(reference), + return new Present(Utils.checkNotNull(function.apply(reference), "the Function passed to Optional.transform() must not return null.")); } @Override public Optional map(Function function) { - return new Present(checkNotNull(function.apply(reference), + return new Present(Utils.checkNotNull(function.apply(reference), "the Function passed to Optional.map() must not return null.")); } @Override public Optional flatMap(Function> function) { - checkNotNull(function); - return checkNotNull(function.apply(reference), + Utils.checkNotNull(function); + return Utils.checkNotNull(function.apply(reference), "the Function passed to Optional.flatMap() must not return null."); } @Override public Optional apply(final Action action) { - checkNotNull(action); + Utils.checkNotNull(action); return map(new Function() { @NotNull @Override public T apply(@NotNull T t) { action.apply(t); diff --git a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/UnmodifiableMapBuilder.java b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/UnmodifiableMapBuilder.java similarity index 91% rename from apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/UnmodifiableMapBuilder.java rename to apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/UnmodifiableMapBuilder.java index b1d38e0fe27..472219326ad 100644 --- a/apollo-api/src/jvmMain/java/com/apollographql/apollo/api/internal/UnmodifiableMapBuilder.java +++ b/apollo-api/src/jvmMain/java/com/homer/apollographql/apollo/api/internal/UnmodifiableMapBuilder.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.internal; +package com.homer.apollographql.apollo.api.internal; import java.util.Collections; import java.util.LinkedHashMap; diff --git a/apollo-api/src/jvmMain/kotlin/com/apollographql/apollo/api/internal/Throws.kt b/apollo-api/src/jvmMain/kotlin/com/apollographql/apollo/api/internal/Throws.kt deleted file mode 100644 index 407eeed2532..00000000000 --- a/apollo-api/src/jvmMain/kotlin/com/apollographql/apollo/api/internal/Throws.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.apollographql.apollo.api.internal - -actual typealias Throws = kotlin.jvm.Throws diff --git a/apollo-api/src/jvmMain/kotlin/com/apollographql/apollo/api/BigDecimal.kt b/apollo-api/src/jvmMain/kotlin/com/homer/apollographql/apollo/api/BigDecimal.kt similarity index 75% rename from apollo-api/src/jvmMain/kotlin/com/apollographql/apollo/api/BigDecimal.kt rename to apollo-api/src/jvmMain/kotlin/com/homer/apollographql/apollo/api/BigDecimal.kt index 93b9f71b29e..c6d93b944e3 100644 --- a/apollo-api/src/jvmMain/kotlin/com/apollographql/apollo/api/BigDecimal.kt +++ b/apollo-api/src/jvmMain/kotlin/com/homer/apollographql/apollo/api/BigDecimal.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api import java.math.BigDecimal as JBigDecimal diff --git a/apollo-api/src/jvmMain/kotlin/com/apollographql/apollo/api/fileupload.kt b/apollo-api/src/jvmMain/kotlin/com/homer/apollographql/apollo/api/fileupload.kt similarity index 90% rename from apollo-api/src/jvmMain/kotlin/com/apollographql/apollo/api/fileupload.kt rename to apollo-api/src/jvmMain/kotlin/com/homer/apollographql/apollo/api/fileupload.kt index 34b4ce3a4c9..f320f9f53c6 100644 --- a/apollo-api/src/jvmMain/kotlin/com/apollographql/apollo/api/fileupload.kt +++ b/apollo-api/src/jvmMain/kotlin/com/homer/apollographql/apollo/api/fileupload.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api +package com.homer.apollographql.apollo.api import okio.BufferedSink import okio.buffer diff --git a/apollo-api/src/jvmMain/kotlin/com/homer/apollographql/apollo/api/internal/Throws.kt b/apollo-api/src/jvmMain/kotlin/com/homer/apollographql/apollo/api/internal/Throws.kt new file mode 100644 index 00000000000..15d9c9bdc54 --- /dev/null +++ b/apollo-api/src/jvmMain/kotlin/com/homer/apollographql/apollo/api/internal/Throws.kt @@ -0,0 +1,3 @@ +package com.homer.apollographql.apollo.api.internal + +actual typealias Throws = kotlin.jvm.Throws diff --git a/apollo-api/src/jvmMain/kotlin/com/apollographql/apollo/api/internal/json/-Platform.kt b/apollo-api/src/jvmMain/kotlin/com/homer/apollographql/apollo/api/internal/json/-Platform.kt similarity index 62% rename from apollo-api/src/jvmMain/kotlin/com/apollographql/apollo/api/internal/json/-Platform.kt rename to apollo-api/src/jvmMain/kotlin/com/homer/apollographql/apollo/api/internal/json/-Platform.kt index 0c62c318f2e..4db9c2f2787 100644 --- a/apollo-api/src/jvmMain/kotlin/com/apollographql/apollo/api/internal/json/-Platform.kt +++ b/apollo-api/src/jvmMain/kotlin/com/homer/apollographql/apollo/api/internal/json/-Platform.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.internal.json +package com.homer.apollographql.apollo.api.internal.json actual typealias Closeable = java.io.Closeable diff --git a/apollo-api/src/jvmTest/java/com/apollographql/apollo/api/graphql/internal/OptionalTest.java b/apollo-api/src/jvmTest/java/com/apollographql/apollo/api/graphql/internal/OptionalTest.java deleted file mode 100644 index 84c2871a674..00000000000 --- a/apollo-api/src/jvmTest/java/com/apollographql/apollo/api/graphql/internal/OptionalTest.java +++ /dev/null @@ -1,359 +0,0 @@ -package com.apollographql.apollo.api.graphql.internal; - -/* - * Copyright (C) 2011 The Guava Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import com.apollographql.apollo.api.internal.Function; -import com.apollographql.apollo.api.internal.Functions; -import com.apollographql.apollo.api.internal.Optional; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableList; -import org.jetbrains.annotations.NotNull; -import org.junit.Test; - -import java.util.Collections; -import java.util.Set; - -import static com.google.common.truth.Truth.assertThat; -import static junit.framework.TestCase.assertFalse; -import static junit.framework.TestCase.assertSame; -import static junit.framework.TestCase.assertTrue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - - -public final class OptionalTest { - @Test - public void testAbsent() { - Optional optionalName = Optional.absent(); - assertFalse(optionalName.isPresent()); - } - - @Test - public void testOf() { - assertEquals("training", Optional.of("training").get()); - } - - @Test - public void testOfNull() { - try { - Optional.of(null); - fail(); - } catch (NullPointerException ignore) { - } - } - - @Test - public void testFromNullable() { - Optional optionalName = Optional.fromNullable("bob"); - assertEquals("bob", optionalName.get()); - } - - @Test - public void testFromNullableNull() { - // not promised by spec, but easier to test - assertSame(Optional.absent(), Optional.fromNullable(null)); - } - - @Test - public void testIsPresentNo() { - assertFalse(Optional.absent().isPresent()); - } - - @Test - public void testIsPresentYes() { - assertTrue(Optional.of("training").isPresent()); - } - - @Test - public void testGetAbsent() { - Optional optional = Optional.absent(); - try { - optional.get(); - fail(); - } catch (IllegalStateException ignore) { - } - } - - @Test - public void testGetPresent() { - assertEquals("training", Optional.of("training").get()); - } - - @Test - public void testOrTPresent() { - assertEquals("a", Optional.of("a").or("default")); - } - - @Test - public void testOrTAbsent() { - assertEquals("default", Optional.absent().or("default")); - } - - @Test - public void testOrOptionalPresent() { - assertEquals(Optional.of("a"), Optional.of("a").or(Optional.of("fallback"))); - } - - @Test - public void testOrOptionalAbsent() { - assertEquals(Optional.of("fallback"), Optional.absent().or(Optional.of("fallback"))); - } - - @Test - public void testOrNullPresent() { - assertEquals("a", Optional.of("a").orNull()); - } - - @Test - public void testOrNullAbsent() { - assertNull(Optional.absent().orNull()); - } - - @Test - public void testAsSetPresent() { - Set expected = Collections.singleton("a"); - assertEquals(expected, Optional.of("a").asSet()); - } - - @Test - public void testAsSetAbsent() { - assertTrue("Returned set should be empty", Optional.absent().asSet().isEmpty()); - } - - @Test - public void testAsSetPresentIsImmutable() { - Set presentAsSet = Optional.of("a").asSet(); - try { - presentAsSet.add("b"); - fail(); - } catch (UnsupportedOperationException ignore) { - } - } - - @Test - public void testAsSetAbsentIsImmutable() { - Set absentAsSet = Optional.absent().asSet(); - try { - absentAsSet.add("foo"); - fail(); - } catch (UnsupportedOperationException ignore) { - } - } - - @Test - public void testTransformAbsent() { - assertEquals(Optional.absent(), Optional.absent().transform(Functions.identity())); - assertEquals(Optional.absent(), Optional.absent().transform(Functions.toStringFunction())); - } - - @Test - public void testTransformPresentIdentity() { - assertEquals(Optional.of("a"), Optional.of("a").transform(Functions.identity())); - } - - @Test - public void testTransformPresentToString() { - assertEquals(Optional.of("42"), Optional.of(42).transform(Functions.toStringFunction())); - } - - @Test - public void testTransformPresentFunctionReturnsNull() { - try { - Optional unused = - Optional.of("a") - .transform( - new Function() { - @Override - public String apply(String input) { - return null; - } - }); - fail("Should throw if Function returns null."); - } catch (NullPointerException ignore) { - } - } - - @Test - public void testTransformAbssentFunctionReturnsNull() { - assertEquals(Optional.absent(), - Optional.absent().transform( - new Function() { - @Override public Object apply(Object input) { - return null; - } - })); - } - - @Test - public void testEqualsAndHashCodeAbsent() { - assertEquals(Optional.absent(), Optional.absent()); - assertEquals(Optional.absent().hashCode(), Optional.absent().hashCode()); - assertThat(Optional.absent().hashCode()) - .isNotEqualTo(Optional.of(0).hashCode()); - } - - @Test - public void testEqualsAndHashCodePresent() { - assertEquals(Optional.of("training"), Optional.of("training")); - assertFalse(Optional.of("a").equals(Optional.of("b"))); - assertFalse(Optional.of("a").equals(Optional.absent())); - assertEquals(Optional.of("training").hashCode(), Optional.of("training").hashCode()); - } - - @Test - public void testToStringAbsent() { - assertEquals("Optional.absent()", Optional.absent().toString()); - } - - @Test - public void testToStringPresent() { - assertEquals("Optional.of(training)", Optional.of("training").toString()); - } - - - private static Optional getSomeOptionalInt() { - return Optional.of(1); - } - - private static FluentIterable getSomeNumbers() { - return FluentIterable.from(ImmutableList.of()); - } - - /* - * The following tests demonstrate the shortcomings of or() and test that the casting workaround - * mentioned in the method Javadoc does in fact compile. - */ - - @SuppressWarnings("unused") // compilation test - @Test - public void testSampleCodeError1() { - Optional optionalInt = getSomeOptionalInt(); - // Number value = optionalInt.or(0.5); // error - } - - - @SuppressWarnings("unused") // compilation test - @Test - public void testSampleCodeFine1() { - Optional optionalInt = Optional.of((Number) 1); - Number value = optionalInt.or(0.5); // fine - } - - @SuppressWarnings("unused") // compilation test - @Test - public void testSampleCodeFine2() { - FluentIterable numbers = getSomeNumbers(); - - // Sadly, the following is what users will have to do in some circumstances. - - } - - @Test - public void testMapAbsent() { - assertEquals(Optional.absent(), Optional.absent().map(Functions.identity())); - assertEquals(Optional.absent(), Optional.absent().map(Functions.toStringFunction())); - } - - @Test - public void testMapPresentIdentity() { - assertEquals(Optional.of("a"), Optional.of("a").map(Functions.identity())); - } - - @Test - public void testMapPresentToString() { - assertEquals(Optional.of("42"), Optional.of(42).map(Functions.toStringFunction())); - } - - @Test - public void testMapPresentFunctionReturnsNull() { - try { - Optional unused = - Optional.of("a") - .map( - new Function() { - @Override - public String apply(String input) { - return null; - } - }); - fail("Should throw if Function returns null."); - } catch (NullPointerException ignore) { - } - } - - @Test - public void testMapAbssentFunctionReturnsNull() { - assertEquals(Optional.absent(), - Optional.absent().map( - new Function() { - @Override public Object apply(Object input) { - return null; - } - })); - } - - @Test - public void testFlatMapAbsent() { - assertEquals(Optional.absent(), Optional.absent().flatMap(new Function>() { - @NotNull @Override public Optional apply(@NotNull Object o) { - return Optional.of(o.toString()); - } - })); - } - - @Test - public void testFlatMapMapPresentIdentity() { - assertEquals(Optional.of("a"), Optional.of("a").flatMap(new Function>() { - @NotNull @Override public Optional apply(@NotNull String s) { - return Optional.of(s); - } - }) - ); - } - - @Test - public void testFlatMapPresentToString() { - assertEquals(Optional.of("42"), Optional.of(42).flatMap(new Function>() { - @NotNull @Override public Optional apply(@NotNull Integer integer) { - return Optional.of(integer.toString()); - } - })); - } - - @Test - public void testFlatMapPresentFunctionReturnsNull() { - try { - Optional unused = Optional.of("a").flatMap(new Function>() { - @NotNull @Override public Optional apply(@NotNull String s) { - return null; - } - }); - fail("Should throw if Function returns null."); - } catch (NullPointerException expected) { - } - } - - @Test - public void testFlatMapAbssentFunctionReturnsNull() { - assertEquals(Optional.absent(), Optional.absent().flatMap(new Function>() { - @NotNull @Override public Optional apply(@NotNull Object o) { - return null; - } - })); - } -} diff --git a/apollo-api/src/jvmTest/java/com/apollographql/apollo/api/internal/SimpleResponseReaderJvmCustomTypesTest.kt b/apollo-api/src/jvmTest/java/com/apollographql/apollo/api/internal/SimpleResponseReaderJvmCustomTypesTest.kt deleted file mode 100644 index 6913f93bed7..00000000000 --- a/apollo-api/src/jvmTest/java/com/apollographql/apollo/api/internal/SimpleResponseReaderJvmCustomTypesTest.kt +++ /dev/null @@ -1,139 +0,0 @@ -package com.apollographql.apollo.api.internal - -import com.apollographql.apollo.api.CustomTypeAdapter -import com.apollographql.apollo.api.CustomTypeValue -import com.apollographql.apollo.api.EMPTY_OPERATION -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarType -import com.apollographql.apollo.api.ScalarTypeAdapters -import org.junit.Assert -import org.junit.Assert.assertEquals -import org.junit.Test -import java.net.URL -import java.text.ParseException -import java.text.SimpleDateFormat -import java.util.Date - -class SimpleResponseReaderJvmCustomTypesTest { - private val noConditions: List = emptyList() - - @Test - fun readCustom() { - val successField = ResponseField.forCustomType("successFieldResponseName", "successFieldName", null, - false, DATE_CUSTOM_TYPE, noConditions) - val classCastExceptionField = ResponseField.forCustomType("classCastExceptionField", - "classCastExceptionField", null, false, DATE_CUSTOM_TYPE, noConditions) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = "2017-04-16" - recordSet["successFieldName"] = "2018-04-16" - recordSet["classCastExceptionField"] = 0 - val responseReader = responseReader(recordSet) - assertEquals(DATE_TIME_FORMAT.parse("2017-04-16"), responseReader.readCustomType(successField)) - try { - responseReader.readCustomType(classCastExceptionField) - Assert.fail("expected ClassCastException") - } catch (expected: ClassCastException) { - // expected - } - } - - @Test - fun readCustomList() { - val successField = ResponseField.forList("successFieldResponseName", "successFieldName", null, false, noConditions) - val recordSet: MutableMap = HashMap() - recordSet["successFieldResponseName"] = listOf("2017-04-16", "2017-04-17", "2017-04-18") - recordSet["successFieldName"] = listOf("2017-04-19", "2017-04-20") - recordSet["classCastExceptionField"] = "anything" - val responseReader = responseReader(recordSet) - assertEquals( - listOf(DATE_TIME_FORMAT.parse("2017-04-16"), DATE_TIME_FORMAT.parse("2017-04-17"), DATE_TIME_FORMAT.parse("2017-04-18")), - responseReader.readList(successField) { reader -> reader.readCustomType(DATE_CUSTOM_TYPE) } - ) - } - - @Test - fun optionalFieldsIOException() { - val responseReader = responseReader(emptyMap()) - responseReader.readCustomType(ResponseField.forCustomType("customTypeField", "customTypeField", null, true, DATE_CUSTOM_TYPE, - noConditions)) - } - - @Test - fun mandatoryFieldsIOException() { - val responseReader = responseReader(emptyMap()) - try { - responseReader.readCustomType(ResponseField.forCustomType("customTypeField", "customTypeField", null, false, DATE_CUSTOM_TYPE, - noConditions)) - Assert.fail("expected NullPointerException") - } catch (expected: NullPointerException) { - //expected - } - } - - companion object { - private fun responseReader(recordSet: Map): SimpleResponseReader { - val customTypeAdapters: MutableMap> = HashMap() - customTypeAdapters[DATE_CUSTOM_TYPE] = object : CustomTypeAdapter { - override fun decode(value: CustomTypeValue<*>): Any { - return try { - DATE_TIME_FORMAT.parse(value.value.toString()) - } catch (e: ParseException) { - throw ClassCastException() - } - } - - override fun encode(value: Any?): CustomTypeValue<*> { - throw UnsupportedOperationException() - } - } - customTypeAdapters[URL_CUSTOM_TYPE] = object : CustomTypeAdapter { - override fun decode(value: CustomTypeValue<*>): Any { - throw UnsupportedOperationException() - } - - override fun encode(value: Any?): CustomTypeValue<*> { - throw UnsupportedOperationException() - } - } - customTypeAdapters[OBJECT_CUSTOM_TYPE] = object : CustomTypeAdapter { - override fun decode(value: CustomTypeValue<*>): Any { - return value.value.toString() - } - - override fun encode(value: Any?): CustomTypeValue<*> { - throw UnsupportedOperationException() - } - } - return SimpleResponseReader(recordSet, EMPTY_OPERATION.variables(), ScalarTypeAdapters(customTypeAdapters)) - } - - private val OBJECT_CUSTOM_TYPE: ScalarType = object : ScalarType { - override fun typeName(): String { - return String::class.java.name - } - - override fun className(): String { - return String::class.java.name - } - } - private val DATE_CUSTOM_TYPE: ScalarType = object : ScalarType { - override fun typeName(): String { - return Date::class.java.name - } - - override fun className(): String { - return Date::class.java.name - } - } - private val URL_CUSTOM_TYPE: ScalarType = object : ScalarType { - override fun typeName(): String { - return URL::class.java.name - } - - override fun className(): String { - return URL::class.java.name - } - } - private val DATE_TIME_FORMAT = SimpleDateFormat("yyyyy-mm-dd") - } -} diff --git a/apollo-compiler/build.gradle.kts b/apollo-compiler/build.gradle.kts index f8f9ff0daf2..79c1c87eca5 100644 --- a/apollo-compiler/build.gradle.kts +++ b/apollo-compiler/build.gradle.kts @@ -36,14 +36,14 @@ abstract class GeneratePluginVersion : DefaultTask() { val versionFile = outputFile.asFile.get() versionFile.parentFile.mkdirs() versionFile.writeText("""// Generated file. Do not edit! -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler val VERSION = "${project.version}" """) } } val pluginVersionTaskProvider = tasks.register("pluginVersion", GeneratePluginVersion::class.java) { - outputFile.set(project.layout.buildDirectory.file("generated/kotlin/com/apollographql/apollo/compiler/Version.kt")) + outputFile.set(project.layout.buildDirectory.file("generated/kotlin/com/homer/apollographql/apollo/compiler/Version.kt")) version.set(project.version.toString()) } @@ -53,7 +53,7 @@ tasks.withType(KotlinCompile::class.java) { } tasks.withType { - exclude("**com/apollographql/apollo/compiler/parser/antlr/**") + exclude("**com/homer/apollographql/apollo/compiler/parser/antlr/**") } // since test/graphql is not an input to Test tasks, they're not run with the changes made in there. diff --git a/apollo-compiler/src/main/antlr/com/apollographql/apollo/compiler/parser/antlr/GraphQL.g4 b/apollo-compiler/src/main/antlr/com/homer/apollographql/apollo/compiler/parser/antlr/GraphQL.g4 similarity index 98% rename from apollo-compiler/src/main/antlr/com/apollographql/apollo/compiler/parser/antlr/GraphQL.g4 rename to apollo-compiler/src/main/antlr/com/homer/apollographql/apollo/compiler/parser/antlr/GraphQL.g4 index 93d15148fe4..b65b2c80002 100644 --- a/apollo-compiler/src/main/antlr/com/apollographql/apollo/compiler/parser/antlr/GraphQL.g4 +++ b/apollo-compiler/src/main/antlr/com/homer/apollographql/apollo/compiler/parser/antlr/GraphQL.g4 @@ -24,7 +24,7 @@ grammar GraphQL; @header { -package com.apollographql.apollo.compiler.parser.antlr; +package com.homer.apollographql.apollo.compiler.parser.antlr; } document diff --git a/apollo-compiler/src/main/antlr/com/apollographql/apollo/compiler/parser/antlr/GraphSDL.g4 b/apollo-compiler/src/main/antlr/com/homer/apollographql/apollo/compiler/parser/antlr/GraphSDL.g4 similarity index 98% rename from apollo-compiler/src/main/antlr/com/apollographql/apollo/compiler/parser/antlr/GraphSDL.g4 rename to apollo-compiler/src/main/antlr/com/homer/apollographql/apollo/compiler/parser/antlr/GraphSDL.g4 index b6c60270704..31b99e21caf 100644 --- a/apollo-compiler/src/main/antlr/com/apollographql/apollo/compiler/parser/antlr/GraphSDL.g4 +++ b/apollo-compiler/src/main/antlr/com/homer/apollographql/apollo/compiler/parser/antlr/GraphSDL.g4 @@ -1,7 +1,7 @@ grammar GraphSDL; @header { -package com.apollographql.apollo.compiler.parser.antlr; +package com.homer.apollographql.apollo.compiler.parser.antlr; } document diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/SchemaConverter.kt b/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/SchemaConverter.kt deleted file mode 100644 index edb86d91971..00000000000 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/SchemaConverter.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.apollographql.apollo.compiler.parser - -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema.Companion.wrap -import com.apollographql.apollo.compiler.parser.introspection.toSDL -import com.apollographql.apollo.compiler.parser.sdl.GraphSdlSchema -import com.apollographql.apollo.compiler.parser.sdl.toIntrospectionSchema -import com.apollographql.apollo.compiler.toJson -import java.io.File - -object SchemaConverter { - -} \ No newline at end of file diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/Annotations.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/Annotations.kt similarity index 95% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/Annotations.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/Annotations.kt index 265e9c30adb..bc627f0fb7c 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/Annotations.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/Annotations.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler import com.squareup.javapoet.AnnotationSpec import com.squareup.javapoet.CodeBlock diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ApolloMetadata.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ApolloMetadata.kt similarity index 95% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ApolloMetadata.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ApolloMetadata.kt index 098b991fc91..012d82a55d2 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ApolloMetadata.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ApolloMetadata.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler -import com.apollographql.apollo.compiler.ir.Fragment -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionQuery +import com.homer.apollographql.apollo.compiler.ir.Fragment +import com.homer.apollographql.apollo.compiler.parser.introspection.IntrospectionQuery import com.squareup.moshi.JsonClass import java.io.File diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/BuilderTypeSpecBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/BuilderTypeSpecBuilder.kt similarity index 98% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/BuilderTypeSpecBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/BuilderTypeSpecBuilder.kt index c5584aa86ec..13fcaf193ca 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/BuilderTypeSpecBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/BuilderTypeSpecBuilder.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler -import com.apollographql.apollo.compiler.ir.TypeDeclaration +import com.homer.apollographql.apollo.compiler.ir.TypeDeclaration import com.squareup.javapoet.* import java.util.* import javax.lang.model.element.Modifier diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ClassNames.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ClassNames.kt similarity index 90% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ClassNames.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ClassNames.kt index 01a7e4d7a81..4973c1597ae 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ClassNames.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ClassNames.kt @@ -1,10 +1,10 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler -import com.apollographql.apollo.api.* -import com.apollographql.apollo.api.internal.Mutator -import com.apollographql.apollo.api.internal.Optional -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder -import com.apollographql.apollo.api.internal.Utils +import com.homer.apollographql.apollo.api.* +import com.homer.apollographql.apollo.api.internal.Mutator +import com.homer.apollographql.apollo.api.internal.Optional +import com.homer.apollographql.apollo.api.internal.UnmodifiableMapBuilder +import com.homer.apollographql.apollo.api.internal.Utils import com.squareup.javapoet.ClassName import com.squareup.javapoet.ParameterizedTypeName import com.squareup.javapoet.TypeName diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/CustomEnumTypeSpecBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/CustomEnumTypeSpecBuilder.kt similarity index 92% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/CustomEnumTypeSpecBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/CustomEnumTypeSpecBuilder.kt index 46a56de127b..ac015769911 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/CustomEnumTypeSpecBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/CustomEnumTypeSpecBuilder.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler -import com.apollographql.apollo.api.ScalarType -import com.apollographql.apollo.compiler.ir.CodeGenerationContext +import com.homer.apollographql.apollo.api.ScalarType +import com.homer.apollographql.apollo.compiler.ir.CodeGenerationContext import com.squareup.javapoet.ClassName import com.squareup.javapoet.MethodSpec import com.squareup.javapoet.TypeSpec diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/DefaultPackageNameProvider.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/DefaultPackageNameProvider.kt similarity index 93% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/DefaultPackageNameProvider.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/DefaultPackageNameProvider.kt index 47db14a92da..e624835a68b 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/DefaultPackageNameProvider.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/DefaultPackageNameProvider.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler import java.io.File diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/FragmentsResponseMapperBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/FragmentsResponseMapperBuilder.kt similarity index 92% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/FragmentsResponseMapperBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/FragmentsResponseMapperBuilder.kt index fd9e7ac2e47..d106ad50516 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/FragmentsResponseMapperBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/FragmentsResponseMapperBuilder.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.compiler.ir.CodeGenerationContext +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper +import com.homer.apollographql.apollo.api.internal.ResponseReader +import com.homer.apollographql.apollo.compiler.ir.CodeGenerationContext import com.squareup.javapoet.* import javax.lang.model.element.Modifier diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/GraphQLCompiler.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/GraphQLCompiler.kt similarity index 89% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/GraphQLCompiler.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/GraphQLCompiler.kt index 5aa87700487..062d86dd0bf 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/GraphQLCompiler.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/GraphQLCompiler.kt @@ -1,27 +1,27 @@ -package com.apollographql.apollo.compiler - -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.compiler.ApolloMetadata.Companion.merge -import com.apollographql.apollo.compiler.codegen.kotlin.GraphQLKompiler -import com.apollographql.apollo.compiler.ir.CodeGenerationContext -import com.apollographql.apollo.compiler.ir.CodeGenerationIR -import com.apollographql.apollo.compiler.ir.Field -import com.apollographql.apollo.compiler.ir.IRBuilder -import com.apollographql.apollo.compiler.ir.ScalarType -import com.apollographql.apollo.compiler.ir.SourceLocation -import com.apollographql.apollo.compiler.ir.TypeDeclaration.Companion.KIND_ENUM -import com.apollographql.apollo.compiler.ir.TypeDeclaration.Companion.KIND_INPUT_OBJECT_TYPE -import com.apollographql.apollo.compiler.operationoutput.OperationDescriptor -import com.apollographql.apollo.compiler.operationoutput.toJson -import com.apollographql.apollo.compiler.parser.error.DocumentParseException -import com.apollographql.apollo.compiler.parser.error.ParseException -import com.apollographql.apollo.compiler.parser.graphql.DocumentParseResult -import com.apollographql.apollo.compiler.parser.graphql.GraphQLDocumentParser -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema.Companion.toIntrospectionSchema -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema.Companion.wrap -import com.apollographql.apollo.compiler.parser.sdl.GraphSdlSchema -import com.apollographql.apollo.compiler.parser.sdl.toIntrospectionSchema +package com.homer.apollographql.apollo.compiler + +import com.homer.apollographql.apollo.api.internal.QueryDocumentMinifier +import com.homer.apollographql.apollo.compiler.ApolloMetadata.Companion.merge +import com.homer.apollographql.apollo.compiler.codegen.kotlin.GraphQLKompiler +import com.homer.apollographql.apollo.compiler.ir.CodeGenerationContext +import com.homer.apollographql.apollo.compiler.ir.CodeGenerationIR +import com.homer.apollographql.apollo.compiler.ir.Field +import com.homer.apollographql.apollo.compiler.ir.IRBuilder +import com.homer.apollographql.apollo.compiler.ir.ScalarType +import com.homer.apollographql.apollo.compiler.ir.SourceLocation +import com.homer.apollographql.apollo.compiler.ir.TypeDeclaration.Companion.KIND_ENUM +import com.homer.apollographql.apollo.compiler.ir.TypeDeclaration.Companion.KIND_INPUT_OBJECT_TYPE +import com.homer.apollographql.apollo.compiler.operationoutput.OperationDescriptor +import com.homer.apollographql.apollo.compiler.operationoutput.toJson +import com.homer.apollographql.apollo.compiler.parser.error.DocumentParseException +import com.homer.apollographql.apollo.compiler.parser.error.ParseException +import com.homer.apollographql.apollo.compiler.parser.graphql.DocumentParseResult +import com.homer.apollographql.apollo.compiler.parser.graphql.GraphQLDocumentParser +import com.homer.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema +import com.homer.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema.Companion.toIntrospectionSchema +import com.homer.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema.Companion.wrap +import com.homer.apollographql.apollo.compiler.parser.sdl.GraphSdlSchema +import com.homer.apollographql.apollo.compiler.parser.sdl.toIntrospectionSchema import com.squareup.javapoet.JavaFile import com.squareup.kotlinpoet.asClassName import java.io.File @@ -153,7 +153,7 @@ class GraphQLCompiler(val logger: Logger = NoOpLogger) { fragments = ir.fragments.filter { ir.fragmentsToGenerate.contains(it.fragmentName) }, generateKotlinModels = generateKotlinModels, customTypesMap = args.customTypeMap, - pluginVersion = com.apollographql.apollo.compiler.VERSION + pluginVersion = com.homer.apollographql.apollo.compiler.VERSION ).let { if (args.rootProjectDir != null) { it.withRelativeFragments(args.rootProjectDir) diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/Inflector.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/Inflector.kt similarity index 97% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/Inflector.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/Inflector.kt index 3d02862caac..d8d5806d1c5 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/Inflector.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/Inflector.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler import java.util.regex.Pattern diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/InputFieldSpec.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/InputFieldSpec.kt similarity index 97% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/InputFieldSpec.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/InputFieldSpec.kt index bfae1bee173..988b994faa8 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/InputFieldSpec.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/InputFieldSpec.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler -import com.apollographql.apollo.api.internal.InputFieldWriter -import com.apollographql.apollo.compiler.ir.CodeGenerationContext +import com.homer.apollographql.apollo.api.internal.InputFieldWriter +import com.homer.apollographql.apollo.compiler.ir.CodeGenerationContext import com.squareup.javapoet.* import java.io.IOException import java.util.* diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/InputTypeSpecBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/InputTypeSpecBuilder.kt similarity index 94% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/InputTypeSpecBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/InputTypeSpecBuilder.kt index 7f5ab40c3b9..06331a32776 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/InputTypeSpecBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/InputTypeSpecBuilder.kt @@ -1,9 +1,9 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.InputFieldWriter -import com.apollographql.apollo.compiler.ir.CodeGenerationContext -import com.apollographql.apollo.compiler.ir.TypeDeclarationField +import com.homer.apollographql.apollo.api.internal.InputFieldMarshaller +import com.homer.apollographql.apollo.api.internal.InputFieldWriter +import com.homer.apollographql.apollo.compiler.ir.CodeGenerationContext +import com.homer.apollographql.apollo.compiler.ir.TypeDeclarationField import com.squareup.javapoet.* import java.io.IOException import javax.lang.model.element.Modifier diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/JavaTypeResolver.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/JavaTypeResolver.kt similarity index 85% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/JavaTypeResolver.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/JavaTypeResolver.kt index 4cd072f14e0..f89563e6ba4 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/JavaTypeResolver.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/JavaTypeResolver.kt @@ -1,11 +1,11 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler -import com.apollographql.apollo.compiler.ClassNames.parameterizedGuavaOptional -import com.apollographql.apollo.compiler.ClassNames.parameterizedInputType -import com.apollographql.apollo.compiler.ClassNames.parameterizedJavaOptional -import com.apollographql.apollo.compiler.ClassNames.parameterizedOptional -import com.apollographql.apollo.compiler.ir.CodeGenerationContext -import com.apollographql.apollo.compiler.ir.ScalarType +import com.homer.apollographql.apollo.compiler.ClassNames.parameterizedGuavaOptional +import com.homer.apollographql.apollo.compiler.ClassNames.parameterizedInputType +import com.homer.apollographql.apollo.compiler.ClassNames.parameterizedJavaOptional +import com.homer.apollographql.apollo.compiler.ClassNames.parameterizedOptional +import com.homer.apollographql.apollo.compiler.ir.CodeGenerationContext +import com.homer.apollographql.apollo.compiler.ir.ScalarType import com.squareup.javapoet.ClassName import com.squareup.javapoet.TypeName diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/NullableValueType.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/NullableValueType.kt similarity index 81% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/NullableValueType.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/NullableValueType.kt index ef27521f5b6..071c0874b8d 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/NullableValueType.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/NullableValueType.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler enum class NullableValueType(val value: String) { ANNOTATED("annotated"), diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/OperationIdGenerator.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/OperationIdGenerator.kt similarity index 96% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/OperationIdGenerator.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/OperationIdGenerator.kt index 2afb8055efe..522a8d0f1e7 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/OperationIdGenerator.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/OperationIdGenerator.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler import java.nio.charset.StandardCharsets import java.security.MessageDigest diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/OperationOutputGenerator.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/OperationOutputGenerator.kt similarity index 72% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/OperationOutputGenerator.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/OperationOutputGenerator.kt index 7a2272ca614..b10992d3ca8 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/OperationOutputGenerator.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/OperationOutputGenerator.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler -import com.apollographql.apollo.compiler.operationoutput.OperationDescriptor -import com.apollographql.apollo.compiler.operationoutput.OperationOutput +import com.homer.apollographql.apollo.compiler.operationoutput.OperationDescriptor +import com.homer.apollographql.apollo.compiler.operationoutput.OperationOutput interface OperationOutputGenerator { diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/OperationTypeSpecBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/OperationTypeSpecBuilder.kt similarity index 94% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/OperationTypeSpecBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/OperationTypeSpecBuilder.kt index 22201c3ab52..7e20fff8d7f 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/OperationTypeSpecBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/OperationTypeSpecBuilder.kt @@ -1,19 +1,19 @@ -package com.apollographql.apollo.compiler - -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.compiler.VisitorSpec.VISITOR_CLASSNAME -import com.apollographql.apollo.compiler.ir.CodeGenerationContext -import com.apollographql.apollo.compiler.ir.CodeGenerator -import com.apollographql.apollo.compiler.ir.Fragment -import com.apollographql.apollo.compiler.ir.Operation -import com.apollographql.apollo.compiler.ir.Variable -import com.apollographql.apollo.compiler.operationoutput.findOperationId +package com.homer.apollographql.apollo.compiler + +import com.homer.apollographql.apollo.api.OperationName +import com.homer.apollographql.apollo.api.Response +import com.homer.apollographql.apollo.api.ScalarTypeAdapters +import com.homer.apollographql.apollo.api.internal.OperationRequestBodyComposer +import com.homer.apollographql.apollo.api.internal.QueryDocumentMinifier +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper +import com.homer.apollographql.apollo.api.internal.SimpleOperationResponseParser +import com.homer.apollographql.apollo.compiler.VisitorSpec.VISITOR_CLASSNAME +import com.homer.apollographql.apollo.compiler.ir.CodeGenerationContext +import com.homer.apollographql.apollo.compiler.ir.CodeGenerator +import com.homer.apollographql.apollo.compiler.ir.Fragment +import com.homer.apollographql.apollo.compiler.ir.Operation +import com.homer.apollographql.apollo.compiler.ir.Variable +import com.homer.apollographql.apollo.compiler.operationoutput.findOperationId import com.squareup.javapoet.ClassName import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.FieldSpec diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/PackageNameProvider.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/PackageNameProvider.kt similarity index 74% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/PackageNameProvider.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/PackageNameProvider.kt index c4f40370148..d03ce70c0b4 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/PackageNameProvider.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/PackageNameProvider.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler interface PackageNameProvider { fun operationPackageName(filePath: String): String diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ResponseFieldSpec.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ResponseFieldSpec.kt similarity index 97% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ResponseFieldSpec.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ResponseFieldSpec.kt index d3f83f3af7a..86a8fedf931 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ResponseFieldSpec.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ResponseFieldSpec.kt @@ -1,12 +1,12 @@ -package com.apollographql.apollo.compiler - -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.ResponseWriter -import com.apollographql.apollo.compiler.ir.CodeGenerationContext -import com.apollographql.apollo.compiler.ir.Condition -import com.apollographql.apollo.compiler.ir.Field -import com.apollographql.apollo.compiler.ir.TypeDeclaration +package com.homer.apollographql.apollo.compiler + +import com.homer.apollographql.apollo.api.ResponseField +import com.homer.apollographql.apollo.api.internal.ResponseReader +import com.homer.apollographql.apollo.api.internal.ResponseWriter +import com.homer.apollographql.apollo.compiler.ir.CodeGenerationContext +import com.homer.apollographql.apollo.compiler.ir.Condition +import com.homer.apollographql.apollo.compiler.ir.Field +import com.homer.apollographql.apollo.compiler.ir.TypeDeclaration import com.squareup.javapoet.* import java.util.* import javax.lang.model.element.Modifier diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/Roots.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/Roots.kt similarity index 95% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/Roots.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/Roots.kt index 8b19e9325bf..b6efea30e48 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/Roots.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/Roots.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler import java.io.File diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/SchemaTypeSpecBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/SchemaTypeSpecBuilder.kt similarity index 97% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/SchemaTypeSpecBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/SchemaTypeSpecBuilder.kt index def849c7182..7068d7af1a0 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/SchemaTypeSpecBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/SchemaTypeSpecBuilder.kt @@ -1,14 +1,14 @@ -package com.apollographql.apollo.compiler - -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.ResponseWriter -import com.apollographql.apollo.compiler.ir.CodeGenerationContext -import com.apollographql.apollo.compiler.ir.Field -import com.apollographql.apollo.compiler.ir.FragmentRef -import com.apollographql.apollo.compiler.ir.InlineFragment +package com.homer.apollographql.apollo.compiler + +import com.homer.apollographql.apollo.api.ResponseField +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper +import com.homer.apollographql.apollo.api.internal.ResponseFieldMarshaller +import com.homer.apollographql.apollo.api.internal.ResponseReader +import com.homer.apollographql.apollo.api.internal.ResponseWriter +import com.homer.apollographql.apollo.compiler.ir.CodeGenerationContext +import com.homer.apollographql.apollo.compiler.ir.Field +import com.homer.apollographql.apollo.compiler.ir.FragmentRef +import com.homer.apollographql.apollo.compiler.ir.InlineFragment import com.squareup.javapoet.* import javax.lang.model.element.Modifier diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/VariablesTypeSpecBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/VariablesTypeSpecBuilder.kt similarity index 94% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/VariablesTypeSpecBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/VariablesTypeSpecBuilder.kt index 9fd09bdc438..ccc4e9b6bf2 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/VariablesTypeSpecBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/VariablesTypeSpecBuilder.kt @@ -1,9 +1,9 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.InputFieldWriter -import com.apollographql.apollo.compiler.ir.CodeGenerationContext -import com.apollographql.apollo.compiler.ir.Variable +import com.homer.apollographql.apollo.api.internal.InputFieldMarshaller +import com.homer.apollographql.apollo.api.internal.InputFieldWriter +import com.homer.apollographql.apollo.compiler.ir.CodeGenerationContext +import com.homer.apollographql.apollo.compiler.ir.Variable import com.squareup.javapoet.* import java.io.IOException import java.util.* diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/VisitorSpec.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/VisitorSpec.kt similarity index 87% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/VisitorSpec.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/VisitorSpec.kt index 27ab0f875b5..eec75819471 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/VisitorSpec.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/VisitorSpec.kt @@ -1,9 +1,9 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler -import com.apollographql.apollo.compiler.VisitorSpec.DEFAULT_VISITOR_METHOD_NAME -import com.apollographql.apollo.compiler.VisitorSpec.VISITOR_CLASSNAME -import com.apollographql.apollo.compiler.VisitorSpec.VISITOR_METHOD_NAME -import com.apollographql.apollo.compiler.VisitorSpec.VISITOR_TYPE_VARIABLE +import com.homer.apollographql.apollo.compiler.VisitorSpec.DEFAULT_VISITOR_METHOD_NAME +import com.homer.apollographql.apollo.compiler.VisitorSpec.VISITOR_CLASSNAME +import com.homer.apollographql.apollo.compiler.VisitorSpec.VISITOR_METHOD_NAME +import com.homer.apollographql.apollo.compiler.VisitorSpec.VISITOR_TYPE_VARIABLE import com.squareup.javapoet.* import javax.lang.model.element.Modifier diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/AST.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/AST.kt similarity index 98% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/AST.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/AST.kt index 8ed437b45a6..e3202483418 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/AST.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/AST.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler.ast +package com.homer.apollographql.apollo.compiler.ast internal class CustomTypes(map: Map) : Map by map diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/Context.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/Context.kt similarity index 79% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/Context.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/Context.kt index c3528d46128..b6ded207f3f 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/Context.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/Context.kt @@ -1,15 +1,15 @@ -package com.apollographql.apollo.compiler.ast.builder +package com.homer.apollographql.apollo.compiler.ast.builder -import com.apollographql.apollo.compiler.ast.CustomTypes -import com.apollographql.apollo.compiler.ast.EnumType -import com.apollographql.apollo.compiler.ast.ObjectType -import com.apollographql.apollo.compiler.ast.TypeRef -import com.apollographql.apollo.compiler.escapeKotlinReservedWord -import com.apollographql.apollo.compiler.ir.Field -import com.apollographql.apollo.compiler.ir.Fragment -import com.apollographql.apollo.compiler.ir.FragmentRef -import com.apollographql.apollo.compiler.ir.InlineFragment -import com.apollographql.apollo.compiler.singularize +import com.homer.apollographql.apollo.compiler.ast.CustomTypes +import com.homer.apollographql.apollo.compiler.ast.EnumType +import com.homer.apollographql.apollo.compiler.ast.ObjectType +import com.homer.apollographql.apollo.compiler.ast.TypeRef +import com.homer.apollographql.apollo.compiler.escapeKotlinReservedWord +import com.homer.apollographql.apollo.compiler.ir.Field +import com.homer.apollographql.apollo.compiler.ir.Fragment +import com.homer.apollographql.apollo.compiler.ir.FragmentRef +import com.homer.apollographql.apollo.compiler.ir.InlineFragment +import com.homer.apollographql.apollo.compiler.singularize internal class Context( val customTypeMap: CustomTypes, diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/EnumTypeBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/EnumTypeBuilder.kt similarity index 61% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/EnumTypeBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/EnumTypeBuilder.kt index 8f62dc5545e..6508e81ce02 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/EnumTypeBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/EnumTypeBuilder.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.compiler.ast.builder +package com.homer.apollographql.apollo.compiler.ast.builder -import com.apollographql.apollo.compiler.ast.EnumType -import com.apollographql.apollo.compiler.escapeKotlinReservedWord -import com.apollographql.apollo.compiler.ir.TypeDeclaration +import com.homer.apollographql.apollo.compiler.ast.EnumType +import com.homer.apollographql.apollo.compiler.escapeKotlinReservedWord +import com.homer.apollographql.apollo.compiler.ir.TypeDeclaration internal fun TypeDeclaration.ast() = EnumType( name = name.capitalize().escapeKotlinReservedWord(), diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/FragmentTypeBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/FragmentTypeBuilder.kt similarity index 86% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/FragmentTypeBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/FragmentTypeBuilder.kt index 4e1791b4356..c56e2055ed8 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/FragmentTypeBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/FragmentTypeBuilder.kt @@ -1,13 +1,13 @@ -package com.apollographql.apollo.compiler.ast.builder +package com.homer.apollographql.apollo.compiler.ast.builder -import com.apollographql.apollo.compiler.ast.FieldType -import com.apollographql.apollo.compiler.ast.FragmentType -import com.apollographql.apollo.compiler.ast.ObjectType -import com.apollographql.apollo.compiler.ast.TypeRef -import com.apollographql.apollo.compiler.escapeKotlinReservedWord -import com.apollographql.apollo.compiler.ir.Condition -import com.apollographql.apollo.compiler.ir.Fragment -import com.apollographql.apollo.compiler.ir.FragmentRef +import com.homer.apollographql.apollo.compiler.ast.FieldType +import com.homer.apollographql.apollo.compiler.ast.FragmentType +import com.homer.apollographql.apollo.compiler.ast.ObjectType +import com.homer.apollographql.apollo.compiler.ast.TypeRef +import com.homer.apollographql.apollo.compiler.escapeKotlinReservedWord +import com.homer.apollographql.apollo.compiler.ir.Condition +import com.homer.apollographql.apollo.compiler.ir.Fragment +import com.homer.apollographql.apollo.compiler.ir.FragmentRef internal fun Fragment.ast(context: Context): FragmentType { val typeRef = context.registerObjectType( diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/InlineFragmentTypeBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/InlineFragmentTypeBuilder.kt similarity index 78% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/InlineFragmentTypeBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/InlineFragmentTypeBuilder.kt index 31d2d77f2ba..e41619f8ca1 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/InlineFragmentTypeBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/InlineFragmentTypeBuilder.kt @@ -1,12 +1,12 @@ -package com.apollographql.apollo.compiler.ast.builder +package com.homer.apollographql.apollo.compiler.ast.builder -import com.apollographql.apollo.compiler.ast.FieldType -import com.apollographql.apollo.compiler.ast.ObjectType -import com.apollographql.apollo.compiler.ast.TypeRef -import com.apollographql.apollo.compiler.escapeKotlinReservedWord -import com.apollographql.apollo.compiler.ir.Condition -import com.apollographql.apollo.compiler.ir.InlineFragment -import com.apollographql.apollo.compiler.singularize +import com.homer.apollographql.apollo.compiler.ast.FieldType +import com.homer.apollographql.apollo.compiler.ast.ObjectType +import com.homer.apollographql.apollo.compiler.ast.TypeRef +import com.homer.apollographql.apollo.compiler.escapeKotlinReservedWord +import com.homer.apollographql.apollo.compiler.ir.Condition +import com.homer.apollographql.apollo.compiler.ir.InlineFragment +import com.homer.apollographql.apollo.compiler.singularize internal fun Context.registerInlineFragmentSuper(type: String, schemaType: String): TypeRef { val superInterfaceName = type.replace("[", "").replace("]", "").replace("!", "").singularize().capitalize() + diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/InputTypeBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/InputTypeBuilder.kt similarity index 72% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/InputTypeBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/InputTypeBuilder.kt index 2a9683f336c..043d2f50cd3 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/InputTypeBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/InputTypeBuilder.kt @@ -1,10 +1,10 @@ -package com.apollographql.apollo.compiler.ast.builder +package com.homer.apollographql.apollo.compiler.ast.builder -import com.apollographql.apollo.compiler.ast.EnumType -import com.apollographql.apollo.compiler.ast.FieldType -import com.apollographql.apollo.compiler.ast.InputType -import com.apollographql.apollo.compiler.escapeKotlinReservedWord -import com.apollographql.apollo.compiler.ir.TypeDeclaration +import com.homer.apollographql.apollo.compiler.ast.EnumType +import com.homer.apollographql.apollo.compiler.ast.FieldType +import com.homer.apollographql.apollo.compiler.ast.InputType +import com.homer.apollographql.apollo.compiler.escapeKotlinReservedWord +import com.homer.apollographql.apollo.compiler.ir.TypeDeclaration internal fun TypeDeclaration.ast( enums: List, diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/ObjectFieldBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/ObjectFieldBuilder.kt similarity index 91% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/ObjectFieldBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/ObjectFieldBuilder.kt index 58b5faacde1..c7894516f94 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/ObjectFieldBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/ObjectFieldBuilder.kt @@ -1,10 +1,10 @@ -package com.apollographql.apollo.compiler.ast.builder +package com.homer.apollographql.apollo.compiler.ast.builder -import com.apollographql.apollo.compiler.ast.FieldType -import com.apollographql.apollo.compiler.ast.ObjectType -import com.apollographql.apollo.compiler.escapeKotlinReservedWord -import com.apollographql.apollo.compiler.ir.Condition -import com.apollographql.apollo.compiler.ir.Field +import com.homer.apollographql.apollo.compiler.ast.FieldType +import com.homer.apollographql.apollo.compiler.ast.ObjectType +import com.homer.apollographql.apollo.compiler.escapeKotlinReservedWord +import com.homer.apollographql.apollo.compiler.ir.Condition +import com.homer.apollographql.apollo.compiler.ir.Field internal fun Field.ast(context: Context): ObjectType.Field { return when { diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/OperationTypeBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/OperationTypeBuilder.kt similarity index 73% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/OperationTypeBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/OperationTypeBuilder.kt index df6c9e1d3bb..83299a987e9 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/OperationTypeBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/OperationTypeBuilder.kt @@ -1,14 +1,14 @@ -package com.apollographql.apollo.compiler.ast.builder +package com.homer.apollographql.apollo.compiler.ast.builder -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.compiler.OperationIdGenerator -import com.apollographql.apollo.compiler.ast.InputType -import com.apollographql.apollo.compiler.ast.ObjectType -import com.apollographql.apollo.compiler.ast.OperationType -import com.apollographql.apollo.compiler.escapeKotlinReservedWord -import com.apollographql.apollo.compiler.ir.Operation -import com.apollographql.apollo.compiler.operationoutput.OperationOutput -import com.apollographql.apollo.compiler.operationoutput.findOperationId +import com.homer.apollographql.apollo.api.internal.QueryDocumentMinifier +import com.homer.apollographql.apollo.compiler.OperationIdGenerator +import com.homer.apollographql.apollo.compiler.ast.InputType +import com.homer.apollographql.apollo.compiler.ast.ObjectType +import com.homer.apollographql.apollo.compiler.ast.OperationType +import com.homer.apollographql.apollo.compiler.escapeKotlinReservedWord +import com.homer.apollographql.apollo.compiler.ir.Operation +import com.homer.apollographql.apollo.compiler.operationoutput.OperationOutput +import com.homer.apollographql.apollo.compiler.operationoutput.findOperationId internal fun Operation.ast( operationClassName: String, diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/SchemaBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/SchemaBuilder.kt similarity index 84% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/SchemaBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/SchemaBuilder.kt index 87a896f9f39..9babc3b6025 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ast/builder/SchemaBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ast/builder/SchemaBuilder.kt @@ -1,15 +1,15 @@ -package com.apollographql.apollo.compiler.ast.builder +package com.homer.apollographql.apollo.compiler.ast.builder -import com.apollographql.apollo.compiler.ast.CustomTypes -import com.apollographql.apollo.compiler.ast.EnumType -import com.apollographql.apollo.compiler.ast.FieldType -import com.apollographql.apollo.compiler.ast.Schema -import com.apollographql.apollo.compiler.ast.TypeRef -import com.apollographql.apollo.compiler.escapeKotlinReservedWord -import com.apollographql.apollo.compiler.ir.CodeGenerationIR -import com.apollographql.apollo.compiler.ir.ScalarType -import com.apollographql.apollo.compiler.ir.TypeDeclaration -import com.apollographql.apollo.compiler.operationoutput.OperationOutput +import com.homer.apollographql.apollo.compiler.ast.CustomTypes +import com.homer.apollographql.apollo.compiler.ast.EnumType +import com.homer.apollographql.apollo.compiler.ast.FieldType +import com.homer.apollographql.apollo.compiler.ast.Schema +import com.homer.apollographql.apollo.compiler.ast.TypeRef +import com.homer.apollographql.apollo.compiler.escapeKotlinReservedWord +import com.homer.apollographql.apollo.compiler.ir.CodeGenerationIR +import com.homer.apollographql.apollo.compiler.ir.ScalarType +import com.homer.apollographql.apollo.compiler.ir.TypeDeclaration +import com.homer.apollographql.apollo.compiler.operationoutput.OperationOutput internal fun CodeGenerationIR.ast( customTypeMap: CustomTypes, diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/CustomType.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/CustomType.kt similarity index 79% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/CustomType.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/CustomType.kt index 603df2793bd..dedbcbb3525 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/CustomType.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/CustomType.kt @@ -1,9 +1,9 @@ -package com.apollographql.apollo.compiler.codegen.kotlin +package com.homer.apollographql.apollo.compiler.codegen.kotlin -import com.apollographql.apollo.api.ScalarType -import com.apollographql.apollo.compiler.applyIf -import com.apollographql.apollo.compiler.ast.CustomTypes -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.normalizeGraphQLType +import com.homer.apollographql.apollo.api.ScalarType +import com.homer.apollographql.apollo.compiler.applyIf +import com.homer.apollographql.apollo.compiler.ast.CustomTypes +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.normalizeGraphQLType import com.squareup.kotlinpoet.* import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/EnumType.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/EnumType.kt similarity index 95% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/EnumType.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/EnumType.kt index 4a504c5c7e1..23e750501e3 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/EnumType.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/EnumType.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.compiler.codegen.kotlin +package com.homer.apollographql.apollo.compiler.codegen.kotlin -import com.apollographql.apollo.api.EnumValue -import com.apollographql.apollo.compiler.applyIf -import com.apollographql.apollo.compiler.ast.EnumType +import com.homer.apollographql.apollo.api.EnumValue +import com.homer.apollographql.apollo.compiler.applyIf +import com.homer.apollographql.apollo.compiler.ast.EnumType import com.squareup.kotlinpoet.* internal fun EnumType.typeSpec( diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/GraphQLKompiler.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/GraphQLKompiler.kt similarity index 72% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/GraphQLKompiler.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/GraphQLKompiler.kt index 3f203f95cd4..0bd461c0580 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/GraphQLKompiler.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/GraphQLKompiler.kt @@ -1,10 +1,10 @@ -package com.apollographql.apollo.compiler.codegen.kotlin +package com.homer.apollographql.apollo.compiler.codegen.kotlin -import com.apollographql.apollo.compiler.ast.CustomTypes -import com.apollographql.apollo.compiler.ast.builder.ast -import com.apollographql.apollo.compiler.ir.CodeGenerationIR -import com.apollographql.apollo.compiler.ir.TypeDeclaration -import com.apollographql.apollo.compiler.operationoutput.OperationOutput +import com.homer.apollographql.apollo.compiler.ast.CustomTypes +import com.homer.apollographql.apollo.compiler.ast.builder.ast +import com.homer.apollographql.apollo.compiler.ir.CodeGenerationIR +import com.homer.apollographql.apollo.compiler.ir.TypeDeclaration +import com.homer.apollographql.apollo.compiler.operationoutput.OperationOutput import com.squareup.kotlinpoet.asClassName import java.io.File diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/InputType.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/InputType.kt similarity index 90% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/InputType.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/InputType.kt index b2e8ade4b15..1a92c9280ff 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/InputType.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/InputType.kt @@ -1,15 +1,15 @@ -package com.apollographql.apollo.compiler.codegen.kotlin +package com.homer.apollographql.apollo.compiler.codegen.kotlin -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.InputFieldWriter -import com.apollographql.apollo.compiler.applyIf -import com.apollographql.apollo.compiler.ast.FieldType -import com.apollographql.apollo.compiler.ast.InputType -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.asPropertySpec -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.asTypeName -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.suppressWarningsAnnotation -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.toDefaultValueCodeBlock +import com.homer.apollographql.apollo.api.Input +import com.homer.apollographql.apollo.api.internal.InputFieldMarshaller +import com.homer.apollographql.apollo.api.internal.InputFieldWriter +import com.homer.apollographql.apollo.compiler.applyIf +import com.homer.apollographql.apollo.compiler.ast.FieldType +import com.homer.apollographql.apollo.compiler.ast.InputType +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.asPropertySpec +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.asTypeName +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.suppressWarningsAnnotation +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.toDefaultValueCodeBlock import com.squareup.kotlinpoet.* import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy @@ -20,7 +20,7 @@ internal fun InputType.typeSpec(generateAsInternal: Boolean = false) = .applyIf(generateAsInternal) { addModifiers(KModifier.INTERNAL) } .addAnnotation(suppressWarningsAnnotation) .addModifiers(KModifier.DATA) - .addSuperinterface(com.apollographql.apollo.api.InputType::class) + .addSuperinterface(com.homer.apollographql.apollo.api.InputType::class) .primaryConstructor(primaryConstructorSpec) .addProperties(fields.map { field -> field.asPropertySpec(initializer = CodeBlock.of(field.name)) }) .addFunction(marshallerFunSpec) diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/KotlinCodeGen.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/KotlinCodeGen.kt similarity index 96% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/KotlinCodeGen.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/KotlinCodeGen.kt index 4ac52d6efa6..a5c846ec2c3 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/KotlinCodeGen.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/KotlinCodeGen.kt @@ -1,15 +1,15 @@ -package com.apollographql.apollo.compiler.codegen.kotlin +package com.homer.apollographql.apollo.compiler.codegen.kotlin -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.compiler.applyIf -import com.apollographql.apollo.compiler.ast.FieldType -import com.apollographql.apollo.compiler.ast.InputType -import com.apollographql.apollo.compiler.ast.ObjectType -import com.apollographql.apollo.compiler.ast.TypeRef +import com.homer.apollographql.apollo.api.Input +import com.homer.apollographql.apollo.api.ResponseField +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper +import com.homer.apollographql.apollo.api.internal.ResponseFieldMarshaller +import com.homer.apollographql.apollo.api.internal.ResponseReader +import com.homer.apollographql.apollo.compiler.applyIf +import com.homer.apollographql.apollo.compiler.ast.FieldType +import com.homer.apollographql.apollo.compiler.ast.InputType +import com.homer.apollographql.apollo.compiler.ast.ObjectType +import com.homer.apollographql.apollo.compiler.ast.TypeRef import com.squareup.kotlinpoet.AnnotationSpec import com.squareup.kotlinpoet.BOOLEAN import com.squareup.kotlinpoet.ClassName diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/KotlinCodeGenUtil.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/KotlinCodeGenUtil.kt similarity index 79% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/KotlinCodeGenUtil.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/KotlinCodeGenUtil.kt index bb102d83a78..c95f9ee4a00 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/KotlinCodeGenUtil.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/KotlinCodeGenUtil.kt @@ -1,10 +1,10 @@ -package com.apollographql.apollo.compiler.codegen.kotlin +package com.homer.apollographql.apollo.compiler.codegen.kotlin import com.squareup.kotlinpoet.AnnotationSpec import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.FunSpec -private val MULTIPLATFORM_THROWS = ClassName("com.apollographql.apollo.api.internal", "Throws") +private val MULTIPLATFORM_THROWS = ClassName("com.homer.apollographql.apollo.api.internal", "Throws") private val MULTIPLATFORM_IO_EXCEPTION = ClassName("okio", "IOException") fun FunSpec.Builder.throwsMultiplatformIOException() = throws(MULTIPLATFORM_IO_EXCEPTION) diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/ObjectType.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/ObjectType.kt similarity index 83% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/ObjectType.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/ObjectType.kt index d87627c8d0f..336897df5c9 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/ObjectType.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/ObjectType.kt @@ -1,17 +1,17 @@ -package com.apollographql.apollo.compiler.codegen.kotlin +package com.homer.apollographql.apollo.compiler.codegen.kotlin -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.compiler.applyIf -import com.apollographql.apollo.compiler.ast.FieldType -import com.apollographql.apollo.compiler.ast.ObjectType -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.asPropertySpec -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.asTypeName -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.createMapperFun -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.marshallerFunSpec -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.responseFieldsPropertySpec -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.toMapperFun -import com.apollographql.apollo.compiler.ir.Field +import com.homer.apollographql.apollo.api.GraphqlFragment +import com.homer.apollographql.apollo.api.internal.ResponseFieldMarshaller +import com.homer.apollographql.apollo.compiler.applyIf +import com.homer.apollographql.apollo.compiler.ast.FieldType +import com.homer.apollographql.apollo.compiler.ast.ObjectType +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.asPropertySpec +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.asTypeName +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.createMapperFun +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.marshallerFunSpec +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.responseFieldsPropertySpec +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.toMapperFun +import com.homer.apollographql.apollo.compiler.ir.Field import com.squareup.kotlinpoet.* internal fun ObjectType.typeSpec(generateAsInternal: Boolean = false): TypeSpec = when (kind) { diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/OperationType.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/OperationType.kt similarity index 87% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/OperationType.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/OperationType.kt index 58cb28ecd1f..a0a3ddbbb8e 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/OperationType.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/OperationType.kt @@ -1,30 +1,30 @@ -package com.apollographql.apollo.compiler.codegen.kotlin +package com.homer.apollographql.apollo.compiler.codegen.kotlin -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.Mutation -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.Subscription -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.compiler.applyIf -import com.apollographql.apollo.compiler.ast.InputType -import com.apollographql.apollo.compiler.ast.ObjectType -import com.apollographql.apollo.compiler.ast.OperationType -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.asPropertySpec -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.asTypeName -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.createMapperFun -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.marshallerFunSpec -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.responseFieldsPropertySpec -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.suppressWarningsAnnotation -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.toDefaultValueCodeBlock -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.toMapperFun +import com.homer.apollographql.apollo.api.Input +import com.homer.apollographql.apollo.api.Mutation +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.OperationName +import com.homer.apollographql.apollo.api.Query +import com.homer.apollographql.apollo.api.Response +import com.homer.apollographql.apollo.api.ScalarTypeAdapters +import com.homer.apollographql.apollo.api.Subscription +import com.homer.apollographql.apollo.api.internal.InputFieldMarshaller +import com.homer.apollographql.apollo.api.internal.OperationRequestBodyComposer +import com.homer.apollographql.apollo.api.internal.QueryDocumentMinifier +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper +import com.homer.apollographql.apollo.api.internal.SimpleOperationResponseParser +import com.homer.apollographql.apollo.compiler.applyIf +import com.homer.apollographql.apollo.compiler.ast.InputType +import com.homer.apollographql.apollo.compiler.ast.ObjectType +import com.homer.apollographql.apollo.compiler.ast.OperationType +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.asPropertySpec +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.asTypeName +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.createMapperFun +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.marshallerFunSpec +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.responseFieldsPropertySpec +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.suppressWarningsAnnotation +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.toDefaultValueCodeBlock +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.toMapperFun import com.squareup.kotlinpoet.ClassName import com.squareup.kotlinpoet.CodeBlock import com.squareup.kotlinpoet.FunSpec diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/SchemaCodegen.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/SchemaCodegen.kt similarity index 76% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/SchemaCodegen.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/SchemaCodegen.kt index 4257d2f04de..6d089ddf6aa 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/codegen/kotlin/SchemaCodegen.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/codegen/kotlin/SchemaCodegen.kt @@ -1,13 +1,13 @@ -package com.apollographql.apollo.compiler.codegen.kotlin +package com.homer.apollographql.apollo.compiler.codegen.kotlin -import com.apollographql.apollo.compiler.ast.CustomTypes -import com.apollographql.apollo.compiler.ast.EnumType -import com.apollographql.apollo.compiler.ast.FragmentType -import com.apollographql.apollo.compiler.ast.InputType -import com.apollographql.apollo.compiler.ast.ObjectType -import com.apollographql.apollo.compiler.ast.OperationType -import com.apollographql.apollo.compiler.ast.SchemaVisitor -import com.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.patchKotlinNativeOptionalArrayProperties +import com.homer.apollographql.apollo.compiler.ast.CustomTypes +import com.homer.apollographql.apollo.compiler.ast.EnumType +import com.homer.apollographql.apollo.compiler.ast.FragmentType +import com.homer.apollographql.apollo.compiler.ast.InputType +import com.homer.apollographql.apollo.compiler.ast.ObjectType +import com.homer.apollographql.apollo.compiler.ast.OperationType +import com.homer.apollographql.apollo.compiler.ast.SchemaVisitor +import com.homer.apollographql.apollo.compiler.codegen.kotlin.KotlinCodeGen.patchKotlinNativeOptionalArrayProperties import com.squareup.kotlinpoet.FileSpec import com.squareup.kotlinpoet.TypeSpec import java.io.File @@ -66,7 +66,7 @@ internal class SchemaCodegen( FileSpec .builder(packageName, name!!) .addType(this) - .addComment("AUTO-GENERATED FILE. DO NOT MODIFY.\n\n" + + .addFileComment("AUTO-GENERATED FILE. DO NOT MODIFY.\n\n" + "This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found.\n" + "It should not be modified by hand.\n" ) diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Argument.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Argument.kt similarity index 95% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Argument.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Argument.kt index 40be153940d..ae712dc7749 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Argument.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Argument.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir import com.squareup.moshi.JsonClass diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/CodeGenerationContext.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/CodeGenerationContext.kt similarity index 72% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/CodeGenerationContext.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/CodeGenerationContext.kt index efeef96eca7..a48d9700dbd 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/CodeGenerationContext.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/CodeGenerationContext.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir -import com.apollographql.apollo.compiler.NullableValueType -import com.apollographql.apollo.compiler.operationoutput.OperationOutput +import com.homer.apollographql.apollo.compiler.NullableValueType +import com.homer.apollographql.apollo.compiler.operationoutput.OperationOutput data class CodeGenerationContext( var reservedTypeNames: List, diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/CodeGenerationIR.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/CodeGenerationIR.kt similarity index 94% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/CodeGenerationIR.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/CodeGenerationIR.kt index df3fcb97291..86b0bc045e3 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/CodeGenerationIR.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/CodeGenerationIR.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir data class CodeGenerationIR( /** diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/CodeGenerator.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/CodeGenerator.kt similarity index 75% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/CodeGenerator.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/CodeGenerator.kt index 4371a65821f..3d121053039 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/CodeGenerator.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/CodeGenerator.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir import com.squareup.javapoet.TypeSpec diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Condition.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Condition.kt similarity index 85% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Condition.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Condition.kt index 24c7c7e8ecd..56866f2a13e 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Condition.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Condition.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir import com.squareup.moshi.JsonClass diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Field.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Field.kt similarity index 92% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Field.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Field.kt index 70ab681401f..6006f82e180 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Field.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Field.kt @@ -1,12 +1,12 @@ -package com.apollographql.apollo.compiler.ir - -import com.apollographql.apollo.compiler.ClassNames -import com.apollographql.apollo.compiler.JavaTypeResolver -import com.apollographql.apollo.compiler.SchemaTypeSpecBuilder -import com.apollographql.apollo.compiler.escapeJavaReservedWord -import com.apollographql.apollo.compiler.singularize -import com.apollographql.apollo.compiler.toJavaBeansSemanticNaming -import com.apollographql.apollo.compiler.withBuilder +package com.homer.apollographql.apollo.compiler.ir + +import com.homer.apollographql.apollo.compiler.ClassNames +import com.homer.apollographql.apollo.compiler.JavaTypeResolver +import com.homer.apollographql.apollo.compiler.SchemaTypeSpecBuilder +import com.homer.apollographql.apollo.compiler.escapeJavaReservedWord +import com.homer.apollographql.apollo.compiler.singularize +import com.homer.apollographql.apollo.compiler.toJavaBeansSemanticNaming +import com.homer.apollographql.apollo.compiler.withBuilder import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.FieldSpec import com.squareup.javapoet.MethodSpec diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Fragment.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Fragment.kt similarity index 83% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Fragment.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Fragment.kt index d33f6a5700a..d3e43cc93b7 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Fragment.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Fragment.kt @@ -1,11 +1,11 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir -import com.apollographql.apollo.compiler.ClassNames -import com.apollographql.apollo.compiler.SchemaTypeSpecBuilder -import com.apollographql.apollo.compiler.Util -import com.apollographql.apollo.compiler.VisitorSpec.VISITOR_CLASSNAME -import com.apollographql.apollo.compiler.flatten -import com.apollographql.apollo.compiler.withBuilder +import com.homer.apollographql.apollo.compiler.ClassNames +import com.homer.apollographql.apollo.compiler.SchemaTypeSpecBuilder +import com.homer.apollographql.apollo.compiler.Util +import com.homer.apollographql.apollo.compiler.VisitorSpec.VISITOR_CLASSNAME +import com.homer.apollographql.apollo.compiler.flatten +import com.homer.apollographql.apollo.compiler.withBuilder import com.squareup.javapoet.ClassName import com.squareup.javapoet.FieldSpec import com.squareup.javapoet.TypeSpec diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/FragmentRef.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/FragmentRef.kt similarity index 89% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/FragmentRef.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/FragmentRef.kt index 63f7a855d1f..09cf961deae 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/FragmentRef.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/FragmentRef.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir import com.squareup.moshi.JsonClass diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/IRBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/IRBuilder.kt similarity index 90% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/IRBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/IRBuilder.kt index 1fe3e0adabd..03684b8587e 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/IRBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/IRBuilder.kt @@ -1,20 +1,20 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir -import com.apollographql.apollo.compiler.ApolloMetadata -import com.apollographql.apollo.compiler.applyIf -import com.apollographql.apollo.compiler.ir.TypeDeclaration.Companion.KIND_ENUM -import com.apollographql.apollo.compiler.ir.TypeDeclaration.Companion.KIND_INPUT_OBJECT_TYPE -import com.apollographql.apollo.compiler.ir.TypeDeclaration.Companion.KIND_SCALAR_TYPE -import com.apollographql.apollo.compiler.parser.error.DocumentParseException -import com.apollographql.apollo.compiler.parser.error.ParseException -import com.apollographql.apollo.compiler.parser.graphql.DocumentParseResult -import com.apollographql.apollo.compiler.parser.graphql.checkMultipleFragmentDefinitions -import com.apollographql.apollo.compiler.parser.graphql.checkMultipleOperationDefinitions -import com.apollographql.apollo.compiler.parser.graphql.validateArguments -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema -import com.apollographql.apollo.compiler.parser.introspection.asGraphQLType -import com.apollographql.apollo.compiler.parser.introspection.possibleTypes -import com.apollographql.apollo.compiler.parser.introspection.rootTypeForOperationType +import com.homer.apollographql.apollo.compiler.ApolloMetadata +import com.homer.apollographql.apollo.compiler.applyIf +import com.homer.apollographql.apollo.compiler.ir.TypeDeclaration.Companion.KIND_ENUM +import com.homer.apollographql.apollo.compiler.ir.TypeDeclaration.Companion.KIND_INPUT_OBJECT_TYPE +import com.homer.apollographql.apollo.compiler.ir.TypeDeclaration.Companion.KIND_SCALAR_TYPE +import com.homer.apollographql.apollo.compiler.parser.error.DocumentParseException +import com.homer.apollographql.apollo.compiler.parser.error.ParseException +import com.homer.apollographql.apollo.compiler.parser.graphql.DocumentParseResult +import com.homer.apollographql.apollo.compiler.parser.graphql.checkMultipleFragmentDefinitions +import com.homer.apollographql.apollo.compiler.parser.graphql.checkMultipleOperationDefinitions +import com.homer.apollographql.apollo.compiler.parser.graphql.validateArguments +import com.homer.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema +import com.homer.apollographql.apollo.compiler.parser.introspection.asGraphQLType +import com.homer.apollographql.apollo.compiler.parser.introspection.possibleTypes +import com.homer.apollographql.apollo.compiler.parser.introspection.rootTypeForOperationType class IRBuilder(private val schema: IntrospectionSchema, private val schemaPackageName: String, diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/InlineFragment.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/InlineFragment.kt similarity index 87% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/InlineFragment.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/InlineFragment.kt index b8c310250ba..4cd01892721 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/InlineFragment.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/InlineFragment.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir -import com.apollographql.apollo.compiler.JavaTypeResolver -import com.apollographql.apollo.compiler.SchemaTypeSpecBuilder -import com.apollographql.apollo.compiler.withBuilder +import com.homer.apollographql.apollo.compiler.JavaTypeResolver +import com.homer.apollographql.apollo.compiler.SchemaTypeSpecBuilder +import com.homer.apollographql.apollo.compiler.withBuilder import com.squareup.javapoet.FieldSpec import com.squareup.javapoet.TypeSpec import com.squareup.moshi.JsonClass diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Operation.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Operation.kt similarity index 90% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Operation.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Operation.kt index c310c763480..4c32bf1e47c 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Operation.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Operation.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.compiler.withBuilder -import com.apollographql.apollo.compiler.SchemaTypeSpecBuilder +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.compiler.withBuilder +import com.homer.apollographql.apollo.compiler.SchemaTypeSpecBuilder import com.squareup.javapoet.TypeSpec import javax.lang.model.element.Modifier diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/ScalarType.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/ScalarType.kt similarity index 89% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/ScalarType.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/ScalarType.kt index 743569a7020..2d8f6ca5faa 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/ScalarType.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/ScalarType.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir sealed class ScalarType(val name: String) { object ID : ScalarType("ID") diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/SourceLocation.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/SourceLocation.kt similarity index 84% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/SourceLocation.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/SourceLocation.kt index 57ef2a2e9a6..d7bc086aed1 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/SourceLocation.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/SourceLocation.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir import com.squareup.moshi.JsonClass diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/TypeDeclaration.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/TypeDeclaration.kt similarity index 92% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/TypeDeclaration.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/TypeDeclaration.kt index c90ce2a7581..ac7c5266759 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/TypeDeclaration.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/TypeDeclaration.kt @@ -1,9 +1,9 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir -import com.apollographql.apollo.compiler.Annotations -import com.apollographql.apollo.compiler.ClassNames -import com.apollographql.apollo.compiler.InputTypeSpecBuilder -import com.apollographql.apollo.compiler.escapeJavaReservedWord +import com.homer.apollographql.apollo.compiler.Annotations +import com.homer.apollographql.apollo.compiler.ClassNames +import com.homer.apollographql.apollo.compiler.InputTypeSpecBuilder +import com.homer.apollographql.apollo.compiler.escapeJavaReservedWord import com.squareup.javapoet.ClassName import com.squareup.javapoet.CodeBlock import com.squareup.javapoet.FieldSpec diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/TypeDeclarationField.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/TypeDeclarationField.kt similarity index 73% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/TypeDeclarationField.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/TypeDeclarationField.kt index de7658824f0..db8899aacc0 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/TypeDeclarationField.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/TypeDeclarationField.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir data class TypeDeclarationField( val name: String, diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/TypeDeclarationValue.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/TypeDeclarationValue.kt similarity index 72% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/TypeDeclarationValue.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/TypeDeclarationValue.kt index 52629ea05c0..70dab4af81a 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/TypeDeclarationValue.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/TypeDeclarationValue.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir data class TypeDeclarationValue( val name: String, diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Variable.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Variable.kt similarity index 76% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Variable.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Variable.kt index ac39751315a..e65f3028d3c 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/ir/Variable.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/ir/Variable.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler.ir +package com.homer.apollographql.apollo.compiler.ir data class Variable( val name: String, diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/moshi.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/moshi.kt similarity index 95% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/moshi.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/moshi.kt index fdb617b5817..47d596e2e18 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/moshi.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/moshi.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema +import com.homer.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema import com.squareup.moshi.JsonAdapter import com.squareup.moshi.JsonReader import com.squareup.moshi.JsonWriter diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/operationoutput/OperationOutput.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/operationoutput/OperationOutput.kt similarity index 92% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/operationoutput/OperationOutput.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/operationoutput/OperationOutput.kt index c41820a84df..f70a59dfcd8 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/operationoutput/OperationOutput.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/operationoutput/OperationOutput.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.compiler.operationoutput +package com.homer.apollographql.apollo.compiler.operationoutput -import com.apollographql.apollo.compiler.applyIf +import com.homer.apollographql.apollo.compiler.applyIf import com.squareup.moshi.JsonAdapter import com.squareup.moshi.JsonClass import com.squareup.moshi.Moshi diff --git a/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/SchemaConverter.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/SchemaConverter.kt new file mode 100644 index 00000000000..0b7f0eba911 --- /dev/null +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/SchemaConverter.kt @@ -0,0 +1,13 @@ +package com.homer.apollographql.apollo.compiler.parser + +import com.homer.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema +import com.homer.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema.Companion.wrap +import com.homer.apollographql.apollo.compiler.parser.introspection.toSDL +import com.homer.apollographql.apollo.compiler.parser.sdl.GraphSdlSchema +import com.homer.apollographql.apollo.compiler.parser.sdl.toIntrospectionSchema +import com.homer.apollographql.apollo.compiler.toJson +import java.io.File + +object SchemaConverter { + +} \ No newline at end of file diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/error/DocumentParseException.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/error/DocumentParseException.kt similarity index 94% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/error/DocumentParseException.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/error/DocumentParseException.kt index 9ddb95c2d15..db0b3388ff0 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/error/DocumentParseException.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/error/DocumentParseException.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.compiler.parser.error +package com.homer.apollographql.apollo.compiler.parser.error -import com.apollographql.apollo.compiler.ir.SourceLocation +import com.homer.apollographql.apollo.compiler.ir.SourceLocation import org.antlr.v4.runtime.Token import java.io.File import java.io.IOException diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/error/ParseException.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/error/ParseException.kt similarity index 80% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/error/ParseException.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/error/ParseException.kt index 7a4d5acc2c2..821e9ee78a0 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/error/ParseException.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/error/ParseException.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.compiler.parser.error +package com.homer.apollographql.apollo.compiler.parser.error -import com.apollographql.apollo.compiler.ir.SourceLocation +import com.homer.apollographql.apollo.compiler.ir.SourceLocation import org.antlr.v4.runtime.Token internal class ParseException(message: String, val sourceLocation: SourceLocation) : RuntimeException(message) { diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/graphql/FieldMerger.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/graphql/FieldMerger.kt similarity index 89% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/graphql/FieldMerger.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/graphql/FieldMerger.kt index a250863e975..987d7cde594 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/graphql/FieldMerger.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/graphql/FieldMerger.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.compiler.parser.graphql +package com.homer.apollographql.apollo.compiler.parser.graphql -import com.apollographql.apollo.compiler.ir.Field -import com.apollographql.apollo.compiler.ir.InlineFragment -import com.apollographql.apollo.compiler.parser.error.ParseException +import com.homer.apollographql.apollo.compiler.ir.Field +import com.homer.apollographql.apollo.compiler.ir.InlineFragment +import com.homer.apollographql.apollo.compiler.parser.error.ParseException internal fun List.mergeFields(others: List): List { val (missing, conflicted) = others.partition { otherField -> diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/graphql/GraphQLDocumentParser.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/graphql/GraphQLDocumentParser.kt similarity index 94% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/graphql/GraphQLDocumentParser.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/graphql/GraphQLDocumentParser.kt index d83a095c083..ab9737762b1 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/graphql/GraphQLDocumentParser.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/graphql/GraphQLDocumentParser.kt @@ -1,26 +1,26 @@ -package com.apollographql.apollo.compiler.parser.graphql - -import com.apollographql.apollo.compiler.PackageNameProvider -import com.apollographql.apollo.compiler.ir.Argument -import com.apollographql.apollo.compiler.ir.Condition -import com.apollographql.apollo.compiler.ir.Field -import com.apollographql.apollo.compiler.ir.Fragment -import com.apollographql.apollo.compiler.ir.FragmentRef -import com.apollographql.apollo.compiler.ir.InlineFragment -import com.apollographql.apollo.compiler.ir.Operation -import com.apollographql.apollo.compiler.ir.ScalarType -import com.apollographql.apollo.compiler.ir.SourceLocation -import com.apollographql.apollo.compiler.ir.Variable -import com.apollographql.apollo.compiler.parser.antlr.GraphQLLexer -import com.apollographql.apollo.compiler.parser.antlr.GraphQLParser -import com.apollographql.apollo.compiler.parser.error.DocumentParseException -import com.apollographql.apollo.compiler.parser.error.ParseException -import com.apollographql.apollo.compiler.parser.graphql.GraphQLDocumentSourceBuilder.graphQLDocumentSource -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema -import com.apollographql.apollo.compiler.parser.introspection.asGraphQLType -import com.apollographql.apollo.compiler.parser.introspection.isAssignableFrom -import com.apollographql.apollo.compiler.parser.introspection.possibleTypes -import com.apollographql.apollo.compiler.parser.introspection.resolveType +package com.homer.apollographql.apollo.compiler.parser.graphql + +import com.homer.apollographql.apollo.compiler.PackageNameProvider +import com.homer.apollographql.apollo.compiler.ir.Argument +import com.homer.apollographql.apollo.compiler.ir.Condition +import com.homer.apollographql.apollo.compiler.ir.Field +import com.homer.apollographql.apollo.compiler.ir.Fragment +import com.homer.apollographql.apollo.compiler.ir.FragmentRef +import com.homer.apollographql.apollo.compiler.ir.InlineFragment +import com.homer.apollographql.apollo.compiler.ir.Operation +import com.homer.apollographql.apollo.compiler.ir.ScalarType +import com.homer.apollographql.apollo.compiler.ir.SourceLocation +import com.homer.apollographql.apollo.compiler.ir.Variable +import com.homer.apollographql.apollo.compiler.parser.antlr.GraphQLLexer +import com.homer.apollographql.apollo.compiler.parser.antlr.GraphQLParser +import com.homer.apollographql.apollo.compiler.parser.error.DocumentParseException +import com.homer.apollographql.apollo.compiler.parser.error.ParseException +import com.homer.apollographql.apollo.compiler.parser.graphql.GraphQLDocumentSourceBuilder.graphQLDocumentSource +import com.homer.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema +import com.homer.apollographql.apollo.compiler.parser.introspection.asGraphQLType +import com.homer.apollographql.apollo.compiler.parser.introspection.isAssignableFrom +import com.homer.apollographql.apollo.compiler.parser.introspection.possibleTypes +import com.homer.apollographql.apollo.compiler.parser.introspection.resolveType import org.antlr.v4.runtime.ANTLRInputStream import org.antlr.v4.runtime.BaseErrorListener import org.antlr.v4.runtime.CommonTokenStream diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/graphql/GraphQLDocumentSourceBuilder.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/graphql/GraphQLDocumentSourceBuilder.kt similarity index 96% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/graphql/GraphQLDocumentSourceBuilder.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/graphql/GraphQLDocumentSourceBuilder.kt index d2245e8b158..55998da8ec0 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/graphql/GraphQLDocumentSourceBuilder.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/graphql/GraphQLDocumentSourceBuilder.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.compiler.parser.graphql +package com.homer.apollographql.apollo.compiler.parser.graphql -import com.apollographql.apollo.compiler.parser.antlr.GraphQLParser +import com.homer.apollographql.apollo.compiler.parser.antlr.GraphQLParser import org.antlr.v4.runtime.ParserRuleContext import org.antlr.v4.runtime.misc.Interval diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/graphql/Validation.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/graphql/Validation.kt similarity index 89% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/graphql/Validation.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/graphql/Validation.kt index 8d31ec43986..d2895058423 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/graphql/Validation.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/graphql/Validation.kt @@ -1,17 +1,17 @@ -package com.apollographql.apollo.compiler.parser.graphql - -import com.apollographql.apollo.compiler.PackageNameProvider -import com.apollographql.apollo.compiler.ir.Field -import com.apollographql.apollo.compiler.ir.Fragment -import com.apollographql.apollo.compiler.ir.Operation -import com.apollographql.apollo.compiler.ir.ScalarType -import com.apollographql.apollo.compiler.ir.SourceLocation -import com.apollographql.apollo.compiler.parser.error.DocumentParseException -import com.apollographql.apollo.compiler.parser.error.ParseException -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema -import com.apollographql.apollo.compiler.parser.introspection.asGraphQLType -import com.apollographql.apollo.compiler.parser.introspection.isAssignableFrom -import com.apollographql.apollo.compiler.parser.introspection.resolveType +package com.homer.apollographql.apollo.compiler.parser.graphql + +import com.homer.apollographql.apollo.compiler.PackageNameProvider +import com.homer.apollographql.apollo.compiler.ir.Field +import com.homer.apollographql.apollo.compiler.ir.Fragment +import com.homer.apollographql.apollo.compiler.ir.Operation +import com.homer.apollographql.apollo.compiler.ir.ScalarType +import com.homer.apollographql.apollo.compiler.ir.SourceLocation +import com.homer.apollographql.apollo.compiler.parser.error.DocumentParseException +import com.homer.apollographql.apollo.compiler.parser.error.ParseException +import com.homer.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema +import com.homer.apollographql.apollo.compiler.parser.introspection.asGraphQLType +import com.homer.apollographql.apollo.compiler.parser.introspection.isAssignableFrom +import com.homer.apollographql.apollo.compiler.parser.introspection.resolveType internal fun List.checkMultipleOperationDefinitions() { groupBy { it.packageName + it.operationName } diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/introspection/IntrospectionSchema.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/introspection/IntrospectionSchema.kt similarity index 98% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/introspection/IntrospectionSchema.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/introspection/IntrospectionSchema.kt index 40e6a7622d8..4924567586e 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/introspection/IntrospectionSchema.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/introspection/IntrospectionSchema.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.compiler.parser.introspection +package com.homer.apollographql.apollo.compiler.parser.introspection -import com.apollographql.apollo.compiler.fromJson +import com.homer.apollographql.apollo.compiler.fromJson import com.squareup.moshi.JsonClass import com.squareup.moshi.JsonReader import okio.ByteString.Companion.decodeHex diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/introspection/Utils.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/introspection/Utils.kt similarity index 96% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/introspection/Utils.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/introspection/Utils.kt index b558c386040..632a0841dce 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/introspection/Utils.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/introspection/Utils.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.compiler.parser.introspection +package com.homer.apollographql.apollo.compiler.parser.introspection -import com.apollographql.apollo.compiler.parser.error.ParseException +import com.homer.apollographql.apollo.compiler.parser.error.ParseException internal fun IntrospectionSchema.Type.possibleTypes(schema: IntrospectionSchema): Set { return when (this) { diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/introspection/introspection2sdl.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/introspection/introspection2sdl.kt similarity index 98% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/introspection/introspection2sdl.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/introspection/introspection2sdl.kt index 0c51e4f527c..013d73874ba 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/introspection/introspection2sdl.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/introspection/introspection2sdl.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.compiler.parser.introspection +package com.homer.apollographql.apollo.compiler.parser.introspection import okio.BufferedSink import okio.buffer diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/sdl/GraphSDLSchemaParser.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/sdl/GraphSDLSchemaParser.kt similarity index 97% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/sdl/GraphSDLSchemaParser.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/sdl/GraphSDLSchemaParser.kt index a7ec027b33a..c61163e1d4e 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/sdl/GraphSDLSchemaParser.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/sdl/GraphSDLSchemaParser.kt @@ -1,11 +1,11 @@ -package com.apollographql.apollo.compiler.parser.sdl - -import com.apollographql.apollo.compiler.ir.SourceLocation -import com.apollographql.apollo.compiler.parser.antlr.GraphSDLLexer -import com.apollographql.apollo.compiler.parser.antlr.GraphSDLParser -import com.apollographql.apollo.compiler.parser.error.DocumentParseException -import com.apollographql.apollo.compiler.parser.error.ParseException -import com.apollographql.apollo.compiler.parser.sdl.GraphSDLSchemaParser.parse +package com.homer.apollographql.apollo.compiler.parser.sdl + +import com.homer.apollographql.apollo.compiler.ir.SourceLocation +import com.homer.apollographql.apollo.compiler.parser.antlr.GraphSDLLexer +import com.homer.apollographql.apollo.compiler.parser.antlr.GraphSDLParser +import com.homer.apollographql.apollo.compiler.parser.error.DocumentParseException +import com.homer.apollographql.apollo.compiler.parser.error.ParseException +import com.homer.apollographql.apollo.compiler.parser.sdl.GraphSDLSchemaParser.parse import org.antlr.v4.runtime.ANTLRInputStream import org.antlr.v4.runtime.BaseErrorListener import org.antlr.v4.runtime.CommonTokenStream diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/sdl/GraphSdlSchema.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/sdl/GraphSdlSchema.kt similarity index 96% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/sdl/GraphSdlSchema.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/sdl/GraphSdlSchema.kt index 4f31ed5195b..f68f34afb08 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/parser/sdl/GraphSdlSchema.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/parser/sdl/GraphSdlSchema.kt @@ -1,9 +1,9 @@ -package com.apollographql.apollo.compiler.parser.sdl +package com.homer.apollographql.apollo.compiler.parser.sdl -import com.apollographql.apollo.compiler.ir.SourceLocation -import com.apollographql.apollo.compiler.parser.error.ParseException -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema -import com.apollographql.apollo.compiler.parser.sdl.GraphSDLSchemaParser.parse +import com.homer.apollographql.apollo.compiler.ir.SourceLocation +import com.homer.apollographql.apollo.compiler.parser.error.ParseException +import com.homer.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema +import com.homer.apollographql.apollo.compiler.parser.sdl.GraphSDLSchemaParser.parse import java.io.File data class GraphSdlSchema( diff --git a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/testUtils.kt b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/testUtils.kt similarity index 99% rename from apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/testUtils.kt rename to apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/testUtils.kt index 894fd6b9801..8a3186172ec 100644 --- a/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/testUtils.kt +++ b/apollo-compiler/src/main/kotlin/com/homer/apollographql/apollo/compiler/testUtils.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.compiler +package com.homer.apollographql.apollo.compiler -import com.apollographql.apollo.compiler.ir.CodeGenerationContext +import com.homer.apollographql.apollo.compiler.ir.CodeGenerationContext import com.squareup.javapoet.* import javax.lang.model.element.Modifier diff --git a/apollo-compiler/src/test/graphql/.gitattributes b/apollo-compiler/src/test/graphql/.gitattributes deleted file mode 100644 index f5ff9d4e5d5..00000000000 --- a/apollo-compiler/src/test/graphql/.gitattributes +++ /dev/null @@ -1,3 +0,0 @@ -# apollo generates code without carriage return. Make sure git does not add them when checking out the test fixtures -/*.kt eof=lf -/*.java eof=lf diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_complex/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/arguments_complex/TestOperation.graphql deleted file mode 100644 index 191dc02f237..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_complex/TestOperation.graphql +++ /dev/null @@ -1,19 +0,0 @@ -query TestQuery($episode: Episode, $stars: Int!, $greenValue: Float!) { - heroWithReview ( - episode: $episode, - review: { - stars: $stars, - favoriteColor: { - red: 0 - green: $greenValue - blue: 0 - } - booleanNonOptional: false - listOfStringNonOptional: [] - }, - listOfInts: [$stars, $stars] - ) { - name - height(unit: FOOT) - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_complex/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/arguments_complex/TestQuery.java deleted file mode 100644 index 00a9ff24b9a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_complex/TestQuery.java +++ /dev/null @@ -1,457 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_complex; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.arguments_complex.type.Episode; -import java.io.IOException; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, TestQuery.Variables> { - public static final String OPERATION_ID = "9bfee0998b66f8adeed48e612153400401690d904e272d69289721b6f39aca5f"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery($episode: Episode, $stars: Int!, $greenValue: Float!) {\n" - + " heroWithReview(episode: $episode, review: {stars: $stars, favoriteColor: {red: 0, green: $greenValue, blue: 0}, booleanNonOptional: false, listOfStringNonOptional: []}, listOfInts: [$stars, $stars]) {\n" - + " __typename\n" - + " name\n" - + " height(unit: FOOT)\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final TestQuery.Variables variables; - - public TestQuery(@NotNull Input episode, int stars, double greenValue) { - Utils.checkNotNull(episode, "episode == null"); - variables = new TestQuery.Variables(episode, stars, greenValue); - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public TestQuery.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - private Input episode = Input.absent(); - - private int stars; - - private double greenValue; - - Builder() { - } - - public Builder episode(@Nullable Episode episode) { - this.episode = Input.fromNullable(episode); - return this; - } - - public Builder stars(int stars) { - this.stars = stars; - return this; - } - - public Builder greenValue(double greenValue) { - this.greenValue = greenValue; - return this; - } - - public Builder episodeInput(@NotNull Input episode) { - this.episode = Utils.checkNotNull(episode, "episode == null"); - return this; - } - - public TestQuery build() { - return new TestQuery(episode, stars, greenValue); - } - } - - public static final class Variables extends Operation.Variables { - private final Input episode; - - private final int stars; - - private final double greenValue; - - private final transient Map valueMap = new LinkedHashMap<>(); - - Variables(Input episode, int stars, double greenValue) { - this.episode = episode; - this.stars = stars; - this.greenValue = greenValue; - if (episode.defined) { - this.valueMap.put("episode", episode.value); - } - this.valueMap.put("stars", stars); - this.valueMap.put("greenValue", greenValue); - } - - public Input episode() { - return episode; - } - - public int stars() { - return stars; - } - - public double greenValue() { - return greenValue; - } - - @Override - public Map valueMap() { - return Collections.unmodifiableMap(valueMap); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - if (episode.defined) { - writer.writeString("episode", episode.value != null ? episode.value.rawValue() : null); - } - writer.writeInt("stars", stars); - writer.writeDouble("greenValue", greenValue); - } - }; - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("heroWithReview", "heroWithReview", new UnmodifiableMapBuilder(3) - .put("episode", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "episode") - .build()) - .put("review", new UnmodifiableMapBuilder(4) - .put("stars", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "stars") - .build()) - .put("favoriteColor", new UnmodifiableMapBuilder(3) - .put("red", "0") - .put("green", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "greenValue") - .build()) - .put("blue", "0.0") - .build()) - .put("booleanNonOptional", "false") - .put("listOfStringNonOptional", "[]") - .build()) - .put("listOfInts", "[{kind=Variable, variableName=stars}, {kind=Variable, variableName=stars}]") - .build(), true, Collections.emptyList()) - }; - - final Optional heroWithReview; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable HeroWithReview heroWithReview) { - this.heroWithReview = Optional.fromNullable(heroWithReview); - } - - public Optional heroWithReview() { - return this.heroWithReview; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], heroWithReview.isPresent() ? heroWithReview.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "heroWithReview=" + heroWithReview - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.heroWithReview.equals(that.heroWithReview); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= heroWithReview.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final HeroWithReview.Mapper heroWithReviewFieldMapper = new HeroWithReview.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final HeroWithReview heroWithReview = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HeroWithReview read(ResponseReader reader) { - return heroWithReviewFieldMapper.map(reader); - } - }); - return new Data(heroWithReview); - } - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - public static class HeroWithReview { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forDouble("height", "height", new UnmodifiableMapBuilder(1) - .put("unit", "FOOT") - .build(), true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional height; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HeroWithReview(@NotNull String __typename, @NotNull String name, - @Nullable Double height) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.height = Optional.fromNullable(height); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - /** - * Height in the preferred unit, default is meters - */ - public Optional height() { - return this.height; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeDouble($responseFields[2], height.isPresent() ? height.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HeroWithReview{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "height=" + height - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HeroWithReview) { - HeroWithReview that = (HeroWithReview) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.height.equals(that.height); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= height.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public HeroWithReview map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final Double height = reader.readDouble($responseFields[2]); - return new HeroWithReview(__typename, name, height); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_complex/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/arguments_complex/TestQuery.kt deleted file mode 100644 index c4450a300af..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_complex/TestQuery.kt +++ /dev/null @@ -1,229 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_complex - -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.arguments_complex.type.Episode -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.Double -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.Map -import kotlin.jvm.Transient -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class TestQuery( - val episode: Input = Input.absent(), - val stars: Int, - val greenValue: Double -) : Query { - @Transient - private val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = mutableMapOf().apply { - if (this@TestQuery.episode.defined) { - this["episode"] = this@TestQuery.episode.value - } - this["stars"] = this@TestQuery.stars - this["greenValue"] = this@TestQuery.greenValue - } - - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - if (this@TestQuery.episode.defined) { - writer.writeString("episode", this@TestQuery.episode.value?.rawValue) - } - writer.writeInt("stars", this@TestQuery.stars) - writer.writeDouble("greenValue", this@TestQuery.greenValue) - } - } - - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = variables - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A humanoid creature from the Star Wars universe - */ - data class HeroWithReview( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String, - /** - * Height in the preferred unit, default is meters - */ - val height: Double? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HeroWithReview.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HeroWithReview.name) - writer.writeDouble(RESPONSE_FIELDS[2], this@HeroWithReview.height) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forDouble("height", "height", mapOf( - "unit" to "FOOT"), true, null) - ) - - operator fun invoke(reader: ResponseReader): HeroWithReview = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val height = readDouble(RESPONSE_FIELDS[2]) - HeroWithReview( - __typename = __typename, - name = name, - height = height - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val heroWithReview: HeroWithReview? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.heroWithReview?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("heroWithReview", "heroWithReview", mapOf( - "episode" to mapOf( - "kind" to "Variable", - "variableName" to "episode"), - "review" to mapOf( - "stars" to mapOf( - "kind" to "Variable", - "variableName" to "stars"), - "favoriteColor" to mapOf( - "red" to "0", - "green" to mapOf( - "kind" to "Variable", - "variableName" to "greenValue"), - "blue" to "0.0"), - "booleanNonOptional" to "false", - "listOfStringNonOptional" to emptyList()), - "listOfInts" to listOf( - mapOf( - "kind" to "Variable", - "variableName" to "stars"), - mapOf( - "kind" to "Variable", - "variableName" to "stars"))), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val heroWithReview = readObject(RESPONSE_FIELDS[0]) { reader -> - HeroWithReview(reader) - } - Data( - heroWithReview = heroWithReview - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "9bfee0998b66f8adeed48e612153400401690d904e272d69289721b6f39aca5f" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery(${'$'}episode: Episode, ${'$'}stars: Int!, ${'$'}greenValue: Float!) { - | heroWithReview(episode: ${'$'}episode, review: {stars: ${'$'}stars, favoriteColor: {red: 0, green: ${'$'}greenValue, blue: 0}, booleanNonOptional: false, listOfStringNonOptional: []}, listOfInts: [${'$'}stars, ${'$'}stars]) { - | __typename - | name - | height(unit: FOOT) - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_complex/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/arguments_complex/type/CustomType.java deleted file mode 100644 index 357a1ed30ee..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_complex/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_complex.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_complex/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/arguments_complex/type/CustomType.kt deleted file mode 100644 index 9867a48fb6a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_complex/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_complex.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_complex/type/Episode.java b/apollo-compiler/src/test/graphql/com/example/arguments_complex/type/Episode.java deleted file mode 100644 index 9ff876b7b1f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_complex/type/Episode.java +++ /dev/null @@ -1,67 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_complex.type; - -import java.lang.Deprecated; -import java.lang.String; - -/** - * The episodes in the Star Wars trilogy - */ -public enum Episode { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - * @deprecated For test purpose only - */ - @Deprecated - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - * @deprecated For test purpose only - */ - @Deprecated - NEW_("new"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Episode(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Episode safeValueOf(String rawValue) { - for (Episode enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Episode.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_complex/type/Episode.kt b/apollo-compiler/src/test/graphql/com/example/arguments_complex/type/Episode.kt deleted file mode 100644 index 8aad1f7f207..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_complex/type/Episode.kt +++ /dev/null @@ -1,62 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_complex.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.Deprecated -import kotlin.String - -/** - * The episodes in the Star Wars trilogy - */ -sealed class Episode( - override val rawValue: String -) : EnumValue { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - object NEWHOPE : Episode(rawValue = "NEWHOPE") - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - object EMPIRE : Episode(rawValue = "EMPIRE") - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - object JEDI : Episode(rawValue = "JEDI") - - /** - * Test deprecated enum value - */ - @Deprecated(message = "For test purpose only") - object DEPRECATED : Episode(rawValue = "DEPRECATED") - - /** - * Test java reserved word - */ - @Deprecated(message = "For test purpose only") - object NEW : Episode(rawValue = "new") - - /** - * Auto generated constant for unknown enum values - */ - class UNKNOWN__( - rawValue: String - ) : Episode(rawValue = rawValue) - - companion object { - fun safeValueOf(rawValue: String): Episode = when(rawValue) { - "NEWHOPE" -> NEWHOPE - "EMPIRE" -> EMPIRE - "JEDI" -> JEDI - "DEPRECATED" -> DEPRECATED - "new" -> NEW - else -> UNKNOWN__(rawValue) - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_hardcoded/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/arguments_hardcoded/TestOperation.graphql deleted file mode 100644 index 81a55fcb637..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_hardcoded/TestOperation.graphql +++ /dev/null @@ -1,7 +0,0 @@ -query TestQuery { - reviews(episode: JEDI starsInt: 10 starsFloat: 9.9) { - stars - commentary - } - testNullableArguments(int: null, string: null, float: null, review: null, episode: null, boolean: null, list: null) -} \ No newline at end of file diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_hardcoded/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/arguments_hardcoded/TestQuery.java deleted file mode 100644 index a5e614c5cf0..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_hardcoded/TestQuery.java +++ /dev/null @@ -1,386 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_hardcoded; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "c079dafcee21e2ecf99031bb06e515f069e661513cedaea29191c98b566125d6"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " reviews(episode: JEDI, starsInt: 10, starsFloat: 9.9) {\n" - + " __typename\n" - + " stars\n" - + " commentary\n" - + " }\n" - + " testNullableArguments(int: null, string: null, float: null, review: null, episode: null, boolean: null, list: null)\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forList("reviews", "reviews", new UnmodifiableMapBuilder(3) - .put("episode", "JEDI") - .put("starsInt", 10) - .put("starsFloat", 9.9f) - .build(), true, Collections.emptyList()), - ResponseField.forInt("testNullableArguments", "testNullableArguments", new UnmodifiableMapBuilder(7) - .put("int", null) - .put("string", null) - .put("float", null) - .put("review", null) - .put("episode", null) - .put("boolean", null) - .put("list", null) - .build(), false, Collections.emptyList()) - }; - - final Optional> reviews; - - final int testNullableArguments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable List reviews, int testNullableArguments) { - this.reviews = Optional.fromNullable(reviews); - this.testNullableArguments = testNullableArguments; - } - - public Optional> reviews() { - return this.reviews; - } - - public int testNullableArguments() { - return this.testNullableArguments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeList($responseFields[0], reviews.isPresent() ? reviews.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Review) item).marshaller()); - } - } - }); - writer.writeInt($responseFields[1], testNullableArguments); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "reviews=" + reviews + ", " - + "testNullableArguments=" + testNullableArguments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.reviews.equals(that.reviews) - && this.testNullableArguments == that.testNullableArguments; - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= reviews.hashCode(); - h *= 1000003; - h ^= testNullableArguments; - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Review.Mapper reviewFieldMapper = new Review.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final List reviews = reader.readList($responseFields[0], new ResponseReader.ListReader() { - @Override - public Review read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Review read(ResponseReader reader) { - return reviewFieldMapper.map(reader); - } - }); - } - }); - final int testNullableArguments = reader.readInt($responseFields[1]); - return new Data(reviews, testNullableArguments); - } - } - } - - /** - * Represents a review for a movie - */ - public static class Review { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("stars", "stars", null, false, Collections.emptyList()), - ResponseField.forString("commentary", "commentary", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final int stars; - - final Optional commentary; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Review(@NotNull String __typename, int stars, @Nullable String commentary) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.stars = stars; - this.commentary = Optional.fromNullable(commentary); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The number of stars this review gave, 1-5 - */ - public int stars() { - return this.stars; - } - - /** - * Comment about the movie - */ - public Optional commentary() { - return this.commentary; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], stars); - writer.writeString($responseFields[2], commentary.isPresent() ? commentary.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Review{" - + "__typename=" + __typename + ", " - + "stars=" + stars + ", " - + "commentary=" + commentary - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Review) { - Review that = (Review) o; - return this.__typename.equals(that.__typename) - && this.stars == that.stars - && this.commentary.equals(that.commentary); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= stars; - h *= 1000003; - h ^= commentary.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Review map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final int stars = reader.readInt($responseFields[1]); - final String commentary = reader.readString($responseFields[2]); - return new Review(__typename, stars, commentary); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_hardcoded/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/arguments_hardcoded/TestQuery.kt deleted file mode 100644 index e0e4f98fd6a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_hardcoded/TestQuery.kt +++ /dev/null @@ -1,201 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_hardcoded - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import kotlin.Array -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * Represents a review for a movie - */ - data class Review( - val __typename: String = "Review", - /** - * The number of stars this review gave, 1-5 - */ - val stars: Int, - /** - * Comment about the movie - */ - val commentary: String? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Review.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@Review.stars) - writer.writeString(RESPONSE_FIELDS[2], this@Review.commentary) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("stars", "stars", null, false, null), - ResponseField.forString("commentary", "commentary", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Review = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val stars = readInt(RESPONSE_FIELDS[1])!! - val commentary = readString(RESPONSE_FIELDS[2]) - Review( - __typename = __typename, - stars = stars, - commentary = commentary - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val reviews: List?, - val testNullableArguments: Int - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeList(RESPONSE_FIELDS[0], this@Data.reviews) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - writer.writeInt(RESPONSE_FIELDS[1], this@Data.testNullableArguments) - } - - fun reviewsFilterNotNull(): List? = reviews?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forList("reviews", "reviews", mapOf( - "episode" to "JEDI", - "starsInt" to "10", - "starsFloat" to "9.9"), true, null), - ResponseField.forInt("testNullableArguments", "testNullableArguments", mapOf( - "int" to null, - "string" to null, - "float" to null, - "review" to null, - "episode" to null, - "boolean" to null, - "list" to null), false, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val reviews = readList(RESPONSE_FIELDS[0]) { reader -> - reader.readObject { reader -> - Review(reader) - } - } - val testNullableArguments = readInt(RESPONSE_FIELDS[1])!! - Data( - reviews = reviews, - testNullableArguments = testNullableArguments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "c079dafcee21e2ecf99031bb06e515f069e661513cedaea29191c98b566125d6" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | reviews(episode: JEDI, starsInt: 10, starsFloat: 9.9) { - | __typename - | stars - | commentary - | } - | testNullableArguments(int: null, string: null, float: null, review: null, episode: null, boolean: null, list: null) - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_hardcoded/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/arguments_hardcoded/type/CustomType.java deleted file mode 100644 index 798f8bdf318..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_hardcoded/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_hardcoded.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_hardcoded/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/arguments_hardcoded/type/CustomType.kt deleted file mode 100644 index c0c9a1b718a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_hardcoded/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_hardcoded.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_simple/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/arguments_simple/TestOperation.graphql deleted file mode 100644 index 433cb18fd9e..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_simple/TestOperation.graphql +++ /dev/null @@ -1,23 +0,0 @@ -query TestQuery($episode: Episode $IncludeName: Boolean! $friendsCount: Int! $listOfListOfStringArgs: [[String]!]!) { - hero(episode: $episode listOfListOfStringArgs: $listOfListOfStringArgs) { - name @include(if: $IncludeName) - ...HeroDetails - } - heroWithReview ( - episode: $episode - review: {}, - ) { - name - } -} - -fragment HeroDetails on Character { - friendsConnection(first: $friendsCount) { - totalCount - edges { - node { - name @include(if: $IncludeName) - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_simple/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/arguments_simple/TestQuery.java deleted file mode 100644 index 14d9524e5be..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_simple/TestQuery.java +++ /dev/null @@ -1,699 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_simple; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.arguments_simple.fragment.HeroDetails; -import com.example.arguments_simple.type.Episode; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, TestQuery.Variables> { - public static final String OPERATION_ID = "89afe30dd0fa5ddce3d0b743d3adf68e55a48d0c11d10e495c0ec095949e6d04"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery($episode: Episode, $IncludeName: Boolean!, $friendsCount: Int!, $listOfListOfStringArgs: [[String]!]!) {\n" - + " hero(episode: $episode, listOfListOfStringArgs: $listOfListOfStringArgs) {\n" - + " __typename\n" - + " name @include(if: $IncludeName)\n" - + " ...HeroDetails\n" - + " }\n" - + " heroWithReview(episode: $episode, review: {}) {\n" - + " __typename\n" - + " name\n" - + " }\n" - + "}\n" - + "fragment HeroDetails on Character {\n" - + " __typename\n" - + " friendsConnection(first: $friendsCount) {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name @include(if: $IncludeName)\n" - + " }\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final TestQuery.Variables variables; - - public TestQuery(@NotNull Input episode, boolean includeName, int friendsCount, - @NotNull List> listOfListOfStringArgs) { - Utils.checkNotNull(episode, "episode == null"); - Utils.checkNotNull(listOfListOfStringArgs, "listOfListOfStringArgs == null"); - variables = new TestQuery.Variables(episode, includeName, friendsCount, listOfListOfStringArgs); - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public TestQuery.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - private Input episode = Input.absent(); - - private boolean includeName; - - private int friendsCount; - - private @NotNull List> listOfListOfStringArgs; - - Builder() { - } - - public Builder episode(@Nullable Episode episode) { - this.episode = Input.fromNullable(episode); - return this; - } - - public Builder includeName(boolean includeName) { - this.includeName = includeName; - return this; - } - - public Builder friendsCount(int friendsCount) { - this.friendsCount = friendsCount; - return this; - } - - public Builder listOfListOfStringArgs(@NotNull List> listOfListOfStringArgs) { - this.listOfListOfStringArgs = listOfListOfStringArgs; - return this; - } - - public Builder episodeInput(@NotNull Input episode) { - this.episode = Utils.checkNotNull(episode, "episode == null"); - return this; - } - - public TestQuery build() { - Utils.checkNotNull(listOfListOfStringArgs, "listOfListOfStringArgs == null"); - return new TestQuery(episode, includeName, friendsCount, listOfListOfStringArgs); - } - } - - public static final class Variables extends Operation.Variables { - private final Input episode; - - private final boolean includeName; - - private final int friendsCount; - - private final @NotNull List> listOfListOfStringArgs; - - private final transient Map valueMap = new LinkedHashMap<>(); - - Variables(Input episode, boolean includeName, int friendsCount, - @NotNull List> listOfListOfStringArgs) { - this.episode = episode; - this.includeName = includeName; - this.friendsCount = friendsCount; - this.listOfListOfStringArgs = listOfListOfStringArgs; - if (episode.defined) { - this.valueMap.put("episode", episode.value); - } - this.valueMap.put("IncludeName", includeName); - this.valueMap.put("friendsCount", friendsCount); - this.valueMap.put("listOfListOfStringArgs", listOfListOfStringArgs); - } - - public Input episode() { - return episode; - } - - public boolean includeName() { - return includeName; - } - - public int friendsCount() { - return friendsCount; - } - - public @NotNull List> listOfListOfStringArgs() { - return listOfListOfStringArgs; - } - - @Override - public Map valueMap() { - return Collections.unmodifiableMap(valueMap); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - if (episode.defined) { - writer.writeString("episode", episode.value != null ? episode.value.rawValue() : null); - } - writer.writeBoolean("includeName", includeName); - writer.writeInt("friendsCount", friendsCount); - writer.writeList("listOfListOfStringArgs", new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final List $item : listOfListOfStringArgs) { - listItemWriter.writeList($item != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws - IOException { - for (final String $$item : $item) { - listItemWriter.writeString($$item); - } - } - } : null); - } - } - }); - } - }; - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", new UnmodifiableMapBuilder(2) - .put("episode", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "episode") - .build()) - .put("listOfListOfStringArgs", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "listOfListOfStringArgs") - .build()) - .build(), true, Collections.emptyList()), - ResponseField.forObject("heroWithReview", "heroWithReview", new UnmodifiableMapBuilder(2) - .put("episode", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "episode") - .build()) - .put("review", new UnmodifiableMapBuilder(0) - .build()) - .build(), true, Collections.emptyList()) - }; - - final Optional hero; - - final Optional heroWithReview; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero, @Nullable HeroWithReview heroWithReview) { - this.hero = Optional.fromNullable(hero); - this.heroWithReview = Optional.fromNullable(heroWithReview); - } - - public Optional hero() { - return this.hero; - } - - public Optional heroWithReview() { - return this.heroWithReview; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - writer.writeObject($responseFields[1], heroWithReview.isPresent() ? heroWithReview.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero + ", " - + "heroWithReview=" + heroWithReview - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero) - && this.heroWithReview.equals(that.heroWithReview); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - h *= 1000003; - h ^= heroWithReview.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - final HeroWithReview.Mapper heroWithReviewFieldMapper = new HeroWithReview.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - final HeroWithReview heroWithReview = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public HeroWithReview read(ResponseReader reader) { - return heroWithReviewFieldMapper.map(reader); - } - }); - return new Data(hero, heroWithReview); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, true, Arrays.asList( - ResponseField.Condition.booleanCondition("IncludeName", false) - )), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional name; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @Nullable String name, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Optional.fromNullable(name); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public Optional name() { - return this.name; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name.isPresent() ? name.get() : null); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @NotNull HeroDetails heroDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@NotNull HeroDetails heroDetails) { - this.heroDetails = Utils.checkNotNull(heroDetails, "heroDetails == null"); - } - - public @NotNull HeroDetails heroDetails() { - return this.heroDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeFragment(heroDetails.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "heroDetails=" + heroDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.heroDetails.equals(that.heroDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= heroDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Collections.emptyList()) - }; - - final HeroDetails.Mapper heroDetailsFieldMapper = new HeroDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HeroDetails heroDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HeroDetails read(ResponseReader reader) { - return heroDetailsFieldMapper.map(reader); - } - }); - return new Fragments(heroDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Hero(__typename, name, fragments); - } - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - public static class HeroWithReview { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HeroWithReview(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HeroWithReview{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HeroWithReview) { - HeroWithReview that = (HeroWithReview) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public HeroWithReview map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new HeroWithReview(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_simple/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/arguments_simple/TestQuery.kt deleted file mode 100644 index 88015b25b09..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_simple/TestQuery.kt +++ /dev/null @@ -1,313 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_simple - -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.arguments_simple.fragment.HeroDetails -import com.example.arguments_simple.type.Episode -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlin.collections.Map -import kotlin.jvm.Transient -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class TestQuery( - val episode: Input = Input.absent(), - val includeName: Boolean, - val friendsCount: Int, - val listOfListOfStringArgs: List> -) : Query { - @Transient - private val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = mutableMapOf().apply { - if (this@TestQuery.episode.defined) { - this["episode"] = this@TestQuery.episode.value - } - this["IncludeName"] = this@TestQuery.includeName - this["friendsCount"] = this@TestQuery.friendsCount - this["listOfListOfStringArgs"] = this@TestQuery.listOfListOfStringArgs - } - - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - if (this@TestQuery.episode.defined) { - writer.writeString("episode", this@TestQuery.episode.value?.rawValue) - } - writer.writeBoolean("IncludeName", this@TestQuery.includeName) - writer.writeInt("friendsCount", this@TestQuery.friendsCount) - writer.writeList("listOfListOfStringArgs") { listItemWriter -> - this@TestQuery.listOfListOfStringArgs.forEach { value -> - listItemWriter.writeList { listItemWriter -> - value.forEach { value -> - listItemWriter.writeString(value) - } - } - } - } - } - } - - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = variables - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String?, - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - this@Hero.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, true, listOf( - ResponseField.Condition.booleanCondition("IncludeName", false) - )), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1]) - val fragments = Fragments(reader) - Hero( - __typename = __typename, - name = name, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val heroDetails: HeroDetails - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.heroDetails.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", null) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val heroDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - HeroDetails(reader) - }!! - Fragments( - heroDetails = heroDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - data class HeroWithReview( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HeroWithReview.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HeroWithReview.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): HeroWithReview = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - HeroWithReview( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero?, - val heroWithReview: HeroWithReview? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - writer.writeObject(RESPONSE_FIELDS[1], this@Data.heroWithReview?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", mapOf( - "episode" to mapOf( - "kind" to "Variable", - "variableName" to "episode"), - "listOfListOfStringArgs" to mapOf( - "kind" to "Variable", - "variableName" to "listOfListOfStringArgs")), true, null), - ResponseField.forObject("heroWithReview", "heroWithReview", mapOf( - "episode" to mapOf( - "kind" to "Variable", - "variableName" to "episode"), - "review" to emptyMap()), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - val heroWithReview = readObject(RESPONSE_FIELDS[1]) { reader -> - HeroWithReview(reader) - } - Data( - hero = hero, - heroWithReview = heroWithReview - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "89afe30dd0fa5ddce3d0b743d3adf68e55a48d0c11d10e495c0ec095949e6d04" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery(${'$'}episode: Episode, ${'$'}IncludeName: Boolean!, ${'$'}friendsCount: Int!, ${'$'}listOfListOfStringArgs: [[String]!]!) { - | hero(episode: ${'$'}episode, listOfListOfStringArgs: ${'$'}listOfListOfStringArgs) { - | __typename - | name @include(if: ${'$'}IncludeName) - | ...HeroDetails - | } - | heroWithReview(episode: ${'$'}episode, review: {}) { - | __typename - | name - | } - |} - |fragment HeroDetails on Character { - | __typename - | friendsConnection(first: ${'$'}friendsCount) { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name @include(if: ${'$'}IncludeName) - | } - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_simple/fragment/HeroDetails.java b/apollo-compiler/src/test/graphql/com/example/arguments_simple/fragment/HeroDetails.java deleted file mode 100644 index 4c27f4774e4..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_simple/fragment/HeroDetails.java +++ /dev/null @@ -1,472 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_simple.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class HeroDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("friendsConnection", "friendsConnection", new UnmodifiableMapBuilder(1) - .put("first", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "friendsCount") - .build()) - .build(), false, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment HeroDetails on Character {\n" - + " __typename\n" - + " friendsConnection(first: $friendsCount) {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name @include(if: $IncludeName)\n" - + " }\n" - + " }\n" - + " }\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull FriendsConnection friendsConnection; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HeroDetails(@NotNull String __typename, @NotNull FriendsConnection friendsConnection) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The friends of the character exposed as a connection with edges - */ - public @NotNull FriendsConnection friendsConnection() { - return this.friendsConnection; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], friendsConnection.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HeroDetails{" - + "__typename=" + __typename + ", " - + "friendsConnection=" + friendsConnection - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HeroDetails) { - HeroDetails that = (HeroDetails) o; - return this.__typename.equals(that.__typename) - && this.friendsConnection.equals(that.friendsConnection); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection.Mapper friendsConnectionFieldMapper = new FriendsConnection.Mapper(); - - @Override - public HeroDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final FriendsConnection friendsConnection = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection read(ResponseReader reader) { - return friendsConnectionFieldMapper.map(reader); - } - }); - return new HeroDetails(__typename, friendsConnection); - } - } - - /** - * A connection object for a character's friends - */ - public static class FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - final Optional> edges; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection(@NotNull String __typename, @Nullable Integer totalCount, - @Nullable List edges) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.fromNullable(totalCount); - this.edges = Optional.fromNullable(edges); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional totalCount() { - return this.totalCount; - } - - /** - * The edges for each of the character's friends. - */ - public Optional> edges() { - return this.edges; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - writer.writeList($responseFields[2], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount + ", " - + "edges=" + edges - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection) { - FriendsConnection that = (FriendsConnection) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount) - && this.edges.equals(that.edges); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge.Mapper edgeFieldMapper = new Edge.Mapper(); - - @Override - public FriendsConnection map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - final List edges = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Edge read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge read(ResponseReader reader) { - return edgeFieldMapper.map(reader); - } - }); - } - }); - return new FriendsConnection(__typename, totalCount, edges); - } - } - } - - /** - * An edge object for a character's friends - */ - public static class Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge(@NotNull String __typename, @Nullable Node node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.fromNullable(node); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The character represented by this friendship edge - */ - public Optional node() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge) { - Edge that = (Edge) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Node.Mapper nodeFieldMapper = new Node.Mapper(); - - @Override - public Edge map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node read(ResponseReader reader) { - return nodeFieldMapper.map(reader); - } - }); - return new Edge(__typename, node); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, true, Arrays.asList( - ResponseField.Condition.booleanCondition("IncludeName", false) - )) - }; - - final @NotNull String __typename; - - final Optional name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node(@NotNull String __typename, @Nullable String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Optional.fromNullable(name); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public Optional name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name.isPresent() ? name.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node) { - Node that = (Node) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Node map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Node(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_simple/fragment/HeroDetails.kt b/apollo-compiler/src/test/graphql/com/example/arguments_simple/fragment/HeroDetails.kt deleted file mode 100644 index dbf4f5b4412..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_simple/fragment/HeroDetails.kt +++ /dev/null @@ -1,199 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_simple.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class HeroDetails( - val __typename: String = "Character", - /** - * The friends of the character exposed as a connection with edges - */ - val friendsConnection: FriendsConnection -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HeroDetails.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@HeroDetails.friendsConnection.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("friendsConnection", "friendsConnection", mapOf( - "first" to mapOf( - "kind" to "Variable", - "variableName" to "friendsCount")), false, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment HeroDetails on Character { - | __typename - | friendsConnection(first: ${'$'}friendsCount) { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name @include(if: ${'$'}IncludeName) - | } - | } - | } - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HeroDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val friendsConnection = readObject(RESPONSE_FIELDS[1]) { reader -> - FriendsConnection(reader) - }!! - HeroDetails( - __typename = __typename, - friendsConnection = friendsConnection - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - /** - * A character from the Star Wars universe - */ - data class Node( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Node.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, true, listOf( - ResponseField.Condition.booleanCondition("IncludeName", false) - )) - ) - - operator fun invoke(reader: ResponseReader): Node = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1]) - Node( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An edge object for a character's friends - */ - data class Edge( - val __typename: String = "FriendsEdge", - /** - * The character represented by this friendship edge - */ - val node: Node? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node(reader) - } - Edge( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int?, - /** - * The edges for each of the character's friends. - */ - val edges: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection.totalCount) - writer.writeList(RESPONSE_FIELDS[2], this@FriendsConnection.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null), - ResponseField.forList("edges", "edges", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - val edges = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Edge(reader) - } - } - FriendsConnection( - __typename = __typename, - totalCount = totalCount, - edges = edges - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_simple/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/arguments_simple/type/CustomType.java deleted file mode 100644 index 0d953855401..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_simple/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_simple.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_simple/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/arguments_simple/type/CustomType.kt deleted file mode 100644 index b9118e979ee..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_simple/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_simple.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_simple/type/Episode.java b/apollo-compiler/src/test/graphql/com/example/arguments_simple/type/Episode.java deleted file mode 100644 index 0c9d4df51df..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_simple/type/Episode.java +++ /dev/null @@ -1,67 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_simple.type; - -import java.lang.Deprecated; -import java.lang.String; - -/** - * The episodes in the Star Wars trilogy - */ -public enum Episode { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - * @deprecated For test purpose only - */ - @Deprecated - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - * @deprecated For test purpose only - */ - @Deprecated - NEW_("new"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Episode(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Episode safeValueOf(String rawValue) { - for (Episode enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Episode.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/arguments_simple/type/Episode.kt b/apollo-compiler/src/test/graphql/com/example/arguments_simple/type/Episode.kt deleted file mode 100644 index 0cadc54d4c7..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/arguments_simple/type/Episode.kt +++ /dev/null @@ -1,62 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.arguments_simple.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.Deprecated -import kotlin.String - -/** - * The episodes in the Star Wars trilogy - */ -sealed class Episode( - override val rawValue: String -) : EnumValue { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - object NEWHOPE : Episode(rawValue = "NEWHOPE") - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - object EMPIRE : Episode(rawValue = "EMPIRE") - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - object JEDI : Episode(rawValue = "JEDI") - - /** - * Test deprecated enum value - */ - @Deprecated(message = "For test purpose only") - object DEPRECATED : Episode(rawValue = "DEPRECATED") - - /** - * Test java reserved word - */ - @Deprecated(message = "For test purpose only") - object NEW : Episode(rawValue = "new") - - /** - * Auto generated constant for unknown enum values - */ - class UNKNOWN__( - rawValue: String - ) : Episode(rawValue = rawValue) - - companion object { - fun safeValueOf(rawValue: String): Episode = when(rawValue) { - "NEWHOPE" -> NEWHOPE - "EMPIRE" -> EMPIRE - "JEDI" -> JEDI - "DEPRECATED" -> DEPRECATED - "new" -> NEW - else -> UNKNOWN__(rawValue) - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/custom_scalar_type/TestOperation.graphql deleted file mode 100644 index 80de9fb38ac..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type/TestOperation.graphql +++ /dev/null @@ -1,10 +0,0 @@ -query TestQuery { - hero { - name - birthDate - appearanceDates - fieldWithUnsupportedType - profileLink - links - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/custom_scalar_type/TestQuery.java deleted file mode 100644 index 28c7f908ca6..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type/TestQuery.java +++ /dev/null @@ -1,446 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.custom_scalar_type; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.custom_scalar_type.type.CustomType; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "5b1986dc0a04871a5bcbfdb1d7a5b9f935fd9b2d68da8990744106c4b253f177"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " birthDate\n" - + " appearanceDates\n" - + " fieldWithUnsupportedType\n" - + " profileLink\n" - + " links\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forCustomType("birthDate", "birthDate", null, false, CustomType.DATE, Collections.emptyList()), - ResponseField.forList("appearanceDates", "appearanceDates", null, false, Collections.emptyList()), - ResponseField.forCustomType("fieldWithUnsupportedType", "fieldWithUnsupportedType", null, false, CustomType.UNSUPPORTEDTYPE, Collections.emptyList()), - ResponseField.forCustomType("profileLink", "profileLink", null, false, CustomType.URL, Collections.emptyList()), - ResponseField.forList("links", "links", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull Date birthDate; - - final @NotNull List appearanceDates; - - final @NotNull Object fieldWithUnsupportedType; - - final @NotNull String profileLink; - - final @NotNull List links; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull String name, @NotNull Date birthDate, - @NotNull List appearanceDates, @NotNull Object fieldWithUnsupportedType, - @NotNull String profileLink, @NotNull List links) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.birthDate = Utils.checkNotNull(birthDate, "birthDate == null"); - this.appearanceDates = Utils.checkNotNull(appearanceDates, "appearanceDates == null"); - this.fieldWithUnsupportedType = Utils.checkNotNull(fieldWithUnsupportedType, "fieldWithUnsupportedType == null"); - this.profileLink = Utils.checkNotNull(profileLink, "profileLink == null"); - this.links = Utils.checkNotNull(links, "links == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The date character was born. - */ - public @NotNull Date birthDate() { - return this.birthDate; - } - - /** - * The dates of appearances - */ - public @NotNull List appearanceDates() { - return this.appearanceDates; - } - - /** - * The date character was born. - */ - public @NotNull Object fieldWithUnsupportedType() { - return this.fieldWithUnsupportedType; - } - - /** - * Profile link - */ - public @NotNull String profileLink() { - return this.profileLink; - } - - /** - * Links - */ - public @NotNull List links() { - return this.links; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[2], birthDate); - writer.writeList($responseFields[3], appearanceDates, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeCustom(CustomType.DATE, item); - } - } - }); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[4], fieldWithUnsupportedType); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[5], profileLink); - writer.writeList($responseFields[6], links, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeCustom(CustomType.URL, item); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "birthDate=" + birthDate + ", " - + "appearanceDates=" + appearanceDates + ", " - + "fieldWithUnsupportedType=" + fieldWithUnsupportedType + ", " - + "profileLink=" + profileLink + ", " - + "links=" + links - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.birthDate.equals(that.birthDate) - && this.appearanceDates.equals(that.appearanceDates) - && this.fieldWithUnsupportedType.equals(that.fieldWithUnsupportedType) - && this.profileLink.equals(that.profileLink) - && this.links.equals(that.links); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= birthDate.hashCode(); - h *= 1000003; - h ^= appearanceDates.hashCode(); - h *= 1000003; - h ^= fieldWithUnsupportedType.hashCode(); - h *= 1000003; - h ^= profileLink.hashCode(); - h *= 1000003; - h ^= links.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final Date birthDate = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[2]); - final List appearanceDates = reader.readList($responseFields[3], new ResponseReader.ListReader() { - @Override - public Date read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readCustomType(CustomType.DATE); - } - }); - final Object fieldWithUnsupportedType = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[4]); - final String profileLink = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[5]); - final List links = reader.readList($responseFields[6], new ResponseReader.ListReader() { - @Override - public String read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readCustomType(CustomType.URL); - } - }); - return new Hero(__typename, name, birthDate, appearanceDates, fieldWithUnsupportedType, profileLink, links); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/custom_scalar_type/TestQuery.kt deleted file mode 100644 index 0cd1e050ffb..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type/TestQuery.kt +++ /dev/null @@ -1,230 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.custom_scalar_type - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.custom_scalar_type.type.CustomType -import java.util.Date -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The date character was born. - */ - val birthDate: Date, - /** - * The dates of appearances - */ - val appearanceDates: List, - /** - * The date character was born. - */ - val fieldWithUnsupportedType: Any, - /** - * Profile link - */ - val profileLink: String, - /** - * Links - */ - val links: List - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeCustom(RESPONSE_FIELDS[2] as ResponseField.CustomTypeField, this@Hero.birthDate) - writer.writeList(RESPONSE_FIELDS[3], this@Hero.appearanceDates) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeCustom(CustomType.DATE, value)} - } - writer.writeCustom(RESPONSE_FIELDS[4] as ResponseField.CustomTypeField, - this@Hero.fieldWithUnsupportedType) - writer.writeCustom(RESPONSE_FIELDS[5] as ResponseField.CustomTypeField, this@Hero.profileLink) - writer.writeList(RESPONSE_FIELDS[6], this@Hero.links) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeCustom(CustomType.URL, value)} - } - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forCustomType("birthDate", "birthDate", null, false, CustomType.DATE, null), - ResponseField.forList("appearanceDates", "appearanceDates", null, false, null), - ResponseField.forCustomType("fieldWithUnsupportedType", "fieldWithUnsupportedType", null, - false, CustomType.UNSUPPORTEDTYPE, null), - ResponseField.forCustomType("profileLink", "profileLink", null, false, CustomType.URL, - null), - ResponseField.forList("links", "links", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val birthDate = readCustomType(RESPONSE_FIELDS[2] as ResponseField.CustomTypeField)!! - val appearanceDates = readList(RESPONSE_FIELDS[3]) { reader -> - reader.readCustomType(CustomType.DATE) - }!!.map { it!! } - val fieldWithUnsupportedType = readCustomType(RESPONSE_FIELDS[4] as - ResponseField.CustomTypeField)!! - val profileLink = readCustomType(RESPONSE_FIELDS[5] as - ResponseField.CustomTypeField)!! - val links = readList(RESPONSE_FIELDS[6]) { reader -> - reader.readCustomType(CustomType.URL) - }!!.map { it!! } - Hero( - __typename = __typename, - name = name, - birthDate = birthDate, - appearanceDates = appearanceDates, - fieldWithUnsupportedType = fieldWithUnsupportedType, - profileLink = profileLink, - links = links - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "5b1986dc0a04871a5bcbfdb1d7a5b9f935fd9b2d68da8990744106c4b253f177" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | name - | birthDate - | appearanceDates - | fieldWithUnsupportedType - | profileLink - | links - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/custom_scalar_type/type/CustomType.java deleted file mode 100644 index 53775e841a0..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type/type/CustomType.java +++ /dev/null @@ -1,60 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.custom_scalar_type.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - DATE { - @Override - public String typeName() { - return "Date"; - } - - @Override - public String className() { - return "java.util.Date"; - } - }, - - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.Integer"; - } - }, - - URL { - @Override - public String typeName() { - return "URL"; - } - - @Override - public String className() { - return "java.lang.String"; - } - }, - - UNSUPPORTEDTYPE { - @Override - public String typeName() { - return "UnsupportedType"; - } - - @Override - public String className() { - return "java.lang.Object"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/custom_scalar_type/type/CustomType.kt deleted file mode 100644 index f69e53ba7d8..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type/type/CustomType.kt +++ /dev/null @@ -1,35 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.custom_scalar_type.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - DATE { - override fun typeName(): String = "Date" - - override fun className(): String = "java.util.Date" - }, - - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.Int" - }, - - URL { - override fun typeName(): String = "URL" - - override fun className(): String = "kotlin.String" - }, - - UNSUPPORTEDTYPE { - override fun typeName(): String = "UnsupportedType" - - override fun className(): String = "kotlin.Any" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type_warnings/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/custom_scalar_type_warnings/TestOperation.graphql deleted file mode 100644 index cf6cc540fb8..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type_warnings/TestOperation.graphql +++ /dev/null @@ -1,5 +0,0 @@ -query TestQuery { - hero { - links - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type_warnings/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/custom_scalar_type_warnings/TestQuery.java deleted file mode 100644 index 55eee36abbd..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type_warnings/TestQuery.java +++ /dev/null @@ -1,341 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.custom_scalar_type_warnings; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.custom_scalar_type_warnings.type.CustomType; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "1a019419389595f8e5269db271bc43dae6cf9733959296ceff6a3270faa91c62"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " links\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forList("links", "links", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull List links; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull List links) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.links = Utils.checkNotNull(links, "links == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * Links - */ - public @NotNull List links() { - return this.links; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeList($responseFields[1], links, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeCustom(CustomType.URL, item); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "links=" + links - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.links.equals(that.links); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= links.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final List links = reader.readList($responseFields[1], new ResponseReader.ListReader() { - @Override - public Object read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readCustomType(CustomType.URL); - } - }); - return new Hero(__typename, links); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type_warnings/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/custom_scalar_type_warnings/TestQuery.kt deleted file mode 100644 index 1ff2f19aade..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type_warnings/TestQuery.kt +++ /dev/null @@ -1,174 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.custom_scalar_type_warnings - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.custom_scalar_type_warnings.type.CustomType -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * Links - */ - val links: List - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeList(RESPONSE_FIELDS[1], this@Hero.links) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeCustom(CustomType.URL, value)} - } - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forList("links", "links", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val links = readList(RESPONSE_FIELDS[1]) { reader -> - reader.readCustomType(CustomType.URL) - }!!.map { it!! } - Hero( - __typename = __typename, - links = links - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "1a019419389595f8e5269db271bc43dae6cf9733959296ceff6a3270faa91c62" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | links - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type_warnings/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/custom_scalar_type_warnings/type/CustomType.java deleted file mode 100644 index c3cdfb2e975..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type_warnings/type/CustomType.java +++ /dev/null @@ -1,39 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.custom_scalar_type_warnings.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @SuppressWarnings("rawtypes") - @Override - public String className() { - return "java.lang.String"; - } - }, - - URL { - @Override - public String typeName() { - return "URL"; - } - - @SuppressWarnings("rawtypes") - @Override - public String className() { - return "java.lang.Object"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type_warnings/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/custom_scalar_type_warnings/type/CustomType.kt deleted file mode 100644 index e9a2b3a99f0..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/custom_scalar_type_warnings/type/CustomType.kt +++ /dev/null @@ -1,23 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.custom_scalar_type_warnings.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - }, - - URL { - override fun typeName(): String = "URL" - - override fun className(): String = "kotlin.Any" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/deprecation/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/deprecation/TestOperation.graphql deleted file mode 100644 index 172fa9f4672..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/deprecation/TestOperation.graphql +++ /dev/null @@ -1,9 +0,0 @@ -query TestQuery($episode: Episode) { - hero(episode: $episode) { - name - deprecated - deprecatedBool - deprecatedWithNoReason - deprecatedWithBlankReason - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/graphql/com/example/deprecation/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/deprecation/TestQuery.java deleted file mode 100644 index f6659f29522..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/deprecation/TestQuery.java +++ /dev/null @@ -1,466 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.deprecation; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.deprecation.type.Episode; -import java.io.IOException; -import java.lang.Deprecated; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, TestQuery.Variables> { - public static final String OPERATION_ID = "82ddc716280f1e2f832345d489f265f98280abf0d9a0257c09ca5bd3779dfd2f"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery($episode: Episode) {\n" - + " hero(episode: $episode) {\n" - + " __typename\n" - + " name\n" - + " deprecated\n" - + " deprecatedBool\n" - + " deprecatedWithNoReason\n" - + " deprecatedWithBlankReason\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final TestQuery.Variables variables; - - public TestQuery(@NotNull Input episode) { - Utils.checkNotNull(episode, "episode == null"); - variables = new TestQuery.Variables(episode); - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public TestQuery.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - private Input episode = Input.absent(); - - Builder() { - } - - public Builder episode(@Nullable Episode episode) { - this.episode = Input.fromNullable(episode); - return this; - } - - public Builder episodeInput(@NotNull Input episode) { - this.episode = Utils.checkNotNull(episode, "episode == null"); - return this; - } - - public TestQuery build() { - return new TestQuery(episode); - } - } - - public static final class Variables extends Operation.Variables { - private final Input episode; - - private final transient Map valueMap = new LinkedHashMap<>(); - - Variables(Input episode) { - this.episode = episode; - if (episode.defined) { - this.valueMap.put("episode", episode.value); - } - } - - public Input episode() { - return episode; - } - - @Override - public Map valueMap() { - return Collections.unmodifiableMap(valueMap); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - if (episode.defined) { - writer.writeString("episode", episode.value != null ? episode.value.rawValue() : null); - } - } - }; - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", new UnmodifiableMapBuilder(1) - .put("episode", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "episode") - .build()) - .build(), true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forString("deprecated", "deprecated", null, false, Collections.emptyList()), - ResponseField.forBoolean("deprecatedBool", "deprecatedBool", null, false, Collections.emptyList()), - ResponseField.forString("deprecatedWithNoReason", "deprecatedWithNoReason", null, false, Collections.emptyList()), - ResponseField.forString("deprecatedWithBlankReason", "deprecatedWithBlankReason", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull @Deprecated String deprecated; - - final @Deprecated boolean deprecatedBool; - - final @NotNull @Deprecated String deprecatedWithNoReason; - - final @NotNull @Deprecated String deprecatedWithBlankReason; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull String name, - @NotNull @Deprecated String deprecated, @Deprecated boolean deprecatedBool, - @NotNull @Deprecated String deprecatedWithNoReason, - @NotNull @Deprecated String deprecatedWithBlankReason) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.deprecated = Utils.checkNotNull(deprecated, "deprecated == null"); - this.deprecatedBool = deprecatedBool; - this.deprecatedWithNoReason = Utils.checkNotNull(deprecatedWithNoReason, "deprecatedWithNoReason == null"); - this.deprecatedWithBlankReason = Utils.checkNotNull(deprecatedWithBlankReason, "deprecatedWithBlankReason == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * Test deprecated field - * @deprecated For test purpose only - */ - public @NotNull @Deprecated String deprecated() { - return this.deprecated; - } - - /** - * Test deprecated field - * @deprecated For test purpose only - */ - public @Deprecated boolean deprecatedBool() { - return this.deprecatedBool; - } - - /** - * Test deprecated field with no reason - * @deprecated No longer supported - */ - public @NotNull @Deprecated String deprecatedWithNoReason() { - return this.deprecatedWithNoReason; - } - - /** - * Test deprecated field with blank reason - * @deprecated - */ - public @NotNull @Deprecated String deprecatedWithBlankReason() { - return this.deprecatedWithBlankReason; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeString($responseFields[2], deprecated); - writer.writeBoolean($responseFields[3], deprecatedBool); - writer.writeString($responseFields[4], deprecatedWithNoReason); - writer.writeString($responseFields[5], deprecatedWithBlankReason); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "deprecated=" + deprecated + ", " - + "deprecatedBool=" + deprecatedBool + ", " - + "deprecatedWithNoReason=" + deprecatedWithNoReason + ", " - + "deprecatedWithBlankReason=" + deprecatedWithBlankReason - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.deprecated.equals(that.deprecated) - && this.deprecatedBool == that.deprecatedBool - && this.deprecatedWithNoReason.equals(that.deprecatedWithNoReason) - && this.deprecatedWithBlankReason.equals(that.deprecatedWithBlankReason); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= deprecated.hashCode(); - h *= 1000003; - h ^= Boolean.valueOf(deprecatedBool).hashCode(); - h *= 1000003; - h ^= deprecatedWithNoReason.hashCode(); - h *= 1000003; - h ^= deprecatedWithBlankReason.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final String deprecated = reader.readString($responseFields[2]); - final boolean deprecatedBool = reader.readBoolean($responseFields[3]); - final String deprecatedWithNoReason = reader.readString($responseFields[4]); - final String deprecatedWithBlankReason = reader.readString($responseFields[5]); - return new Hero(__typename, name, deprecated, deprecatedBool, deprecatedWithNoReason, deprecatedWithBlankReason); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/deprecation/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/deprecation/TestQuery.kt deleted file mode 100644 index 7fe46db5ae1..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/deprecation/TestQuery.kt +++ /dev/null @@ -1,235 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.deprecation - -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.deprecation.type.Episode -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.Deprecated -import kotlin.String -import kotlin.Suppress -import kotlin.collections.Map -import kotlin.jvm.Transient -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class TestQuery( - val episode: Input = Input.absent() -) : Query { - @Transient - private val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = mutableMapOf().apply { - if (this@TestQuery.episode.defined) { - this["episode"] = this@TestQuery.episode.value - } - } - - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - if (this@TestQuery.episode.defined) { - writer.writeString("episode", this@TestQuery.episode.value?.rawValue) - } - } - } - - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = variables - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * Test deprecated field - */ - @Deprecated(message = "For test purpose only") - val deprecated: String, - /** - * Test deprecated field - */ - @Deprecated(message = "For test purpose only") - val deprecatedBool: Boolean, - /** - * Test deprecated field with no reason - */ - @Deprecated(message = "No longer supported") - val deprecatedWithNoReason: String, - /** - * Test deprecated field with blank reason - */ - @Deprecated(message = "") - val deprecatedWithBlankReason: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeString(RESPONSE_FIELDS[2], this@Hero.deprecated) - writer.writeBoolean(RESPONSE_FIELDS[3], this@Hero.deprecatedBool) - writer.writeString(RESPONSE_FIELDS[4], this@Hero.deprecatedWithNoReason) - writer.writeString(RESPONSE_FIELDS[5], this@Hero.deprecatedWithBlankReason) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forString("deprecated", "deprecated", null, false, null), - ResponseField.forBoolean("deprecatedBool", "deprecatedBool", null, false, null), - ResponseField.forString("deprecatedWithNoReason", "deprecatedWithNoReason", null, false, - null), - ResponseField.forString("deprecatedWithBlankReason", "deprecatedWithBlankReason", null, - false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val deprecated = readString(RESPONSE_FIELDS[2])!! - val deprecatedBool = readBoolean(RESPONSE_FIELDS[3])!! - val deprecatedWithNoReason = readString(RESPONSE_FIELDS[4])!! - val deprecatedWithBlankReason = readString(RESPONSE_FIELDS[5])!! - Hero( - __typename = __typename, - name = name, - deprecated = deprecated, - deprecatedBool = deprecatedBool, - deprecatedWithNoReason = deprecatedWithNoReason, - deprecatedWithBlankReason = deprecatedWithBlankReason - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", mapOf( - "episode" to mapOf( - "kind" to "Variable", - "variableName" to "episode")), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "82ddc716280f1e2f832345d489f265f98280abf0d9a0257c09ca5bd3779dfd2f" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery(${'$'}episode: Episode) { - | hero(episode: ${'$'}episode) { - | __typename - | name - | deprecated - | deprecatedBool - | deprecatedWithNoReason - | deprecatedWithBlankReason - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/deprecation/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/deprecation/type/CustomType.java deleted file mode 100644 index df99ceb2f4b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/deprecation/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.deprecation.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/deprecation/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/deprecation/type/CustomType.kt deleted file mode 100644 index 782c21123c9..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/deprecation/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.deprecation.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/deprecation/type/Episode.java b/apollo-compiler/src/test/graphql/com/example/deprecation/type/Episode.java deleted file mode 100644 index 985088c9158..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/deprecation/type/Episode.java +++ /dev/null @@ -1,67 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.deprecation.type; - -import java.lang.Deprecated; -import java.lang.String; - -/** - * The episodes in the Star Wars trilogy - */ -public enum Episode { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - * @deprecated For test purpose only - */ - @Deprecated - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - * @deprecated For test purpose only - */ - @Deprecated - NEW_("new"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Episode(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Episode safeValueOf(String rawValue) { - for (Episode enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Episode.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/deprecation/type/Episode.kt b/apollo-compiler/src/test/graphql/com/example/deprecation/type/Episode.kt deleted file mode 100644 index a344dfb7429..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/deprecation/type/Episode.kt +++ /dev/null @@ -1,54 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.deprecation.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.Deprecated -import kotlin.String - -/** - * The episodes in the Star Wars trilogy - */ -enum class Episode( - override val rawValue: String -) : EnumValue { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - */ - @Deprecated(message = "For test purpose only") - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - */ - @Deprecated(message = "For test purpose only") - NEW("new"), - - /** - * Auto generated constant for unknown enum values - */ - UNKNOWN__("UNKNOWN__"); - - companion object { - fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: - UNKNOWN__ - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/TestOperation.graphql deleted file mode 100644 index 76488ac8b12..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/TestOperation.graphql +++ /dev/null @@ -1,15 +0,0 @@ -query TestQuery($withDetails: Boolean!, $skipHumanDetails: Boolean!) { - hero { - id - ... HeroDetails @include(if: $withDetails) @skip(if: $skipHumanDetails) - ... HumanDetails @include(if: $withDetails) - } -} - -fragment HeroDetails on Character { - name -} - -fragment HumanDetails on Human { - homePlanet -} diff --git a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/TestQuery.java deleted file mode 100644 index 935ed88624c..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/TestQuery.java +++ /dev/null @@ -1,527 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directive_with_fragment; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.directive_with_fragment.fragment.HeroDetails; -import com.example.directive_with_fragment.fragment.HumanDetails; -import com.example.directive_with_fragment.type.CustomType; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, TestQuery.Variables> { - public static final String OPERATION_ID = "e7ae0709b15d61fbba95a5c2e74b439fbed8ccf8d68fd389f4dd8250b55efeaf"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery($withDetails: Boolean!, $skipHumanDetails: Boolean!) {\n" - + " hero {\n" - + " __typename\n" - + " id\n" - + " ... HeroDetails @include(if: $withDetails) @skip(if: $skipHumanDetails)\n" - + " ... HumanDetails @include(if: $withDetails)\n" - + " }\n" - + "}\n" - + "fragment HeroDetails on Character {\n" - + " __typename\n" - + " name\n" - + "}\n" - + "fragment HumanDetails on Human {\n" - + " __typename\n" - + " homePlanet\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final TestQuery.Variables variables; - - public TestQuery(boolean withDetails, boolean skipHumanDetails) { - variables = new TestQuery.Variables(withDetails, skipHumanDetails); - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public TestQuery.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - private boolean withDetails; - - private boolean skipHumanDetails; - - Builder() { - } - - public Builder withDetails(boolean withDetails) { - this.withDetails = withDetails; - return this; - } - - public Builder skipHumanDetails(boolean skipHumanDetails) { - this.skipHumanDetails = skipHumanDetails; - return this; - } - - public TestQuery build() { - return new TestQuery(withDetails, skipHumanDetails); - } - } - - public static final class Variables extends Operation.Variables { - private final boolean withDetails; - - private final boolean skipHumanDetails; - - private final transient Map valueMap = new LinkedHashMap<>(); - - Variables(boolean withDetails, boolean skipHumanDetails) { - this.withDetails = withDetails; - this.skipHumanDetails = skipHumanDetails; - this.valueMap.put("withDetails", withDetails); - this.valueMap.put("skipHumanDetails", skipHumanDetails); - } - - public boolean withDetails() { - return withDetails; - } - - public boolean skipHumanDetails() { - return skipHumanDetails; - } - - @Override - public Map valueMap() { - return Collections.unmodifiableMap(valueMap); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - writer.writeBoolean("withDetails", withDetails); - writer.writeBoolean("skipHumanDetails", skipHumanDetails); - } - }; - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String id; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull String id, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.id = Utils.checkNotNull(id, "id == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The ID of the character - */ - public @NotNull String id() { - return this.id; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[1], id); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "id=" + id + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.id.equals(that.id) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= id.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final Optional heroDetails; - - final Optional humanDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@Nullable HeroDetails heroDetails, @Nullable HumanDetails humanDetails) { - this.heroDetails = Optional.fromNullable(heroDetails); - this.humanDetails = Optional.fromNullable(humanDetails); - } - - public Optional heroDetails() { - return this.heroDetails; - } - - public Optional humanDetails() { - return this.humanDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - final HeroDetails $heroDetails = heroDetails.isPresent() ? heroDetails.get() : null; - if ($heroDetails != null) { - writer.writeFragment($heroDetails.marshaller()); - } - final HumanDetails $humanDetails = humanDetails.isPresent() ? humanDetails.get() : null; - if ($humanDetails != null) { - writer.writeFragment($humanDetails.marshaller()); - } - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "heroDetails=" + heroDetails + ", " - + "humanDetails=" + humanDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.heroDetails.equals(that.heroDetails) - && this.humanDetails.equals(that.humanDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= heroDetails.hashCode(); - h *= 1000003; - h ^= humanDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.booleanCondition("withDetails", false), - ResponseField.Condition.booleanCondition("skipHumanDetails", true) - )), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.booleanCondition("withDetails", false), - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )) - }; - - final HeroDetails.Mapper heroDetailsFieldMapper = new HeroDetails.Mapper(); - - final HumanDetails.Mapper humanDetailsFieldMapper = new HumanDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HeroDetails heroDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HeroDetails read(ResponseReader reader) { - return heroDetailsFieldMapper.map(reader); - } - }); - final HumanDetails humanDetails = reader.readFragment($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public HumanDetails read(ResponseReader reader) { - return humanDetailsFieldMapper.map(reader); - } - }); - return new Fragments(heroDetails, humanDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Hero(__typename, id, fragments); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/TestQuery.kt deleted file mode 100644 index 6c0d0b96717..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/TestQuery.kt +++ /dev/null @@ -1,243 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directive_with_fragment - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.directive_with_fragment.fragment.HeroDetails -import com.example.directive_with_fragment.fragment.HumanDetails -import com.example.directive_with_fragment.type.CustomType -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.Map -import kotlin.jvm.Transient -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class TestQuery( - val withDetails: Boolean, - val skipHumanDetails: Boolean -) : Query { - @Transient - private val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = mutableMapOf().apply { - this["withDetails"] = this@TestQuery.withDetails - this["skipHumanDetails"] = this@TestQuery.skipHumanDetails - } - - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - writer.writeBoolean("withDetails", this@TestQuery.withDetails) - writer.writeBoolean("skipHumanDetails", this@TestQuery.skipHumanDetails) - } - } - - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = variables - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The ID of the character - */ - val id: String, - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeCustom(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField, this@Hero.id) - this@Hero.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val id = readCustomType(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField)!! - val fragments = Fragments(reader) - Hero( - __typename = __typename, - id = id, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val heroDetails: HeroDetails?, - val humanDetails: HumanDetails? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.heroDetails?.marshaller()) - writer.writeFragment(this@Fragments.humanDetails?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.booleanCondition("withDetails", false), - ResponseField.Condition.booleanCondition("skipHumanDetails", true) - )), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.booleanCondition("withDetails", false), - ResponseField.Condition.typeCondition(arrayOf("Human")) - )) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val heroDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - HeroDetails(reader) - } - val humanDetails = readFragment(RESPONSE_FIELDS[1]) { reader -> - HumanDetails(reader) - } - Fragments( - heroDetails = heroDetails, - humanDetails = humanDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "e7ae0709b15d61fbba95a5c2e74b439fbed8ccf8d68fd389f4dd8250b55efeaf" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery(${'$'}withDetails: Boolean!, ${'$'}skipHumanDetails: Boolean!) { - | hero { - | __typename - | id - | ... HeroDetails @include(if: ${'$'}withDetails) @skip(if: ${'$'}skipHumanDetails) - | ... HumanDetails @include(if: ${'$'}withDetails) - | } - |} - |fragment HeroDetails on Character { - | __typename - | name - |} - |fragment HumanDetails on Human { - | __typename - | homePlanet - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/fragment/HeroDetails.java b/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/fragment/HeroDetails.java deleted file mode 100644 index 5b65fab93af..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/fragment/HeroDetails.java +++ /dev/null @@ -1,116 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directive_with_fragment.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; - -public class HeroDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment HeroDetails on Character {\n" - + " __typename\n" - + " name\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HeroDetails(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HeroDetails{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HeroDetails) { - HeroDetails that = (HeroDetails) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public HeroDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new HeroDetails(__typename, name); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/fragment/HeroDetails.kt b/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/fragment/HeroDetails.kt deleted file mode 100644 index 858cf1c7efd..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/fragment/HeroDetails.kt +++ /dev/null @@ -1,56 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directive_with_fragment.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class HeroDetails( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HeroDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HeroDetails.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment HeroDetails on Character { - | __typename - | name - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HeroDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - HeroDetails( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/fragment/HumanDetails.java b/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/fragment/HumanDetails.java deleted file mode 100644 index dfc7c735cb8..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/fragment/HumanDetails.java +++ /dev/null @@ -1,118 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directive_with_fragment.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class HumanDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("homePlanet", "homePlanet", null, true, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment HumanDetails on Human {\n" - + " __typename\n" - + " homePlanet\n" - + "}"; - - final @NotNull String __typename; - - final Optional homePlanet; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HumanDetails(@NotNull String __typename, @Nullable String homePlanet) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.homePlanet = Optional.fromNullable(homePlanet); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The home planet of the human, or null if unknown - */ - public Optional homePlanet() { - return this.homePlanet; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], homePlanet.isPresent() ? homePlanet.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HumanDetails{" - + "__typename=" + __typename + ", " - + "homePlanet=" + homePlanet - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HumanDetails) { - HumanDetails that = (HumanDetails) o; - return this.__typename.equals(that.__typename) - && this.homePlanet.equals(that.homePlanet); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= homePlanet.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public HumanDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String homePlanet = reader.readString($responseFields[1]); - return new HumanDetails(__typename, homePlanet); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/fragment/HumanDetails.kt b/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/fragment/HumanDetails.kt deleted file mode 100644 index 5d06afcf686..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/fragment/HumanDetails.kt +++ /dev/null @@ -1,56 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directive_with_fragment.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class HumanDetails( - val __typename: String = "Human", - /** - * The home planet of the human, or null if unknown - */ - val homePlanet: String? -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HumanDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HumanDetails.homePlanet) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("homePlanet", "homePlanet", null, true, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment HumanDetails on Human { - | __typename - | homePlanet - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HumanDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val homePlanet = readString(RESPONSE_FIELDS[1]) - HumanDetails( - __typename = __typename, - homePlanet = homePlanet - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/type/CustomType.java deleted file mode 100644 index 81b1c5a11ba..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directive_with_fragment.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/type/CustomType.kt deleted file mode 100644 index 96c14e7714e..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directive_with_fragment/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directive_with_fragment.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directive_with_inline_fragment/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/directive_with_inline_fragment/TestOperation.graphql deleted file mode 100644 index 4c65e3bb048..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directive_with_inline_fragment/TestOperation.graphql +++ /dev/null @@ -1,16 +0,0 @@ -query TestQuery($withDetails: Boolean!, $skipHumanDetails: Boolean!) { - hero { - id - ... on Human @include(if: $withDetails) @skip(if: $skipHumanDetails) { - name - homePlanet - } - ... on Droid @include(if: $withDetails) { - name - primaryFunction - } - ... on Character @include(if: $withDetails) { - name - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directive_with_inline_fragment/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/directive_with_inline_fragment/TestQuery.java deleted file mode 100644 index 6b771bdb143..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directive_with_inline_fragment/TestQuery.java +++ /dev/null @@ -1,863 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directive_with_inline_fragment; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.directive_with_inline_fragment.type.CustomType; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, TestQuery.Variables> { - public static final String OPERATION_ID = "1fc50a1808d1ff72f74d821b563ee69df2fc04dd650e41d27d75d90d0413bd65"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery($withDetails: Boolean!, $skipHumanDetails: Boolean!) {\n" - + " hero {\n" - + " __typename\n" - + " id\n" - + " ... on Human @include(if: $withDetails) @skip(if: $skipHumanDetails) {\n" - + " name\n" - + " homePlanet\n" - + " }\n" - + " ... on Droid @include(if: $withDetails) {\n" - + " name\n" - + " primaryFunction\n" - + " }\n" - + " ... on Character @include(if: $withDetails) {\n" - + " name\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final TestQuery.Variables variables; - - public TestQuery(boolean withDetails, boolean skipHumanDetails) { - variables = new TestQuery.Variables(withDetails, skipHumanDetails); - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public TestQuery.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - private boolean withDetails; - - private boolean skipHumanDetails; - - Builder() { - } - - public Builder withDetails(boolean withDetails) { - this.withDetails = withDetails; - return this; - } - - public Builder skipHumanDetails(boolean skipHumanDetails) { - this.skipHumanDetails = skipHumanDetails; - return this; - } - - public TestQuery build() { - return new TestQuery(withDetails, skipHumanDetails); - } - } - - public static final class Variables extends Operation.Variables { - private final boolean withDetails; - - private final boolean skipHumanDetails; - - private final transient Map valueMap = new LinkedHashMap<>(); - - Variables(boolean withDetails, boolean skipHumanDetails) { - this.withDetails = withDetails; - this.skipHumanDetails = skipHumanDetails; - this.valueMap.put("withDetails", withDetails); - this.valueMap.put("skipHumanDetails", skipHumanDetails); - } - - public boolean withDetails() { - return withDetails; - } - - public boolean skipHumanDetails() { - return skipHumanDetails; - } - - @Override - public Map valueMap() { - return Collections.unmodifiableMap(valueMap); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - writer.writeBoolean("withDetails", withDetails); - writer.writeBoolean("skipHumanDetails", skipHumanDetails); - } - }; - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public interface Hero { - @NotNull String __typename(); - - /** - * The ID of the character - */ - @NotNull String id(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsHuman) { - return visitor.visit((AsHuman) this); - } else if (this instanceof AsDroid) { - return visitor.visit((AsDroid) this); - } else if (this instanceof AsCharacter) { - return visitor.visit((AsCharacter) this); - } else if (this instanceof AsCharacter1) { - return visitor.visit((AsCharacter1) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.booleanCondition("withDetails", false), - ResponseField.Condition.booleanCondition("skipHumanDetails", true), - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.booleanCondition("withDetails", false), - ResponseField.Condition.typeCondition(new String[] {"Droid"}) - )), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.booleanCondition("withDetails", false), - ResponseField.Condition.typeCondition(new String[] {"Droid", "Human"}) - )) - }; - - final AsHuman.Mapper asHumanFieldMapper = new AsHuman.Mapper(); - - final AsDroid.Mapper asDroidFieldMapper = new AsDroid.Mapper(); - - final AsCharacter.Mapper asCharacterFieldMapper = new AsCharacter.Mapper(); - - final AsCharacter1.Mapper asCharacter1FieldMapper = new AsCharacter1.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final AsHuman asHuman = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsHuman read(ResponseReader reader) { - return asHumanFieldMapper.map(reader); - } - }); - if (asHuman != null) { - return asHuman; - } - final AsDroid asDroid = reader.readFragment($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public AsDroid read(ResponseReader reader) { - return asDroidFieldMapper.map(reader); - } - }); - if (asDroid != null) { - return asDroid; - } - final AsCharacter asCharacter = reader.readFragment($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public AsCharacter read(ResponseReader reader) { - return asCharacterFieldMapper.map(reader); - } - }); - if (asCharacter != null) { - return asCharacter; - } - return asCharacter1FieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull Hero hero); - - T visit(@NotNull AsHuman asHuman); - - T visit(@NotNull AsDroid asDroid); - - T visit(@NotNull AsCharacter asCharacter); - - T visit(@NotNull AsCharacter1 asCharacter1); - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - public static class AsHuman implements Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forString("homePlanet", "homePlanet", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String id; - - final @NotNull String name; - - final Optional homePlanet; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsHuman(@NotNull String __typename, @NotNull String id, @NotNull String name, - @Nullable String homePlanet) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.id = Utils.checkNotNull(id, "id == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.homePlanet = Optional.fromNullable(homePlanet); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The ID of the human - */ - public @NotNull String id() { - return this.id; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - /** - * The home planet of the human, or null if unknown - */ - public Optional homePlanet() { - return this.homePlanet; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[1], id); - writer.writeString($responseFields[2], name); - writer.writeString($responseFields[3], homePlanet.isPresent() ? homePlanet.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsHuman{" - + "__typename=" + __typename + ", " - + "id=" + id + ", " - + "name=" + name + ", " - + "homePlanet=" + homePlanet - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsHuman) { - AsHuman that = (AsHuman) o; - return this.__typename.equals(that.__typename) - && this.id.equals(that.id) - && this.name.equals(that.name) - && this.homePlanet.equals(that.homePlanet); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= id.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= homePlanet.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsHuman map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]); - final String name = reader.readString($responseFields[2]); - final String homePlanet = reader.readString($responseFields[3]); - return new AsHuman(__typename, id, name, homePlanet); - } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - public static class AsDroid implements Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String id; - - final @NotNull String name; - - final Optional primaryFunction; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsDroid(@NotNull String __typename, @NotNull String id, @NotNull String name, - @Nullable String primaryFunction) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.id = Utils.checkNotNull(id, "id == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.primaryFunction = Optional.fromNullable(primaryFunction); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The ID of the droid - */ - public @NotNull String id() { - return this.id; - } - - /** - * What others call this droid - */ - public @NotNull String name() { - return this.name; - } - - /** - * This droid's primary function - */ - public Optional primaryFunction() { - return this.primaryFunction; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[1], id); - writer.writeString($responseFields[2], name); - writer.writeString($responseFields[3], primaryFunction.isPresent() ? primaryFunction.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsDroid{" - + "__typename=" + __typename + ", " - + "id=" + id + ", " - + "name=" + name + ", " - + "primaryFunction=" + primaryFunction - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsDroid) { - AsDroid that = (AsDroid) o; - return this.__typename.equals(that.__typename) - && this.id.equals(that.id) - && this.name.equals(that.name) - && this.primaryFunction.equals(that.primaryFunction); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= id.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= primaryFunction.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsDroid map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]); - final String name = reader.readString($responseFields[2]); - final String primaryFunction = reader.readString($responseFields[3]); - return new AsDroid(__typename, id, name, primaryFunction); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class AsCharacter implements Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String id; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter(@NotNull String __typename, @NotNull String id, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.id = Utils.checkNotNull(id, "id == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The ID of the character - */ - public @NotNull String id() { - return this.id; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[1], id); - writer.writeString($responseFields[2], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter{" - + "__typename=" + __typename + ", " - + "id=" + id + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter) { - AsCharacter that = (AsCharacter) o; - return this.__typename.equals(that.__typename) - && this.id.equals(that.id) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= id.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsCharacter map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]); - final String name = reader.readString($responseFields[2]); - return new AsCharacter(__typename, id, name); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class AsCharacter1 implements Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String id; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter1(@NotNull String __typename, @NotNull String id) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.id = Utils.checkNotNull(id, "id == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The ID of the character - */ - public @NotNull String id() { - return this.id; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[1], id); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter1{" - + "__typename=" + __typename + ", " - + "id=" + id - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter1) { - AsCharacter1 that = (AsCharacter1) o; - return this.__typename.equals(that.__typename) - && this.id.equals(that.id); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= id.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsCharacter1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]); - return new AsCharacter1(__typename, id); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directive_with_inline_fragment/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/directive_with_inline_fragment/TestQuery.kt deleted file mode 100644 index deb784e91cb..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directive_with_inline_fragment/TestQuery.kt +++ /dev/null @@ -1,378 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directive_with_inline_fragment - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.directive_with_inline_fragment.type.CustomType -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.Map -import kotlin.jvm.Transient -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class TestQuery( - val withDetails: Boolean, - val skipHumanDetails: Boolean -) : Query { - @Transient - private val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = mutableMapOf().apply { - this["withDetails"] = this@TestQuery.withDetails - this["skipHumanDetails"] = this@TestQuery.skipHumanDetails - } - - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - writer.writeBoolean("withDetails", this@TestQuery.withDetails) - writer.writeBoolean("skipHumanDetails", this@TestQuery.skipHumanDetails) - } - } - - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = variables - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - interface HeroCharacter { - fun marshaller(): ResponseFieldMarshaller - } - - /** - * A humanoid creature from the Star Wars universe - */ - data class AsHuman( - val __typename: String = "Human", - /** - * The ID of the human - */ - val id: String, - /** - * What this human calls themselves - */ - val name: String, - /** - * The home planet of the human, or null if unknown - */ - val homePlanet: String? - ) : HeroCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsHuman.__typename) - writer.writeCustom(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField, this@AsHuman.id) - writer.writeString(RESPONSE_FIELDS[2], this@AsHuman.name) - writer.writeString(RESPONSE_FIELDS[3], this@AsHuman.homePlanet) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forString("homePlanet", "homePlanet", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): AsHuman = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val id = readCustomType(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField)!! - val name = readString(RESPONSE_FIELDS[2])!! - val homePlanet = readString(RESPONSE_FIELDS[3]) - AsHuman( - __typename = __typename, - id = id, - name = name, - homePlanet = homePlanet - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - data class AsDroid( - val __typename: String = "Droid", - /** - * The ID of the droid - */ - val id: String, - /** - * What others call this droid - */ - val name: String, - /** - * This droid's primary function - */ - val primaryFunction: String? - ) : HeroCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsDroid.__typename) - writer.writeCustom(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField, this@AsDroid.id) - writer.writeString(RESPONSE_FIELDS[2], this@AsDroid.name) - writer.writeString(RESPONSE_FIELDS[3], this@AsDroid.primaryFunction) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): AsDroid = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val id = readCustomType(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField)!! - val name = readString(RESPONSE_FIELDS[2])!! - val primaryFunction = readString(RESPONSE_FIELDS[3]) - AsDroid( - __typename = __typename, - id = id, - name = name, - primaryFunction = primaryFunction - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class AsCharacter( - val __typename: String = "Character", - /** - * The ID of the character - */ - val id: String, - /** - * The name of the character - */ - val name: String - ) : HeroCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsCharacter.__typename) - writer.writeCustom(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField, this@AsCharacter.id) - writer.writeString(RESPONSE_FIELDS[2], this@AsCharacter.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): AsCharacter = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val id = readCustomType(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField)!! - val name = readString(RESPONSE_FIELDS[2])!! - AsCharacter( - __typename = __typename, - id = id, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The ID of the character - */ - val id: String, - val asHuman: AsHuman?, - val asDroid: AsDroid?, - val asCharacter: AsCharacter? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeCustom(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField, this@Hero.id) - writer.writeFragment(this@Hero.asHuman?.marshaller()) - writer.writeFragment(this@Hero.asDroid?.marshaller()) - writer.writeFragment(this@Hero.asCharacter?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.booleanCondition("withDetails", false), - ResponseField.Condition.booleanCondition("skipHumanDetails", true), - ResponseField.Condition.typeCondition(arrayOf("Human")) - )), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.booleanCondition("withDetails", false), - ResponseField.Condition.typeCondition(arrayOf("Droid")) - )), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.booleanCondition("withDetails", false), - ResponseField.Condition.typeCondition(arrayOf("Droid", "Human")) - )) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val id = readCustomType(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField)!! - val asHuman = readFragment(RESPONSE_FIELDS[2]) { reader -> - AsHuman(reader) - } - val asDroid = readFragment(RESPONSE_FIELDS[3]) { reader -> - AsDroid(reader) - } - val asCharacter = readFragment(RESPONSE_FIELDS[4]) { reader -> - AsCharacter(reader) - } - Hero( - __typename = __typename, - id = id, - asHuman = asHuman, - asDroid = asDroid, - asCharacter = asCharacter - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "1fc50a1808d1ff72f74d821b563ee69df2fc04dd650e41d27d75d90d0413bd65" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery(${'$'}withDetails: Boolean!, ${'$'}skipHumanDetails: Boolean!) { - | hero { - | __typename - | id - | ... on Human @include(if: ${'$'}withDetails) @skip(if: ${'$'}skipHumanDetails) { - | name - | homePlanet - | } - | ... on Droid @include(if: ${'$'}withDetails) { - | name - | primaryFunction - | } - | ... on Character @include(if: ${'$'}withDetails) { - | name - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directive_with_inline_fragment/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/directive_with_inline_fragment/type/CustomType.java deleted file mode 100644 index 5ab6e8df7a7..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directive_with_inline_fragment/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directive_with_inline_fragment.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directive_with_inline_fragment/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/directive_with_inline_fragment/type/CustomType.kt deleted file mode 100644 index cad9a08c5a8..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directive_with_inline_fragment/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directive_with_inline_fragment.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directives/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/directives/TestOperation.graphql deleted file mode 100644 index feac0ef5f87..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directives/TestOperation.graphql +++ /dev/null @@ -1,8 +0,0 @@ -query TestQuery($includeName: Boolean!, $skipFriends: Boolean!) @operationDirective(dummy0: "hello", dummy1: 0) { - hero { - name @include(if: $includeName) - friendsConnection @skip(if: $skipFriends) { - totalCount - } - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/graphql/com/example/directives/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/directives/TestQuery.java deleted file mode 100644 index 78049aae372..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directives/TestQuery.java +++ /dev/null @@ -1,513 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directives; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, TestQuery.Variables> { - public static final String OPERATION_ID = "c8809f9b337abc20e8dd014ef3baac57633a1a31a604a8663fe470459712113d"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery($includeName: Boolean!, $skipFriends: Boolean!) @operationDirective(dummy0: \"hello\", dummy1: 0) {\n" - + " hero {\n" - + " __typename\n" - + " name @include(if: $includeName)\n" - + " friendsConnection @skip(if: $skipFriends) {\n" - + " __typename\n" - + " totalCount\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final TestQuery.Variables variables; - - public TestQuery(boolean includeName, boolean skipFriends) { - variables = new TestQuery.Variables(includeName, skipFriends); - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public TestQuery.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - private boolean includeName; - - private boolean skipFriends; - - Builder() { - } - - public Builder includeName(boolean includeName) { - this.includeName = includeName; - return this; - } - - public Builder skipFriends(boolean skipFriends) { - this.skipFriends = skipFriends; - return this; - } - - public TestQuery build() { - return new TestQuery(includeName, skipFriends); - } - } - - public static final class Variables extends Operation.Variables { - private final boolean includeName; - - private final boolean skipFriends; - - private final transient Map valueMap = new LinkedHashMap<>(); - - Variables(boolean includeName, boolean skipFriends) { - this.includeName = includeName; - this.skipFriends = skipFriends; - this.valueMap.put("includeName", includeName); - this.valueMap.put("skipFriends", skipFriends); - } - - public boolean includeName() { - return includeName; - } - - public boolean skipFriends() { - return skipFriends; - } - - @Override - public Map valueMap() { - return Collections.unmodifiableMap(valueMap); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - writer.writeBoolean("includeName", includeName); - writer.writeBoolean("skipFriends", skipFriends); - } - }; - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, true, Arrays.asList( - ResponseField.Condition.booleanCondition("includeName", false) - )), - ResponseField.forObject("friendsConnection", "friendsConnection", null, true, Arrays.asList( - ResponseField.Condition.booleanCondition("skipFriends", true) - )) - }; - - final @NotNull String __typename; - - final Optional name; - - final Optional friendsConnection; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @Nullable String name, - @Nullable FriendsConnection friendsConnection) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Optional.fromNullable(name); - this.friendsConnection = Optional.fromNullable(friendsConnection); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public Optional name() { - return this.name; - } - - /** - * The friends of the character exposed as a connection with edges - */ - public Optional friendsConnection() { - return this.friendsConnection; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name.isPresent() ? name.get() : null); - writer.writeObject($responseFields[2], friendsConnection.isPresent() ? friendsConnection.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection.Mapper friendsConnectionFieldMapper = new FriendsConnection.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final FriendsConnection friendsConnection = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection read(ResponseReader reader) { - return friendsConnectionFieldMapper.map(reader); - } - }); - return new Hero(__typename, name, friendsConnection); - } - } - } - - /** - * A connection object for a character's friends - */ - public static class FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection(@NotNull String __typename, @Nullable Integer totalCount) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.fromNullable(totalCount); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional totalCount() { - return this.totalCount; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection) { - FriendsConnection that = (FriendsConnection) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public FriendsConnection map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - return new FriendsConnection(__typename, totalCount); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directives/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/directives/TestQuery.kt deleted file mode 100644 index 6d45e92aadf..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directives/TestQuery.kt +++ /dev/null @@ -1,240 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directives - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.Map -import kotlin.jvm.Transient -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class TestQuery( - val includeName: Boolean, - val skipFriends: Boolean -) : Query { - @Transient - private val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = mutableMapOf().apply { - this["includeName"] = this@TestQuery.includeName - this["skipFriends"] = this@TestQuery.skipFriends - } - - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - writer.writeBoolean("includeName", this@TestQuery.includeName) - writer.writeBoolean("skipFriends", this@TestQuery.skipFriends) - } - } - - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = variables - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A connection object for a character's friends - */ - data class FriendsConnection( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection.totalCount) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - FriendsConnection( - __typename = __typename, - totalCount = totalCount - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String?, - /** - * The friends of the character exposed as a connection with edges - */ - val friendsConnection: FriendsConnection? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeObject(RESPONSE_FIELDS[2], this@Hero.friendsConnection?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, true, listOf( - ResponseField.Condition.booleanCondition("includeName", false) - )), - ResponseField.forObject("friendsConnection", "friendsConnection", null, true, listOf( - ResponseField.Condition.booleanCondition("skipFriends", true) - )) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1]) - val friendsConnection = readObject(RESPONSE_FIELDS[2]) { reader -> - FriendsConnection(reader) - } - Hero( - __typename = __typename, - name = name, - friendsConnection = friendsConnection - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "c8809f9b337abc20e8dd014ef3baac57633a1a31a604a8663fe470459712113d" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery(${'$'}includeName: Boolean!, ${'$'}skipFriends: Boolean!) @operationDirective(dummy0: "hello", dummy1: 0) { - | hero { - | __typename - | name @include(if: ${'$'}includeName) - | friendsConnection @skip(if: ${'$'}skipFriends) { - | __typename - | totalCount - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directives/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/directives/type/CustomType.java deleted file mode 100644 index e58af26a2d0..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directives/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directives.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/directives/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/directives/type/CustomType.kt deleted file mode 100644 index a0f43893510..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/directives/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.directives.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/empty/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/empty/TestOperation.graphql deleted file mode 100644 index c71224647c5..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/empty/TestOperation.graphql +++ /dev/null @@ -1,5 +0,0 @@ -#query TestQuery { -# hero { -# name -# } -#} diff --git a/apollo-compiler/src/test/graphql/com/example/empty/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/empty/type/CustomType.java deleted file mode 100644 index ae8b39ca1b7..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/empty/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.empty.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/empty/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/empty/type/CustomType.kt deleted file mode 100644 index f00a19e796a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/empty/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.empty.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/enum_type/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/enum_type/TestOperation.graphql deleted file mode 100644 index e07d2278a5d..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/enum_type/TestOperation.graphql +++ /dev/null @@ -1,7 +0,0 @@ -query TestQuery { - hero { - name - appearsIn - firstAppearsIn - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/graphql/com/example/enum_type/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/enum_type/TestQuery.java deleted file mode 100644 index 25cfbceb0bf..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/enum_type/TestQuery.java +++ /dev/null @@ -1,384 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.enum_type; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.enum_type.type.Episode; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "2c07c7e101fe2bc0f8f43bbbeea320dad58fe57996d7f88872eaf50e4a448924"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " appearsIn\n" - + " firstAppearsIn\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forList("appearsIn", "appearsIn", null, false, Collections.emptyList()), - ResponseField.forString("firstAppearsIn", "firstAppearsIn", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull List appearsIn; - - final @NotNull Episode firstAppearsIn; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull String name, @NotNull List appearsIn, - @NotNull Episode firstAppearsIn) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.appearsIn = Utils.checkNotNull(appearsIn, "appearsIn == null"); - this.firstAppearsIn = Utils.checkNotNull(firstAppearsIn, "firstAppearsIn == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The movies this character appears in - */ - public @NotNull List appearsIn() { - return this.appearsIn; - } - - /** - * The movie this character first appears in - */ - public @NotNull Episode firstAppearsIn() { - return this.firstAppearsIn; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeList($responseFields[2], appearsIn, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeString(((Episode) item).rawValue()); - } - } - }); - writer.writeString($responseFields[3], firstAppearsIn.rawValue()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "appearsIn=" + appearsIn + ", " - + "firstAppearsIn=" + firstAppearsIn - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.appearsIn.equals(that.appearsIn) - && this.firstAppearsIn.equals(that.firstAppearsIn); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= appearsIn.hashCode(); - h *= 1000003; - h ^= firstAppearsIn.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final List appearsIn = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Episode read(ResponseReader.ListItemReader listItemReader) { - return Episode.safeValueOf(listItemReader.readString()); - } - }); - final String firstAppearsInStr = reader.readString($responseFields[3]); - final Episode firstAppearsIn; - if (firstAppearsInStr != null) { - firstAppearsIn = Episode.safeValueOf(firstAppearsInStr); - } else { - firstAppearsIn = null; - } - return new Hero(__typename, name, appearsIn, firstAppearsIn); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/enum_type/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/enum_type/TestQuery.kt deleted file mode 100644 index 7742e21925b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/enum_type/TestQuery.kt +++ /dev/null @@ -1,193 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.enum_type - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.enum_type.type.Episode -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The movies this character appears in - */ - val appearsIn: List, - /** - * The movie this character first appears in - */ - val firstAppearsIn: Episode - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeList(RESPONSE_FIELDS[2], this@Hero.appearsIn) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeString(value?.rawValue)} - } - writer.writeString(RESPONSE_FIELDS[3], this@Hero.firstAppearsIn.rawValue) - } - - fun appearsInFilterNotNull(): List = appearsIn.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forList("appearsIn", "appearsIn", null, false, null), - ResponseField.forEnum("firstAppearsIn", "firstAppearsIn", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val appearsIn = readList(RESPONSE_FIELDS[2]) { reader -> - Episode.safeValueOf(reader.readString()) - }!! - val firstAppearsIn = Episode.safeValueOf(readString(RESPONSE_FIELDS[3])!!) - Hero( - __typename = __typename, - name = name, - appearsIn = appearsIn, - firstAppearsIn = firstAppearsIn - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "2c07c7e101fe2bc0f8f43bbbeea320dad58fe57996d7f88872eaf50e4a448924" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | name - | appearsIn - | firstAppearsIn - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/enum_type/schema.sdl b/apollo-compiler/src/test/graphql/com/example/enum_type/schema.sdl deleted file mode 100644 index c70da385385..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/enum_type/schema.sdl +++ /dev/null @@ -1,215 +0,0 @@ -"""A character from the Star Wars universe""" -interface Character { - """The movies this character appears in""" - appearsIn: [Episode]! - - """The date character was born.""" - birthDate: Date! - - """The date character was born.""" - deathDate: Date! - - """The movie this character first appears in""" - firstAppearsIn: Episode! - - """The friends of the character, or an empty list if they have none""" - friends: [Character] - - """The friends of the character exposed as a connection with edges""" - friendsConnection(first: Int, after: ID): FriendsConnection! - - """The ID of the character""" - id: ID! - - """The name of the character""" - name: String! -} - -"""The input object sent when passing in a color""" -input ColorInput { - red: Int! - green: Int! - blue: Int! -} - -"""The `Date` scalar type represents date format.""" -scalar Date - -"""An autonomous mechanical character in the Star Wars universe""" -type Droid implements Character { - """The movies this droid appears in""" - appearsIn: [Episode]! - - """The date droid was created.""" - birthDate: Date! - - """The droid character was decomissioned.""" - deathDate: Date! - - """The movie this character first appears in""" - firstAppearsIn: Episode! - - """This droid's friends, or an empty list if they have none""" - friends: [Character] - - """The friends of the droid exposed as a connection with edges""" - friendsConnection(first: Int, after: ID): FriendsConnection! - - """The ID of the droid""" - id: ID! - - """What others call this droid""" - name: String! - - """This droid's primary function""" - primaryFunction: String -} - -"""The episodes in the Star Wars trilogy (with special symbol $S)""" -enum Episode { - """ - Star Wars Episode IV: A New Hope, released in 1977. (with special symbol $S) - """ - NEWHOPE - - """Star Wars Episode V: The Empire Strikes Back, released in 1980.""" - EMPIRE - - """ - Star Wars Episode VI: Return of the Jedi, released in 1983. (JEDI in lowercase) - """ - jedi -} - -"""A connection object for a character's friends""" -type FriendsConnection { - """The edges for each of the character's friends.""" - edges: [FriendsEdge] - - """A list of the friends, as a convenience when edges are not needed.""" - friends: [Character] - - """Information for paginating this connection""" - pageInfo: PageInfo! - - """The total number of friends""" - totalCount: Int -} - -"""An edge object for a character's friends""" -type FriendsEdge { - """A cursor used for pagination""" - cursor: ID! - - """The character represented by this friendship edge""" - node: Character -} - -"""A humanoid creature from the Star Wars universe""" -type Human implements Character { - """The movies this human appears in""" - appearsIn: [Episode]! - - """The date character was born.""" - birthDate: Date! - - """The date character was born.""" - deathDate: Date! - - """The movie this character first appears in""" - firstAppearsIn: Episode! - - """This human's friends, or an empty list if they have none""" - friends: [Character] - - """The friends of the human exposed as a connection with edges""" - friendsConnection(first: Int, after: ID): FriendsConnection! - - """Height in the preferred unit, default is meters""" - height(unit: LengthUnit = METER): Float - - """The home planet of the human, or null if unknown""" - homePlanet: String - - """The ID of the human""" - id: ID! - - """Mass in kilograms, or null if unknown""" - mass: Float - - """What this human calls themselves""" - name: String! - - """A list of starships this person has piloted, or an empty list if none""" - starships: [Starship] -} - -"""Units of height""" -enum LengthUnit { - """The standard unit around the world""" - METER - - """Primarily used in the United States""" - FOOT -} - -"""The mutation type, represents all updates we can make to our data""" -type Mutation { - createReview(episode: Episode, review: ReviewInput!): Review -} - -"""Information for paginating this connection""" -type PageInfo { - endCursor: ID - hasNextPage: Boolean! - startCursor: ID -} - -""" -The query type, represents all of the entry points into our object graph -""" -type Query { - character(id: ID!): Character - droid(id: ID!): Droid - hero(episode: Episode): Character - human(id: ID!): Human - reviews(episode: Episode!): [Review] - search(text: String): [SearchResult] - starship(id: ID!): Starship -} - -"""Represents a review for a movie""" -type Review { - """Comment about the movie""" - commentary: String - - """The number of stars this review gave, 1-5""" - stars: Int! -} - -"""The input object sent when someone is creating a new review""" -input ReviewInput { - """0-5 stars""" - stars: Int! - - """Comment about the movie, optional""" - commentary: String - - """Favorite color, optional""" - favoriteColor: ColorInput -} - -union SearchResult = Human | Droid | Starship - -type Starship { - coordinates: [[Float!]!] - - """The ID of the starship""" - id: ID! - - """Length of the starship, along the longest axis""" - length(unit: LengthUnit = METER): Float - - """The name of the starship""" - name: String! -} diff --git a/apollo-compiler/src/test/graphql/com/example/enum_type/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/enum_type/type/CustomType.java deleted file mode 100644 index 4e77f1204cf..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/enum_type/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.enum_type.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/enum_type/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/enum_type/type/CustomType.kt deleted file mode 100644 index 21af90f687a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/enum_type/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.enum_type.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/enum_type/type/Episode.java b/apollo-compiler/src/test/graphql/com/example/enum_type/type/Episode.java deleted file mode 100644 index af4b629dd1e..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/enum_type/type/Episode.java +++ /dev/null @@ -1,52 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.enum_type.type; - -import java.lang.String; - -/** - * The episodes in the Star Wars trilogy (with special symbol $S) - */ -public enum Episode { - /** - * Star Wars Episode IV: A New Hope, released in 1977. (with special symbol $S) - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. (JEDI in lowercase) - */ - JEDI("jedi"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Episode(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Episode safeValueOf(String rawValue) { - for (Episode enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Episode.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/enum_type/type/Episode.kt b/apollo-compiler/src/test/graphql/com/example/enum_type/type/Episode.kt deleted file mode 100644 index 14b83e465ab..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/enum_type/type/Episode.kt +++ /dev/null @@ -1,41 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.enum_type.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.String - -/** - * The episodes in the Star Wars trilogy (with special symbol $S) - */ -enum class Episode( - override val rawValue: String -) : EnumValue { - /** - * Star Wars Episode IV: A New Hope, released in 1977. (with special symbol $S) - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. (JEDI in lowercase) - */ - JEDI("jedi"), - - /** - * Auto generated constant for unknown enum values - */ - UNKNOWN__("UNKNOWN__"); - - companion object { - fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: - UNKNOWN__ - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/TestOperation.graphql deleted file mode 100644 index a9f6f15bb7b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/TestOperation.graphql +++ /dev/null @@ -1,17 +0,0 @@ -query TestQuery { - hero { - ...HeroDetails - } -} - -fragment HeroDetails on Character { - name - friendsConnection { - totalCount - edges { - node { - name - } - } - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/TestQuery.java deleted file mode 100644 index 6025f919d80..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/TestQuery.java +++ /dev/null @@ -1,422 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_friends_connection; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.fragment_friends_connection.fragment.HeroDetails; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "bf3304288b337985db99d4a206f0c91e2e4db84bc882cf7cf404da3df053f5e9"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " ...HeroDetails\n" - + " }\n" - + "}\n" - + "fragment HeroDetails on Character {\n" - + " __typename\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @NotNull HeroDetails heroDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@NotNull HeroDetails heroDetails) { - this.heroDetails = Utils.checkNotNull(heroDetails, "heroDetails == null"); - } - - public @NotNull HeroDetails heroDetails() { - return this.heroDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeFragment(heroDetails.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "heroDetails=" + heroDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.heroDetails.equals(that.heroDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= heroDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Collections.emptyList()) - }; - - final HeroDetails.Mapper heroDetailsFieldMapper = new HeroDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HeroDetails heroDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HeroDetails read(ResponseReader reader) { - return heroDetailsFieldMapper.map(reader); - } - }); - return new Fragments(heroDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Hero(__typename, fragments); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/TestQuery.kt deleted file mode 100644 index 06e6f708be0..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/TestQuery.kt +++ /dev/null @@ -1,205 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_friends_connection - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.fragment_friends_connection.fragment.HeroDetails -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - this@Hero.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val fragments = Fragments(reader) - Hero( - __typename = __typename, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val heroDetails: HeroDetails - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.heroDetails.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", null) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val heroDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - HeroDetails(reader) - }!! - Fragments( - heroDetails = heroDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "bf3304288b337985db99d4a206f0c91e2e4db84bc882cf7cf404da3df053f5e9" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | ...HeroDetails - | } - |} - |fragment HeroDetails on Character { - | __typename - | name - | friendsConnection { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/fragment/HeroDetails.java b/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/fragment/HeroDetails.java deleted file mode 100644 index 663f591990b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/fragment/HeroDetails.java +++ /dev/null @@ -1,482 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_friends_connection.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class HeroDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment HeroDetails on Character {\n" - + " __typename\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " }\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull FriendsConnection friendsConnection; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HeroDetails(@NotNull String __typename, @NotNull String name, - @NotNull FriendsConnection friendsConnection) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The friends of the character exposed as a connection with edges - */ - public @NotNull FriendsConnection friendsConnection() { - return this.friendsConnection; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeObject($responseFields[2], friendsConnection.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HeroDetails{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HeroDetails) { - HeroDetails that = (HeroDetails) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection.Mapper friendsConnectionFieldMapper = new FriendsConnection.Mapper(); - - @Override - public HeroDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final FriendsConnection friendsConnection = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection read(ResponseReader reader) { - return friendsConnectionFieldMapper.map(reader); - } - }); - return new HeroDetails(__typename, name, friendsConnection); - } - } - - /** - * A connection object for a character's friends - */ - public static class FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - final Optional> edges; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection(@NotNull String __typename, @Nullable Integer totalCount, - @Nullable List edges) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.fromNullable(totalCount); - this.edges = Optional.fromNullable(edges); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional totalCount() { - return this.totalCount; - } - - /** - * The edges for each of the character's friends. - */ - public Optional> edges() { - return this.edges; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - writer.writeList($responseFields[2], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount + ", " - + "edges=" + edges - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection) { - FriendsConnection that = (FriendsConnection) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount) - && this.edges.equals(that.edges); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge.Mapper edgeFieldMapper = new Edge.Mapper(); - - @Override - public FriendsConnection map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - final List edges = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Edge read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge read(ResponseReader reader) { - return edgeFieldMapper.map(reader); - } - }); - } - }); - return new FriendsConnection(__typename, totalCount, edges); - } - } - } - - /** - * An edge object for a character's friends - */ - public static class Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge(@NotNull String __typename, @Nullable Node node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.fromNullable(node); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The character represented by this friendship edge - */ - public Optional node() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge) { - Edge that = (Edge) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Node.Mapper nodeFieldMapper = new Node.Mapper(); - - @Override - public Edge map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node read(ResponseReader reader) { - return nodeFieldMapper.map(reader); - } - }); - return new Edge(__typename, node); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node) { - Node that = (Node) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Node map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Node(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/fragment/HeroDetails.kt b/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/fragment/HeroDetails.kt deleted file mode 100644 index e70ca2e8cd1..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/fragment/HeroDetails.kt +++ /dev/null @@ -1,203 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_friends_connection.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class HeroDetails( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The friends of the character exposed as a connection with edges - */ - val friendsConnection: FriendsConnection -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HeroDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HeroDetails.name) - writer.writeObject(RESPONSE_FIELDS[2], this@HeroDetails.friendsConnection.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment HeroDetails on Character { - | __typename - | name - | friendsConnection { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | } - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HeroDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friendsConnection = readObject(RESPONSE_FIELDS[2]) { reader -> - FriendsConnection(reader) - }!! - HeroDetails( - __typename = __typename, - name = name, - friendsConnection = friendsConnection - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - /** - * A character from the Star Wars universe - */ - data class Node( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Node.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Node( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An edge object for a character's friends - */ - data class Edge( - val __typename: String = "FriendsEdge", - /** - * The character represented by this friendship edge - */ - val node: Node? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node(reader) - } - Edge( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int?, - /** - * The edges for each of the character's friends. - */ - val edges: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection.totalCount) - writer.writeList(RESPONSE_FIELDS[2], this@FriendsConnection.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null), - ResponseField.forList("edges", "edges", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - val edges = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Edge(reader) - } - } - FriendsConnection( - __typename = __typename, - totalCount = totalCount, - edges = edges - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/type/CustomType.java deleted file mode 100644 index 41f50ef04cb..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_friends_connection.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/type/CustomType.kt deleted file mode 100644 index 9d8eb4f455c..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_friends_connection/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_friends_connection.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/AllStarships.java b/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/AllStarships.java deleted file mode 100644 index 8e83d789ece..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/AllStarships.java +++ /dev/null @@ -1,658 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_in_fragment; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.fragment_in_fragment.fragment.StarshipFragment; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class AllStarships implements Query, Operation.Variables> { - public static final String OPERATION_ID = "1296a4041eb330b2810e426f9347f76c6df3a969ab7f7e56f250bf9c6a07982e"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query AllStarships {\n" - + " allStarships(first: 7) {\n" - + " __typename\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " ...starshipFragment\n" - + " }\n" - + " }\n" - + " }\n" - + "}\n" - + "fragment starshipFragment on Starship {\n" - + " __typename\n" - + " id\n" - + " name\n" - + " pilotConnection {\n" - + " __typename\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " ...pilotFragment\n" - + " }\n" - + " }\n" - + " }\n" - + "}\n" - + "fragment pilotFragment on Person {\n" - + " __typename\n" - + " name\n" - + " homeworld {\n" - + " __typename\n" - + " ...planetFragment\n" - + " }\n" - + "}\n" - + "fragment planetFragment on Planet {\n" - + " __typename\n" - + " name\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "AllStarships"; - } - }; - - private final Operation.Variables variables; - - public AllStarships() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(AllStarships.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public AllStarships build() { - return new AllStarships(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("allStarships", "allStarships", new UnmodifiableMapBuilder(1) - .put("first", 7) - .build(), true, Collections.emptyList()) - }; - - final Optional allStarships; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable AllStarships1 allStarships) { - this.allStarships = Optional.fromNullable(allStarships); - } - - public Optional allStarships() { - return this.allStarships; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], allStarships.isPresent() ? allStarships.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "allStarships=" + allStarships - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.allStarships.equals(that.allStarships); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= allStarships.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final AllStarships1.Mapper allStarships1FieldMapper = new AllStarships1.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final AllStarships1 allStarships = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AllStarships1 read(ResponseReader reader) { - return allStarships1FieldMapper.map(reader); - } - }); - return new Data(allStarships); - } - } - } - - /** - * A connection to a list of items. - */ - public static class AllStarships1 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional> edges; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AllStarships1(@NotNull String __typename, @Nullable List edges) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.edges = Optional.fromNullable(edges); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * A list of edges. - */ - public Optional> edges() { - return this.edges; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeList($responseFields[1], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AllStarships1{" - + "__typename=" + __typename + ", " - + "edges=" + edges - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AllStarships1) { - AllStarships1 that = (AllStarships1) o; - return this.__typename.equals(that.__typename) - && this.edges.equals(that.edges); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge.Mapper edgeFieldMapper = new Edge.Mapper(); - - @Override - public AllStarships1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final List edges = reader.readList($responseFields[1], new ResponseReader.ListReader() { - @Override - public Edge read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge read(ResponseReader reader) { - return edgeFieldMapper.map(reader); - } - }); - } - }); - return new AllStarships1(__typename, edges); - } - } - } - - /** - * An edge in a connection. - */ - public static class Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge(@NotNull String __typename, @Nullable Node node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.fromNullable(node); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The item at the end of the edge - */ - public Optional node() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge) { - Edge that = (Edge) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Node.Mapper nodeFieldMapper = new Node.Mapper(); - - @Override - public Edge map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node read(ResponseReader reader) { - return nodeFieldMapper.map(reader); - } - }); - return new Edge(__typename, node); - } - } - } - - /** - * A single transport craft that has hyperdrive capability. - */ - public static class Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node(@NotNull String __typename, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node{" - + "__typename=" + __typename + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node) { - Node that = (Node) o; - return this.__typename.equals(that.__typename) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @NotNull StarshipFragment starshipFragment; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@NotNull StarshipFragment starshipFragment) { - this.starshipFragment = Utils.checkNotNull(starshipFragment, "starshipFragment == null"); - } - - public @NotNull StarshipFragment starshipFragment() { - return this.starshipFragment; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeFragment(starshipFragment.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "starshipFragment=" + starshipFragment - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.starshipFragment.equals(that.starshipFragment); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= starshipFragment.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Collections.emptyList()) - }; - - final StarshipFragment.Mapper starshipFragmentFieldMapper = new StarshipFragment.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final StarshipFragment starshipFragment = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public StarshipFragment read(ResponseReader reader) { - return starshipFragmentFieldMapper.map(reader); - } - }); - return new Fragments(starshipFragment); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Node map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Node(__typename, fragments); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/AllStarships.kt b/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/AllStarships.kt deleted file mode 100644 index a4c201476be..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/AllStarships.kt +++ /dev/null @@ -1,306 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_in_fragment - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.fragment_in_fragment.fragment.StarshipFragment -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class AllStarships : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A single transport craft that has hyperdrive capability. - */ - data class Node( - val __typename: String = "Starship", - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node.__typename) - this@Node.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val fragments = Fragments(reader) - Node( - __typename = __typename, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val starshipFragment: StarshipFragment - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.starshipFragment.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", null) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val starshipFragment = readFragment(RESPONSE_FIELDS[0]) { reader -> - StarshipFragment(reader) - }!! - Fragments( - starshipFragment = starshipFragment - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * An edge in a connection. - */ - data class Edge( - val __typename: String = "StarshipsEdge", - /** - * The item at the end of the edge - */ - val node: Node? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node(reader) - } - Edge( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection to a list of items. - */ - data class AllStarships( - val __typename: String = "StarshipsConnection", - /** - * A list of edges. - */ - val edges: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AllStarships.__typename) - writer.writeList(RESPONSE_FIELDS[1], this@AllStarships.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forList("edges", "edges", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): AllStarships = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val edges = readList(RESPONSE_FIELDS[1]) { reader -> - reader.readObject { reader -> - Edge(reader) - } - } - AllStarships( - __typename = __typename, - edges = edges - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val allStarships: AllStarships? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.allStarships?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("allStarships", "allStarships", mapOf( - "first" to "7"), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val allStarships = readObject(RESPONSE_FIELDS[0]) { reader -> - AllStarships(reader) - } - Data( - allStarships = allStarships - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "1296a4041eb330b2810e426f9347f76c6df3a969ab7f7e56f250bf9c6a07982e" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query AllStarships { - | allStarships(first: 7) { - | __typename - | edges { - | __typename - | node { - | __typename - | ...starshipFragment - | } - | } - | } - |} - |fragment starshipFragment on Starship { - | __typename - | id - | name - | pilotConnection { - | __typename - | edges { - | __typename - | node { - | __typename - | ...pilotFragment - | } - | } - | } - |} - |fragment pilotFragment on Person { - | __typename - | name - | homeworld { - | __typename - | ...planetFragment - | } - |} - |fragment planetFragment on Planet { - | __typename - | name - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "AllStarships" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/TestOperation.graphql deleted file mode 100644 index 641c8824896..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/TestOperation.graphql +++ /dev/null @@ -1,32 +0,0 @@ -query AllStarships { - allStarships(first: 7) { - edges { - node { - ...starshipFragment - } - } - } -} - -fragment starshipFragment on Starship { - id - name - pilotConnection { - edges { - node { - ...pilotFragment - } - } - } -} - -fragment pilotFragment on Person { - name - homeworld { - ...planetFragment - } -} - -fragment planetFragment on Planet { - name -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/PilotFragment.java b/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/PilotFragment.java deleted file mode 100644 index 90440500be9..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/PilotFragment.java +++ /dev/null @@ -1,321 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_in_fragment.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class PilotFragment implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, true, Collections.emptyList()), - ResponseField.forObject("homeworld", "homeworld", null, true, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment pilotFragment on Person {\n" - + " __typename\n" - + " name\n" - + " homeworld {\n" - + " __typename\n" - + " ...planetFragment\n" - + " }\n" - + "}"; - - final @NotNull String __typename; - - final Optional name; - - final Optional homeworld; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public PilotFragment(@NotNull String __typename, @Nullable String name, - @Nullable Homeworld homeworld) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Optional.fromNullable(name); - this.homeworld = Optional.fromNullable(homeworld); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of this person. - */ - public Optional name() { - return this.name; - } - - /** - * A planet that this person was born on or inhabits. - */ - public Optional homeworld() { - return this.homeworld; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name.isPresent() ? name.get() : null); - writer.writeObject($responseFields[2], homeworld.isPresent() ? homeworld.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "PilotFragment{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "homeworld=" + homeworld - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof PilotFragment) { - PilotFragment that = (PilotFragment) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.homeworld.equals(that.homeworld); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= homeworld.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Homeworld.Mapper homeworldFieldMapper = new Homeworld.Mapper(); - - @Override - public PilotFragment map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final Homeworld homeworld = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public Homeworld read(ResponseReader reader) { - return homeworldFieldMapper.map(reader); - } - }); - return new PilotFragment(__typename, name, homeworld); - } - } - - /** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ - public static class Homeworld { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Homeworld(@NotNull String __typename, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Homeworld{" - + "__typename=" + __typename + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Homeworld) { - Homeworld that = (Homeworld) o; - return this.__typename.equals(that.__typename) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @NotNull PlanetFragment planetFragment; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@NotNull PlanetFragment planetFragment) { - this.planetFragment = Utils.checkNotNull(planetFragment, "planetFragment == null"); - } - - public @NotNull PlanetFragment planetFragment() { - return this.planetFragment; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeFragment(planetFragment.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "planetFragment=" + planetFragment - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.planetFragment.equals(that.planetFragment); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= planetFragment.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Collections.emptyList()) - }; - - final PlanetFragment.Mapper planetFragmentFieldMapper = new PlanetFragment.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final PlanetFragment planetFragment = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public PlanetFragment read(ResponseReader reader) { - return planetFragmentFieldMapper.map(reader); - } - }); - return new Fragments(planetFragment); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Homeworld map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Homeworld(__typename, fragments); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/PilotFragment.kt b/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/PilotFragment.kt deleted file mode 100644 index 29df80588e7..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/PilotFragment.kt +++ /dev/null @@ -1,129 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_in_fragment.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class PilotFragment( - val __typename: String = "Person", - /** - * The name of this person. - */ - val name: String?, - /** - * A planet that this person was born on or inhabits. - */ - val homeworld: Homeworld? -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@PilotFragment.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@PilotFragment.name) - writer.writeObject(RESPONSE_FIELDS[2], this@PilotFragment.homeworld?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, true, null), - ResponseField.forObject("homeworld", "homeworld", null, true, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment pilotFragment on Person { - | __typename - | name - | homeworld { - | __typename - | ...planetFragment - | } - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): PilotFragment = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1]) - val homeworld = readObject(RESPONSE_FIELDS[2]) { reader -> - Homeworld(reader) - } - PilotFragment( - __typename = __typename, - name = name, - homeworld = homeworld - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - /** - * A large mass, planet or planetoid in the Star Wars Universe, at the time of - * 0 ABY. - */ - data class Homeworld( - val __typename: String = "Planet", - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Homeworld.__typename) - this@Homeworld.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Homeworld = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val fragments = Fragments(reader) - Homeworld( - __typename = __typename, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val planetFragment: PlanetFragment - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.planetFragment.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", null) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val planetFragment = readFragment(RESPONSE_FIELDS[0]) { reader -> - PlanetFragment(reader) - }!! - Fragments( - planetFragment = planetFragment - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/PlanetFragment.java b/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/PlanetFragment.java deleted file mode 100644 index 9e095c95670..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/PlanetFragment.java +++ /dev/null @@ -1,118 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_in_fragment.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class PlanetFragment implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, true, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment planetFragment on Planet {\n" - + " __typename\n" - + " name\n" - + "}"; - - final @NotNull String __typename; - - final Optional name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public PlanetFragment(@NotNull String __typename, @Nullable String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Optional.fromNullable(name); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of this planet. - */ - public Optional name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name.isPresent() ? name.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "PlanetFragment{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof PlanetFragment) { - PlanetFragment that = (PlanetFragment) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public PlanetFragment map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new PlanetFragment(__typename, name); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/PlanetFragment.kt b/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/PlanetFragment.kt deleted file mode 100644 index eb0747c4db8..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/PlanetFragment.kt +++ /dev/null @@ -1,56 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_in_fragment.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class PlanetFragment( - val __typename: String = "Planet", - /** - * The name of this planet. - */ - val name: String? -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@PlanetFragment.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@PlanetFragment.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, true, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment planetFragment on Planet { - | __typename - | name - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): PlanetFragment = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1]) - PlanetFragment( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/StarshipFragment.java b/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/StarshipFragment.java deleted file mode 100644 index 843e928ce1a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/StarshipFragment.java +++ /dev/null @@ -1,557 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_in_fragment.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import com.example.fragment_in_fragment.type.CustomType; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class StarshipFragment implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()), - ResponseField.forString("name", "name", null, true, Collections.emptyList()), - ResponseField.forObject("pilotConnection", "pilotConnection", null, true, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment starshipFragment on Starship {\n" - + " __typename\n" - + " id\n" - + " name\n" - + " pilotConnection {\n" - + " __typename\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " ...pilotFragment\n" - + " }\n" - + " }\n" - + " }\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String id; - - final Optional name; - - final Optional pilotConnection; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public StarshipFragment(@NotNull String __typename, @NotNull String id, @Nullable String name, - @Nullable PilotConnection pilotConnection) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.id = Utils.checkNotNull(id, "id == null"); - this.name = Optional.fromNullable(name); - this.pilotConnection = Optional.fromNullable(pilotConnection); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The ID of an object - */ - public @NotNull String id() { - return this.id; - } - - /** - * The name of this starship. The common name, such as "Death Star". - */ - public Optional name() { - return this.name; - } - - public Optional pilotConnection() { - return this.pilotConnection; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[1], id); - writer.writeString($responseFields[2], name.isPresent() ? name.get() : null); - writer.writeObject($responseFields[3], pilotConnection.isPresent() ? pilotConnection.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "StarshipFragment{" - + "__typename=" + __typename + ", " - + "id=" + id + ", " - + "name=" + name + ", " - + "pilotConnection=" + pilotConnection - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof StarshipFragment) { - StarshipFragment that = (StarshipFragment) o; - return this.__typename.equals(that.__typename) - && this.id.equals(that.id) - && this.name.equals(that.name) - && this.pilotConnection.equals(that.pilotConnection); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= id.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= pilotConnection.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final PilotConnection.Mapper pilotConnectionFieldMapper = new PilotConnection.Mapper(); - - @Override - public StarshipFragment map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]); - final String name = reader.readString($responseFields[2]); - final PilotConnection pilotConnection = reader.readObject($responseFields[3], new ResponseReader.ObjectReader() { - @Override - public PilotConnection read(ResponseReader reader) { - return pilotConnectionFieldMapper.map(reader); - } - }); - return new StarshipFragment(__typename, id, name, pilotConnection); - } - } - - /** - * A connection to a list of items. - */ - public static class PilotConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional> edges; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public PilotConnection(@NotNull String __typename, @Nullable List edges) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.edges = Optional.fromNullable(edges); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * A list of edges. - */ - public Optional> edges() { - return this.edges; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeList($responseFields[1], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "PilotConnection{" - + "__typename=" + __typename + ", " - + "edges=" + edges - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof PilotConnection) { - PilotConnection that = (PilotConnection) o; - return this.__typename.equals(that.__typename) - && this.edges.equals(that.edges); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge.Mapper edgeFieldMapper = new Edge.Mapper(); - - @Override - public PilotConnection map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final List edges = reader.readList($responseFields[1], new ResponseReader.ListReader() { - @Override - public Edge read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge read(ResponseReader reader) { - return edgeFieldMapper.map(reader); - } - }); - } - }); - return new PilotConnection(__typename, edges); - } - } - } - - /** - * An edge in a connection. - */ - public static class Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge(@NotNull String __typename, @Nullable Node node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.fromNullable(node); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The item at the end of the edge - */ - public Optional node() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge) { - Edge that = (Edge) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Node.Mapper nodeFieldMapper = new Node.Mapper(); - - @Override - public Edge map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node read(ResponseReader reader) { - return nodeFieldMapper.map(reader); - } - }); - return new Edge(__typename, node); - } - } - } - - /** - * An individual person or character within the Star Wars universe. - */ - public static class Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node(@NotNull String __typename, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node{" - + "__typename=" + __typename + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node) { - Node that = (Node) o; - return this.__typename.equals(that.__typename) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @NotNull PilotFragment pilotFragment; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@NotNull PilotFragment pilotFragment) { - this.pilotFragment = Utils.checkNotNull(pilotFragment, "pilotFragment == null"); - } - - public @NotNull PilotFragment pilotFragment() { - return this.pilotFragment; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeFragment(pilotFragment.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "pilotFragment=" + pilotFragment - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.pilotFragment.equals(that.pilotFragment); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= pilotFragment.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Collections.emptyList()) - }; - - final PilotFragment.Mapper pilotFragmentFieldMapper = new PilotFragment.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final PilotFragment pilotFragment = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public PilotFragment read(ResponseReader reader) { - return pilotFragmentFieldMapper.map(reader); - } - }); - return new Fragments(pilotFragment); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Node map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Node(__typename, fragments); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/StarshipFragment.kt b/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/StarshipFragment.kt deleted file mode 100644 index 8be6e460327..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/fragment/StarshipFragment.kt +++ /dev/null @@ -1,224 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_in_fragment.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.example.fragment_in_fragment.type.CustomType -import kotlin.Array -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class StarshipFragment( - val __typename: String = "Starship", - /** - * The ID of an object - */ - val id: String, - /** - * The name of this starship. The common name, such as "Death Star". - */ - val name: String?, - val pilotConnection: PilotConnection? -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@StarshipFragment.__typename) - writer.writeCustom(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField, - this@StarshipFragment.id) - writer.writeString(RESPONSE_FIELDS[2], this@StarshipFragment.name) - writer.writeObject(RESPONSE_FIELDS[3], this@StarshipFragment.pilotConnection?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, null), - ResponseField.forString("name", "name", null, true, null), - ResponseField.forObject("pilotConnection", "pilotConnection", null, true, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment starshipFragment on Starship { - | __typename - | id - | name - | pilotConnection { - | __typename - | edges { - | __typename - | node { - | __typename - | ...pilotFragment - | } - | } - | } - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): StarshipFragment = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val id = readCustomType(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField)!! - val name = readString(RESPONSE_FIELDS[2]) - val pilotConnection = readObject(RESPONSE_FIELDS[3]) { reader -> - PilotConnection(reader) - } - StarshipFragment( - __typename = __typename, - id = id, - name = name, - pilotConnection = pilotConnection - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - /** - * An individual person or character within the Star Wars universe. - */ - data class Node( - val __typename: String = "Person", - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node.__typename) - this@Node.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val fragments = Fragments(reader) - Node( - __typename = __typename, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val pilotFragment: PilotFragment - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.pilotFragment.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", null) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val pilotFragment = readFragment(RESPONSE_FIELDS[0]) { reader -> - PilotFragment(reader) - }!! - Fragments( - pilotFragment = pilotFragment - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * An edge in a connection. - */ - data class Edge( - val __typename: String = "StarshipPilotsEdge", - /** - * The item at the end of the edge - */ - val node: Node? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node(reader) - } - Edge( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection to a list of items. - */ - data class PilotConnection( - val __typename: String = "StarshipPilotsConnection", - /** - * A list of edges. - */ - val edges: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@PilotConnection.__typename) - writer.writeList(RESPONSE_FIELDS[1], this@PilotConnection.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forList("edges", "edges", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): PilotConnection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val edges = readList(RESPONSE_FIELDS[1]) { reader -> - reader.readObject { reader -> - Edge(reader) - } - } - PilotConnection( - __typename = __typename, - edges = edges - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/schema.sdl b/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/schema.sdl deleted file mode 100644 index 2b7bff04478..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/schema.sdl +++ /dev/null @@ -1,1167 +0,0 @@ -schema { - query: Root -} - -"""A single film.""" -type Film implements Node { - characterConnection(after: String, first: Int, before: String, last: Int): FilmCharactersConnection - - """The ISO 8601 date format of the time that this resource was created.""" - created: String - - """The name of the director of this film.""" - director: String - - """The ISO 8601 date format of the time that this resource was edited.""" - edited: String - - """The episode number of this film.""" - episodeID: Int - - """The ID of an object""" - id: ID! - - """The opening paragraphs at the beginning of this film.""" - openingCrawl: String - planetConnection(after: String, first: Int, before: String, last: Int): FilmPlanetsConnection - - """The name(s) of the producer(s) of this film.""" - producers: [String] - - """The ISO 8601 date format of film release at original creator country.""" - releaseDate: String - speciesConnection(after: String, first: Int, before: String, last: Int): FilmSpeciesConnection - starshipConnection(after: String, first: Int, before: String, last: Int): FilmStarshipsConnection - - """The title of this film.""" - title: String - vehicleConnection(after: String, first: Int, before: String, last: Int): FilmVehiclesConnection -} - -"""A connection to a list of items.""" -type FilmCharactersConnection { - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - characters: [Person] - - """A list of edges.""" - edges: [FilmCharactersEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type FilmCharactersEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Person -} - -"""A connection to a list of items.""" -type FilmPlanetsConnection { - """A list of edges.""" - edges: [FilmPlanetsEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - planets: [Planet] - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type FilmPlanetsEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Planet -} - -"""A connection to a list of items.""" -type FilmsConnection { - """A list of edges.""" - edges: [FilmsEdge] - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - films: [Film] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type FilmsEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Film -} - -"""A connection to a list of items.""" -type FilmSpeciesConnection { - """A list of edges.""" - edges: [FilmSpeciesEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - species: [Species] - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type FilmSpeciesEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Species -} - -"""A connection to a list of items.""" -type FilmStarshipsConnection { - """A list of edges.""" - edges: [FilmStarshipsEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - starships: [Starship] - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type FilmStarshipsEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Starship -} - -"""A connection to a list of items.""" -type FilmVehiclesConnection { - """A list of edges.""" - edges: [FilmVehiclesEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - vehicles: [Vehicle] -} - -"""An edge in a connection.""" -type FilmVehiclesEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Vehicle -} - -"""An object with an ID""" -interface Node { - """The id of the object.""" - id: ID! -} - -"""Information about pagination in a connection.""" -type PageInfo { - """When paginating forwards, the cursor to continue.""" - endCursor: String - - """When paginating forwards, are there more items?""" - hasNextPage: Boolean! - - """When paginating backwards, are there more items?""" - hasPreviousPage: Boolean! - - """When paginating backwards, the cursor to continue.""" - startCursor: String -} - -"""A connection to a list of items.""" -type PeopleConnection { - """A list of edges.""" - edges: [PeopleEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - people: [Person] - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type PeopleEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Person -} - -"""An individual person or character within the Star Wars universe.""" -type Person implements Node { - """ - The birth year of the person, using the in-universe standard of BBY or ABY - - Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is - a battle that occurs at the end of Star Wars episode IV: A New Hope. - """ - birthYear: String - - """The ISO 8601 date format of the time that this resource was created.""" - created: String - - """The ISO 8601 date format of the time that this resource was edited.""" - edited: String - - """ - The eye color of this person. Will be "unknown" if not known or "n/a" if the - person does not have an eye. - """ - eyeColor: String - filmConnection(after: String, first: Int, before: String, last: Int): PersonFilmsConnection - - """ - The gender of this person. Either "Male", "Female" or "unknown", - "n/a" if the person does not have a gender. - """ - gender: String - - """ - The hair color of this person. Will be "unknown" if not known or "n/a" if the - person does not have hair. - """ - hairColor: String - - """The height of the person in centimeters.""" - height: Int - - """A planet that this person was born on or inhabits.""" - homeworld: Planet - - """The ID of an object""" - id: ID! - - """The mass of the person in kilograms.""" - mass: Int - - """The name of this person.""" - name: String - - """The skin color of this person.""" - skinColor: String - - """The species that this person belongs to, or null if unknown.""" - species: Species - starshipConnection(after: String, first: Int, before: String, last: Int): PersonStarshipsConnection - vehicleConnection(after: String, first: Int, before: String, last: Int): PersonVehiclesConnection -} - -"""A connection to a list of items.""" -type PersonFilmsConnection { - """A list of edges.""" - edges: [PersonFilmsEdge] - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - films: [Film] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type PersonFilmsEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Film -} - -"""A connection to a list of items.""" -type PersonStarshipsConnection { - """A list of edges.""" - edges: [PersonStarshipsEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - starships: [Starship] - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type PersonStarshipsEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Starship -} - -"""A connection to a list of items.""" -type PersonVehiclesConnection { - """A list of edges.""" - edges: [PersonVehiclesEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - vehicles: [Vehicle] -} - -"""An edge in a connection.""" -type PersonVehiclesEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Vehicle -} - -""" -A large mass, planet or planetoid in the Star Wars Universe, at the time of -0 ABY. -""" -type Planet implements Node { - """The climates of this planet.""" - climates: [String] - - """The ISO 8601 date format of the time that this resource was created.""" - created: String - - """The diameter of this planet in kilometers.""" - diameter: Int - - """The ISO 8601 date format of the time that this resource was edited.""" - edited: String - filmConnection(after: String, first: Int, before: String, last: Int): PlanetFilmsConnection - - """ - A number denoting the gravity of this planet, where "1" is normal or 1 standard - G. "2" is twice or 2 standard Gs. "0.5" is half or 0.5 standard Gs. - """ - gravity: String - - """The ID of an object""" - id: ID! - - """The name of this planet.""" - name: String - - """ - The number of standard days it takes for this planet to complete a single orbit - of its local star. - """ - orbitalPeriod: Int - - """The average population of sentient beings inhabiting this planet.""" - population: Int - residentConnection(after: String, first: Int, before: String, last: Int): PlanetResidentsConnection - - """ - The number of standard hours it takes for this planet to complete a single - rotation on its axis. - """ - rotationPeriod: Int - - """ - The percentage of the planet surface that is naturally occuring water or bodies - of water. - """ - surfaceWater: Float - - """The terrains of this planet.""" - terrains: [String] -} - -"""A connection to a list of items.""" -type PlanetFilmsConnection { - """A list of edges.""" - edges: [PlanetFilmsEdge] - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - films: [Film] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type PlanetFilmsEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Film -} - -"""A connection to a list of items.""" -type PlanetResidentsConnection { - """A list of edges.""" - edges: [PlanetResidentsEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - residents: [Person] - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type PlanetResidentsEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Person -} - -"""A connection to a list of items.""" -type PlanetsConnection { - """A list of edges.""" - edges: [PlanetsEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - planets: [Planet] - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type PlanetsEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Planet -} - -type Root { - allFilms(after: String, first: Int, before: String, last: Int): FilmsConnection - allPeople(after: String, first: Int, before: String, last: Int): PeopleConnection - allPlanets(after: String, first: Int, before: String, last: Int): PlanetsConnection - allSpecies(after: String, first: Int, before: String, last: Int): SpeciesConnection - allStarships(after: String, first: Int, before: String, last: Int): StarshipsConnection - allVehicles(after: String, first: Int, before: String, last: Int): VehiclesConnection - film(id: ID, filmID: ID): Film - - """Fetches an object given its ID""" - node( - """The ID of an object""" - id: ID! - ): Node - person(id: ID, personID: ID): Person - planet(id: ID, planetID: ID): Planet - species(id: ID, speciesID: ID): Species - starship(id: ID, starshipID: ID): Starship - vehicle(id: ID, vehicleID: ID): Vehicle -} - -"""A type of person or character within the Star Wars Universe.""" -type Species implements Node { - """The average height of this species in centimeters.""" - averageHeight: Float - - """The average lifespan of this species in years, null if unknown.""" - averageLifespan: Int - - """The classification of this species, such as "mammal" or "reptile".""" - classification: String - - """The ISO 8601 date format of the time that this resource was created.""" - created: String - - """The designation of this species, such as "sentient".""" - designation: String - - """The ISO 8601 date format of the time that this resource was edited.""" - edited: String - - """ - Common eye colors for this species, null if this species does not typically - have eyes. - """ - eyeColors: [String] - filmConnection(after: String, first: Int, before: String, last: Int): SpeciesFilmsConnection - - """ - Common hair colors for this species, null if this species does not typically - have hair. - """ - hairColors: [String] - - """A planet that this species originates from.""" - homeworld: Planet - - """The ID of an object""" - id: ID! - - """The language commonly spoken by this species.""" - language: String - - """The name of this species.""" - name: String - personConnection(after: String, first: Int, before: String, last: Int): SpeciesPeopleConnection - - """ - Common skin colors for this species, null if this species does not typically - have skin. - """ - skinColors: [String] -} - -"""A connection to a list of items.""" -type SpeciesConnection { - """A list of edges.""" - edges: [SpeciesEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - species: [Species] - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type SpeciesEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Species -} - -"""A connection to a list of items.""" -type SpeciesFilmsConnection { - """A list of edges.""" - edges: [SpeciesFilmsEdge] - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - films: [Film] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type SpeciesFilmsEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Film -} - -"""A connection to a list of items.""" -type SpeciesPeopleConnection { - """A list of edges.""" - edges: [SpeciesPeopleEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - people: [Person] - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type SpeciesPeopleEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Person -} - -"""A single transport craft that has hyperdrive capability.""" -type Starship implements Node { - """The maximum number of kilograms that this starship can transport.""" - cargoCapacity: Float - - """ - The maximum length of time that this starship can provide consumables for its - entire crew without having to resupply. - """ - consumables: String - - """The cost of this starship new, in galactic credits.""" - costInCredits: Float - - """The ISO 8601 date format of the time that this resource was created.""" - created: String - - """The number of personnel needed to run or pilot this starship.""" - crew: String - - """The ISO 8601 date format of the time that this resource was edited.""" - edited: String - filmConnection(after: String, first: Int, before: String, last: Int): StarshipFilmsConnection - - """The class of this starships hyperdrive.""" - hyperdriveRating: Float - - """The ID of an object""" - id: ID! - - """The length of this starship in meters.""" - length: Float - - """The manufacturers of this starship.""" - manufacturers: [String] - - """ - The maximum speed of this starship in atmosphere. null if this starship is - incapable of atmosphering flight. - """ - maxAtmospheringSpeed: Int - - """ - The Maximum number of Megalights this starship can travel in a standard hour. - A "Megalight" is a standard unit of distance and has never been defined before - within the Star Wars universe. This figure is only really useful for measuring - the difference in speed of starships. We can assume it is similar to AU, the - distance between our Sun (Sol) and Earth. - """ - MGLT: Int - - """ - The model or official name of this starship. Such as "T-65 X-wing" or "DS-1 - Orbital Battle Station". - """ - model: String - - """The name of this starship. The common name, such as "Death Star".""" - name: String - - """The number of non-essential people this starship can transport.""" - passengers: String - pilotConnection(after: String, first: Int, before: String, last: Int): StarshipPilotsConnection - - """ - The class of this starship, such as "Starfighter" or "Deep Space Mobile - Battlestation" - """ - starshipClass: String -} - -"""A connection to a list of items.""" -type StarshipFilmsConnection { - """A list of edges.""" - edges: [StarshipFilmsEdge] - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - films: [Film] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type StarshipFilmsEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Film -} - -"""A connection to a list of items.""" -type StarshipPilotsConnection { - """A list of edges.""" - edges: [StarshipPilotsEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - pilots: [Person] - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type StarshipPilotsEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Person -} - -"""A connection to a list of items.""" -type StarshipsConnection { - """A list of edges.""" - edges: [StarshipsEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - starships: [Starship] - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type StarshipsEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Starship -} - -"""A single transport craft that does not have hyperdrive capability""" -type Vehicle implements Node { - """The maximum number of kilograms that this vehicle can transport.""" - cargoCapacity: Int - - """ - The maximum length of time that this vehicle can provide consumables for its - entire crew without having to resupply. - """ - consumables: String - - """The cost of this vehicle new, in Galactic Credits.""" - costInCredits: Int - - """The ISO 8601 date format of the time that this resource was created.""" - created: String - - """The number of personnel needed to run or pilot this vehicle.""" - crew: String - - """The ISO 8601 date format of the time that this resource was edited.""" - edited: String - filmConnection(after: String, first: Int, before: String, last: Int): VehicleFilmsConnection - - """The ID of an object""" - id: ID! - - """The length of this vehicle in meters.""" - length: Float - - """The manufacturers of this vehicle.""" - manufacturers: [String] - - """The maximum speed of this vehicle in atmosphere.""" - maxAtmospheringSpeed: Int - - """ - The model or official name of this vehicle. Such as "All-Terrain Attack - Transport". - """ - model: String - - """ - The name of this vehicle. The common name, such as "Sand Crawler" or "Speeder - bike". - """ - name: String - - """The number of non-essential people this vehicle can transport.""" - passengers: String - pilotConnection(after: String, first: Int, before: String, last: Int): VehiclePilotsConnection - - """The class of this vehicle, such as "Wheeled" or "Repulsorcraft".""" - vehicleClass: String -} - -"""A connection to a list of items.""" -type VehicleFilmsConnection { - """A list of edges.""" - edges: [VehicleFilmsEdge] - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - films: [Film] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type VehicleFilmsEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Film -} - -"""A connection to a list of items.""" -type VehiclePilotsConnection { - """A list of edges.""" - edges: [VehiclePilotsEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - pilots: [Person] - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int -} - -"""An edge in a connection.""" -type VehiclePilotsEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Person -} - -"""A connection to a list of items.""" -type VehiclesConnection { - """A list of edges.""" - edges: [VehiclesEdge] - - """Information to aid in pagination.""" - pageInfo: PageInfo! - - """ - A count of the total number of objects in this connection, ignoring pagination. - This allows a client to fetch the first five objects by passing "5" as the - argument to "first", then fetch the total count so it could display "5 of 83", - for example. - """ - totalCount: Int - - """ - A list of all of the objects returned in the connection. This is a convenience - field provided for quickly exploring the API; rather than querying for - "{ edges { node } }" when no edge data is needed, this field can be be used - instead. Note that when clients like Relay need to fetch the "cursor" field on - the edge to enable efficient pagination, this shortcut cannot be used, and the - full "{ edges { node } }" version should be used instead. - """ - vehicles: [Vehicle] -} - -"""An edge in a connection.""" -type VehiclesEdge { - """A cursor for use in pagination""" - cursor: String! - - """The item at the end of the edge""" - node: Vehicle -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/type/CustomType.java deleted file mode 100644 index f0eacb41d35..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_in_fragment.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/type/CustomType.kt deleted file mode 100644 index b9fbfd0440f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_in_fragment/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_in_fragment.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_package_name/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/fragment_package_name/TestOperation.graphql deleted file mode 100644 index 15fbfb81b5e..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_package_name/TestOperation.graphql +++ /dev/null @@ -1,9 +0,0 @@ -fragment HeroDetails on Character { - name -} - -query TestQuery { - hero { - ...HeroDetails - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/TestQuery.java deleted file mode 100644 index cbc5743b317..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/TestQuery.java +++ /dev/null @@ -1,411 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_package_name.another; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.fragment_package_name.another.fragment.HeroDetails; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "e260c178778c0f5f21feb122b2a06e55726fae44d2aebf4a7b28f5a218f6373b"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " ...HeroDetails\n" - + " }\n" - + "}\n" - + "fragment HeroDetails on Character {\n" - + " __typename\n" - + " name\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @NotNull HeroDetails heroDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@NotNull HeroDetails heroDetails) { - this.heroDetails = Utils.checkNotNull(heroDetails, "heroDetails == null"); - } - - public @NotNull HeroDetails heroDetails() { - return this.heroDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeFragment(heroDetails.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "heroDetails=" + heroDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.heroDetails.equals(that.heroDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= heroDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Collections.emptyList()) - }; - - final HeroDetails.Mapper heroDetailsFieldMapper = new HeroDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HeroDetails heroDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HeroDetails read(ResponseReader reader) { - return heroDetailsFieldMapper.map(reader); - } - }); - return new Fragments(heroDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Hero(__typename, fragments); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/TestQuery.kt deleted file mode 100644 index dc0f9f10574..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/TestQuery.kt +++ /dev/null @@ -1,194 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_package_name.another - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.fragment_package_name.another.fragment.HeroDetails -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - this@Hero.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val fragments = Fragments(reader) - Hero( - __typename = __typename, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val heroDetails: HeroDetails - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.heroDetails.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", null) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val heroDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - HeroDetails(reader) - }!! - Fragments( - heroDetails = heroDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "e260c178778c0f5f21feb122b2a06e55726fae44d2aebf4a7b28f5a218f6373b" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | ...HeroDetails - | } - |} - |fragment HeroDetails on Character { - | __typename - | name - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/fragment/HeroDetails.java b/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/fragment/HeroDetails.java deleted file mode 100644 index 1172f527c4a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/fragment/HeroDetails.java +++ /dev/null @@ -1,116 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_package_name.another.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; - -public class HeroDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment HeroDetails on Character {\n" - + " __typename\n" - + " name\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HeroDetails(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HeroDetails{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HeroDetails) { - HeroDetails that = (HeroDetails) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public HeroDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new HeroDetails(__typename, name); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/fragment/HeroDetails.kt b/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/fragment/HeroDetails.kt deleted file mode 100644 index 87a854b881a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/fragment/HeroDetails.kt +++ /dev/null @@ -1,56 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_package_name.another.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class HeroDetails( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HeroDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HeroDetails.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment HeroDetails on Character { - | __typename - | name - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HeroDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - HeroDetails( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/type/CustomType.java deleted file mode 100644 index 1d61cec4a91..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_package_name.another.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/type/CustomType.kt deleted file mode 100644 index c6aeacd1d39..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_package_name/another/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_package_name.another.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/TestOperation.graphql deleted file mode 100644 index cb810c86d5b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/TestOperation.graphql +++ /dev/null @@ -1,24 +0,0 @@ -query TestQuery { - hero { - __typename - ...HeroDetails - ...HumanDetails - } -} - -fragment HeroDetails on Character { - __typename - name - ...CharacterDetails -} - -fragment HumanDetails on Human { - __typename - name - ...CharacterDetails -} - -fragment CharacterDetails on Character { - name - birthDate -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/TestQuery.java deleted file mode 100644 index 6d1ea3bbd59..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/TestQuery.java +++ /dev/null @@ -1,451 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_used_twice; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.fragment_used_twice.fragment.HeroDetails; -import com.example.fragment_used_twice.fragment.HumanDetails; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "0717d3202204df80ffc6546a0b8dd179f40c29c183ebbea21e7c16ae27e0d056"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " ...HeroDetails\n" - + " ...HumanDetails\n" - + " }\n" - + "}\n" - + "fragment HeroDetails on Character {\n" - + " __typename\n" - + " name\n" - + " ...CharacterDetails\n" - + "}\n" - + "fragment HumanDetails on Human {\n" - + " __typename\n" - + " name\n" - + " ...CharacterDetails\n" - + "}\n" - + "fragment CharacterDetails on Character {\n" - + " __typename\n" - + " name\n" - + " birthDate\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @NotNull HeroDetails heroDetails; - - final Optional humanDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@NotNull HeroDetails heroDetails, @Nullable HumanDetails humanDetails) { - this.heroDetails = Utils.checkNotNull(heroDetails, "heroDetails == null"); - this.humanDetails = Optional.fromNullable(humanDetails); - } - - public @NotNull HeroDetails heroDetails() { - return this.heroDetails; - } - - public Optional humanDetails() { - return this.humanDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeFragment(heroDetails.marshaller()); - final HumanDetails $humanDetails = humanDetails.isPresent() ? humanDetails.get() : null; - if ($humanDetails != null) { - writer.writeFragment($humanDetails.marshaller()); - } - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "heroDetails=" + heroDetails + ", " - + "humanDetails=" + humanDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.heroDetails.equals(that.heroDetails) - && this.humanDetails.equals(that.humanDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= heroDetails.hashCode(); - h *= 1000003; - h ^= humanDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Collections.emptyList()), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )) - }; - - final HeroDetails.Mapper heroDetailsFieldMapper = new HeroDetails.Mapper(); - - final HumanDetails.Mapper humanDetailsFieldMapper = new HumanDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HeroDetails heroDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HeroDetails read(ResponseReader reader) { - return heroDetailsFieldMapper.map(reader); - } - }); - final HumanDetails humanDetails = reader.readFragment($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public HumanDetails read(ResponseReader reader) { - return humanDetailsFieldMapper.map(reader); - } - }); - return new Fragments(heroDetails, humanDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Hero(__typename, fragments); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/TestQuery.kt deleted file mode 100644 index 5f21480a7f2..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/TestQuery.kt +++ /dev/null @@ -1,216 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_used_twice - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.fragment_used_twice.fragment.HeroDetails -import com.example.fragment_used_twice.fragment.HumanDetails -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - this@Hero.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val fragments = Fragments(reader) - Hero( - __typename = __typename, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val heroDetails: HeroDetails, - val humanDetails: HumanDetails? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.heroDetails.marshaller()) - writer.writeFragment(this@Fragments.humanDetails?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val heroDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - HeroDetails(reader) - }!! - val humanDetails = readFragment(RESPONSE_FIELDS[1]) { reader -> - HumanDetails(reader) - } - Fragments( - heroDetails = heroDetails, - humanDetails = humanDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "0717d3202204df80ffc6546a0b8dd179f40c29c183ebbea21e7c16ae27e0d056" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | ...HeroDetails - | ...HumanDetails - | } - |} - |fragment HeroDetails on Character { - | __typename - | name - | ...CharacterDetails - |} - |fragment HumanDetails on Human { - | __typename - | name - | ...CharacterDetails - |} - |fragment CharacterDetails on Character { - | __typename - | name - | birthDate - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/CharacterDetails.java b/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/CharacterDetails.java deleted file mode 100644 index b3842f874eb..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/CharacterDetails.java +++ /dev/null @@ -1,136 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_used_twice.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import com.example.fragment_used_twice.type.CustomType; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; - -public class CharacterDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forCustomType("birthDate", "birthDate", null, false, CustomType.DATE, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment CharacterDetails on Character {\n" - + " __typename\n" - + " name\n" - + " birthDate\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull Object birthDate; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public CharacterDetails(@NotNull String __typename, @NotNull String name, - @NotNull Object birthDate) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.birthDate = Utils.checkNotNull(birthDate, "birthDate == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The date character was born. - */ - public @NotNull Object birthDate() { - return this.birthDate; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[2], birthDate); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "CharacterDetails{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "birthDate=" + birthDate - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof CharacterDetails) { - CharacterDetails that = (CharacterDetails) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.birthDate.equals(that.birthDate); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= birthDate.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public CharacterDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final Object birthDate = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[2]); - return new CharacterDetails(__typename, name, birthDate); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/CharacterDetails.kt b/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/CharacterDetails.kt deleted file mode 100644 index 4f77ab99cbc..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/CharacterDetails.kt +++ /dev/null @@ -1,68 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_used_twice.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.example.fragment_used_twice.type.CustomType -import kotlin.Any -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class CharacterDetails( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The date character was born. - */ - val birthDate: Any -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@CharacterDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@CharacterDetails.name) - writer.writeCustom(RESPONSE_FIELDS[2] as ResponseField.CustomTypeField, - this@CharacterDetails.birthDate) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forCustomType("birthDate", "birthDate", null, false, CustomType.DATE, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment CharacterDetails on Character { - | __typename - | name - | birthDate - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): CharacterDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val birthDate = readCustomType(RESPONSE_FIELDS[2] as ResponseField.CustomTypeField)!! - CharacterDetails( - __typename = __typename, - name = name, - birthDate = birthDate - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/HeroDetails.java b/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/HeroDetails.java deleted file mode 100644 index b9ab1b76fb3..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/HeroDetails.java +++ /dev/null @@ -1,214 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_used_twice.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; - -public class HeroDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment HeroDetails on Character {\n" - + " __typename\n" - + " name\n" - + " ...CharacterDetails\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HeroDetails(@NotNull String __typename, @NotNull String name, - @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HeroDetails{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HeroDetails) { - HeroDetails that = (HeroDetails) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @NotNull CharacterDetails characterDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@NotNull CharacterDetails characterDetails) { - this.characterDetails = Utils.checkNotNull(characterDetails, "characterDetails == null"); - } - - public @NotNull CharacterDetails characterDetails() { - return this.characterDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeFragment(characterDetails.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "characterDetails=" + characterDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.characterDetails.equals(that.characterDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= characterDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Collections.emptyList()) - }; - - final CharacterDetails.Mapper characterDetailsFieldMapper = new CharacterDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final CharacterDetails characterDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public CharacterDetails read(ResponseReader reader) { - return characterDetailsFieldMapper.map(reader); - } - }); - return new Fragments(characterDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public HeroDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new HeroDetails(__typename, name, fragments); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/HeroDetails.kt b/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/HeroDetails.kt deleted file mode 100644 index 817ab70cbfc..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/HeroDetails.kt +++ /dev/null @@ -1,88 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_used_twice.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class HeroDetails( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - val fragments: Fragments -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HeroDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HeroDetails.name) - this@HeroDetails.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment HeroDetails on Character { - | __typename - | name - | ...CharacterDetails - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HeroDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val fragments = Fragments(reader) - HeroDetails( - __typename = __typename, - name = name, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val characterDetails: CharacterDetails - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.characterDetails.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", null) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val characterDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - CharacterDetails(reader) - }!! - Fragments( - characterDetails = characterDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/HumanDetails.java b/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/HumanDetails.java deleted file mode 100644 index 326b28aeff0..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/HumanDetails.java +++ /dev/null @@ -1,222 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_used_twice.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class HumanDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment HumanDetails on Human {\n" - + " __typename\n" - + " name\n" - + " ...CharacterDetails\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HumanDetails(@NotNull String __typename, @NotNull String name, - @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HumanDetails{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HumanDetails) { - HumanDetails that = (HumanDetails) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final Optional characterDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@Nullable CharacterDetails characterDetails) { - this.characterDetails = Optional.fromNullable(characterDetails); - } - - public Optional characterDetails() { - return this.characterDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - final CharacterDetails $characterDetails = characterDetails.isPresent() ? characterDetails.get() : null; - if ($characterDetails != null) { - writer.writeFragment($characterDetails.marshaller()); - } - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "characterDetails=" + characterDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.characterDetails.equals(that.characterDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= characterDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid", "Human"}) - )) - }; - - final CharacterDetails.Mapper characterDetailsFieldMapper = new CharacterDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final CharacterDetails characterDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public CharacterDetails read(ResponseReader reader) { - return characterDetailsFieldMapper.map(reader); - } - }); - return new Fragments(characterDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public HumanDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new HumanDetails(__typename, name, fragments); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/HumanDetails.kt b/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/HumanDetails.kt deleted file mode 100644 index 4eeb57772c9..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/fragment/HumanDetails.kt +++ /dev/null @@ -1,90 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_used_twice.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class HumanDetails( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String, - val fragments: Fragments -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HumanDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HumanDetails.name) - this@HumanDetails.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment HumanDetails on Human { - | __typename - | name - | ...CharacterDetails - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HumanDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val fragments = Fragments(reader) - HumanDetails( - __typename = __typename, - name = name, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val characterDetails: CharacterDetails? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.characterDetails?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid", "Human")) - )) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val characterDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - CharacterDetails(reader) - } - Fragments( - characterDetails = characterDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/type/CustomType.java deleted file mode 100644 index 3389fb52536..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/type/CustomType.java +++ /dev/null @@ -1,36 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_used_twice.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - DATE { - @Override - public String typeName() { - return "Date"; - } - - @Override - public String className() { - return "java.lang.Object"; - } - }, - - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/type/CustomType.kt deleted file mode 100644 index 09b2c0d6c0d..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_used_twice/type/CustomType.kt +++ /dev/null @@ -1,23 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_used_twice.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - DATE { - override fun typeName(): String = "Date" - - override fun className(): String = "kotlin.Any" - }, - - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/TestOperation.graphql deleted file mode 100644 index df6563be29e..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/TestOperation.graphql +++ /dev/null @@ -1,32 +0,0 @@ -query TestQuery { - hero { - name - ...HeroDetails - appearsIn - } -} - -fragment HeroDetails on Character { - ... HumanDetails - ... on Droid { - ...DroidDetails - } - name - friendsConnection { - totalCount - edges { - node { - name - } - } - } -} - -fragment DroidDetails on Droid { - name - primaryFunction -} - -fragment HumanDetails on Human { - name -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/TestQuery.java deleted file mode 100644 index c1ff4678e08..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/TestQuery.java +++ /dev/null @@ -1,610 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_with_inline_fragment; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.Mutator; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.fragment_with_inline_fragment.fragment.HeroDetails; -import com.example.fragment_with_inline_fragment.type.Episode; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "cf2801bb0424f62ecf3504cedcf40d0fc0f5b5b75bdaf1a9febb5e63bea91306"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " ...HeroDetails\n" - + " appearsIn\n" - + " }\n" - + "}\n" - + "fragment HeroDetails on Character {\n" - + " __typename\n" - + " ... HumanDetails\n" - + " ... on Droid {\n" - + " ...DroidDetails\n" - + " }\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " }\n" - + "}\n" - + "fragment HumanDetails on Human {\n" - + " __typename\n" - + " name\n" - + "}\n" - + "fragment DroidDetails on Droid {\n" - + " __typename\n" - + " name\n" - + " primaryFunction\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public Builder toBuilder() { - Builder builder = new Builder(); - builder.hero = hero.isPresent() ? hero.get() : null; - return builder; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - - public static final class Builder { - private @Nullable Hero hero; - - Builder() { - } - - public Builder hero(@Nullable Hero hero) { - this.hero = hero; - return this; - } - - public Builder hero(@NotNull Mutator mutator) { - Utils.checkNotNull(mutator, "mutator == null"); - Hero.Builder builder = this.hero != null ? this.hero.toBuilder() : Hero.builder(); - mutator.accept(builder); - this.hero = builder.build(); - return this; - } - - public Data build() { - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forList("appearsIn", "appearsIn", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull List appearsIn; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull String name, @NotNull List appearsIn, - @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.appearsIn = Utils.checkNotNull(appearsIn, "appearsIn == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The movies this character appears in - */ - public @NotNull List appearsIn() { - return this.appearsIn; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeList($responseFields[2], appearsIn, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeString(((Episode) item).rawValue()); - } - } - }); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "appearsIn=" + appearsIn + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.appearsIn.equals(that.appearsIn) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= appearsIn.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public Builder toBuilder() { - Builder builder = new Builder(); - builder.__typename = __typename; - builder.name = name; - builder.appearsIn = appearsIn; - builder.fragments = fragments; - return builder; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Fragments { - final @NotNull HeroDetails heroDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@NotNull HeroDetails heroDetails) { - this.heroDetails = Utils.checkNotNull(heroDetails, "heroDetails == null"); - } - - public @NotNull HeroDetails heroDetails() { - return this.heroDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeFragment(heroDetails.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "heroDetails=" + heroDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.heroDetails.equals(that.heroDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= heroDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public Builder toBuilder() { - Builder builder = new Builder(); - builder.heroDetails = heroDetails; - return builder; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Collections.emptyList()) - }; - - final HeroDetails.Mapper heroDetailsFieldMapper = new HeroDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HeroDetails heroDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HeroDetails read(ResponseReader reader) { - return heroDetailsFieldMapper.map(reader); - } - }); - return new Fragments(heroDetails); - } - } - - public static final class Builder { - private @NotNull HeroDetails heroDetails; - - Builder() { - } - - public Builder heroDetails(@NotNull HeroDetails heroDetails) { - this.heroDetails = heroDetails; - return this; - } - - public Fragments build() { - Utils.checkNotNull(heroDetails, "heroDetails == null"); - return new Fragments(heroDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final List appearsIn = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Episode read(ResponseReader.ListItemReader listItemReader) { - return Episode.safeValueOf(listItemReader.readString()); - } - }); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Hero(__typename, name, appearsIn, fragments); - } - } - - public static final class Builder { - private @NotNull String __typename; - - private @NotNull String name; - - private @NotNull List appearsIn; - - private @NotNull Fragments fragments; - - Builder() { - } - - public Builder __typename(@NotNull String __typename) { - this.__typename = __typename; - return this; - } - - public Builder name(@NotNull String name) { - this.name = name; - return this; - } - - public Builder appearsIn(@NotNull List appearsIn) { - this.appearsIn = appearsIn; - return this; - } - - public Builder fragments(@NotNull Fragments fragments) { - this.fragments = fragments; - return this; - } - - public Builder fragments(@NotNull Mutator mutator) { - Utils.checkNotNull(mutator, "mutator == null"); - Fragments.Builder builder = this.fragments != null ? this.fragments.toBuilder() : Fragments.builder(); - mutator.accept(builder); - this.fragments = builder.build(); - return this; - } - - public Hero build() { - Utils.checkNotNull(__typename, "__typename == null"); - Utils.checkNotNull(name, "name == null"); - Utils.checkNotNull(appearsIn, "appearsIn == null"); - Utils.checkNotNull(fragments, "fragments == null"); - return new Hero(__typename, name, appearsIn, fragments); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/TestQuery.kt deleted file mode 100644 index be2bc1edf22..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/TestQuery.kt +++ /dev/null @@ -1,245 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_with_inline_fragment - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.fragment_with_inline_fragment.fragment.HeroDetails -import com.example.fragment_with_inline_fragment.type.Episode -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The movies this character appears in - */ - val appearsIn: List, - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeList(RESPONSE_FIELDS[2], this@Hero.appearsIn) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeString(value?.rawValue)} - } - this@Hero.fragments.marshaller().marshal(writer) - } - - fun appearsInFilterNotNull(): List = appearsIn.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forList("appearsIn", "appearsIn", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val appearsIn = readList(RESPONSE_FIELDS[2]) { reader -> - Episode.safeValueOf(reader.readString()) - }!! - val fragments = Fragments(reader) - Hero( - __typename = __typename, - name = name, - appearsIn = appearsIn, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val heroDetails: HeroDetails - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.heroDetails.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", null) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val heroDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - HeroDetails(reader) - }!! - Fragments( - heroDetails = heroDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "cf2801bb0424f62ecf3504cedcf40d0fc0f5b5b75bdaf1a9febb5e63bea91306" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | name - | ...HeroDetails - | appearsIn - | } - |} - |fragment HeroDetails on Character { - | __typename - | ... HumanDetails - | ... on Droid { - | ...DroidDetails - | } - | name - | friendsConnection { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | } - |} - |fragment HumanDetails on Human { - | __typename - | name - |} - |fragment DroidDetails on Droid { - | __typename - | name - | primaryFunction - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/DroidDetails.java b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/DroidDetails.java deleted file mode 100644 index 22551744e9c..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/DroidDetails.java +++ /dev/null @@ -1,181 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_with_inline_fragment.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class DroidDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment DroidDetails on Droid {\n" - + " __typename\n" - + " name\n" - + " primaryFunction\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional primaryFunction; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public DroidDetails(@NotNull String __typename, @NotNull String name, - @Nullable String primaryFunction) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.primaryFunction = Optional.fromNullable(primaryFunction); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What others call this droid - */ - public @NotNull String name() { - return this.name; - } - - /** - * This droid's primary function - */ - public Optional primaryFunction() { - return this.primaryFunction; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeString($responseFields[2], primaryFunction.isPresent() ? primaryFunction.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "DroidDetails{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "primaryFunction=" + primaryFunction - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof DroidDetails) { - DroidDetails that = (DroidDetails) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.primaryFunction.equals(that.primaryFunction); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= primaryFunction.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public Builder toBuilder() { - Builder builder = new Builder(); - builder.__typename = __typename; - builder.name = name; - builder.primaryFunction = primaryFunction.isPresent() ? primaryFunction.get() : null; - return builder; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public DroidDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final String primaryFunction = reader.readString($responseFields[2]); - return new DroidDetails(__typename, name, primaryFunction); - } - } - - public static final class Builder { - private @NotNull String __typename; - - private @NotNull String name; - - private @Nullable String primaryFunction; - - Builder() { - } - - public Builder __typename(@NotNull String __typename) { - this.__typename = __typename; - return this; - } - - public Builder name(@NotNull String name) { - this.name = name; - return this; - } - - public Builder primaryFunction(@Nullable String primaryFunction) { - this.primaryFunction = primaryFunction; - return this; - } - - public DroidDetails build() { - Utils.checkNotNull(__typename, "__typename == null"); - Utils.checkNotNull(name, "name == null"); - return new DroidDetails(__typename, name, primaryFunction); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/DroidDetails.kt b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/DroidDetails.kt deleted file mode 100644 index ff1bfb46d2f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/DroidDetails.kt +++ /dev/null @@ -1,65 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_with_inline_fragment.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class DroidDetails( - val __typename: String = "Droid", - /** - * What others call this droid - */ - val name: String, - /** - * This droid's primary function - */ - val primaryFunction: String? -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@DroidDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@DroidDetails.name) - writer.writeString(RESPONSE_FIELDS[2], this@DroidDetails.primaryFunction) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment DroidDetails on Droid { - | __typename - | name - | primaryFunction - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): DroidDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val primaryFunction = readString(RESPONSE_FIELDS[2]) - DroidDetails( - __typename = __typename, - name = name, - primaryFunction = primaryFunction - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/HeroDetails.java b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/HeroDetails.java deleted file mode 100644 index 61104897e7b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/HeroDetails.java +++ /dev/null @@ -1,1708 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_with_inline_fragment.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Mutator; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public interface HeroDetails extends GraphqlFragment { - String FRAGMENT_DEFINITION = "fragment HeroDetails on Character {\n" - + " __typename\n" - + " ... HumanDetails\n" - + " ... on Droid {\n" - + " ...DroidDetails\n" - + " }\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " }\n" - + "}"; - - @NotNull String __typename(); - - /** - * The name of the character - */ - @NotNull String name(); - - /** - * The friends of the character exposed as a connection with edges - */ - @NotNull FriendsConnection friendsConnection(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsDroid) { - return visitor.visit((AsDroid) this); - } else if (this instanceof AsCharacter) { - return visitor.visit((AsCharacter) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid"}) - )) - }; - - final AsDroid.Mapper asDroidFieldMapper = new AsDroid.Mapper(); - - final AsCharacter.Mapper asCharacterFieldMapper = new AsCharacter.Mapper(); - - @Override - public HeroDetails map(ResponseReader reader) { - final AsDroid asDroid = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsDroid read(ResponseReader reader) { - return asDroidFieldMapper.map(reader); - } - }); - if (asDroid != null) { - return asDroid; - } - return asCharacterFieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull HeroDetails heroDetails); - - T visit(@NotNull AsDroid asDroid); - - T visit(@NotNull AsCharacter asCharacter); - } - - /** - * A connection object for a character's friends - */ - interface FriendsConnection { - @NotNull String __typename(); - - /** - * The total number of friends - */ - Optional totalCount(); - - /** - * The edges for each of the character's friends. - */ - Optional> edges(); - - ResponseFieldMarshaller marshaller(); - } - - /** - * An edge object for a character's friends - */ - interface Edge { - @NotNull String __typename(); - - /** - * The character represented by this friendship edge - */ - Optional node(); - - ResponseFieldMarshaller marshaller(); - } - - /** - * A character from the Star Wars universe - */ - interface Node { - @NotNull String __typename(); - - /** - * The name of the character - */ - @NotNull String name(); - - ResponseFieldMarshaller marshaller(); - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - class AsDroid implements HeroDetails { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull FriendsConnection1 friendsConnection; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsDroid(@NotNull String __typename, @NotNull String name, - @NotNull FriendsConnection1 friendsConnection, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What others call this droid - */ - public @NotNull String name() { - return this.name; - } - - /** - * The friends of the droid exposed as a connection with edges - */ - public @NotNull FriendsConnection1 friendsConnection() { - return this.friendsConnection; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeObject($responseFields[2], friendsConnection.marshaller()); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsDroid{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsDroid) { - AsDroid that = (AsDroid) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public Builder toBuilder() { - Builder builder = new Builder(); - builder.__typename = __typename; - builder.name = name; - builder.friendsConnection = friendsConnection; - builder.fragments = fragments; - return builder; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Fragments { - final @NotNull DroidDetails droidDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@NotNull DroidDetails droidDetails) { - this.droidDetails = Utils.checkNotNull(droidDetails, "droidDetails == null"); - } - - public @NotNull DroidDetails droidDetails() { - return this.droidDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeFragment(droidDetails.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "droidDetails=" + droidDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.droidDetails.equals(that.droidDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= droidDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public Builder toBuilder() { - Builder builder = new Builder(); - builder.droidDetails = droidDetails; - return builder; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Collections.emptyList()) - }; - - final DroidDetails.Mapper droidDetailsFieldMapper = new DroidDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final DroidDetails droidDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public DroidDetails read(ResponseReader reader) { - return droidDetailsFieldMapper.map(reader); - } - }); - return new Fragments(droidDetails); - } - } - - public static final class Builder { - private @NotNull DroidDetails droidDetails; - - Builder() { - } - - public Builder droidDetails(@NotNull DroidDetails droidDetails) { - this.droidDetails = droidDetails; - return this; - } - - public Fragments build() { - Utils.checkNotNull(droidDetails, "droidDetails == null"); - return new Fragments(droidDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection1.Mapper friendsConnection1FieldMapper = new FriendsConnection1.Mapper(); - - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public AsDroid map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final FriendsConnection1 friendsConnection = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection1 read(ResponseReader reader) { - return friendsConnection1FieldMapper.map(reader); - } - }); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new AsDroid(__typename, name, friendsConnection, fragments); - } - } - - public static final class Builder { - private @NotNull String __typename; - - private @NotNull String name; - - private @NotNull FriendsConnection1 friendsConnection; - - private @NotNull Fragments fragments; - - Builder() { - } - - public Builder __typename(@NotNull String __typename) { - this.__typename = __typename; - return this; - } - - public Builder name(@NotNull String name) { - this.name = name; - return this; - } - - public Builder friendsConnection(@NotNull FriendsConnection1 friendsConnection) { - this.friendsConnection = friendsConnection; - return this; - } - - public Builder fragments(@NotNull Fragments fragments) { - this.fragments = fragments; - return this; - } - - public Builder friendsConnection(@NotNull Mutator mutator) { - Utils.checkNotNull(mutator, "mutator == null"); - FriendsConnection1.Builder builder = this.friendsConnection != null ? this.friendsConnection.toBuilder() : FriendsConnection1.builder(); - mutator.accept(builder); - this.friendsConnection = builder.build(); - return this; - } - - public Builder fragments(@NotNull Mutator mutator) { - Utils.checkNotNull(mutator, "mutator == null"); - Fragments.Builder builder = this.fragments != null ? this.fragments.toBuilder() : Fragments.builder(); - mutator.accept(builder); - this.fragments = builder.build(); - return this; - } - - public AsDroid build() { - Utils.checkNotNull(__typename, "__typename == null"); - Utils.checkNotNull(name, "name == null"); - Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - Utils.checkNotNull(fragments, "fragments == null"); - return new AsDroid(__typename, name, friendsConnection, fragments); - } - } - } - - /** - * A connection object for a character's friends - */ - class FriendsConnection1 implements FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - final Optional> edges; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection1(@NotNull String __typename, @Nullable Integer totalCount, - @Nullable List edges) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.fromNullable(totalCount); - this.edges = Optional.fromNullable(edges); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional totalCount() { - return this.totalCount; - } - - /** - * The edges for each of the character's friends. - */ - public Optional> edges() { - return this.edges; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - writer.writeList($responseFields[2], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge1) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection1{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount + ", " - + "edges=" + edges - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection1) { - FriendsConnection1 that = (FriendsConnection1) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount) - && this.edges.equals(that.edges); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public Builder toBuilder() { - Builder builder = new Builder(); - builder.__typename = __typename; - builder.totalCount = totalCount.isPresent() ? totalCount.get() : null; - builder.edges = edges.isPresent() ? edges.get() : null; - return builder; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge1.Mapper edge1FieldMapper = new Edge1.Mapper(); - - @Override - public FriendsConnection1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - final List edges = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Edge1 read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge1 read(ResponseReader reader) { - return edge1FieldMapper.map(reader); - } - }); - } - }); - return new FriendsConnection1(__typename, totalCount, edges); - } - } - - public static final class Builder { - private @NotNull String __typename; - - private @Nullable Integer totalCount; - - private @Nullable List edges; - - Builder() { - } - - public Builder __typename(@NotNull String __typename) { - this.__typename = __typename; - return this; - } - - public Builder totalCount(@Nullable Integer totalCount) { - this.totalCount = totalCount; - return this; - } - - public Builder edges(@Nullable List edges) { - this.edges = edges; - return this; - } - - public Builder edges(@NotNull Mutator> mutator) { - Utils.checkNotNull(mutator, "mutator == null"); - List builders = new ArrayList<>(); - if (this.edges != null) { - for (Edge1 item : this.edges) { - builders.add(item != null ? item.toBuilder() : null); - } - } - mutator.accept(builders); - List edges = new ArrayList<>(); - for (Edge1.Builder item : builders) { - edges.add(item != null ? item.build() : null); - } - this.edges = edges; - return this; - } - - public FriendsConnection1 build() { - Utils.checkNotNull(__typename, "__typename == null"); - return new FriendsConnection1(__typename, totalCount, edges); - } - } - } - - /** - * An edge object for a character's friends - */ - class Edge1 implements Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge1(@NotNull String __typename, @Nullable Node1 node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.fromNullable(node); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The character represented by this friendship edge - */ - public Optional node() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge1{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge1) { - Edge1 that = (Edge1) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public Builder toBuilder() { - Builder builder = new Builder(); - builder.__typename = __typename; - builder.node = node.isPresent() ? node.get() : null; - return builder; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Mapper implements ResponseFieldMapper { - final Node1.Mapper node1FieldMapper = new Node1.Mapper(); - - @Override - public Edge1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node1 node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node1 read(ResponseReader reader) { - return node1FieldMapper.map(reader); - } - }); - return new Edge1(__typename, node); - } - } - - public static final class Builder { - private @NotNull String __typename; - - private @Nullable Node1 node; - - Builder() { - } - - public Builder __typename(@NotNull String __typename) { - this.__typename = __typename; - return this; - } - - public Builder node(@Nullable Node1 node) { - this.node = node; - return this; - } - - public Builder node(@NotNull Mutator mutator) { - Utils.checkNotNull(mutator, "mutator == null"); - Node1.Builder builder = this.node != null ? this.node.toBuilder() : Node1.builder(); - mutator.accept(builder); - this.node = builder.build(); - return this; - } - - public Edge1 build() { - Utils.checkNotNull(__typename, "__typename == null"); - return new Edge1(__typename, node); - } - } - } - - /** - * A character from the Star Wars universe - */ - class Node1 implements Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node1(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node1{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node1) { - Node1 that = (Node1) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public Builder toBuilder() { - Builder builder = new Builder(); - builder.__typename = __typename; - builder.name = name; - return builder; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Node1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Node1(__typename, name); - } - } - - public static final class Builder { - private @NotNull String __typename; - - private @NotNull String name; - - Builder() { - } - - public Builder __typename(@NotNull String __typename) { - this.__typename = __typename; - return this; - } - - public Builder name(@NotNull String name) { - this.name = name; - return this; - } - - public Node1 build() { - Utils.checkNotNull(__typename, "__typename == null"); - Utils.checkNotNull(name, "name == null"); - return new Node1(__typename, name); - } - } - } - - class AsCharacter implements HeroDetails { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull FriendsConnection2 friendsConnection; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter(@NotNull String __typename, @NotNull String name, - @NotNull FriendsConnection2 friendsConnection, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The friends of the character exposed as a connection with edges - */ - public @NotNull FriendsConnection2 friendsConnection() { - return this.friendsConnection; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeObject($responseFields[2], friendsConnection.marshaller()); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter) { - AsCharacter that = (AsCharacter) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public Builder toBuilder() { - Builder builder = new Builder(); - builder.__typename = __typename; - builder.name = name; - builder.friendsConnection = friendsConnection; - builder.fragments = fragments; - return builder; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Fragments { - final Optional humanDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@Nullable HumanDetails humanDetails) { - this.humanDetails = Optional.fromNullable(humanDetails); - } - - public Optional humanDetails() { - return this.humanDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - final HumanDetails $humanDetails = humanDetails.isPresent() ? humanDetails.get() : null; - if ($humanDetails != null) { - writer.writeFragment($humanDetails.marshaller()); - } - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "humanDetails=" + humanDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.humanDetails.equals(that.humanDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= humanDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public Builder toBuilder() { - Builder builder = new Builder(); - builder.humanDetails = humanDetails.isPresent() ? humanDetails.get() : null; - return builder; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )) - }; - - final HumanDetails.Mapper humanDetailsFieldMapper = new HumanDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HumanDetails humanDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HumanDetails read(ResponseReader reader) { - return humanDetailsFieldMapper.map(reader); - } - }); - return new Fragments(humanDetails); - } - } - - public static final class Builder { - private @Nullable HumanDetails humanDetails; - - Builder() { - } - - public Builder humanDetails(@Nullable HumanDetails humanDetails) { - this.humanDetails = humanDetails; - return this; - } - - public Fragments build() { - return new Fragments(humanDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection2.Mapper friendsConnection2FieldMapper = new FriendsConnection2.Mapper(); - - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public AsCharacter map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final FriendsConnection2 friendsConnection = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection2 read(ResponseReader reader) { - return friendsConnection2FieldMapper.map(reader); - } - }); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new AsCharacter(__typename, name, friendsConnection, fragments); - } - } - - public static final class Builder { - private @NotNull String __typename; - - private @NotNull String name; - - private @NotNull FriendsConnection2 friendsConnection; - - private @NotNull Fragments fragments; - - Builder() { - } - - public Builder __typename(@NotNull String __typename) { - this.__typename = __typename; - return this; - } - - public Builder name(@NotNull String name) { - this.name = name; - return this; - } - - public Builder friendsConnection(@NotNull FriendsConnection2 friendsConnection) { - this.friendsConnection = friendsConnection; - return this; - } - - public Builder fragments(@NotNull Fragments fragments) { - this.fragments = fragments; - return this; - } - - public Builder friendsConnection(@NotNull Mutator mutator) { - Utils.checkNotNull(mutator, "mutator == null"); - FriendsConnection2.Builder builder = this.friendsConnection != null ? this.friendsConnection.toBuilder() : FriendsConnection2.builder(); - mutator.accept(builder); - this.friendsConnection = builder.build(); - return this; - } - - public Builder fragments(@NotNull Mutator mutator) { - Utils.checkNotNull(mutator, "mutator == null"); - Fragments.Builder builder = this.fragments != null ? this.fragments.toBuilder() : Fragments.builder(); - mutator.accept(builder); - this.fragments = builder.build(); - return this; - } - - public AsCharacter build() { - Utils.checkNotNull(__typename, "__typename == null"); - Utils.checkNotNull(name, "name == null"); - Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - Utils.checkNotNull(fragments, "fragments == null"); - return new AsCharacter(__typename, name, friendsConnection, fragments); - } - } - } - - /** - * A connection object for a character's friends - */ - class FriendsConnection2 implements FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - final Optional> edges; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection2(@NotNull String __typename, @Nullable Integer totalCount, - @Nullable List edges) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.fromNullable(totalCount); - this.edges = Optional.fromNullable(edges); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional totalCount() { - return this.totalCount; - } - - /** - * The edges for each of the character's friends. - */ - public Optional> edges() { - return this.edges; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - writer.writeList($responseFields[2], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge2) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection2{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount + ", " - + "edges=" + edges - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection2) { - FriendsConnection2 that = (FriendsConnection2) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount) - && this.edges.equals(that.edges); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public Builder toBuilder() { - Builder builder = new Builder(); - builder.__typename = __typename; - builder.totalCount = totalCount.isPresent() ? totalCount.get() : null; - builder.edges = edges.isPresent() ? edges.get() : null; - return builder; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge2.Mapper edge2FieldMapper = new Edge2.Mapper(); - - @Override - public FriendsConnection2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - final List edges = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Edge2 read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge2 read(ResponseReader reader) { - return edge2FieldMapper.map(reader); - } - }); - } - }); - return new FriendsConnection2(__typename, totalCount, edges); - } - } - - public static final class Builder { - private @NotNull String __typename; - - private @Nullable Integer totalCount; - - private @Nullable List edges; - - Builder() { - } - - public Builder __typename(@NotNull String __typename) { - this.__typename = __typename; - return this; - } - - public Builder totalCount(@Nullable Integer totalCount) { - this.totalCount = totalCount; - return this; - } - - public Builder edges(@Nullable List edges) { - this.edges = edges; - return this; - } - - public Builder edges(@NotNull Mutator> mutator) { - Utils.checkNotNull(mutator, "mutator == null"); - List builders = new ArrayList<>(); - if (this.edges != null) { - for (Edge2 item : this.edges) { - builders.add(item != null ? item.toBuilder() : null); - } - } - mutator.accept(builders); - List edges = new ArrayList<>(); - for (Edge2.Builder item : builders) { - edges.add(item != null ? item.build() : null); - } - this.edges = edges; - return this; - } - - public FriendsConnection2 build() { - Utils.checkNotNull(__typename, "__typename == null"); - return new FriendsConnection2(__typename, totalCount, edges); - } - } - } - - /** - * An edge object for a character's friends - */ - class Edge2 implements Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge2(@NotNull String __typename, @Nullable Node2 node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.fromNullable(node); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The character represented by this friendship edge - */ - public Optional node() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge2{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge2) { - Edge2 that = (Edge2) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public Builder toBuilder() { - Builder builder = new Builder(); - builder.__typename = __typename; - builder.node = node.isPresent() ? node.get() : null; - return builder; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Mapper implements ResponseFieldMapper { - final Node2.Mapper node2FieldMapper = new Node2.Mapper(); - - @Override - public Edge2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node2 node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node2 read(ResponseReader reader) { - return node2FieldMapper.map(reader); - } - }); - return new Edge2(__typename, node); - } - } - - public static final class Builder { - private @NotNull String __typename; - - private @Nullable Node2 node; - - Builder() { - } - - public Builder __typename(@NotNull String __typename) { - this.__typename = __typename; - return this; - } - - public Builder node(@Nullable Node2 node) { - this.node = node; - return this; - } - - public Builder node(@NotNull Mutator mutator) { - Utils.checkNotNull(mutator, "mutator == null"); - Node2.Builder builder = this.node != null ? this.node.toBuilder() : Node2.builder(); - mutator.accept(builder); - this.node = builder.build(); - return this; - } - - public Edge2 build() { - Utils.checkNotNull(__typename, "__typename == null"); - return new Edge2(__typename, node); - } - } - } - - /** - * A character from the Star Wars universe - */ - class Node2 implements Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node2(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node2{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node2) { - Node2 that = (Node2) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public Builder toBuilder() { - Builder builder = new Builder(); - builder.__typename = __typename; - builder.name = name; - return builder; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Node2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Node2(__typename, name); - } - } - - public static final class Builder { - private @NotNull String __typename; - - private @NotNull String name; - - Builder() { - } - - public Builder __typename(@NotNull String __typename) { - this.__typename = __typename; - return this; - } - - public Builder name(@NotNull String name) { - this.name = name; - return this; - } - - public Node2 build() { - Utils.checkNotNull(__typename, "__typename == null"); - Utils.checkNotNull(name, "name == null"); - return new Node2(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/HeroDetails.kt b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/HeroDetails.kt deleted file mode 100644 index 5e85f0852c6..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/HeroDetails.kt +++ /dev/null @@ -1,453 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_with_inline_fragment.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class HeroDetails( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The friends of the character exposed as a connection with edges - */ - val friendsConnection: FriendsConnection, - val fragments: Fragments, - val asDroid: AsDroid? -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HeroDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HeroDetails.name) - writer.writeObject(RESPONSE_FIELDS[2], this@HeroDetails.friendsConnection.marshaller()) - this@HeroDetails.fragments.marshaller().marshal(writer) - writer.writeFragment(this@HeroDetails.asDroid?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid")) - )) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment HeroDetails on Character { - | __typename - | ... HumanDetails - | ... on Droid { - | ...DroidDetails - | } - | name - | friendsConnection { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | } - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HeroDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friendsConnection = readObject(RESPONSE_FIELDS[2]) { reader -> - FriendsConnection(reader) - }!! - val fragments = Fragments(reader) - val asDroid = readFragment(RESPONSE_FIELDS[4]) { reader -> - AsDroid(reader) - } - HeroDetails( - __typename = __typename, - name = name, - friendsConnection = friendsConnection, - fragments = fragments, - asDroid = asDroid - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val humanDetails: HumanDetails? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.humanDetails?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val humanDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - HumanDetails(reader) - } - Fragments( - humanDetails = humanDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Node( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Node.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Node( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An edge object for a character's friends - */ - data class Edge( - val __typename: String = "FriendsEdge", - /** - * The character represented by this friendship edge - */ - val node: Node? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node(reader) - } - Edge( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int?, - /** - * The edges for each of the character's friends. - */ - val edges: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection.totalCount) - writer.writeList(RESPONSE_FIELDS[2], this@FriendsConnection.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null), - ResponseField.forList("edges", "edges", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - val edges = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Edge(reader) - } - } - FriendsConnection( - __typename = __typename, - totalCount = totalCount, - edges = edges - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - interface HeroDetailCharacter { - fun marshaller(): ResponseFieldMarshaller - } - - /** - * A character from the Star Wars universe - */ - data class Node1( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node1.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Node1.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Node1( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An edge object for a character's friends - */ - data class Edge1( - val __typename: String = "FriendsEdge", - /** - * The character represented by this friendship edge - */ - val node: Node1? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge1.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge1.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node1(reader) - } - Edge1( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection1( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int?, - /** - * The edges for each of the character's friends. - */ - val edges: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection1.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection1.totalCount) - writer.writeList(RESPONSE_FIELDS[2], this@FriendsConnection1.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null), - ResponseField.forList("edges", "edges", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - val edges = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Edge1(reader) - } - } - FriendsConnection1( - __typename = __typename, - totalCount = totalCount, - edges = edges - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - data class AsDroid( - val __typename: String = "Droid", - /** - * What others call this droid - */ - val name: String, - /** - * The friends of the droid exposed as a connection with edges - */ - val friendsConnection: FriendsConnection1, - val fragments: Fragments - ) : HeroDetailCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsDroid.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsDroid.name) - writer.writeObject(RESPONSE_FIELDS[2], this@AsDroid.friendsConnection.marshaller()) - this@AsDroid.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): AsDroid = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friendsConnection = readObject(RESPONSE_FIELDS[2]) { reader -> - FriendsConnection1(reader) - }!! - val fragments = Fragments(reader) - AsDroid( - __typename = __typename, - name = name, - friendsConnection = friendsConnection, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val droidDetails: DroidDetails - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.droidDetails.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", null) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val droidDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - DroidDetails(reader) - }!! - Fragments( - droidDetails = droidDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/HumanDetails.java b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/HumanDetails.java deleted file mode 100644 index af945e58b5b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/HumanDetails.java +++ /dev/null @@ -1,152 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_with_inline_fragment.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; - -public class HumanDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment HumanDetails on Human {\n" - + " __typename\n" - + " name\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HumanDetails(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HumanDetails{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HumanDetails) { - HumanDetails that = (HumanDetails) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public Builder toBuilder() { - Builder builder = new Builder(); - builder.__typename = __typename; - builder.name = name; - return builder; - } - - public static Builder builder() { - return new Builder(); - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public HumanDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new HumanDetails(__typename, name); - } - } - - public static final class Builder { - private @NotNull String __typename; - - private @NotNull String name; - - Builder() { - } - - public Builder __typename(@NotNull String __typename) { - this.__typename = __typename; - return this; - } - - public Builder name(@NotNull String name) { - this.name = name; - return this; - } - - public HumanDetails build() { - Utils.checkNotNull(__typename, "__typename == null"); - Utils.checkNotNull(name, "name == null"); - return new HumanDetails(__typename, name); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/HumanDetails.kt b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/HumanDetails.kt deleted file mode 100644 index 7d8d7056c95..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/fragment/HumanDetails.kt +++ /dev/null @@ -1,56 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_with_inline_fragment.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class HumanDetails( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HumanDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HumanDetails.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment HumanDetails on Human { - | __typename - | name - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HumanDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - HumanDetails( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/type/CustomType.java deleted file mode 100644 index c9b7ce108c3..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_with_inline_fragment.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/type/CustomType.kt deleted file mode 100644 index fbd53588b1d..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_with_inline_fragment.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/type/Episode.java b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/type/Episode.java deleted file mode 100644 index 13acfca14fe..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/type/Episode.java +++ /dev/null @@ -1,67 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_with_inline_fragment.type; - -import java.lang.Deprecated; -import java.lang.String; - -/** - * The episodes in the Star Wars trilogy - */ -public enum Episode { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - * @deprecated For test purpose only - */ - @Deprecated - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - * @deprecated For test purpose only - */ - @Deprecated - NEW_("new"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Episode(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Episode safeValueOf(String rawValue) { - for (Episode enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Episode.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/type/Episode.kt b/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/type/Episode.kt deleted file mode 100644 index 9fb0d29ffb3..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragment_with_inline_fragment/type/Episode.kt +++ /dev/null @@ -1,54 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragment_with_inline_fragment.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.Deprecated -import kotlin.String - -/** - * The episodes in the Star Wars trilogy - */ -enum class Episode( - override val rawValue: String -) : EnumValue { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - */ - @Deprecated(message = "For test purpose only") - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - */ - @Deprecated(message = "For test purpose only") - NEW("new"), - - /** - * Auto generated constant for unknown enum values - */ - UNKNOWN__("UNKNOWN__"); - - companion object { - fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: - UNKNOWN__ - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/TestOperation.graphql deleted file mode 100644 index 1a4ee39b674..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/TestOperation.graphql +++ /dev/null @@ -1,20 +0,0 @@ -query TestQuery { - r2: hero { - ...HumanDetails - ...DroidDetails - } - luke: hero { - ...HumanDetails - ...DroidDetails - } -} - -fragment HumanDetails on Human { - name - height -} - -fragment DroidDetails on Droid { - name - primaryFunction -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/TestQuery.java deleted file mode 100644 index 838e2131c49..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/TestQuery.java +++ /dev/null @@ -1,681 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.fragments_with_type_condition.fragment.DroidDetails; -import com.example.fragments_with_type_condition.fragment.HumanDetails; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "919cec7210259fa24fc6026fe680b96f357c14ebf3c8a734979dcfb819685d6a"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " r2: hero {\n" - + " __typename\n" - + " ...HumanDetails\n" - + " ...DroidDetails\n" - + " }\n" - + " luke: hero {\n" - + " __typename\n" - + " ...HumanDetails\n" - + " ...DroidDetails\n" - + " }\n" - + "}\n" - + "fragment HumanDetails on Human {\n" - + " __typename\n" - + " name\n" - + " height\n" - + "}\n" - + "fragment DroidDetails on Droid {\n" - + " __typename\n" - + " name\n" - + " primaryFunction\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("r2", "hero", null, true, Collections.emptyList()), - ResponseField.forObject("luke", "hero", null, true, Collections.emptyList()) - }; - - final Optional r2; - - final Optional luke; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable R2 r2, @Nullable Luke luke) { - this.r2 = Optional.fromNullable(r2); - this.luke = Optional.fromNullable(luke); - } - - public Optional r2() { - return this.r2; - } - - public Optional luke() { - return this.luke; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], r2.isPresent() ? r2.get().marshaller() : null); - writer.writeObject($responseFields[1], luke.isPresent() ? luke.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "r2=" + r2 + ", " - + "luke=" + luke - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.r2.equals(that.r2) - && this.luke.equals(that.luke); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= r2.hashCode(); - h *= 1000003; - h ^= luke.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final R2.Mapper r2FieldMapper = new R2.Mapper(); - - final Luke.Mapper lukeFieldMapper = new Luke.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final R2 r2 = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public R2 read(ResponseReader reader) { - return r2FieldMapper.map(reader); - } - }); - final Luke luke = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Luke read(ResponseReader reader) { - return lukeFieldMapper.map(reader); - } - }); - return new Data(r2, luke); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class R2 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public R2(@NotNull String __typename, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "R2{" - + "__typename=" + __typename + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof R2) { - R2 that = (R2) o; - return this.__typename.equals(that.__typename) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final Optional humanDetails; - - final Optional droidDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@Nullable HumanDetails humanDetails, @Nullable DroidDetails droidDetails) { - this.humanDetails = Optional.fromNullable(humanDetails); - this.droidDetails = Optional.fromNullable(droidDetails); - } - - public Optional humanDetails() { - return this.humanDetails; - } - - public Optional droidDetails() { - return this.droidDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - final HumanDetails $humanDetails = humanDetails.isPresent() ? humanDetails.get() : null; - if ($humanDetails != null) { - writer.writeFragment($humanDetails.marshaller()); - } - final DroidDetails $droidDetails = droidDetails.isPresent() ? droidDetails.get() : null; - if ($droidDetails != null) { - writer.writeFragment($droidDetails.marshaller()); - } - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "humanDetails=" + humanDetails + ", " - + "droidDetails=" + droidDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.humanDetails.equals(that.humanDetails) - && this.droidDetails.equals(that.droidDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= humanDetails.hashCode(); - h *= 1000003; - h ^= droidDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid"}) - )) - }; - - final HumanDetails.Mapper humanDetailsFieldMapper = new HumanDetails.Mapper(); - - final DroidDetails.Mapper droidDetailsFieldMapper = new DroidDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HumanDetails humanDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HumanDetails read(ResponseReader reader) { - return humanDetailsFieldMapper.map(reader); - } - }); - final DroidDetails droidDetails = reader.readFragment($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public DroidDetails read(ResponseReader reader) { - return droidDetailsFieldMapper.map(reader); - } - }); - return new Fragments(humanDetails, droidDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public R2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new R2(__typename, fragments); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Luke { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Luke(@NotNull String __typename, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Luke{" - + "__typename=" + __typename + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Luke) { - Luke that = (Luke) o; - return this.__typename.equals(that.__typename) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final Optional humanDetails; - - final Optional droidDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@Nullable HumanDetails humanDetails, @Nullable DroidDetails droidDetails) { - this.humanDetails = Optional.fromNullable(humanDetails); - this.droidDetails = Optional.fromNullable(droidDetails); - } - - public Optional humanDetails() { - return this.humanDetails; - } - - public Optional droidDetails() { - return this.droidDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - final HumanDetails $humanDetails = humanDetails.isPresent() ? humanDetails.get() : null; - if ($humanDetails != null) { - writer.writeFragment($humanDetails.marshaller()); - } - final DroidDetails $droidDetails = droidDetails.isPresent() ? droidDetails.get() : null; - if ($droidDetails != null) { - writer.writeFragment($droidDetails.marshaller()); - } - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "humanDetails=" + humanDetails + ", " - + "droidDetails=" + droidDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.humanDetails.equals(that.humanDetails) - && this.droidDetails.equals(that.droidDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= humanDetails.hashCode(); - h *= 1000003; - h ^= droidDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid"}) - )) - }; - - final HumanDetails.Mapper humanDetailsFieldMapper = new HumanDetails.Mapper(); - - final DroidDetails.Mapper droidDetailsFieldMapper = new DroidDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HumanDetails humanDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HumanDetails read(ResponseReader reader) { - return humanDetailsFieldMapper.map(reader); - } - }); - final DroidDetails droidDetails = reader.readFragment($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public DroidDetails read(ResponseReader reader) { - return droidDetailsFieldMapper.map(reader); - } - }); - return new Fragments(humanDetails, droidDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Luke map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Luke(__typename, fragments); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/TestQuery.kt deleted file mode 100644 index 0cef10efe49..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/TestQuery.kt +++ /dev/null @@ -1,294 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.fragments_with_type_condition.fragment.DroidDetails -import com.example.fragments_with_type_condition.fragment.HumanDetails -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class R2( - val __typename: String = "Character", - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@R2.__typename) - this@R2.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): R2 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val fragments = Fragments(reader) - R2( - __typename = __typename, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val humanDetails: HumanDetails?, - val droidDetails: DroidDetails? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.humanDetails?.marshaller()) - writer.writeFragment(this@Fragments.droidDetails?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid")) - )) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val humanDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - HumanDetails(reader) - } - val droidDetails = readFragment(RESPONSE_FIELDS[1]) { reader -> - DroidDetails(reader) - } - Fragments( - humanDetails = humanDetails, - droidDetails = droidDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * A character from the Star Wars universe - */ - data class Luke( - val __typename: String = "Character", - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Luke.__typename) - this@Luke.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Luke = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val fragments = Fragments(reader) - Luke( - __typename = __typename, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val humanDetails: HumanDetails?, - val droidDetails: DroidDetails? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.humanDetails?.marshaller()) - writer.writeFragment(this@Fragments.droidDetails?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid")) - )) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val humanDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - HumanDetails(reader) - } - val droidDetails = readFragment(RESPONSE_FIELDS[1]) { reader -> - DroidDetails(reader) - } - Fragments( - humanDetails = humanDetails, - droidDetails = droidDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val r2: R2?, - val luke: Luke? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.r2?.marshaller()) - writer.writeObject(RESPONSE_FIELDS[1], this@Data.luke?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("r2", "hero", null, true, null), - ResponseField.forObject("luke", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val r2 = readObject(RESPONSE_FIELDS[0]) { reader -> - R2(reader) - } - val luke = readObject(RESPONSE_FIELDS[1]) { reader -> - Luke(reader) - } - Data( - r2 = r2, - luke = luke - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "919cec7210259fa24fc6026fe680b96f357c14ebf3c8a734979dcfb819685d6a" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | r2: hero { - | __typename - | ...HumanDetails - | ...DroidDetails - | } - | luke: hero { - | __typename - | ...HumanDetails - | ...DroidDetails - | } - |} - |fragment HumanDetails on Human { - | __typename - | name - | height - |} - |fragment DroidDetails on Droid { - | __typename - | name - | primaryFunction - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/fragment/DroidDetails.java b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/fragment/DroidDetails.java deleted file mode 100644 index 7fda87f4b91..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/fragment/DroidDetails.java +++ /dev/null @@ -1,137 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class DroidDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment DroidDetails on Droid {\n" - + " __typename\n" - + " name\n" - + " primaryFunction\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional primaryFunction; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public DroidDetails(@NotNull String __typename, @NotNull String name, - @Nullable String primaryFunction) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.primaryFunction = Optional.fromNullable(primaryFunction); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What others call this droid - */ - public @NotNull String name() { - return this.name; - } - - /** - * This droid's primary function - */ - public Optional primaryFunction() { - return this.primaryFunction; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeString($responseFields[2], primaryFunction.isPresent() ? primaryFunction.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "DroidDetails{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "primaryFunction=" + primaryFunction - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof DroidDetails) { - DroidDetails that = (DroidDetails) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.primaryFunction.equals(that.primaryFunction); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= primaryFunction.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public DroidDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final String primaryFunction = reader.readString($responseFields[2]); - return new DroidDetails(__typename, name, primaryFunction); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/fragment/DroidDetails.kt b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/fragment/DroidDetails.kt deleted file mode 100644 index a83f245e6f2..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/fragment/DroidDetails.kt +++ /dev/null @@ -1,65 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class DroidDetails( - val __typename: String = "Droid", - /** - * What others call this droid - */ - val name: String, - /** - * This droid's primary function - */ - val primaryFunction: String? -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@DroidDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@DroidDetails.name) - writer.writeString(RESPONSE_FIELDS[2], this@DroidDetails.primaryFunction) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment DroidDetails on Droid { - | __typename - | name - | primaryFunction - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): DroidDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val primaryFunction = readString(RESPONSE_FIELDS[2]) - DroidDetails( - __typename = __typename, - name = name, - primaryFunction = primaryFunction - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/fragment/HumanDetails.java b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/fragment/HumanDetails.java deleted file mode 100644 index 64e23af2669..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/fragment/HumanDetails.java +++ /dev/null @@ -1,137 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class HumanDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forDouble("height", "height", null, true, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment HumanDetails on Human {\n" - + " __typename\n" - + " name\n" - + " height\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional height; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HumanDetails(@NotNull String __typename, @NotNull String name, @Nullable Double height) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.height = Optional.fromNullable(height); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - /** - * Height in the preferred unit, default is meters - */ - public Optional height() { - return this.height; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeDouble($responseFields[2], height.isPresent() ? height.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HumanDetails{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "height=" + height - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HumanDetails) { - HumanDetails that = (HumanDetails) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.height.equals(that.height); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= height.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public HumanDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final Double height = reader.readDouble($responseFields[2]); - return new HumanDetails(__typename, name, height); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/fragment/HumanDetails.kt b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/fragment/HumanDetails.kt deleted file mode 100644 index f8a18f1f5c8..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/fragment/HumanDetails.kt +++ /dev/null @@ -1,66 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.Double -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class HumanDetails( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String, - /** - * Height in the preferred unit, default is meters - */ - val height: Double? -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HumanDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HumanDetails.name) - writer.writeDouble(RESPONSE_FIELDS[2], this@HumanDetails.height) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forDouble("height", "height", null, true, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment HumanDetails on Human { - | __typename - | name - | height - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HumanDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val height = readDouble(RESPONSE_FIELDS[2]) - HumanDetails( - __typename = __typename, - name = name, - height = height - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/type/CustomType.java deleted file mode 100644 index bf2f753bae8..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/type/CustomType.kt deleted file mode 100644 index fdb51f373a2..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/TestOperation.graphql deleted file mode 100644 index 1a4ee39b674..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/TestOperation.graphql +++ /dev/null @@ -1,20 +0,0 @@ -query TestQuery { - r2: hero { - ...HumanDetails - ...DroidDetails - } - luke: hero { - ...HumanDetails - ...DroidDetails - } -} - -fragment HumanDetails on Human { - name - height -} - -fragment DroidDetails on Droid { - name - primaryFunction -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/TestQuery.java deleted file mode 100644 index 00fb9248bb9..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/TestQuery.java +++ /dev/null @@ -1,678 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition_nullable; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.fragments_with_type_condition_nullable.fragment.DroidDetails; -import com.example.fragments_with_type_condition_nullable.fragment.HumanDetails; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query { - public static final String OPERATION_ID = "919cec7210259fa24fc6026fe680b96f357c14ebf3c8a734979dcfb819685d6a"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " r2: hero {\n" - + " __typename\n" - + " ...HumanDetails\n" - + " ...DroidDetails\n" - + " }\n" - + " luke: hero {\n" - + " __typename\n" - + " ...HumanDetails\n" - + " ...DroidDetails\n" - + " }\n" - + "}\n" - + "fragment HumanDetails on Human {\n" - + " __typename\n" - + " name\n" - + " height\n" - + "}\n" - + "fragment DroidDetails on Droid {\n" - + " __typename\n" - + " name\n" - + " primaryFunction\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public TestQuery.Data wrapData(TestQuery.Data data) { - return data; - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response parse(@NotNull final BufferedSource source) throws IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response parse(@NotNull final ByteString byteString) throws IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("r2", "hero", null, true, Collections.emptyList()), - ResponseField.forObject("luke", "hero", null, true, Collections.emptyList()) - }; - - final @Nullable R2 r2; - - final @Nullable Luke luke; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable R2 r2, @Nullable Luke luke) { - this.r2 = r2; - this.luke = luke; - } - - public @Nullable R2 r2() { - return this.r2; - } - - public @Nullable Luke luke() { - return this.luke; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], r2 != null ? r2.marshaller() : null); - writer.writeObject($responseFields[1], luke != null ? luke.marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "r2=" + r2 + ", " - + "luke=" + luke - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return ((this.r2 == null) ? (that.r2 == null) : this.r2.equals(that.r2)) - && ((this.luke == null) ? (that.luke == null) : this.luke.equals(that.luke)); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= (r2 == null) ? 0 : r2.hashCode(); - h *= 1000003; - h ^= (luke == null) ? 0 : luke.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final R2.Mapper r2FieldMapper = new R2.Mapper(); - - final Luke.Mapper lukeFieldMapper = new Luke.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final R2 r2 = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public R2 read(ResponseReader reader) { - return r2FieldMapper.map(reader); - } - }); - final Luke luke = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Luke read(ResponseReader reader) { - return lukeFieldMapper.map(reader); - } - }); - return new Data(r2, luke); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class R2 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public R2(@NotNull String __typename, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "R2{" - + "__typename=" + __typename + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof R2) { - R2 that = (R2) o; - return this.__typename.equals(that.__typename) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @Nullable HumanDetails humanDetails; - - final @Nullable DroidDetails droidDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@Nullable HumanDetails humanDetails, @Nullable DroidDetails droidDetails) { - this.humanDetails = humanDetails; - this.droidDetails = droidDetails; - } - - public @Nullable HumanDetails humanDetails() { - return this.humanDetails; - } - - public @Nullable DroidDetails droidDetails() { - return this.droidDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - final HumanDetails $humanDetails = humanDetails; - if ($humanDetails != null) { - writer.writeFragment($humanDetails.marshaller()); - } - final DroidDetails $droidDetails = droidDetails; - if ($droidDetails != null) { - writer.writeFragment($droidDetails.marshaller()); - } - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "humanDetails=" + humanDetails + ", " - + "droidDetails=" + droidDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return ((this.humanDetails == null) ? (that.humanDetails == null) : this.humanDetails.equals(that.humanDetails)) - && ((this.droidDetails == null) ? (that.droidDetails == null) : this.droidDetails.equals(that.droidDetails)); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= (humanDetails == null) ? 0 : humanDetails.hashCode(); - h *= 1000003; - h ^= (droidDetails == null) ? 0 : droidDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid"}) - )) - }; - - final HumanDetails.Mapper humanDetailsFieldMapper = new HumanDetails.Mapper(); - - final DroidDetails.Mapper droidDetailsFieldMapper = new DroidDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HumanDetails humanDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HumanDetails read(ResponseReader reader) { - return humanDetailsFieldMapper.map(reader); - } - }); - final DroidDetails droidDetails = reader.readFragment($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public DroidDetails read(ResponseReader reader) { - return droidDetailsFieldMapper.map(reader); - } - }); - return new Fragments(humanDetails, droidDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public R2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new R2(__typename, fragments); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Luke { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Luke(@NotNull String __typename, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Luke{" - + "__typename=" + __typename + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Luke) { - Luke that = (Luke) o; - return this.__typename.equals(that.__typename) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @Nullable HumanDetails humanDetails; - - final @Nullable DroidDetails droidDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@Nullable HumanDetails humanDetails, @Nullable DroidDetails droidDetails) { - this.humanDetails = humanDetails; - this.droidDetails = droidDetails; - } - - public @Nullable HumanDetails humanDetails() { - return this.humanDetails; - } - - public @Nullable DroidDetails droidDetails() { - return this.droidDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - final HumanDetails $humanDetails = humanDetails; - if ($humanDetails != null) { - writer.writeFragment($humanDetails.marshaller()); - } - final DroidDetails $droidDetails = droidDetails; - if ($droidDetails != null) { - writer.writeFragment($droidDetails.marshaller()); - } - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "humanDetails=" + humanDetails + ", " - + "droidDetails=" + droidDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return ((this.humanDetails == null) ? (that.humanDetails == null) : this.humanDetails.equals(that.humanDetails)) - && ((this.droidDetails == null) ? (that.droidDetails == null) : this.droidDetails.equals(that.droidDetails)); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= (humanDetails == null) ? 0 : humanDetails.hashCode(); - h *= 1000003; - h ^= (droidDetails == null) ? 0 : droidDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid"}) - )) - }; - - final HumanDetails.Mapper humanDetailsFieldMapper = new HumanDetails.Mapper(); - - final DroidDetails.Mapper droidDetailsFieldMapper = new DroidDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HumanDetails humanDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HumanDetails read(ResponseReader reader) { - return humanDetailsFieldMapper.map(reader); - } - }); - final DroidDetails droidDetails = reader.readFragment($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public DroidDetails read(ResponseReader reader) { - return droidDetailsFieldMapper.map(reader); - } - }); - return new Fragments(humanDetails, droidDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Luke map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Luke(__typename, fragments); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/TestQuery.kt deleted file mode 100644 index 4178eb447e5..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/TestQuery.kt +++ /dev/null @@ -1,294 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition_nullable - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.fragments_with_type_condition_nullable.fragment.DroidDetails -import com.example.fragments_with_type_condition_nullable.fragment.HumanDetails -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class R2( - val __typename: String = "Character", - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@R2.__typename) - this@R2.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): R2 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val fragments = Fragments(reader) - R2( - __typename = __typename, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val humanDetails: HumanDetails?, - val droidDetails: DroidDetails? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.humanDetails?.marshaller()) - writer.writeFragment(this@Fragments.droidDetails?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid")) - )) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val humanDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - HumanDetails(reader) - } - val droidDetails = readFragment(RESPONSE_FIELDS[1]) { reader -> - DroidDetails(reader) - } - Fragments( - humanDetails = humanDetails, - droidDetails = droidDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * A character from the Star Wars universe - */ - data class Luke( - val __typename: String = "Character", - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Luke.__typename) - this@Luke.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Luke = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val fragments = Fragments(reader) - Luke( - __typename = __typename, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val humanDetails: HumanDetails?, - val droidDetails: DroidDetails? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.humanDetails?.marshaller()) - writer.writeFragment(this@Fragments.droidDetails?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid")) - )) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val humanDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - HumanDetails(reader) - } - val droidDetails = readFragment(RESPONSE_FIELDS[1]) { reader -> - DroidDetails(reader) - } - Fragments( - humanDetails = humanDetails, - droidDetails = droidDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val r2: R2?, - val luke: Luke? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.r2?.marshaller()) - writer.writeObject(RESPONSE_FIELDS[1], this@Data.luke?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("r2", "hero", null, true, null), - ResponseField.forObject("luke", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val r2 = readObject(RESPONSE_FIELDS[0]) { reader -> - R2(reader) - } - val luke = readObject(RESPONSE_FIELDS[1]) { reader -> - Luke(reader) - } - Data( - r2 = r2, - luke = luke - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "919cec7210259fa24fc6026fe680b96f357c14ebf3c8a734979dcfb819685d6a" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | r2: hero { - | __typename - | ...HumanDetails - | ...DroidDetails - | } - | luke: hero { - | __typename - | ...HumanDetails - | ...DroidDetails - | } - |} - |fragment HumanDetails on Human { - | __typename - | name - | height - |} - |fragment DroidDetails on Droid { - | __typename - | name - | primaryFunction - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/fragment/DroidDetails.java b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/fragment/DroidDetails.java deleted file mode 100644 index 60089a3037b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/fragment/DroidDetails.java +++ /dev/null @@ -1,136 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition_nullable.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class DroidDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment DroidDetails on Droid {\n" - + " __typename\n" - + " name\n" - + " primaryFunction\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - final @Nullable String primaryFunction; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public DroidDetails(@NotNull String __typename, @NotNull String name, - @Nullable String primaryFunction) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.primaryFunction = primaryFunction; - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What others call this droid - */ - public @NotNull String name() { - return this.name; - } - - /** - * This droid's primary function - */ - public @Nullable String primaryFunction() { - return this.primaryFunction; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeString($responseFields[2], primaryFunction); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "DroidDetails{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "primaryFunction=" + primaryFunction - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof DroidDetails) { - DroidDetails that = (DroidDetails) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && ((this.primaryFunction == null) ? (that.primaryFunction == null) : this.primaryFunction.equals(that.primaryFunction)); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= (primaryFunction == null) ? 0 : primaryFunction.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public DroidDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final String primaryFunction = reader.readString($responseFields[2]); - return new DroidDetails(__typename, name, primaryFunction); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/fragment/DroidDetails.kt b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/fragment/DroidDetails.kt deleted file mode 100644 index 710f8b55412..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/fragment/DroidDetails.kt +++ /dev/null @@ -1,65 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition_nullable.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class DroidDetails( - val __typename: String = "Droid", - /** - * What others call this droid - */ - val name: String, - /** - * This droid's primary function - */ - val primaryFunction: String? -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@DroidDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@DroidDetails.name) - writer.writeString(RESPONSE_FIELDS[2], this@DroidDetails.primaryFunction) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment DroidDetails on Droid { - | __typename - | name - | primaryFunction - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): DroidDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val primaryFunction = readString(RESPONSE_FIELDS[2]) - DroidDetails( - __typename = __typename, - name = name, - primaryFunction = primaryFunction - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/fragment/HumanDetails.java b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/fragment/HumanDetails.java deleted file mode 100644 index e0585333666..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/fragment/HumanDetails.java +++ /dev/null @@ -1,136 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition_nullable.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class HumanDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forDouble("height", "height", null, true, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment HumanDetails on Human {\n" - + " __typename\n" - + " name\n" - + " height\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - final @Nullable Double height; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HumanDetails(@NotNull String __typename, @NotNull String name, @Nullable Double height) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.height = height; - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - /** - * Height in the preferred unit, default is meters - */ - public @Nullable Double height() { - return this.height; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeDouble($responseFields[2], height); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HumanDetails{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "height=" + height - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HumanDetails) { - HumanDetails that = (HumanDetails) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && ((this.height == null) ? (that.height == null) : this.height.equals(that.height)); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= (height == null) ? 0 : height.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public HumanDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final Double height = reader.readDouble($responseFields[2]); - return new HumanDetails(__typename, name, height); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/fragment/HumanDetails.kt b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/fragment/HumanDetails.kt deleted file mode 100644 index 2f2ad9b4b08..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/fragment/HumanDetails.kt +++ /dev/null @@ -1,66 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition_nullable.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.Double -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class HumanDetails( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String, - /** - * Height in the preferred unit, default is meters - */ - val height: Double? -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HumanDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HumanDetails.name) - writer.writeDouble(RESPONSE_FIELDS[2], this@HumanDetails.height) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forDouble("height", "height", null, true, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment HumanDetails on Human { - | __typename - | name - | height - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HumanDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val height = readDouble(RESPONSE_FIELDS[2]) - HumanDetails( - __typename = __typename, - name = name, - height = height - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/type/CustomType.java deleted file mode 100644 index 0ad328a5c4f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition_nullable.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/type/CustomType.kt deleted file mode 100644 index 366dd299fe3..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/fragments_with_type_condition_nullable/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.fragments_with_type_condition_nullable.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details/HeroDetails.java b/apollo-compiler/src/test/graphql/com/example/hero_details/HeroDetails.java deleted file mode 100644 index 9d8463a2675..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details/HeroDetails.java +++ /dev/null @@ -1,716 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.hero_details.type.Hero_type; -import java.io.IOException; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class HeroDetails implements Query, Operation.Variables> { - public static final String OPERATION_ID = "e9e881883e577da3a4dc0ea9eedbdbc8a05f65fe08bd6f1ae6c1e993b75dfbe4"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query HeroDetails {\n" - + " hero {\n" - + " __typename\n" - + " type\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "HeroDetails"; - } - }; - - private final Operation.Variables variables; - - public HeroDetails() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(HeroDetails.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public HeroDetails build() { - return new HeroDetails(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("type", "type", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull Hero_type type; - - final @NotNull String name; - - final @NotNull FriendsConnection friendsConnection; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull Hero_type type, @NotNull String name, - @NotNull FriendsConnection friendsConnection) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.type = Utils.checkNotNull(type, "type == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * Hero type - */ - public @NotNull Hero_type type() { - return this.type; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The friends of the character exposed as a connection with edges - */ - public @NotNull FriendsConnection friendsConnection() { - return this.friendsConnection; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], type.rawValue()); - writer.writeString($responseFields[2], name); - writer.writeObject($responseFields[3], friendsConnection.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "type=" + type + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.type.equals(that.type) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= type.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection.Mapper friendsConnectionFieldMapper = new FriendsConnection.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String typeStr = reader.readString($responseFields[1]); - final Hero_type type; - if (typeStr != null) { - type = Hero_type.safeValueOf(typeStr); - } else { - type = null; - } - final String name = reader.readString($responseFields[2]); - final FriendsConnection friendsConnection = reader.readObject($responseFields[3], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection read(ResponseReader reader) { - return friendsConnectionFieldMapper.map(reader); - } - }); - return new Hero(__typename, type, name, friendsConnection); - } - } - } - - /** - * A connection object for a character's friends - */ - public static class FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - final Optional> edges; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection(@NotNull String __typename, @Nullable Integer totalCount, - @Nullable List edges) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.fromNullable(totalCount); - this.edges = Optional.fromNullable(edges); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional totalCount() { - return this.totalCount; - } - - /** - * The edges for each of the character's friends. - */ - public Optional> edges() { - return this.edges; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - writer.writeList($responseFields[2], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount + ", " - + "edges=" + edges - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection) { - FriendsConnection that = (FriendsConnection) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount) - && this.edges.equals(that.edges); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge.Mapper edgeFieldMapper = new Edge.Mapper(); - - @Override - public FriendsConnection map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - final List edges = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Edge read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge read(ResponseReader reader) { - return edgeFieldMapper.map(reader); - } - }); - } - }); - return new FriendsConnection(__typename, totalCount, edges); - } - } - } - - /** - * An edge object for a character's friends - */ - public static class Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge(@NotNull String __typename, @Nullable Node node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.fromNullable(node); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The character represented by this friendship edge - */ - public Optional node() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge) { - Edge that = (Edge) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Node.Mapper nodeFieldMapper = new Node.Mapper(); - - @Override - public Edge map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node read(ResponseReader reader) { - return nodeFieldMapper.map(reader); - } - }); - return new Edge(__typename, node); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node) { - Node that = (Node) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Node map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Node(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details/HeroDetails.kt b/apollo-compiler/src/test/graphql/com/example/hero_details/HeroDetails.kt deleted file mode 100644 index ce99aa866c7..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details/HeroDetails.kt +++ /dev/null @@ -1,323 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.hero_details.type.Hero_type -import kotlin.Array -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class HeroDetails : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Node( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Node.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Node( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An edge object for a character's friends - */ - data class Edge( - val __typename: String = "FriendsEdge", - /** - * The character represented by this friendship edge - */ - val node: Node? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node(reader) - } - Edge( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int?, - /** - * The edges for each of the character's friends. - */ - val edges: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection.totalCount) - writer.writeList(RESPONSE_FIELDS[2], this@FriendsConnection.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null), - ResponseField.forList("edges", "edges", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - val edges = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Edge(reader) - } - } - FriendsConnection( - __typename = __typename, - totalCount = totalCount, - edges = edges - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * Hero type - */ - val type: Hero_type, - /** - * The name of the character - */ - val name: String, - /** - * The friends of the character exposed as a connection with edges - */ - val friendsConnection: FriendsConnection - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.type.rawValue) - writer.writeString(RESPONSE_FIELDS[2], this@Hero.name) - writer.writeObject(RESPONSE_FIELDS[3], this@Hero.friendsConnection.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forEnum("type", "type", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val type = Hero_type.safeValueOf(readString(RESPONSE_FIELDS[1])!!) - val name = readString(RESPONSE_FIELDS[2])!! - val friendsConnection = readObject(RESPONSE_FIELDS[3]) { reader -> - FriendsConnection(reader) - }!! - Hero( - __typename = __typename, - type = type, - name = name, - friendsConnection = friendsConnection - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "e9e881883e577da3a4dc0ea9eedbdbc8a05f65fe08bd6f1ae6c1e993b75dfbe4" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query HeroDetails { - | hero { - | __typename - | type - | name - | friendsConnection { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "HeroDetails" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/hero_details/TestOperation.graphql deleted file mode 100644 index 1043b37df79..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details/TestOperation.graphql +++ /dev/null @@ -1,14 +0,0 @@ -query HeroDetails { - hero { - type - name - friendsConnection { - totalCount - edges { - node { - name - } - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/hero_details/type/CustomType.java deleted file mode 100644 index 078a3aec22b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/hero_details/type/CustomType.kt deleted file mode 100644 index c128c01f550..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details/type/Hero_type.java b/apollo-compiler/src/test/graphql/com/example/hero_details/type/Hero_type.java deleted file mode 100644 index b6366a7c259..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details/type/Hero_type.java +++ /dev/null @@ -1,41 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details.type; - -import java.lang.String; - -/** - * Lower case enum type name - */ -public enum Hero_type { - HUMAN("human"), - - DROID("droid"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Hero_type(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Hero_type safeValueOf(String rawValue) { - for (Hero_type enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Hero_type.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details/type/Hero_type.kt b/apollo-compiler/src/test/graphql/com/example/hero_details/type/Hero_type.kt deleted file mode 100644 index acbfd06623b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details/type/Hero_type.kt +++ /dev/null @@ -1,30 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.String - -/** - * Lower case enum type name - */ -enum class Hero_type( - override val rawValue: String -) : EnumValue { - HUMAN("human"), - - DROID("droid"), - - /** - * Auto generated constant for unknown enum values - */ - UNKNOWN__("UNKNOWN__"); - - companion object { - fun safeValueOf(rawValue: String): Hero_type = values().find { it.rawValue == rawValue } ?: - UNKNOWN__ - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_guava/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/hero_details_guava/TestOperation.graphql deleted file mode 100644 index f3b74f57a4d..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_guava/TestOperation.graphql +++ /dev/null @@ -1,13 +0,0 @@ -query TestQuery { - hero { - name - friendsConnection { - totalCount - edges { - node { - name - } - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_guava/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/hero_details_guava/TestQuery.java deleted file mode 100644 index c949230270f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_guava/TestQuery.java +++ /dev/null @@ -1,691 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_guava; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.google.common.base.Optional; -import java.io.IOException; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "6298efc5535c4a084ea32f95e9be418d8539c852ce96af37110175be4ceed09b"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull FriendsConnection friendsConnection; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull String name, - @NotNull FriendsConnection friendsConnection) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The friends of the character exposed as a connection with edges - */ - public @NotNull FriendsConnection friendsConnection() { - return this.friendsConnection; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeObject($responseFields[2], friendsConnection.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection.Mapper friendsConnectionFieldMapper = new FriendsConnection.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final FriendsConnection friendsConnection = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection read(ResponseReader reader) { - return friendsConnectionFieldMapper.map(reader); - } - }); - return new Hero(__typename, name, friendsConnection); - } - } - } - - /** - * A connection object for a character's friends - */ - public static class FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - final Optional> edges; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection(@NotNull String __typename, @Nullable Integer totalCount, - @Nullable List edges) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.fromNullable(totalCount); - this.edges = Optional.fromNullable(edges); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional totalCount() { - return this.totalCount; - } - - /** - * The edges for each of the character's friends. - */ - public Optional> edges() { - return this.edges; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - writer.writeList($responseFields[2], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount + ", " - + "edges=" + edges - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection) { - FriendsConnection that = (FriendsConnection) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount) - && this.edges.equals(that.edges); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge.Mapper edgeFieldMapper = new Edge.Mapper(); - - @Override - public FriendsConnection map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - final List edges = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Edge read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge read(ResponseReader reader) { - return edgeFieldMapper.map(reader); - } - }); - } - }); - return new FriendsConnection(__typename, totalCount, edges); - } - } - } - - /** - * An edge object for a character's friends - */ - public static class Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge(@NotNull String __typename, @Nullable Node node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.fromNullable(node); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The character represented by this friendship edge - */ - public Optional node() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge) { - Edge that = (Edge) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Node.Mapper nodeFieldMapper = new Node.Mapper(); - - @Override - public Edge map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node read(ResponseReader reader) { - return nodeFieldMapper.map(reader); - } - }); - return new Edge(__typename, node); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node) { - Node that = (Node) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Node map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Node(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_guava/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/hero_details_guava/TestQuery.kt deleted file mode 100644 index a58ea87d5e2..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_guava/TestQuery.kt +++ /dev/null @@ -1,313 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_guava - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import kotlin.Array -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Node( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Node.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Node( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An edge object for a character's friends - */ - data class Edge( - val __typename: String = "FriendsEdge", - /** - * The character represented by this friendship edge - */ - val node: Node? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node(reader) - } - Edge( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int?, - /** - * The edges for each of the character's friends. - */ - val edges: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection.totalCount) - writer.writeList(RESPONSE_FIELDS[2], this@FriendsConnection.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null), - ResponseField.forList("edges", "edges", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - val edges = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Edge(reader) - } - } - FriendsConnection( - __typename = __typename, - totalCount = totalCount, - edges = edges - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The friends of the character exposed as a connection with edges - */ - val friendsConnection: FriendsConnection - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeObject(RESPONSE_FIELDS[2], this@Hero.friendsConnection.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friendsConnection = readObject(RESPONSE_FIELDS[2]) { reader -> - FriendsConnection(reader) - }!! - Hero( - __typename = __typename, - name = name, - friendsConnection = friendsConnection - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "6298efc5535c4a084ea32f95e9be418d8539c852ce96af37110175be4ceed09b" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | name - | friendsConnection { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_guava/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/hero_details_guava/type/CustomType.java deleted file mode 100644 index ab4d4dd18a2..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_guava/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_guava.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_guava/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/hero_details_guava/type/CustomType.kt deleted file mode 100644 index 6907fd59f6f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_guava/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_guava.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_java_optional/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/hero_details_java_optional/TestOperation.graphql deleted file mode 100644 index f3b74f57a4d..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_java_optional/TestOperation.graphql +++ /dev/null @@ -1,13 +0,0 @@ -query TestQuery { - hero { - name - friendsConnection { - totalCount - edges { - node { - name - } - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_java_optional/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/hero_details_java_optional/TestQuery.java deleted file mode 100644 index a99afcf6053..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_java_optional/TestQuery.java +++ /dev/null @@ -1,691 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_java_optional; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "6298efc5535c4a084ea32f95e9be418d8539c852ce96af37110175be4ceed09b"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.ofNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.ofNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull FriendsConnection friendsConnection; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull String name, - @NotNull FriendsConnection friendsConnection) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The friends of the character exposed as a connection with edges - */ - public @NotNull FriendsConnection friendsConnection() { - return this.friendsConnection; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeObject($responseFields[2], friendsConnection.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection.Mapper friendsConnectionFieldMapper = new FriendsConnection.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final FriendsConnection friendsConnection = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection read(ResponseReader reader) { - return friendsConnectionFieldMapper.map(reader); - } - }); - return new Hero(__typename, name, friendsConnection); - } - } - } - - /** - * A connection object for a character's friends - */ - public static class FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - final Optional> edges; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection(@NotNull String __typename, @Nullable Integer totalCount, - @Nullable List edges) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.ofNullable(totalCount); - this.edges = Optional.ofNullable(edges); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional totalCount() { - return this.totalCount; - } - - /** - * The edges for each of the character's friends. - */ - public Optional> edges() { - return this.edges; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - writer.writeList($responseFields[2], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount + ", " - + "edges=" + edges - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection) { - FriendsConnection that = (FriendsConnection) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount) - && this.edges.equals(that.edges); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge.Mapper edgeFieldMapper = new Edge.Mapper(); - - @Override - public FriendsConnection map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - final List edges = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Edge read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge read(ResponseReader reader) { - return edgeFieldMapper.map(reader); - } - }); - } - }); - return new FriendsConnection(__typename, totalCount, edges); - } - } - } - - /** - * An edge object for a character's friends - */ - public static class Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge(@NotNull String __typename, @Nullable Node node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.ofNullable(node); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The character represented by this friendship edge - */ - public Optional node() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge) { - Edge that = (Edge) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Node.Mapper nodeFieldMapper = new Node.Mapper(); - - @Override - public Edge map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node read(ResponseReader reader) { - return nodeFieldMapper.map(reader); - } - }); - return new Edge(__typename, node); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node) { - Node that = (Node) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Node map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Node(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_java_optional/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/hero_details_java_optional/TestQuery.kt deleted file mode 100644 index 43e20469d44..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_java_optional/TestQuery.kt +++ /dev/null @@ -1,313 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_java_optional - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import kotlin.Array -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Node( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Node.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Node( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An edge object for a character's friends - */ - data class Edge( - val __typename: String = "FriendsEdge", - /** - * The character represented by this friendship edge - */ - val node: Node? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node(reader) - } - Edge( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int?, - /** - * The edges for each of the character's friends. - */ - val edges: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection.totalCount) - writer.writeList(RESPONSE_FIELDS[2], this@FriendsConnection.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null), - ResponseField.forList("edges", "edges", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - val edges = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Edge(reader) - } - } - FriendsConnection( - __typename = __typename, - totalCount = totalCount, - edges = edges - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The friends of the character exposed as a connection with edges - */ - val friendsConnection: FriendsConnection - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeObject(RESPONSE_FIELDS[2], this@Hero.friendsConnection.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friendsConnection = readObject(RESPONSE_FIELDS[2]) { reader -> - FriendsConnection(reader) - }!! - Hero( - __typename = __typename, - name = name, - friendsConnection = friendsConnection - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "6298efc5535c4a084ea32f95e9be418d8539c852ce96af37110175be4ceed09b" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | name - | friendsConnection { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_java_optional/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/hero_details_java_optional/type/CustomType.java deleted file mode 100644 index 4cce6351698..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_java_optional/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_java_optional.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_java_optional/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/hero_details_java_optional/type/CustomType.kt deleted file mode 100644 index 3c226162ea9..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_java_optional/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_java_optional.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_nullable/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/hero_details_nullable/TestOperation.graphql deleted file mode 100644 index f3b74f57a4d..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_nullable/TestOperation.graphql +++ /dev/null @@ -1,13 +0,0 @@ -query TestQuery { - hero { - name - friendsConnection { - totalCount - edges { - node { - name - } - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_nullable/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/hero_details_nullable/TestQuery.java deleted file mode 100644 index 9b6d6d2f7d9..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_nullable/TestQuery.java +++ /dev/null @@ -1,688 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_nullable; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query { - public static final String OPERATION_ID = "6298efc5535c4a084ea32f95e9be418d8539c852ce96af37110175be4ceed09b"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public TestQuery.Data wrapData(TestQuery.Data data) { - return data; - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response parse(@NotNull final BufferedSource source) throws IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response parse(@NotNull final ByteString byteString) throws IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final @Nullable Hero hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = hero; - } - - public @Nullable Hero hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero != null ? hero.marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return ((this.hero == null) ? (that.hero == null) : this.hero.equals(that.hero)); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= (hero == null) ? 0 : hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull FriendsConnection friendsConnection; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull String name, - @NotNull FriendsConnection friendsConnection) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The friends of the character exposed as a connection with edges - */ - public @NotNull FriendsConnection friendsConnection() { - return this.friendsConnection; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeObject($responseFields[2], friendsConnection.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection.Mapper friendsConnectionFieldMapper = new FriendsConnection.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final FriendsConnection friendsConnection = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection read(ResponseReader reader) { - return friendsConnectionFieldMapper.map(reader); - } - }); - return new Hero(__typename, name, friendsConnection); - } - } - } - - /** - * A connection object for a character's friends - */ - public static class FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @Nullable Integer totalCount; - - final @Nullable List edges; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection(@NotNull String __typename, @Nullable Integer totalCount, - @Nullable List edges) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = totalCount; - this.edges = edges; - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public @Nullable Integer totalCount() { - return this.totalCount; - } - - /** - * The edges for each of the character's friends. - */ - public @Nullable List edges() { - return this.edges; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount); - writer.writeList($responseFields[2], edges, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount + ", " - + "edges=" + edges - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection) { - FriendsConnection that = (FriendsConnection) o; - return this.__typename.equals(that.__typename) - && ((this.totalCount == null) ? (that.totalCount == null) : this.totalCount.equals(that.totalCount)) - && ((this.edges == null) ? (that.edges == null) : this.edges.equals(that.edges)); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= (totalCount == null) ? 0 : totalCount.hashCode(); - h *= 1000003; - h ^= (edges == null) ? 0 : edges.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge.Mapper edgeFieldMapper = new Edge.Mapper(); - - @Override - public FriendsConnection map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - final List edges = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Edge read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge read(ResponseReader reader) { - return edgeFieldMapper.map(reader); - } - }); - } - }); - return new FriendsConnection(__typename, totalCount, edges); - } - } - } - - /** - * An edge object for a character's friends - */ - public static class Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @Nullable Node node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge(@NotNull String __typename, @Nullable Node node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = node; - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The character represented by this friendship edge - */ - public @Nullable Node node() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node != null ? node.marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge) { - Edge that = (Edge) o; - return this.__typename.equals(that.__typename) - && ((this.node == null) ? (that.node == null) : this.node.equals(that.node)); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= (node == null) ? 0 : node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Node.Mapper nodeFieldMapper = new Node.Mapper(); - - @Override - public Edge map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node read(ResponseReader reader) { - return nodeFieldMapper.map(reader); - } - }); - return new Edge(__typename, node); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node) { - Node that = (Node) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Node map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Node(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_nullable/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/hero_details_nullable/TestQuery.kt deleted file mode 100644 index 46b27884d79..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_nullable/TestQuery.kt +++ /dev/null @@ -1,313 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_nullable - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import kotlin.Array -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Node( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Node.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Node( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An edge object for a character's friends - */ - data class Edge( - val __typename: String = "FriendsEdge", - /** - * The character represented by this friendship edge - */ - val node: Node? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node(reader) - } - Edge( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int?, - /** - * The edges for each of the character's friends. - */ - val edges: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection.totalCount) - writer.writeList(RESPONSE_FIELDS[2], this@FriendsConnection.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null), - ResponseField.forList("edges", "edges", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - val edges = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Edge(reader) - } - } - FriendsConnection( - __typename = __typename, - totalCount = totalCount, - edges = edges - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The friends of the character exposed as a connection with edges - */ - val friendsConnection: FriendsConnection - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeObject(RESPONSE_FIELDS[2], this@Hero.friendsConnection.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friendsConnection = readObject(RESPONSE_FIELDS[2]) { reader -> - FriendsConnection(reader) - }!! - Hero( - __typename = __typename, - name = name, - friendsConnection = friendsConnection - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "6298efc5535c4a084ea32f95e9be418d8539c852ce96af37110175be4ceed09b" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | name - | friendsConnection { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_nullable/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/hero_details_nullable/type/CustomType.java deleted file mode 100644 index 8f1cb378826..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_nullable/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_nullable.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_nullable/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/hero_details_nullable/type/CustomType.kt deleted file mode 100644 index e99883d82bc..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_nullable/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_nullable.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_semantic_naming/HeroDetailsQuery.java b/apollo-compiler/src/test/graphql/com/example/hero_details_semantic_naming/HeroDetailsQuery.java deleted file mode 100644 index a5d0e2c0c2c..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_semantic_naming/HeroDetailsQuery.java +++ /dev/null @@ -1,691 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_semantic_naming; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class HeroDetailsQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "257332d822c9bcd5dabeff3f3dda46875a47846f6eeae88f9042c94e3effeee7"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query HeroDetails {\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "HeroDetails"; - } - }; - - private final Operation.Variables variables; - - public HeroDetailsQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(HeroDetailsQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) - throws IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) - throws IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public HeroDetailsQuery build() { - return new HeroDetailsQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull FriendsConnection friendsConnection; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull String name, - @NotNull FriendsConnection friendsConnection) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The friends of the character exposed as a connection with edges - */ - public @NotNull FriendsConnection friendsConnection() { - return this.friendsConnection; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeObject($responseFields[2], friendsConnection.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection.Mapper friendsConnectionFieldMapper = new FriendsConnection.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final FriendsConnection friendsConnection = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection read(ResponseReader reader) { - return friendsConnectionFieldMapper.map(reader); - } - }); - return new Hero(__typename, name, friendsConnection); - } - } - } - - /** - * A connection object for a character's friends - */ - public static class FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - final Optional> edges; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection(@NotNull String __typename, @Nullable Integer totalCount, - @Nullable List edges) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.fromNullable(totalCount); - this.edges = Optional.fromNullable(edges); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional totalCount() { - return this.totalCount; - } - - /** - * The edges for each of the character's friends. - */ - public Optional> edges() { - return this.edges; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - writer.writeList($responseFields[2], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount + ", " - + "edges=" + edges - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection) { - FriendsConnection that = (FriendsConnection) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount) - && this.edges.equals(that.edges); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge.Mapper edgeFieldMapper = new Edge.Mapper(); - - @Override - public FriendsConnection map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - final List edges = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Edge read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge read(ResponseReader reader) { - return edgeFieldMapper.map(reader); - } - }); - } - }); - return new FriendsConnection(__typename, totalCount, edges); - } - } - } - - /** - * An edge object for a character's friends - */ - public static class Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge(@NotNull String __typename, @Nullable Node node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.fromNullable(node); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The character represented by this friendship edge - */ - public Optional node() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge) { - Edge that = (Edge) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Node.Mapper nodeFieldMapper = new Node.Mapper(); - - @Override - public Edge map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node read(ResponseReader reader) { - return nodeFieldMapper.map(reader); - } - }); - return new Edge(__typename, node); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node) { - Node that = (Node) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Node map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Node(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_semantic_naming/HeroDetailsQuery.kt b/apollo-compiler/src/test/graphql/com/example/hero_details_semantic_naming/HeroDetailsQuery.kt deleted file mode 100644 index 92cf5026d45..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_semantic_naming/HeroDetailsQuery.kt +++ /dev/null @@ -1,313 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_semantic_naming - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import kotlin.Array -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class HeroDetailsQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Node( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Node.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Node( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An edge object for a character's friends - */ - data class Edge( - val __typename: String = "FriendsEdge", - /** - * The character represented by this friendship edge - */ - val node: Node? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node(reader) - } - Edge( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int?, - /** - * The edges for each of the character's friends. - */ - val edges: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection.totalCount) - writer.writeList(RESPONSE_FIELDS[2], this@FriendsConnection.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null), - ResponseField.forList("edges", "edges", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - val edges = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Edge(reader) - } - } - FriendsConnection( - __typename = __typename, - totalCount = totalCount, - edges = edges - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The friends of the character exposed as a connection with edges - */ - val friendsConnection: FriendsConnection - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeObject(RESPONSE_FIELDS[2], this@Hero.friendsConnection.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friendsConnection = readObject(RESPONSE_FIELDS[2]) { reader -> - FriendsConnection(reader) - }!! - Hero( - __typename = __typename, - name = name, - friendsConnection = friendsConnection - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "257332d822c9bcd5dabeff3f3dda46875a47846f6eeae88f9042c94e3effeee7" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query HeroDetails { - | hero { - | __typename - | name - | friendsConnection { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "HeroDetails" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_semantic_naming/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/hero_details_semantic_naming/TestOperation.graphql deleted file mode 100644 index 94c730fafe7..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_semantic_naming/TestOperation.graphql +++ /dev/null @@ -1,13 +0,0 @@ -query HeroDetails { - hero { - name - friendsConnection { - totalCount - edges { - node { - name - } - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_semantic_naming/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/hero_details_semantic_naming/type/CustomType.java deleted file mode 100644 index e5e7893559e..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_semantic_naming/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_semantic_naming.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_details_semantic_naming/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/hero_details_semantic_naming/type/CustomType.kt deleted file mode 100644 index 6fb03bfdeb3..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_details_semantic_naming/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_details_semantic_naming.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_name/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/hero_name/TestOperation.graphql deleted file mode 100644 index 4789454707d..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_name/TestOperation.graphql +++ /dev/null @@ -1,14 +0,0 @@ -# This is a sample query to fetch hero name -# that demonstrates Java / Kotlin docs generations -# for query data model -query TestQuery { - # another comment - hero { - # the last comment - name - } - hero { - id - name - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_name/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/hero_name/TestQuery.java deleted file mode 100644 index 8a8f7386750..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_name/TestQuery.java +++ /dev/null @@ -1,355 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_name; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.hero_name.type.CustomType; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * This is a sample query to fetch hero name - * that demonstrates Java / Kotlin docs generations - * for query data model - */ -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "c10c6dfe569b0fbb60c67e42c973f7ffef2314b43004c527a03bdd790ef0f5dc"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " hero {\n" - + " __typename\n" - + " id\n" - + " name\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull String id; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull String name, @NotNull String id) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.id = Utils.checkNotNull(id, "id == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The ID of the character - */ - public @NotNull String id() { - return this.id; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[2], id); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "id=" + id - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.id.equals(that.id); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= id.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[2]); - return new Hero(__typename, name, id); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_name/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/hero_name/TestQuery.kt deleted file mode 100644 index 790c99445c4..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_name/TestQuery.kt +++ /dev/null @@ -1,185 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_name - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.hero_name.type.CustomType -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -/** - * This is a sample query to fetch hero name - * that demonstrates Java / Kotlin docs generations - * for query data model - */ -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The ID of the character - */ - val id: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeCustom(RESPONSE_FIELDS[2] as ResponseField.CustomTypeField, this@Hero.id) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val id = readCustomType(RESPONSE_FIELDS[2] as ResponseField.CustomTypeField)!! - Hero( - __typename = __typename, - name = name, - id = id - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "c10c6dfe569b0fbb60c67e42c973f7ffef2314b43004c527a03bdd790ef0f5dc" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | name - | } - | hero { - | __typename - | id - | name - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_name/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/hero_name/type/CustomType.java deleted file mode 100644 index a150593c9e8..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_name/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_name.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_name/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/hero_name/type/CustomType.kt deleted file mode 100644 index 404e3f2d0c6..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_name/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_name.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/TestOperation.graphql deleted file mode 100644 index ea8e556cc34..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/TestOperation.graphql +++ /dev/null @@ -1,5 +0,0 @@ -query TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName($episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName:Episode) { - heroAVeryAVeryAVeryAVeryAVeryAVeryAV: hero(episode: $episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName) { - nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName: name - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.java b/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.java deleted file mode 100644 index 56d8017a028..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.java +++ /dev/null @@ -1,387 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_name_query_long_name; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.hero_name_query_long_name.type.Episode; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName implements Query, TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.Variables> { - public static final String OPERATION_ID = "da1b713dcfa710f7f5dbe01186d56ebdec768de44002ab965740de6acbee1d01"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName($episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName:Episode) {\n" - + " heroAVeryAVeryAVeryAVeryAVeryAVeryAV: hero(episode: $episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName) {\n" - + " __typename\n" - + " nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName: name\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName"; - } - }; - - private final TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.Variables variables; - - public TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName(@NotNull Input episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName) { - Utils.checkNotNull(episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName, "episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName == null"); - variables = new TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.Variables(episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName); - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.Data data) { - return Optional.fromNullable(data); - } - - @Override - public TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) - throws IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) - throws IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - private Input episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName = Input.absent(); - - Builder() { - } - - public Builder episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName(@Nullable Episode episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName) { - this.episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName = Input.fromNullable(episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName); - return this; - } - - public Builder episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongNameInput(@NotNull Input episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName) { - this.episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName = Utils.checkNotNull(episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName, "episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName == null"); - return this; - } - - public TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName build() { - return new TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName(episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName); - } - } - - public static final class Variables extends Operation.Variables { - private final Input episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName; - - private final transient Map valueMap = new LinkedHashMap<>(); - - Variables(Input episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName) { - this.episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName = episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName; - if (episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.defined) { - this.valueMap.put("episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName", episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.value); - } - } - - public Input episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName() { - return episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName; - } - - @Override - public Map valueMap() { - return Collections.unmodifiableMap(valueMap); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - if (episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.defined) { - writer.writeString("episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName", episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.value != null ? episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.value.rawValue() : null); - } - } - }; - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("heroAVeryAVeryAVeryAVeryAVeryAVeryAV", "hero", new UnmodifiableMapBuilder(1) - .put("episode", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName") - .build()) - .build(), true, Collections.emptyList()) - }; - - final Optional heroAVeryAVeryAVeryAVeryAVeryAVeryAV; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable HeroAVeryAVeryAVeryAVeryAVeryAVeryAV heroAVeryAVeryAVeryAVeryAVeryAVeryAV) { - this.heroAVeryAVeryAVeryAVeryAVeryAVeryAV = Optional.fromNullable(heroAVeryAVeryAVeryAVeryAVeryAVeryAV); - } - - public Optional heroAVeryAVeryAVeryAVeryAVeryAVeryAV() { - return this.heroAVeryAVeryAVeryAVeryAVeryAVeryAV; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], heroAVeryAVeryAVeryAVeryAVeryAVeryAV.isPresent() ? heroAVeryAVeryAVeryAVeryAVeryAVeryAV.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "heroAVeryAVeryAVeryAVeryAVeryAVeryAV=" + heroAVeryAVeryAVeryAVeryAVeryAVeryAV - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.heroAVeryAVeryAVeryAVeryAVeryAVeryAV.equals(that.heroAVeryAVeryAVeryAVeryAVeryAVeryAV); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= heroAVeryAVeryAVeryAVeryAVeryAVeryAV.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final HeroAVeryAVeryAVeryAVeryAVeryAVeryAV.Mapper heroAVeryAVeryAVeryAVeryAVeryAVeryAVFieldMapper = new HeroAVeryAVeryAVeryAVeryAVeryAVeryAV.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final HeroAVeryAVeryAVeryAVeryAVeryAVeryAV heroAVeryAVeryAVeryAVeryAVeryAVeryAV = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HeroAVeryAVeryAVeryAVeryAVeryAVeryAV read(ResponseReader reader) { - return heroAVeryAVeryAVeryAVeryAVeryAVeryAVFieldMapper.map(reader); - } - }); - return new Data(heroAVeryAVeryAVeryAVeryAVeryAVeryAV); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class HeroAVeryAVeryAVeryAVeryAVeryAVeryAV { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HeroAVeryAVeryAVeryAVeryAVeryAVeryAV(@NotNull String __typename, - @NotNull String nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName = Utils.checkNotNull(nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName, "nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName() { - return this.nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HeroAVeryAVeryAVeryAVeryAVeryAVeryAV{" - + "__typename=" + __typename + ", " - + "nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName=" + nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HeroAVeryAVeryAVeryAVeryAVeryAVeryAV) { - HeroAVeryAVeryAVeryAVeryAVeryAVeryAV that = (HeroAVeryAVeryAVeryAVeryAVeryAVeryAV) o; - return this.__typename.equals(that.__typename) - && this.nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.equals(that.nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public HeroAVeryAVeryAVeryAVeryAVeryAVeryAV map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName = reader.readString($responseFields[1]); - return new HeroAVeryAVeryAVeryAVeryAVeryAVeryAV(__typename, nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.kt b/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.kt deleted file mode 100644 index 11a0a85a2dd..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.kt +++ /dev/null @@ -1,210 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_name_query_long_name - -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.hero_name_query_long_name.type.Episode -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.Map -import kotlin.jvm.Transient -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName( - val episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName: - Input = Input.absent() -) : - Query { - @Transient - private val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = mutableMapOf().apply { - if (this@TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.defined) { - this["episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName"] = this@TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.value - } - } - - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - if (this@TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.defined) { - writer.writeString("episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName", - this@TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName.value?.rawValue) - } - } - } - - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = variables - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class HeroAVeryAVeryAVeryAVeryAVeryAVeryAV( - val __typename: String = "Character", - /** - * The name of the character - */ - val nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName: - String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HeroAVeryAVeryAVeryAVeryAVeryAVeryAV.__typename) - writer.writeString(RESPONSE_FIELDS[1], - this@HeroAVeryAVeryAVeryAVeryAVeryAVeryAV.nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName", - "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): HeroAVeryAVeryAVeryAVeryAVeryAVeryAV = - reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName - = readString(RESPONSE_FIELDS[1])!! - HeroAVeryAVeryAVeryAVeryAVeryAVeryAV( - __typename = __typename, - nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName = - nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = - ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val heroAVeryAVeryAVeryAVeryAVeryAVeryAV: HeroAVeryAVeryAVeryAVeryAVeryAVeryAV? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], - this@Data.heroAVeryAVeryAVeryAVeryAVeryAVeryAV?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("heroAVeryAVeryAVeryAVeryAVeryAVeryAV", "hero", mapOf( - "episode" to mapOf( - "kind" to "Variable", - "variableName" to - "episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName")), - true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val heroAVeryAVeryAVeryAVeryAVeryAVeryAV = - readObject(RESPONSE_FIELDS[0]) { reader -> - HeroAVeryAVeryAVeryAVeryAVeryAVeryAV(reader) - } - Data( - heroAVeryAVeryAVeryAVeryAVeryAVeryAV = heroAVeryAVeryAVeryAVeryAVeryAVeryAV - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "da1b713dcfa710f7f5dbe01186d56ebdec768de44002ab965740de6acbee1d01" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName(${'$'}episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName:Episode) { - | heroAVeryAVeryAVeryAVeryAVeryAVeryAV: hero(episode: ${'$'}episodeAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName) { - | __typename - | nameAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName: name - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = - "TestQueryWithAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryAVeryLongName" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/type/CustomType.java deleted file mode 100644 index d33e53c2944..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_name_query_long_name.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/type/CustomType.kt deleted file mode 100644 index 73586ae2087..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_name_query_long_name.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/type/Episode.java b/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/type/Episode.java deleted file mode 100644 index ea4378f0d76..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/type/Episode.java +++ /dev/null @@ -1,67 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_name_query_long_name.type; - -import java.lang.Deprecated; -import java.lang.String; - -/** - * The episodes in the Star Wars trilogy - */ -public enum Episode { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - * @deprecated For test purpose only - */ - @Deprecated - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - * @deprecated For test purpose only - */ - @Deprecated - NEW_("new"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Episode(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Episode safeValueOf(String rawValue) { - for (Episode enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Episode.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/type/Episode.kt b/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/type/Episode.kt deleted file mode 100644 index 1f056375640..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_name_query_long_name/type/Episode.kt +++ /dev/null @@ -1,54 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_name_query_long_name.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.Deprecated -import kotlin.String - -/** - * The episodes in the Star Wars trilogy - */ -enum class Episode( - override val rawValue: String -) : EnumValue { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - */ - @Deprecated(message = "For test purpose only") - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - */ - @Deprecated(message = "For test purpose only") - NEW("new"), - - /** - * Auto generated constant for unknown enum values - */ - UNKNOWN__("UNKNOWN__"); - - companion object { - fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: - UNKNOWN__ - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_with_review/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/hero_with_review/TestOperation.graphql deleted file mode 100644 index 9a2543e3dbf..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_with_review/TestOperation.graphql +++ /dev/null @@ -1,6 +0,0 @@ -mutation TestQuery($ep: Episode!) { - createReview(episode: $ep, review: {stars: 5, listOfEnums: [JEDI EMPIRE NEWHOPE], listOfStringNonOptional: ["1" "2" "3"], favoriteColor: {red: 1, blue: 1}}) { - stars - commentary - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_with_review/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/hero_with_review/TestQuery.java deleted file mode 100644 index c5deb68bce6..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_with_review/TestQuery.java +++ /dev/null @@ -1,404 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_with_review; - -import com.apollographql.apollo.api.Mutation; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.hero_with_review.type.Episode; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Mutation, TestQuery.Variables> { - public static final String OPERATION_ID = "df7f6bf82724eedee5118f165075b5de1a2b3a06d0390126bf7932dc8df3f082"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "mutation TestQuery($ep: Episode!) {\n" - + " createReview(episode: $ep, review: {stars: 5, listOfEnums: [JEDI, EMPIRE, NEWHOPE], listOfStringNonOptional: [\"1\", \"2\", \"3\"], favoriteColor: {red: 1, blue: 1}}) {\n" - + " __typename\n" - + " stars\n" - + " commentary\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final TestQuery.Variables variables; - - public TestQuery(@NotNull Episode ep) { - Utils.checkNotNull(ep, "ep == null"); - variables = new TestQuery.Variables(ep); - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public TestQuery.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - private @NotNull Episode ep; - - Builder() { - } - - public Builder ep(@NotNull Episode ep) { - this.ep = ep; - return this; - } - - public TestQuery build() { - Utils.checkNotNull(ep, "ep == null"); - return new TestQuery(ep); - } - } - - public static final class Variables extends Operation.Variables { - private final @NotNull Episode ep; - - private final transient Map valueMap = new LinkedHashMap<>(); - - Variables(@NotNull Episode ep) { - this.ep = ep; - this.valueMap.put("ep", ep); - } - - public @NotNull Episode ep() { - return ep; - } - - @Override - public Map valueMap() { - return Collections.unmodifiableMap(valueMap); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - writer.writeString("ep", ep.rawValue()); - } - }; - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("createReview", "createReview", new UnmodifiableMapBuilder(2) - .put("episode", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "ep") - .build()) - .put("review", new UnmodifiableMapBuilder(4) - .put("stars", "5") - .put("listOfEnums", "[JEDI, EMPIRE, NEWHOPE]") - .put("listOfStringNonOptional", "[1, 2, 3]") - .put("favoriteColor", new UnmodifiableMapBuilder(2) - .put("red", "1") - .put("blue", "1.0") - .build()) - .build()) - .build(), true, Collections.emptyList()) - }; - - final Optional createReview; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable CreateReview createReview) { - this.createReview = Optional.fromNullable(createReview); - } - - public Optional createReview() { - return this.createReview; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], createReview.isPresent() ? createReview.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "createReview=" + createReview - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.createReview.equals(that.createReview); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= createReview.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final CreateReview.Mapper createReviewFieldMapper = new CreateReview.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final CreateReview createReview = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public CreateReview read(ResponseReader reader) { - return createReviewFieldMapper.map(reader); - } - }); - return new Data(createReview); - } - } - } - - /** - * Represents a review for a movie - */ - public static class CreateReview { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("stars", "stars", null, false, Collections.emptyList()), - ResponseField.forString("commentary", "commentary", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final int stars; - - final Optional commentary; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public CreateReview(@NotNull String __typename, int stars, @Nullable String commentary) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.stars = stars; - this.commentary = Optional.fromNullable(commentary); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The number of stars this review gave, 1-5 - */ - public int stars() { - return this.stars; - } - - /** - * Comment about the movie - */ - public Optional commentary() { - return this.commentary; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], stars); - writer.writeString($responseFields[2], commentary.isPresent() ? commentary.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "CreateReview{" - + "__typename=" + __typename + ", " - + "stars=" + stars + ", " - + "commentary=" + commentary - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof CreateReview) { - CreateReview that = (CreateReview) o; - return this.__typename.equals(that.__typename) - && this.stars == that.stars - && this.commentary.equals(that.commentary); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= stars; - h *= 1000003; - h ^= commentary.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public CreateReview map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final int stars = reader.readInt($responseFields[1]); - final String commentary = reader.readString($responseFields[2]); - return new CreateReview(__typename, stars, commentary); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_with_review/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/hero_with_review/TestQuery.kt deleted file mode 100644 index 690061a9e10..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_with_review/TestQuery.kt +++ /dev/null @@ -1,210 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_with_review - -import com.apollographql.apollo.api.Mutation -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.hero_with_review.type.Episode -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.Map -import kotlin.jvm.Transient -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class TestQuery( - val ep: Episode -) : Mutation { - @Transient - private val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = mutableMapOf().apply { - this["ep"] = this@TestQuery.ep - } - - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - writer.writeString("ep", this@TestQuery.ep.rawValue) - } - } - - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = variables - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * Represents a review for a movie - */ - data class CreateReview( - val __typename: String = "Review", - /** - * The number of stars this review gave, 1-5 - */ - val stars: Int, - /** - * Comment about the movie - */ - val commentary: String? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@CreateReview.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@CreateReview.stars) - writer.writeString(RESPONSE_FIELDS[2], this@CreateReview.commentary) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("stars", "stars", null, false, null), - ResponseField.forString("commentary", "commentary", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): CreateReview = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val stars = readInt(RESPONSE_FIELDS[1])!! - val commentary = readString(RESPONSE_FIELDS[2]) - CreateReview( - __typename = __typename, - stars = stars, - commentary = commentary - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val createReview: CreateReview? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.createReview?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("createReview", "createReview", mapOf( - "episode" to mapOf( - "kind" to "Variable", - "variableName" to "ep"), - "review" to mapOf( - "stars" to "5", - "listOfEnums" to listOf( - "JEDI", - "EMPIRE", - "NEWHOPE"), - "listOfStringNonOptional" to listOf( - "1", - "2", - "3"), - "favoriteColor" to mapOf( - "red" to "1", - "blue" to "1.0"))), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val createReview = readObject(RESPONSE_FIELDS[0]) { reader -> - CreateReview(reader) - } - Data( - createReview = createReview - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "df7f6bf82724eedee5118f165075b5de1a2b3a06d0390126bf7932dc8df3f082" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |mutation TestQuery(${'$'}ep: Episode!) { - | createReview(episode: ${'$'}ep, review: {stars: 5, listOfEnums: [JEDI, EMPIRE, NEWHOPE], listOfStringNonOptional: ["1", "2", "3"], favoriteColor: {red: 1, blue: 1}}) { - | __typename - | stars - | commentary - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_with_review/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/hero_with_review/type/CustomType.java deleted file mode 100644 index e0975c1adf2..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_with_review/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_with_review.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_with_review/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/hero_with_review/type/CustomType.kt deleted file mode 100644 index 015c1e73f01..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_with_review/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_with_review.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_with_review/type/Episode.java b/apollo-compiler/src/test/graphql/com/example/hero_with_review/type/Episode.java deleted file mode 100644 index 54d7a7a05e9..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_with_review/type/Episode.java +++ /dev/null @@ -1,67 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_with_review.type; - -import java.lang.Deprecated; -import java.lang.String; - -/** - * The episodes in the Star Wars trilogy - */ -public enum Episode { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - * @deprecated For test purpose only - */ - @Deprecated - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - * @deprecated For test purpose only - */ - @Deprecated - NEW_("new"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Episode(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Episode safeValueOf(String rawValue) { - for (Episode enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Episode.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/hero_with_review/type/Episode.kt b/apollo-compiler/src/test/graphql/com/example/hero_with_review/type/Episode.kt deleted file mode 100644 index 7001ff29fcb..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/hero_with_review/type/Episode.kt +++ /dev/null @@ -1,54 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.hero_with_review.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.Deprecated -import kotlin.String - -/** - * The episodes in the Star Wars trilogy - */ -enum class Episode( - override val rawValue: String -) : EnumValue { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - */ - @Deprecated(message = "For test purpose only") - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - */ - @Deprecated(message = "For test purpose only") - NEW("new"), - - /** - * Auto generated constant for unknown enum values - */ - UNKNOWN__("UNKNOWN__"); - - companion object { - fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: - UNKNOWN__ - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_for_non_optional_field/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/inline_fragment_for_non_optional_field/TestOperation.graphql deleted file mode 100644 index 1deb67114da..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_for_non_optional_field/TestOperation.graphql +++ /dev/null @@ -1,8 +0,0 @@ -query TestQuery { - nonOptionalHero(episode: EMPIRE) { - name - ... on Human { - height - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_for_non_optional_field/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/inline_fragment_for_non_optional_field/TestQuery.java deleted file mode 100644 index 3f92ebe030e..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_for_non_optional_field/TestQuery.java +++ /dev/null @@ -1,503 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_for_non_optional_field; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "e33ec8a463abf6b32191d1f07aa6c7e4d038a493cace83a45a64632eb65b1ced"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " nonOptionalHero(episode: EMPIRE) {\n" - + " __typename\n" - + " name\n" - + " ... on Human {\n" - + " height\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("nonOptionalHero", "nonOptionalHero", new UnmodifiableMapBuilder(1) - .put("episode", "EMPIRE") - .build(), false, Collections.emptyList()) - }; - - final @NotNull NonOptionalHero nonOptionalHero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@NotNull NonOptionalHero nonOptionalHero) { - this.nonOptionalHero = Utils.checkNotNull(nonOptionalHero, "nonOptionalHero == null"); - } - - public @NotNull NonOptionalHero nonOptionalHero() { - return this.nonOptionalHero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], nonOptionalHero.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "nonOptionalHero=" + nonOptionalHero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.nonOptionalHero.equals(that.nonOptionalHero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= nonOptionalHero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final NonOptionalHero.Mapper nonOptionalHeroFieldMapper = new NonOptionalHero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final NonOptionalHero nonOptionalHero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public NonOptionalHero read(ResponseReader reader) { - return nonOptionalHeroFieldMapper.map(reader); - } - }); - return new Data(nonOptionalHero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public interface NonOptionalHero { - @NotNull String __typename(); - - /** - * The name of the character - */ - @NotNull String name(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsHuman) { - return visitor.visit((AsHuman) this); - } else if (this instanceof AsCharacter) { - return visitor.visit((AsCharacter) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )) - }; - - final AsHuman.Mapper asHumanFieldMapper = new AsHuman.Mapper(); - - final AsCharacter.Mapper asCharacterFieldMapper = new AsCharacter.Mapper(); - - @Override - public NonOptionalHero map(ResponseReader reader) { - final AsHuman asHuman = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsHuman read(ResponseReader reader) { - return asHumanFieldMapper.map(reader); - } - }); - if (asHuman != null) { - return asHuman; - } - return asCharacterFieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull NonOptionalHero nonOptionalHero); - - T visit(@NotNull AsHuman asHuman); - - T visit(@NotNull AsCharacter asCharacter); - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - public static class AsHuman implements NonOptionalHero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forDouble("height", "height", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional height; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsHuman(@NotNull String __typename, @NotNull String name, @Nullable Double height) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.height = Optional.fromNullable(height); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - /** - * Height in the preferred unit, default is meters - */ - public Optional height() { - return this.height; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeDouble($responseFields[2], height.isPresent() ? height.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsHuman{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "height=" + height - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsHuman) { - AsHuman that = (AsHuman) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.height.equals(that.height); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= height.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsHuman map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final Double height = reader.readDouble($responseFields[2]); - return new AsHuman(__typename, name, height); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class AsCharacter implements NonOptionalHero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter) { - AsCharacter that = (AsCharacter) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsCharacter map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new AsCharacter(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_for_non_optional_field/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/inline_fragment_for_non_optional_field/TestQuery.kt deleted file mode 100644 index afbf4322710..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_for_non_optional_field/TestQuery.kt +++ /dev/null @@ -1,227 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_for_non_optional_field - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import kotlin.Array -import kotlin.Boolean -import kotlin.Double -import kotlin.String -import kotlin.Suppress -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - interface NonOptionalHeroCharacter { - fun marshaller(): ResponseFieldMarshaller - } - - /** - * A humanoid creature from the Star Wars universe - */ - data class AsHuman( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String, - /** - * Height in the preferred unit, default is meters - */ - val height: Double? - ) : NonOptionalHeroCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsHuman.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsHuman.name) - writer.writeDouble(RESPONSE_FIELDS[2], this@AsHuman.height) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forDouble("height", "height", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): AsHuman = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val height = readDouble(RESPONSE_FIELDS[2]) - AsHuman( - __typename = __typename, - name = name, - height = height - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class NonOptionalHero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - val asHuman: AsHuman? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@NonOptionalHero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@NonOptionalHero.name) - writer.writeFragment(this@NonOptionalHero.asHuman?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )) - ) - - operator fun invoke(reader: ResponseReader): NonOptionalHero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val asHuman = readFragment(RESPONSE_FIELDS[2]) { reader -> - AsHuman(reader) - } - NonOptionalHero( - __typename = __typename, - name = name, - asHuman = asHuman - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val nonOptionalHero: NonOptionalHero - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.nonOptionalHero.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("nonOptionalHero", "nonOptionalHero", mapOf( - "episode" to "EMPIRE"), false, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val nonOptionalHero = readObject(RESPONSE_FIELDS[0]) { reader -> - NonOptionalHero(reader) - }!! - Data( - nonOptionalHero = nonOptionalHero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "e33ec8a463abf6b32191d1f07aa6c7e4d038a493cace83a45a64632eb65b1ced" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | nonOptionalHero(episode: EMPIRE) { - | __typename - | name - | ... on Human { - | height - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_for_non_optional_field/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/inline_fragment_for_non_optional_field/type/CustomType.java deleted file mode 100644 index c731d4a6484..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_for_non_optional_field/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_for_non_optional_field.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_for_non_optional_field/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/inline_fragment_for_non_optional_field/type/CustomType.kt deleted file mode 100644 index cb76348f3e7..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_for_non_optional_field/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_for_non_optional_field.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_inside_inline_fragment/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/inline_fragment_inside_inline_fragment/TestOperation.graphql deleted file mode 100644 index 124b8309041..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_inside_inline_fragment/TestOperation.graphql +++ /dev/null @@ -1,13 +0,0 @@ -query TestQuery { - search(text: "bla-bla") { - ... on Character { - name - ...on Human { - homePlanet - } - ...on Droid { - primaryFunction - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_inside_inline_fragment/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/inline_fragment_inside_inline_fragment/TestQuery.java deleted file mode 100644 index 21b649c016b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_inside_inline_fragment/TestQuery.java +++ /dev/null @@ -1,774 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_inside_inline_fragment; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "4f32ea4bdd2a95a29bde61273602c22c698cd333f1701001d1a339fb276c6438"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " search(text: \"bla-bla\") {\n" - + " __typename\n" - + " ... on Character {\n" - + " __typename\n" - + " name\n" - + " ... on Human {\n" - + " homePlanet\n" - + " }\n" - + " ... on Droid {\n" - + " primaryFunction\n" - + " }\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forList("search", "search", new UnmodifiableMapBuilder(1) - .put("text", "bla-bla") - .build(), true, Collections.emptyList()) - }; - - final Optional> search; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable List search) { - this.search = Optional.fromNullable(search); - } - - public Optional> search() { - return this.search; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeList($responseFields[0], search.isPresent() ? search.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Search) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "search=" + search - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.search.equals(that.search); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= search.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Search.Mapper searchFieldMapper = new Search.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final List search = reader.readList($responseFields[0], new ResponseReader.ListReader() { - @Override - public Search read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Search read(ResponseReader reader) { - return searchFieldMapper.map(reader); - } - }); - } - }); - return new Data(search); - } - } - } - - public interface Search { - @NotNull String __typename(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsCharacter) { - return visitor.visit((AsCharacter) this); - } else if (this instanceof AsSearchResult) { - return visitor.visit((AsSearchResult) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid", "Human"}) - )) - }; - - final AsCharacter.Mapper asCharacterFieldMapper = new AsCharacter.Mapper(); - - final AsSearchResult.Mapper asSearchResultFieldMapper = new AsSearchResult.Mapper(); - - @Override - public Search map(ResponseReader reader) { - final AsCharacter asCharacter = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsCharacter read(ResponseReader reader) { - return asCharacterFieldMapper.map(reader); - } - }); - if (asCharacter != null) { - return asCharacter; - } - return asSearchResultFieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull Search search); - - T visit(@NotNull AsCharacter asCharacter); - - T visit(@NotNull AsSearchResult asSearchResult); - } - } - - /** - * A character from the Star Wars universe - */ - public interface AsCharacter extends Search { - @NotNull String __typename(); - - /** - * The name of the character - */ - @NotNull String name(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsHuman) { - return visitor.visit((AsHuman) this); - } else if (this instanceof AsDroid) { - return visitor.visit((AsDroid) this); - } else if (this instanceof AsCharacter1) { - return visitor.visit((AsCharacter1) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid"}) - )) - }; - - final AsHuman.Mapper asHumanFieldMapper = new AsHuman.Mapper(); - - final AsDroid.Mapper asDroidFieldMapper = new AsDroid.Mapper(); - - final AsCharacter1.Mapper asCharacter1FieldMapper = new AsCharacter1.Mapper(); - - @Override - public AsCharacter map(ResponseReader reader) { - final AsHuman asHuman = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsHuman read(ResponseReader reader) { - return asHumanFieldMapper.map(reader); - } - }); - if (asHuman != null) { - return asHuman; - } - final AsDroid asDroid = reader.readFragment($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public AsDroid read(ResponseReader reader) { - return asDroidFieldMapper.map(reader); - } - }); - if (asDroid != null) { - return asDroid; - } - return asCharacter1FieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull AsCharacter asCharacter); - - T visit(@NotNull AsHuman asHuman); - - T visit(@NotNull AsDroid asDroid); - - T visit(@NotNull AsCharacter1 asCharacter1); - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - public static class AsHuman implements AsCharacter { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forString("homePlanet", "homePlanet", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional homePlanet; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsHuman(@NotNull String __typename, @NotNull String name, @Nullable String homePlanet) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.homePlanet = Optional.fromNullable(homePlanet); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - /** - * The home planet of the human, or null if unknown - */ - public Optional homePlanet() { - return this.homePlanet; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeString($responseFields[2], homePlanet.isPresent() ? homePlanet.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsHuman{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "homePlanet=" + homePlanet - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsHuman) { - AsHuman that = (AsHuman) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.homePlanet.equals(that.homePlanet); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= homePlanet.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsHuman map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final String homePlanet = reader.readString($responseFields[2]); - return new AsHuman(__typename, name, homePlanet); - } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - public static class AsDroid implements AsCharacter { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional primaryFunction; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsDroid(@NotNull String __typename, @NotNull String name, - @Nullable String primaryFunction) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.primaryFunction = Optional.fromNullable(primaryFunction); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What others call this droid - */ - public @NotNull String name() { - return this.name; - } - - /** - * This droid's primary function - */ - public Optional primaryFunction() { - return this.primaryFunction; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeString($responseFields[2], primaryFunction.isPresent() ? primaryFunction.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsDroid{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "primaryFunction=" + primaryFunction - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsDroid) { - AsDroid that = (AsDroid) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.primaryFunction.equals(that.primaryFunction); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= primaryFunction.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsDroid map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final String primaryFunction = reader.readString($responseFields[2]); - return new AsDroid(__typename, name, primaryFunction); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class AsCharacter1 implements AsCharacter { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter1(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter1{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter1) { - AsCharacter1 that = (AsCharacter1) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsCharacter1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new AsCharacter1(__typename, name); - } - } - } - - public static class AsSearchResult implements Search { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsSearchResult(@NotNull String __typename) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsSearchResult{" - + "__typename=" + __typename - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsSearchResult) { - AsSearchResult that = (AsSearchResult) o; - return this.__typename.equals(that.__typename); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsSearchResult map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - return new AsSearchResult(__typename); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_inside_inline_fragment/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/inline_fragment_inside_inline_fragment/TestQuery.kt deleted file mode 100644 index 1853fef300f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_inside_inline_fragment/TestQuery.kt +++ /dev/null @@ -1,329 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_inside_inline_fragment - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - interface SearchSearchResult { - fun marshaller(): ResponseFieldMarshaller - } - - interface AsCharacterCharacter { - fun marshaller(): ResponseFieldMarshaller - } - - /** - * A humanoid creature from the Star Wars universe - */ - data class AsHuman( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String, - /** - * The home planet of the human, or null if unknown - */ - val homePlanet: String? - ) : AsCharacterCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsHuman.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsHuman.name) - writer.writeString(RESPONSE_FIELDS[2], this@AsHuman.homePlanet) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forString("homePlanet", "homePlanet", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): AsHuman = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val homePlanet = readString(RESPONSE_FIELDS[2]) - AsHuman( - __typename = __typename, - name = name, - homePlanet = homePlanet - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - data class AsDroid( - val __typename: String = "Droid", - /** - * What others call this droid - */ - val name: String, - /** - * This droid's primary function - */ - val primaryFunction: String? - ) : AsCharacterCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsDroid.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsDroid.name) - writer.writeString(RESPONSE_FIELDS[2], this@AsDroid.primaryFunction) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): AsDroid = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val primaryFunction = readString(RESPONSE_FIELDS[2]) - AsDroid( - __typename = __typename, - name = name, - primaryFunction = primaryFunction - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class AsCharacter( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - val asHuman: AsHuman?, - val asDroid: AsDroid? - ) : SearchSearchResult { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsCharacter.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsCharacter.name) - writer.writeFragment(this@AsCharacter.asHuman?.marshaller()) - writer.writeFragment(this@AsCharacter.asDroid?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid")) - )) - ) - - operator fun invoke(reader: ResponseReader): AsCharacter = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val asHuman = readFragment(RESPONSE_FIELDS[2]) { reader -> - AsHuman(reader) - } - val asDroid = readFragment(RESPONSE_FIELDS[3]) { reader -> - AsDroid(reader) - } - AsCharacter( - __typename = __typename, - name = name, - asHuman = asHuman, - asDroid = asDroid - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - data class Search( - val __typename: String = "SearchResult", - val asCharacter: AsCharacter? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Search.__typename) - writer.writeFragment(this@Search.asCharacter?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid", "Human")) - )) - ) - - operator fun invoke(reader: ResponseReader): Search = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val asCharacter = readFragment(RESPONSE_FIELDS[1]) { reader -> - AsCharacter(reader) - } - Search( - __typename = __typename, - asCharacter = asCharacter - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val search: List? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeList(RESPONSE_FIELDS[0], this@Data.search) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun searchFilterNotNull(): List? = search?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forList("search", "search", mapOf( - "text" to "bla-bla"), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val search = readList(RESPONSE_FIELDS[0]) { reader -> - reader.readObject { reader -> - Search(reader) - } - } - Data( - search = search - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "4f32ea4bdd2a95a29bde61273602c22c698cd333f1701001d1a339fb276c6438" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | search(text: "bla-bla") { - | __typename - | ... on Character { - | __typename - | name - | ... on Human { - | homePlanet - | } - | ... on Droid { - | primaryFunction - | } - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_inside_inline_fragment/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/inline_fragment_inside_inline_fragment/type/CustomType.java deleted file mode 100644 index 092fd079994..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_inside_inline_fragment/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_inside_inline_fragment.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_inside_inline_fragment/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/inline_fragment_inside_inline_fragment/type/CustomType.kt deleted file mode 100644 index 37c15361c66..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_inside_inline_fragment/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_inside_inline_fragment.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_merge_fields/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/inline_fragment_merge_fields/TestOperation.graphql deleted file mode 100644 index f49415fbded..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_merge_fields/TestOperation.graphql +++ /dev/null @@ -1,23 +0,0 @@ -query TestQuery { - hero { - name - friendsConnection { - edges { - node { - name - } - } - } - ... on Character { - name - profileLink - friendsConnection { - edges { - node { - name - } - } - } - } - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_merge_fields/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/inline_fragment_merge_fields/TestQuery.java deleted file mode 100644 index f3db99c62f1..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_merge_fields/TestQuery.java +++ /dev/null @@ -1,703 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_merge_fields; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.inline_fragment_merge_fields.type.CustomType; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "5ff8c88e5dfec4301ed7c0603bae2088ecdd096a8336ed0c2e5d386b08ebe5c5"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " }\n" - + " ... on Character {\n" - + " name\n" - + " profileLink\n" - + " friendsConnection {\n" - + " __typename\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, Collections.emptyList()), - ResponseField.forCustomType("profileLink", "profileLink", null, false, CustomType.URL, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull FriendsConnection friendsConnection; - - final @NotNull Object profileLink; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull String name, - @NotNull FriendsConnection friendsConnection, @NotNull Object profileLink) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - this.profileLink = Utils.checkNotNull(profileLink, "profileLink == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The friends of the character exposed as a connection with edges - */ - public @NotNull FriendsConnection friendsConnection() { - return this.friendsConnection; - } - - /** - * Profile link - */ - public @NotNull Object profileLink() { - return this.profileLink; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeObject($responseFields[2], friendsConnection.marshaller()); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[3], profileLink); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection + ", " - + "profileLink=" + profileLink - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection) - && this.profileLink.equals(that.profileLink); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - h *= 1000003; - h ^= profileLink.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection.Mapper friendsConnectionFieldMapper = new FriendsConnection.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final FriendsConnection friendsConnection = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection read(ResponseReader reader) { - return friendsConnectionFieldMapper.map(reader); - } - }); - final Object profileLink = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[3]); - return new Hero(__typename, name, friendsConnection, profileLink); - } - } - } - - /** - * A connection object for a character's friends - */ - public static class FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional> edges; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection(@NotNull String __typename, @Nullable List edges) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.edges = Optional.fromNullable(edges); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The edges for each of the character's friends. - */ - public Optional> edges() { - return this.edges; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeList($responseFields[1], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection{" - + "__typename=" + __typename + ", " - + "edges=" + edges - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection) { - FriendsConnection that = (FriendsConnection) o; - return this.__typename.equals(that.__typename) - && this.edges.equals(that.edges); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge.Mapper edgeFieldMapper = new Edge.Mapper(); - - @Override - public FriendsConnection map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final List edges = reader.readList($responseFields[1], new ResponseReader.ListReader() { - @Override - public Edge read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge read(ResponseReader reader) { - return edgeFieldMapper.map(reader); - } - }); - } - }); - return new FriendsConnection(__typename, edges); - } - } - } - - /** - * An edge object for a character's friends - */ - public static class Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge(@NotNull String __typename, @Nullable Node node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.fromNullable(node); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The character represented by this friendship edge - */ - public Optional node() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge) { - Edge that = (Edge) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Node.Mapper nodeFieldMapper = new Node.Mapper(); - - @Override - public Edge map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node read(ResponseReader reader) { - return nodeFieldMapper.map(reader); - } - }); - return new Edge(__typename, node); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node) { - Node that = (Node) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Node map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Node(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_merge_fields/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/inline_fragment_merge_fields/TestQuery.kt deleted file mode 100644 index eda54a84176..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_merge_fields/TestQuery.kt +++ /dev/null @@ -1,328 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_merge_fields - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.inline_fragment_merge_fields.type.CustomType -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Node( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Node.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Node( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An edge object for a character's friends - */ - data class Edge( - val __typename: String = "FriendsEdge", - /** - * The character represented by this friendship edge - */ - val node: Node? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node(reader) - } - Edge( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection( - val __typename: String = "FriendsConnection", - /** - * The edges for each of the character's friends. - */ - val edges: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection.__typename) - writer.writeList(RESPONSE_FIELDS[1], this@FriendsConnection.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forList("edges", "edges", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val edges = readList(RESPONSE_FIELDS[1]) { reader -> - reader.readObject { reader -> - Edge(reader) - } - } - FriendsConnection( - __typename = __typename, - edges = edges - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The friends of the character exposed as a connection with edges - */ - val friendsConnection: FriendsConnection, - /** - * Profile link - */ - val profileLink: Any - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeObject(RESPONSE_FIELDS[2], this@Hero.friendsConnection.marshaller()) - writer.writeCustom(RESPONSE_FIELDS[3] as ResponseField.CustomTypeField, this@Hero.profileLink) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, null), - ResponseField.forCustomType("profileLink", "profileLink", null, false, CustomType.URL, - null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friendsConnection = readObject(RESPONSE_FIELDS[2]) { reader -> - FriendsConnection(reader) - }!! - val profileLink = readCustomType(RESPONSE_FIELDS[3] as ResponseField.CustomTypeField)!! - Hero( - __typename = __typename, - name = name, - friendsConnection = friendsConnection, - profileLink = profileLink - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "5ff8c88e5dfec4301ed7c0603bae2088ecdd096a8336ed0c2e5d386b08ebe5c5" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | name - | friendsConnection { - | __typename - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | } - | ... on Character { - | name - | profileLink - | friendsConnection { - | __typename - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | } - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_merge_fields/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/inline_fragment_merge_fields/type/CustomType.java deleted file mode 100644 index 43109c40a73..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_merge_fields/type/CustomType.java +++ /dev/null @@ -1,36 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_merge_fields.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - }, - - URL { - @Override - public String typeName() { - return "URL"; - } - - @Override - public String className() { - return "java.lang.Object"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_merge_fields/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/inline_fragment_merge_fields/type/CustomType.kt deleted file mode 100644 index 3bd36d6f9ee..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_merge_fields/type/CustomType.kt +++ /dev/null @@ -1,23 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_merge_fields.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - }, - - URL { - override fun typeName(): String = "URL" - - override fun className(): String = "kotlin.Any" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_type_coercion/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/inline_fragment_type_coercion/TestOperation.graphql deleted file mode 100644 index 092e41a4d69..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_type_coercion/TestOperation.graphql +++ /dev/null @@ -1,8 +0,0 @@ -query TestQuery { - foo { - foo - ... on Bar { - bar - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_type_coercion/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/inline_fragment_type_coercion/TestQuery.java deleted file mode 100644 index 8360fed3416..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_type_coercion/TestQuery.java +++ /dev/null @@ -1,490 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_type_coercion; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "65c4fd857f5cbd2283f0783a3b3cefd9ead5abb159f5cc20922b0d8e04286662"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " foo {\n" - + " __typename\n" - + " foo\n" - + " ... on Bar {\n" - + " bar\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("foo", "foo", null, true, Collections.emptyList()) - }; - - final Optional foo; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Foo foo) { - this.foo = Optional.fromNullable(foo); - } - - /** - * For testing fragment type coercion - */ - public Optional foo() { - return this.foo; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], foo.isPresent() ? foo.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "foo=" + foo - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.foo.equals(that.foo); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= foo.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Foo.Mapper fooFieldMapper = new Foo.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Foo foo = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Foo read(ResponseReader reader) { - return fooFieldMapper.map(reader); - } - }); - return new Data(foo); - } - } - } - - /** - * For testing fragment type coercion - */ - public interface Foo { - @NotNull String __typename(); - - @NotNull String foo(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsBar) { - return visitor.visit((AsBar) this); - } else if (this instanceof AsFoo) { - return visitor.visit((AsFoo) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"BarObject", "FooBar"}) - )) - }; - - final AsBar.Mapper asBarFieldMapper = new AsBar.Mapper(); - - final AsFoo.Mapper asFooFieldMapper = new AsFoo.Mapper(); - - @Override - public Foo map(ResponseReader reader) { - final AsBar asBar = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsBar read(ResponseReader reader) { - return asBarFieldMapper.map(reader); - } - }); - if (asBar != null) { - return asBar; - } - return asFooFieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull Foo foo); - - T visit(@NotNull AsBar asBar); - - T visit(@NotNull AsFoo asFoo); - } - } - - /** - * For testing fragment type coercion - */ - public static class AsBar implements Foo { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("foo", "foo", null, false, Collections.emptyList()), - ResponseField.forString("bar", "bar", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String foo; - - final @NotNull String bar; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsBar(@NotNull String __typename, @NotNull String foo, @NotNull String bar) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.foo = Utils.checkNotNull(foo, "foo == null"); - this.bar = Utils.checkNotNull(bar, "bar == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull String foo() { - return this.foo; - } - - public @NotNull String bar() { - return this.bar; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], foo); - writer.writeString($responseFields[2], bar); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsBar{" - + "__typename=" + __typename + ", " - + "foo=" + foo + ", " - + "bar=" + bar - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsBar) { - AsBar that = (AsBar) o; - return this.__typename.equals(that.__typename) - && this.foo.equals(that.foo) - && this.bar.equals(that.bar); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= foo.hashCode(); - h *= 1000003; - h ^= bar.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsBar map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String foo = reader.readString($responseFields[1]); - final String bar = reader.readString($responseFields[2]); - return new AsBar(__typename, foo, bar); - } - } - } - - /** - * For testing fragment type coercion - */ - public static class AsFoo implements Foo { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("foo", "foo", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String foo; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsFoo(@NotNull String __typename, @NotNull String foo) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.foo = Utils.checkNotNull(foo, "foo == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull String foo() { - return this.foo; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], foo); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsFoo{" - + "__typename=" + __typename + ", " - + "foo=" + foo - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsFoo) { - AsFoo that = (AsFoo) o; - return this.__typename.equals(that.__typename) - && this.foo.equals(that.foo); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= foo.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsFoo map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String foo = reader.readString($responseFields[1]); - return new AsFoo(__typename, foo); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_type_coercion/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/inline_fragment_type_coercion/TestQuery.kt deleted file mode 100644 index cdac67804a6..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_type_coercion/TestQuery.kt +++ /dev/null @@ -1,219 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_type_coercion - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - interface FooFoo { - fun marshaller(): ResponseFieldMarshaller - } - - /** - * For testing fragment type coercion - */ - data class AsBar( - val __typename: String = "Bar", - val foo: String, - val bar: String - ) : FooFoo { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsBar.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsBar.foo) - writer.writeString(RESPONSE_FIELDS[2], this@AsBar.bar) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("foo", "foo", null, false, null), - ResponseField.forString("bar", "bar", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): AsBar = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val foo = readString(RESPONSE_FIELDS[1])!! - val bar = readString(RESPONSE_FIELDS[2])!! - AsBar( - __typename = __typename, - foo = foo, - bar = bar - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * For testing fragment type coercion - */ - data class Foo( - val __typename: String = "Foo", - val foo: String, - val asBar: AsBar? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Foo.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Foo.foo) - writer.writeFragment(this@Foo.asBar?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("foo", "foo", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("BarObject", "FooBar")) - )) - ) - - operator fun invoke(reader: ResponseReader): Foo = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val foo = readString(RESPONSE_FIELDS[1])!! - val asBar = readFragment(RESPONSE_FIELDS[2]) { reader -> - AsBar(reader) - } - Foo( - __typename = __typename, - foo = foo, - asBar = asBar - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - /** - * For testing fragment type coercion - */ - val foo: Foo? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.foo?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("foo", "foo", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val foo = readObject(RESPONSE_FIELDS[0]) { reader -> - Foo(reader) - } - Data( - foo = foo - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "65c4fd857f5cbd2283f0783a3b3cefd9ead5abb159f5cc20922b0d8e04286662" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | foo { - | __typename - | foo - | ... on Bar { - | bar - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_type_coercion/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/inline_fragment_type_coercion/type/CustomType.java deleted file mode 100644 index 37b191e9af7..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_type_coercion/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_type_coercion.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragment_type_coercion/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/inline_fragment_type_coercion/type/CustomType.kt deleted file mode 100644 index f2413fbb18e..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragment_type_coercion/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragment_type_coercion.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/TestOperation.graphql deleted file mode 100644 index 5174ed366f2..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/TestOperation.graphql +++ /dev/null @@ -1,17 +0,0 @@ -query TestQuery { - hero { - name - ... on Human { - height - friends { - appearsIn - } - } - ... on Droid { - primaryFunction - friends { - id - } - } - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/TestQuery.java deleted file mode 100644 index 6511bb85e78..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/TestQuery.java +++ /dev/null @@ -1,917 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragments_with_friends; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.inline_fragments_with_friends.type.CustomType; -import com.example.inline_fragments_with_friends.type.Episode; -import java.io.IOException; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "6a20c9553e5f209b6cc63f98b9d154b5d5917cdea11a903e5dc7f8f420f949b6"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " ... on Human {\n" - + " height\n" - + " friends {\n" - + " __typename\n" - + " appearsIn\n" - + " }\n" - + " }\n" - + " ... on Droid {\n" - + " primaryFunction\n" - + " friends {\n" - + " __typename\n" - + " id\n" - + " }\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public interface Hero { - @NotNull String __typename(); - - /** - * The name of the character - */ - @NotNull String name(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsHuman) { - return visitor.visit((AsHuman) this); - } else if (this instanceof AsDroid) { - return visitor.visit((AsDroid) this); - } else if (this instanceof AsCharacter) { - return visitor.visit((AsCharacter) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid"}) - )) - }; - - final AsHuman.Mapper asHumanFieldMapper = new AsHuman.Mapper(); - - final AsDroid.Mapper asDroidFieldMapper = new AsDroid.Mapper(); - - final AsCharacter.Mapper asCharacterFieldMapper = new AsCharacter.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final AsHuman asHuman = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsHuman read(ResponseReader reader) { - return asHumanFieldMapper.map(reader); - } - }); - if (asHuman != null) { - return asHuman; - } - final AsDroid asDroid = reader.readFragment($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public AsDroid read(ResponseReader reader) { - return asDroidFieldMapper.map(reader); - } - }); - if (asDroid != null) { - return asDroid; - } - return asCharacterFieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull Hero hero); - - T visit(@NotNull AsHuman asHuman); - - T visit(@NotNull AsDroid asDroid); - - T visit(@NotNull AsCharacter asCharacter); - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - public static class AsHuman implements Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forDouble("height", "height", null, true, Collections.emptyList()), - ResponseField.forList("friends", "friends", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional height; - - final Optional> friends; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsHuman(@NotNull String __typename, @NotNull String name, @Nullable Double height, - @Nullable List friends) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.height = Optional.fromNullable(height); - this.friends = Optional.fromNullable(friends); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - /** - * Height in the preferred unit, default is meters - */ - public Optional height() { - return this.height; - } - - /** - * This human's friends, or an empty list if they have none - */ - public Optional> friends() { - return this.friends; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeDouble($responseFields[2], height.isPresent() ? height.get() : null); - writer.writeList($responseFields[3], friends.isPresent() ? friends.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Friend) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsHuman{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "height=" + height + ", " - + "friends=" + friends - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsHuman) { - AsHuman that = (AsHuman) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.height.equals(that.height) - && this.friends.equals(that.friends); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= height.hashCode(); - h *= 1000003; - h ^= friends.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Friend.Mapper friendFieldMapper = new Friend.Mapper(); - - @Override - public AsHuman map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final Double height = reader.readDouble($responseFields[2]); - final List friends = reader.readList($responseFields[3], new ResponseReader.ListReader() { - @Override - public Friend read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Friend read(ResponseReader reader) { - return friendFieldMapper.map(reader); - } - }); - } - }); - return new AsHuman(__typename, name, height, friends); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Friend { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forList("appearsIn", "appearsIn", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull List appearsIn; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Friend(@NotNull String __typename, @NotNull List appearsIn) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.appearsIn = Utils.checkNotNull(appearsIn, "appearsIn == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The movies this character appears in - */ - public @NotNull List appearsIn() { - return this.appearsIn; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeList($responseFields[1], appearsIn, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeString(((Episode) item).rawValue()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Friend{" - + "__typename=" + __typename + ", " - + "appearsIn=" + appearsIn - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Friend) { - Friend that = (Friend) o; - return this.__typename.equals(that.__typename) - && this.appearsIn.equals(that.appearsIn); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= appearsIn.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Friend map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final List appearsIn = reader.readList($responseFields[1], new ResponseReader.ListReader() { - @Override - public Episode read(ResponseReader.ListItemReader listItemReader) { - return Episode.safeValueOf(listItemReader.readString()); - } - }); - return new Friend(__typename, appearsIn); - } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - public static class AsDroid implements Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, Collections.emptyList()), - ResponseField.forList("friends", "friends", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional primaryFunction; - - final Optional> friends; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsDroid(@NotNull String __typename, @NotNull String name, - @Nullable String primaryFunction, @Nullable List friends) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.primaryFunction = Optional.fromNullable(primaryFunction); - this.friends = Optional.fromNullable(friends); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What others call this droid - */ - public @NotNull String name() { - return this.name; - } - - /** - * This droid's primary function - */ - public Optional primaryFunction() { - return this.primaryFunction; - } - - /** - * This droid's friends, or an empty list if they have none - */ - public Optional> friends() { - return this.friends; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeString($responseFields[2], primaryFunction.isPresent() ? primaryFunction.get() : null); - writer.writeList($responseFields[3], friends.isPresent() ? friends.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Friend1) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsDroid{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "primaryFunction=" + primaryFunction + ", " - + "friends=" + friends - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsDroid) { - AsDroid that = (AsDroid) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.primaryFunction.equals(that.primaryFunction) - && this.friends.equals(that.friends); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= primaryFunction.hashCode(); - h *= 1000003; - h ^= friends.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Friend1.Mapper friend1FieldMapper = new Friend1.Mapper(); - - @Override - public AsDroid map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final String primaryFunction = reader.readString($responseFields[2]); - final List friends = reader.readList($responseFields[3], new ResponseReader.ListReader() { - @Override - public Friend1 read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Friend1 read(ResponseReader reader) { - return friend1FieldMapper.map(reader); - } - }); - } - }); - return new AsDroid(__typename, name, primaryFunction, friends); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Friend1 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String id; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Friend1(@NotNull String __typename, @NotNull String id) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.id = Utils.checkNotNull(id, "id == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The ID of the character - */ - public @NotNull String id() { - return this.id; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[1], id); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Friend1{" - + "__typename=" + __typename + ", " - + "id=" + id - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Friend1) { - Friend1 that = (Friend1) o; - return this.__typename.equals(that.__typename) - && this.id.equals(that.id); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= id.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Friend1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]); - return new Friend1(__typename, id); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class AsCharacter implements Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter) { - AsCharacter that = (AsCharacter) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsCharacter map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new AsCharacter(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/TestQuery.kt deleted file mode 100644 index 4d02cbebe20..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/TestQuery.kt +++ /dev/null @@ -1,403 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragments_with_friends - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.inline_fragments_with_friends.type.CustomType -import com.example.inline_fragments_with_friends.type.Episode -import kotlin.Array -import kotlin.Boolean -import kotlin.Double -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - interface HeroCharacter { - fun marshaller(): ResponseFieldMarshaller - } - - /** - * A character from the Star Wars universe - */ - data class Friend( - val __typename: String = "Character", - /** - * The movies this character appears in - */ - val appearsIn: List - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Friend.__typename) - writer.writeList(RESPONSE_FIELDS[1], this@Friend.appearsIn) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeString(value?.rawValue)} - } - } - - fun appearsInFilterNotNull(): List = appearsIn.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forList("appearsIn", "appearsIn", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Friend = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val appearsIn = readList(RESPONSE_FIELDS[1]) { reader -> - Episode.safeValueOf(reader.readString()) - }!! - Friend( - __typename = __typename, - appearsIn = appearsIn - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - data class AsHuman( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String, - /** - * Height in the preferred unit, default is meters - */ - val height: Double?, - /** - * This human's friends, or an empty list if they have none - */ - val friends: List? - ) : HeroCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsHuman.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsHuman.name) - writer.writeDouble(RESPONSE_FIELDS[2], this@AsHuman.height) - writer.writeList(RESPONSE_FIELDS[3], this@AsHuman.friends) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun friendsFilterNotNull(): List? = friends?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forDouble("height", "height", null, true, null), - ResponseField.forList("friends", "friends", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): AsHuman = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val height = readDouble(RESPONSE_FIELDS[2]) - val friends = readList(RESPONSE_FIELDS[3]) { reader -> - reader.readObject { reader -> - Friend(reader) - } - } - AsHuman( - __typename = __typename, - name = name, - height = height, - friends = friends - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Friend1( - val __typename: String = "Character", - /** - * The ID of the character - */ - val id: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Friend1.__typename) - writer.writeCustom(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField, this@Friend1.id) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, null) - ) - - operator fun invoke(reader: ResponseReader): Friend1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val id = readCustomType(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField)!! - Friend1( - __typename = __typename, - id = id - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - data class AsDroid( - val __typename: String = "Droid", - /** - * What others call this droid - */ - val name: String, - /** - * This droid's primary function - */ - val primaryFunction: String?, - /** - * This droid's friends, or an empty list if they have none - */ - val friends: List? - ) : HeroCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsDroid.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsDroid.name) - writer.writeString(RESPONSE_FIELDS[2], this@AsDroid.primaryFunction) - writer.writeList(RESPONSE_FIELDS[3], this@AsDroid.friends) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun friendsFilterNotNull(): List? = friends?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, null), - ResponseField.forList("friends", "friends", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): AsDroid = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val primaryFunction = readString(RESPONSE_FIELDS[2]) - val friends = readList(RESPONSE_FIELDS[3]) { reader -> - reader.readObject { reader -> - Friend1(reader) - } - } - AsDroid( - __typename = __typename, - name = name, - primaryFunction = primaryFunction, - friends = friends - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - val asHuman: AsHuman?, - val asDroid: AsDroid? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeFragment(this@Hero.asHuman?.marshaller()) - writer.writeFragment(this@Hero.asDroid?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid")) - )) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val asHuman = readFragment(RESPONSE_FIELDS[2]) { reader -> - AsHuman(reader) - } - val asDroid = readFragment(RESPONSE_FIELDS[3]) { reader -> - AsDroid(reader) - } - Hero( - __typename = __typename, - name = name, - asHuman = asHuman, - asDroid = asDroid - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "6a20c9553e5f209b6cc63f98b9d154b5d5917cdea11a903e5dc7f8f420f949b6" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | name - | ... on Human { - | height - | friends { - | __typename - | appearsIn - | } - | } - | ... on Droid { - | primaryFunction - | friends { - | __typename - | id - | } - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/type/CustomType.java deleted file mode 100644 index f046a7ce818..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragments_with_friends.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/type/CustomType.kt deleted file mode 100644 index 0fa422099ac..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragments_with_friends.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/type/Episode.java b/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/type/Episode.java deleted file mode 100644 index 99dbfe3a8fd..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/type/Episode.java +++ /dev/null @@ -1,67 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragments_with_friends.type; - -import java.lang.Deprecated; -import java.lang.String; - -/** - * The episodes in the Star Wars trilogy - */ -public enum Episode { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - * @deprecated For test purpose only - */ - @Deprecated - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - * @deprecated For test purpose only - */ - @Deprecated - NEW_("new"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Episode(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Episode safeValueOf(String rawValue) { - for (Episode enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Episode.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/type/Episode.kt b/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/type/Episode.kt deleted file mode 100644 index e5e13df177d..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/inline_fragments_with_friends/type/Episode.kt +++ /dev/null @@ -1,54 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.inline_fragments_with_friends.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.Deprecated -import kotlin.String - -/** - * The episodes in the Star Wars trilogy - */ -enum class Episode( - override val rawValue: String -) : EnumValue { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - */ - @Deprecated(message = "For test purpose only") - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - */ - @Deprecated(message = "For test purpose only") - NEW("new"), - - /** - * Auto generated constant for unknown enum values - */ - UNKNOWN__("UNKNOWN__"); - - companion object { - fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: - UNKNOWN__ - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/input_object_type/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/input_object_type/TestOperation.graphql deleted file mode 100644 index 54828d3ef1a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/input_object_type/TestOperation.graphql +++ /dev/null @@ -1,6 +0,0 @@ -mutation TestQuery($ep: Episode!, $review: ReviewInput!) { - createReview(episode: $ep, review: $review) { - stars - commentary - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/input_object_type/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/input_object_type/TestQuery.java deleted file mode 100644 index 3d2e418e61b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/input_object_type/TestQuery.java +++ /dev/null @@ -1,418 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.input_object_type; - -import com.apollographql.apollo.api.Mutation; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.input_object_type.type.Episode; -import com.example.input_object_type.type.ReviewInput; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Mutation, TestQuery.Variables> { - public static final String OPERATION_ID = "9850c60bd20e2361afd7a41d51b709fcba9637809e387afe5c7a1cb738fc254b"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "mutation TestQuery($ep: Episode!, $review: ReviewInput!) {\n" - + " createReview(episode: $ep, review: $review) {\n" - + " __typename\n" - + " stars\n" - + " commentary\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final TestQuery.Variables variables; - - public TestQuery(@NotNull Episode ep, @NotNull ReviewInput review) { - Utils.checkNotNull(ep, "ep == null"); - Utils.checkNotNull(review, "review == null"); - variables = new TestQuery.Variables(ep, review); - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public TestQuery.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - private @NotNull Episode ep; - - private @NotNull ReviewInput review; - - Builder() { - } - - public Builder ep(@NotNull Episode ep) { - this.ep = ep; - return this; - } - - public Builder review(@NotNull ReviewInput review) { - this.review = review; - return this; - } - - public TestQuery build() { - Utils.checkNotNull(ep, "ep == null"); - Utils.checkNotNull(review, "review == null"); - return new TestQuery(ep, review); - } - } - - public static final class Variables extends Operation.Variables { - private final @NotNull Episode ep; - - private final @NotNull ReviewInput review; - - private final transient Map valueMap = new LinkedHashMap<>(); - - Variables(@NotNull Episode ep, @NotNull ReviewInput review) { - this.ep = ep; - this.review = review; - this.valueMap.put("ep", ep); - this.valueMap.put("review", review); - } - - public @NotNull Episode ep() { - return ep; - } - - public @NotNull ReviewInput review() { - return review; - } - - @Override - public Map valueMap() { - return Collections.unmodifiableMap(valueMap); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - writer.writeString("ep", ep.rawValue()); - writer.writeObject("review", review.marshaller()); - } - }; - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("createReview", "createReview", new UnmodifiableMapBuilder(2) - .put("episode", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "ep") - .build()) - .put("review", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "review") - .build()) - .build(), true, Collections.emptyList()) - }; - - final Optional createReview; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable CreateReview createReview) { - this.createReview = Optional.fromNullable(createReview); - } - - public Optional createReview() { - return this.createReview; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], createReview.isPresent() ? createReview.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "createReview=" + createReview - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.createReview.equals(that.createReview); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= createReview.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final CreateReview.Mapper createReviewFieldMapper = new CreateReview.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final CreateReview createReview = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public CreateReview read(ResponseReader reader) { - return createReviewFieldMapper.map(reader); - } - }); - return new Data(createReview); - } - } - } - - /** - * Represents a review for a movie - */ - public static class CreateReview { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("stars", "stars", null, false, Collections.emptyList()), - ResponseField.forString("commentary", "commentary", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final int stars; - - final Optional commentary; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public CreateReview(@NotNull String __typename, int stars, @Nullable String commentary) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.stars = stars; - this.commentary = Optional.fromNullable(commentary); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The number of stars this review gave, 1-5 - */ - public int stars() { - return this.stars; - } - - /** - * Comment about the movie - */ - public Optional commentary() { - return this.commentary; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], stars); - writer.writeString($responseFields[2], commentary.isPresent() ? commentary.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "CreateReview{" - + "__typename=" + __typename + ", " - + "stars=" + stars + ", " - + "commentary=" + commentary - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof CreateReview) { - CreateReview that = (CreateReview) o; - return this.__typename.equals(that.__typename) - && this.stars == that.stars - && this.commentary.equals(that.commentary); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= stars; - h *= 1000003; - h ^= commentary.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public CreateReview map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final int stars = reader.readInt($responseFields[1]); - final String commentary = reader.readString($responseFields[2]); - return new CreateReview(__typename, stars, commentary); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/input_object_type/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/input_object_type/TestQuery.kt deleted file mode 100644 index 570e25428c8..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/input_object_type/TestQuery.kt +++ /dev/null @@ -1,204 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.input_object_type - -import com.apollographql.apollo.api.Mutation -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.input_object_type.type.Episode -import com.example.input_object_type.type.ReviewInput -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.Map -import kotlin.jvm.Transient -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class TestQuery( - val ep: Episode, - val review: ReviewInput -) : Mutation { - @Transient - private val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = mutableMapOf().apply { - this["ep"] = this@TestQuery.ep - this["review"] = this@TestQuery.review - } - - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - writer.writeString("ep", this@TestQuery.ep.rawValue) - writer.writeObject("review", this@TestQuery.review.marshaller()) - } - } - - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = variables - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * Represents a review for a movie - */ - data class CreateReview( - val __typename: String = "Review", - /** - * The number of stars this review gave, 1-5 - */ - val stars: Int, - /** - * Comment about the movie - */ - val commentary: String? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@CreateReview.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@CreateReview.stars) - writer.writeString(RESPONSE_FIELDS[2], this@CreateReview.commentary) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("stars", "stars", null, false, null), - ResponseField.forString("commentary", "commentary", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): CreateReview = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val stars = readInt(RESPONSE_FIELDS[1])!! - val commentary = readString(RESPONSE_FIELDS[2]) - CreateReview( - __typename = __typename, - stars = stars, - commentary = commentary - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val createReview: CreateReview? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.createReview?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("createReview", "createReview", mapOf( - "episode" to mapOf( - "kind" to "Variable", - "variableName" to "ep"), - "review" to mapOf( - "kind" to "Variable", - "variableName" to "review")), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val createReview = readObject(RESPONSE_FIELDS[0]) { reader -> - CreateReview(reader) - } - Data( - createReview = createReview - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "9850c60bd20e2361afd7a41d51b709fcba9637809e387afe5c7a1cb738fc254b" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |mutation TestQuery(${'$'}ep: Episode!, ${'$'}review: ReviewInput!) { - | createReview(episode: ${'$'}ep, review: ${'$'}review) { - | __typename - | stars - | commentary - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ColorInput.java b/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ColorInput.java deleted file mode 100644 index a18058831de..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ColorInput.java +++ /dev/null @@ -1,221 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.input_object_type.type; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.InputType; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class ColorInput implements InputType { - private final int red; - - private final Input green; - - private final double blue; - - private final Input enumWithDefaultValue; - - private final Input reviewRefInput; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - ColorInput(int red, Input green, double blue, Input enumWithDefaultValue, - Input reviewRefInput) { - this.red = red; - this.green = green; - this.blue = blue; - this.enumWithDefaultValue = enumWithDefaultValue; - this.reviewRefInput = reviewRefInput; - } - - /** - * Red color - */ - public int red() { - return this.red; - } - - /** - * Green color - */ - public @Nullable Double green() { - return this.green.value; - } - - /** - * Blue color - */ - public double blue() { - return this.blue; - } - - /** - * for test purpose only - */ - public @Nullable Episode enumWithDefaultValue() { - return this.enumWithDefaultValue.value; - } - - /** - * Circle ref to review input - */ - public @Nullable ReviewRefInput reviewRefInput() { - return this.reviewRefInput.value; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - writer.writeInt("red", red); - if (green.defined) { - writer.writeDouble("green", green.value); - } - writer.writeDouble("blue", blue); - if (enumWithDefaultValue.defined) { - writer.writeString("enumWithDefaultValue", enumWithDefaultValue.value != null ? enumWithDefaultValue.value.rawValue() : null); - } - if (reviewRefInput.defined) { - writer.writeObject("reviewRefInput", reviewRefInput.value != null ? reviewRefInput.value.marshaller() : null); - } - } - }; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= red; - h *= 1000003; - h ^= green.hashCode(); - h *= 1000003; - h ^= Double.valueOf(blue).hashCode(); - h *= 1000003; - h ^= enumWithDefaultValue.hashCode(); - h *= 1000003; - h ^= reviewRefInput.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof ColorInput) { - ColorInput that = (ColorInput) o; - return this.red == that.red - && this.green.equals(that.green) - && Double.doubleToLongBits(this.blue) == Double.doubleToLongBits(that.blue) - && this.enumWithDefaultValue.equals(that.enumWithDefaultValue) - && this.reviewRefInput.equals(that.reviewRefInput); - } - return false; - } - - public static final class Builder { - private int red = 1; - - private Input green = Input.fromNullable(0.0); - - private double blue = 1.5; - - private Input enumWithDefaultValue = Input.fromNullable(Episode.safeValueOf("new")); - - private Input reviewRefInput = Input.absent(); - - Builder() { - } - - /** - * Red color - */ - public Builder red(int red) { - this.red = red; - return this; - } - - /** - * Green color - */ - public Builder green(@Nullable Double green) { - this.green = Input.fromNullable(green); - return this; - } - - /** - * Blue color - */ - public Builder blue(double blue) { - this.blue = blue; - return this; - } - - /** - * for test purpose only - */ - public Builder enumWithDefaultValue(@Nullable Episode enumWithDefaultValue) { - this.enumWithDefaultValue = Input.fromNullable(enumWithDefaultValue); - return this; - } - - /** - * Circle ref to review input - */ - public Builder reviewRefInput(@Nullable ReviewRefInput reviewRefInput) { - this.reviewRefInput = Input.fromNullable(reviewRefInput); - return this; - } - - /** - * Green color - */ - public Builder greenInput(@NotNull Input green) { - this.green = Utils.checkNotNull(green, "green == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder enumWithDefaultValueInput(@NotNull Input enumWithDefaultValue) { - this.enumWithDefaultValue = Utils.checkNotNull(enumWithDefaultValue, "enumWithDefaultValue == null"); - return this; - } - - /** - * Circle ref to review input - */ - public Builder reviewRefInputInput(@NotNull Input reviewRefInput) { - this.reviewRefInput = Utils.checkNotNull(reviewRefInput, "reviewRefInput == null"); - return this; - } - - public ColorInput build() { - return new ColorInput(red, green, blue, enumWithDefaultValue, reviewRefInput); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ColorInput.kt b/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ColorInput.kt deleted file mode 100644 index ebf7e482864..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ColorInput.kt +++ /dev/null @@ -1,56 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.input_object_type.type - -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.InputType -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import kotlin.Double -import kotlin.Int -import kotlin.Suppress - -/** - * The input object sent when passing in a color - */ -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class ColorInput( - /** - * Red color - */ - val red: Int = 1, - /** - * Green color - */ - val green: Input = Input.optional(0.0), - /** - * Blue color - */ - val blue: Double = 1.5, - /** - * for test purpose only - */ - val enumWithDefaultValue: Input = Input.optional(Episode.safeValueOf("new")), - /** - * Circle ref to review input - */ - val reviewRefInput: Input = Input.absent() -) : InputType { - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - writer.writeInt("red", this@ColorInput.red) - if (this@ColorInput.green.defined) { - writer.writeDouble("green", this@ColorInput.green.value) - } - writer.writeDouble("blue", this@ColorInput.blue) - if (this@ColorInput.enumWithDefaultValue.defined) { - writer.writeString("enumWithDefaultValue", - this@ColorInput.enumWithDefaultValue.value?.rawValue) - } - if (this@ColorInput.reviewRefInput.defined) { - writer.writeObject("reviewRefInput", this@ColorInput.reviewRefInput.value?.marshaller()) - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/input_object_type/type/CustomType.java deleted file mode 100644 index c12f20597a5..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/CustomType.java +++ /dev/null @@ -1,36 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.input_object_type.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - DATE { - @Override - public String typeName() { - return "Date"; - } - - @Override - public String className() { - return "java.util.Date"; - } - }, - - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.Integer"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/input_object_type/type/CustomType.kt deleted file mode 100644 index 425015df5ac..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/CustomType.kt +++ /dev/null @@ -1,23 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.input_object_type.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - DATE { - override fun typeName(): String = "Date" - - override fun className(): String = "java.util.Date" - }, - - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.Int" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/Episode.java b/apollo-compiler/src/test/graphql/com/example/input_object_type/type/Episode.java deleted file mode 100644 index 31b53898985..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/Episode.java +++ /dev/null @@ -1,67 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.input_object_type.type; - -import java.lang.Deprecated; -import java.lang.String; - -/** - * The episodes in the Star Wars trilogy - */ -public enum Episode { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - * @deprecated For test purpose only - */ - @Deprecated - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - * @deprecated For test purpose only - */ - @Deprecated - NEW_("new"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Episode(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Episode safeValueOf(String rawValue) { - for (Episode enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Episode.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/Episode.kt b/apollo-compiler/src/test/graphql/com/example/input_object_type/type/Episode.kt deleted file mode 100644 index d4541827cfa..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/Episode.kt +++ /dev/null @@ -1,54 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.input_object_type.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.Deprecated -import kotlin.String - -/** - * The episodes in the Star Wars trilogy - */ -enum class Episode( - override val rawValue: String -) : EnumValue { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - */ - @Deprecated(message = "For test purpose only") - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - */ - @Deprecated(message = "For test purpose only") - NEW("new"), - - /** - * Auto generated constant for unknown enum values - */ - UNKNOWN__("UNKNOWN__"); - - companion object { - fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: - UNKNOWN__ - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ReviewInput.java b/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ReviewInput.java deleted file mode 100644 index b491aaed479..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ReviewInput.java +++ /dev/null @@ -1,898 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.input_object_type.type; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.InputType; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Boolean; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class ReviewInput implements InputType { - private final int stars; - - private final Input nullableIntFieldWithDefaultValue; - - private final Input commentary; - - private final @NotNull ColorInput favoriteColor; - - private final Input enumWithDefaultValue; - - private final @NotNull Episode nonNullableEnumWithDefaultValue; - - private final Input nullableEnum; - - private final Input> listOfCustomScalar; - - private final Input customScalar; - - private final Input> listOfEnums; - - private final Input> listOfInt; - - private final Input> listOfString; - - private final @NotNull List listOfStringNonOptional; - - private final Input> listOfInputTypes; - - private final Input booleanWithDefaultValue; - - private final Input booleanNonOptional; - - private final Input>> listOfListOfString; - - private final Input>> listOfListOfEnum; - - private final Input>> listOfListOfCustom; - - private final Input>> listOfListOfObject; - - private final Input capitalizedField; - - private final Input capitalizedInt; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - ReviewInput(int stars, Input nullableIntFieldWithDefaultValue, Input commentary, - @NotNull ColorInput favoriteColor, Input enumWithDefaultValue, - @NotNull Episode nonNullableEnumWithDefaultValue, Input nullableEnum, - Input> listOfCustomScalar, Input customScalar, - Input> listOfEnums, Input> listOfInt, - Input> listOfString, @NotNull List listOfStringNonOptional, - Input> listOfInputTypes, Input booleanWithDefaultValue, - Input booleanNonOptional, Input>> listOfListOfString, - Input>> listOfListOfEnum, Input>> listOfListOfCustom, - Input>> listOfListOfObject, Input capitalizedField, - Input capitalizedInt) { - this.stars = stars; - this.nullableIntFieldWithDefaultValue = nullableIntFieldWithDefaultValue; - this.commentary = commentary; - this.favoriteColor = favoriteColor; - this.enumWithDefaultValue = enumWithDefaultValue; - this.nonNullableEnumWithDefaultValue = nonNullableEnumWithDefaultValue; - this.nullableEnum = nullableEnum; - this.listOfCustomScalar = listOfCustomScalar; - this.customScalar = customScalar; - this.listOfEnums = listOfEnums; - this.listOfInt = listOfInt; - this.listOfString = listOfString; - this.listOfStringNonOptional = listOfStringNonOptional; - this.listOfInputTypes = listOfInputTypes; - this.booleanWithDefaultValue = booleanWithDefaultValue; - this.booleanNonOptional = booleanNonOptional; - this.listOfListOfString = listOfListOfString; - this.listOfListOfEnum = listOfListOfEnum; - this.listOfListOfCustom = listOfListOfCustom; - this.listOfListOfObject = listOfListOfObject; - this.capitalizedField = capitalizedField; - this.capitalizedInt = capitalizedInt; - } - - /** - * 0-5 stars - */ - public int stars() { - return this.stars; - } - - /** - * for test purpose only - */ - public @Nullable Integer nullableIntFieldWithDefaultValue() { - return this.nullableIntFieldWithDefaultValue.value; - } - - /** - * Comment about the movie, optional - */ - public @Nullable String commentary() { - return this.commentary.value; - } - - /** - * Favorite color, optional - */ - public @NotNull ColorInput favoriteColor() { - return this.favoriteColor; - } - - /** - * for test purpose only - */ - public @Nullable Episode enumWithDefaultValue() { - return this.enumWithDefaultValue.value; - } - - /** - * for test purpose only - */ - public @NotNull Episode nonNullableEnumWithDefaultValue() { - return this.nonNullableEnumWithDefaultValue; - } - - /** - * for test purpose only - */ - public @Nullable Episode nullableEnum() { - return this.nullableEnum.value; - } - - /** - * for test purpose only - */ - public @Nullable List listOfCustomScalar() { - return this.listOfCustomScalar.value; - } - - /** - * for test purpose only - */ - public @Nullable Date customScalar() { - return this.customScalar.value; - } - - /** - * for test purpose only - */ - public @Nullable List listOfEnums() { - return this.listOfEnums.value; - } - - /** - * for test purpose only - */ - public @Nullable List listOfInt() { - return this.listOfInt.value; - } - - /** - * for test purpose only - */ - public @Nullable List listOfString() { - return this.listOfString.value; - } - - /** - * for test purpose only - */ - public @NotNull List listOfStringNonOptional() { - return this.listOfStringNonOptional; - } - - /** - * for test purpose only - */ - public @Nullable List listOfInputTypes() { - return this.listOfInputTypes.value; - } - - /** - * for test purpose only - */ - public @Nullable Boolean booleanWithDefaultValue() { - return this.booleanWithDefaultValue.value; - } - - /** - * for test purpose only - */ - public @Nullable Boolean booleanNonOptional() { - return this.booleanNonOptional.value; - } - - /** - * for test purpose only - */ - public @Nullable List> listOfListOfString() { - return this.listOfListOfString.value; - } - - /** - * for test purpose only - */ - public @Nullable List> listOfListOfEnum() { - return this.listOfListOfEnum.value; - } - - /** - * for test purpose only - */ - public @Nullable List> listOfListOfCustom() { - return this.listOfListOfCustom.value; - } - - /** - * for test purpose only - */ - public @Nullable List> listOfListOfObject() { - return this.listOfListOfObject.value; - } - - /** - * for test purpose only - */ - public @Nullable String capitalizedField() { - return this.capitalizedField.value; - } - - /** - * for test purpose only - */ - public @Nullable Integer capitalizedInt() { - return this.capitalizedInt.value; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - writer.writeInt("stars", stars); - if (nullableIntFieldWithDefaultValue.defined) { - writer.writeInt("nullableIntFieldWithDefaultValue", nullableIntFieldWithDefaultValue.value); - } - if (commentary.defined) { - writer.writeString("commentary", commentary.value); - } - writer.writeObject("favoriteColor", favoriteColor.marshaller()); - if (enumWithDefaultValue.defined) { - writer.writeString("enumWithDefaultValue", enumWithDefaultValue.value != null ? enumWithDefaultValue.value.rawValue() : null); - } - writer.writeString("nonNullableEnumWithDefaultValue", nonNullableEnumWithDefaultValue.rawValue()); - if (nullableEnum.defined) { - writer.writeString("nullableEnum", nullableEnum.value != null ? nullableEnum.value.rawValue() : null); - } - if (listOfCustomScalar.defined) { - writer.writeList("listOfCustomScalar", listOfCustomScalar.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final Date $item : listOfCustomScalar.value) { - listItemWriter.writeCustom(CustomType.DATE, $item); - } - } - } : null); - } - if (customScalar.defined) { - writer.writeCustom("customScalar", com.example.input_object_type.type.CustomType.DATE, customScalar.value != null ? customScalar.value : null); - } - if (listOfEnums.defined) { - writer.writeList("listOfEnums", listOfEnums.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final Episode $item : listOfEnums.value) { - listItemWriter.writeString($item != null ? $item.rawValue() : null); - } - } - } : null); - } - if (listOfInt.defined) { - writer.writeList("listOfInt", listOfInt.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final Integer $item : listOfInt.value) { - listItemWriter.writeInt($item); - } - } - } : null); - } - if (listOfString.defined) { - writer.writeList("listOfString", listOfString.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final String $item : listOfString.value) { - listItemWriter.writeString($item); - } - } - } : null); - } - writer.writeList("listOfStringNonOptional", new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final String $item : listOfStringNonOptional) { - listItemWriter.writeString($item); - } - } - }); - if (listOfInputTypes.defined) { - writer.writeList("listOfInputTypes", listOfInputTypes.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final ColorInput $item : listOfInputTypes.value) { - listItemWriter.writeObject($item != null ? $item.marshaller() : null); - } - } - } : null); - } - if (booleanWithDefaultValue.defined) { - writer.writeBoolean("booleanWithDefaultValue", booleanWithDefaultValue.value); - } - if (booleanNonOptional.defined) { - writer.writeBoolean("booleanNonOptional", booleanNonOptional.value); - } - if (listOfListOfString.defined) { - writer.writeList("listOfListOfString", listOfListOfString.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final List $item : listOfListOfString.value) { - listItemWriter.writeList($item != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws - IOException { - for (final String $$item : $item) { - listItemWriter.writeString($$item); - } - } - } : null); - } - } - } : null); - } - if (listOfListOfEnum.defined) { - writer.writeList("listOfListOfEnum", listOfListOfEnum.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final List $item : listOfListOfEnum.value) { - listItemWriter.writeList($item != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws - IOException { - for (final Episode $$item : $item) { - listItemWriter.writeString($$item != null ? $$item.rawValue() : null); - } - } - } : null); - } - } - } : null); - } - if (listOfListOfCustom.defined) { - writer.writeList("listOfListOfCustom", listOfListOfCustom.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final List $item : listOfListOfCustom.value) { - listItemWriter.writeList($item != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws - IOException { - for (final Date $$item : $item) { - listItemWriter.writeCustom(CustomType.DATE, $$item); - } - } - } : null); - } - } - } : null); - } - if (listOfListOfObject.defined) { - writer.writeList("listOfListOfObject", listOfListOfObject.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final List $item : listOfListOfObject.value) { - listItemWriter.writeList($item != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws - IOException { - for (final ColorInput $$item : $item) { - listItemWriter.writeObject($$item != null ? $$item.marshaller() : null); - } - } - } : null); - } - } - } : null); - } - if (capitalizedField.defined) { - writer.writeString("CapitalizedField", capitalizedField.value); - } - if (capitalizedInt.defined) { - writer.writeInt("CapitalizedInt", capitalizedInt.value); - } - } - }; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= stars; - h *= 1000003; - h ^= nullableIntFieldWithDefaultValue.hashCode(); - h *= 1000003; - h ^= commentary.hashCode(); - h *= 1000003; - h ^= favoriteColor.hashCode(); - h *= 1000003; - h ^= enumWithDefaultValue.hashCode(); - h *= 1000003; - h ^= nonNullableEnumWithDefaultValue.hashCode(); - h *= 1000003; - h ^= nullableEnum.hashCode(); - h *= 1000003; - h ^= listOfCustomScalar.hashCode(); - h *= 1000003; - h ^= customScalar.hashCode(); - h *= 1000003; - h ^= listOfEnums.hashCode(); - h *= 1000003; - h ^= listOfInt.hashCode(); - h *= 1000003; - h ^= listOfString.hashCode(); - h *= 1000003; - h ^= listOfStringNonOptional.hashCode(); - h *= 1000003; - h ^= listOfInputTypes.hashCode(); - h *= 1000003; - h ^= booleanWithDefaultValue.hashCode(); - h *= 1000003; - h ^= booleanNonOptional.hashCode(); - h *= 1000003; - h ^= listOfListOfString.hashCode(); - h *= 1000003; - h ^= listOfListOfEnum.hashCode(); - h *= 1000003; - h ^= listOfListOfCustom.hashCode(); - h *= 1000003; - h ^= listOfListOfObject.hashCode(); - h *= 1000003; - h ^= capitalizedField.hashCode(); - h *= 1000003; - h ^= capitalizedInt.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof ReviewInput) { - ReviewInput that = (ReviewInput) o; - return this.stars == that.stars - && this.nullableIntFieldWithDefaultValue.equals(that.nullableIntFieldWithDefaultValue) - && this.commentary.equals(that.commentary) - && this.favoriteColor.equals(that.favoriteColor) - && this.enumWithDefaultValue.equals(that.enumWithDefaultValue) - && this.nonNullableEnumWithDefaultValue.equals(that.nonNullableEnumWithDefaultValue) - && this.nullableEnum.equals(that.nullableEnum) - && this.listOfCustomScalar.equals(that.listOfCustomScalar) - && this.customScalar.equals(that.customScalar) - && this.listOfEnums.equals(that.listOfEnums) - && this.listOfInt.equals(that.listOfInt) - && this.listOfString.equals(that.listOfString) - && this.listOfStringNonOptional.equals(that.listOfStringNonOptional) - && this.listOfInputTypes.equals(that.listOfInputTypes) - && this.booleanWithDefaultValue.equals(that.booleanWithDefaultValue) - && this.booleanNonOptional.equals(that.booleanNonOptional) - && this.listOfListOfString.equals(that.listOfListOfString) - && this.listOfListOfEnum.equals(that.listOfListOfEnum) - && this.listOfListOfCustom.equals(that.listOfListOfCustom) - && this.listOfListOfObject.equals(that.listOfListOfObject) - && this.capitalizedField.equals(that.capitalizedField) - && this.capitalizedInt.equals(that.capitalizedInt); - } - return false; - } - - public static final class Builder { - private int stars; - - private Input nullableIntFieldWithDefaultValue = Input.fromNullable(10); - - private Input commentary = Input.absent(); - - private @NotNull ColorInput favoriteColor; - - private Input enumWithDefaultValue = Input.fromNullable(Episode.safeValueOf("JEDI")); - - private @NotNull Episode nonNullableEnumWithDefaultValue = Episode.safeValueOf("JEDI"); - - private Input nullableEnum = Input.absent(); - - private Input> listOfCustomScalar = Input.absent(); - - private Input customScalar = Input.absent(); - - private Input> listOfEnums = Input.fromNullable(Arrays.asList(Episode.safeValueOf("NEWHOPE"), Episode.safeValueOf("EMPIRE"))); - - private Input> listOfInt = Input.fromNullable(Arrays.asList(1, 2, 3)); - - private Input> listOfString = Input.fromNullable(Arrays.asList("test1", "test2", "test3")); - - private @NotNull List listOfStringNonOptional; - - private Input> listOfInputTypes = Input.fromNullable(Arrays.asList()); - - private Input booleanWithDefaultValue = Input.fromNullable(true); - - private Input booleanNonOptional = Input.absent(); - - private Input>> listOfListOfString = Input.absent(); - - private Input>> listOfListOfEnum = Input.absent(); - - private Input>> listOfListOfCustom = Input.absent(); - - private Input>> listOfListOfObject = Input.absent(); - - private Input capitalizedField = Input.absent(); - - private Input capitalizedInt = Input.absent(); - - Builder() { - } - - /** - * 0-5 stars - */ - public Builder stars(int stars) { - this.stars = stars; - return this; - } - - /** - * for test purpose only - */ - public Builder nullableIntFieldWithDefaultValue(@Nullable Integer nullableIntFieldWithDefaultValue) { - this.nullableIntFieldWithDefaultValue = Input.fromNullable(nullableIntFieldWithDefaultValue); - return this; - } - - /** - * Comment about the movie, optional - */ - public Builder commentary(@Nullable String commentary) { - this.commentary = Input.fromNullable(commentary); - return this; - } - - /** - * Favorite color, optional - */ - public Builder favoriteColor(@NotNull ColorInput favoriteColor) { - this.favoriteColor = favoriteColor; - return this; - } - - /** - * for test purpose only - */ - public Builder enumWithDefaultValue(@Nullable Episode enumWithDefaultValue) { - this.enumWithDefaultValue = Input.fromNullable(enumWithDefaultValue); - return this; - } - - /** - * for test purpose only - */ - public Builder nonNullableEnumWithDefaultValue(@NotNull Episode nonNullableEnumWithDefaultValue) { - this.nonNullableEnumWithDefaultValue = nonNullableEnumWithDefaultValue; - return this; - } - - /** - * for test purpose only - */ - public Builder nullableEnum(@Nullable Episode nullableEnum) { - this.nullableEnum = Input.fromNullable(nullableEnum); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfCustomScalar(@Nullable List listOfCustomScalar) { - this.listOfCustomScalar = Input.fromNullable(listOfCustomScalar); - return this; - } - - /** - * for test purpose only - */ - public Builder customScalar(@Nullable Date customScalar) { - this.customScalar = Input.fromNullable(customScalar); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfEnums(@Nullable List listOfEnums) { - this.listOfEnums = Input.fromNullable(listOfEnums); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfInt(@Nullable List listOfInt) { - this.listOfInt = Input.fromNullable(listOfInt); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfString(@Nullable List listOfString) { - this.listOfString = Input.fromNullable(listOfString); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfStringNonOptional(@NotNull List listOfStringNonOptional) { - this.listOfStringNonOptional = listOfStringNonOptional; - return this; - } - - /** - * for test purpose only - */ - public Builder listOfInputTypes(@Nullable List listOfInputTypes) { - this.listOfInputTypes = Input.fromNullable(listOfInputTypes); - return this; - } - - /** - * for test purpose only - */ - public Builder booleanWithDefaultValue(@Nullable Boolean booleanWithDefaultValue) { - this.booleanWithDefaultValue = Input.fromNullable(booleanWithDefaultValue); - return this; - } - - /** - * for test purpose only - */ - public Builder booleanNonOptional(@Nullable Boolean booleanNonOptional) { - this.booleanNonOptional = Input.fromNullable(booleanNonOptional); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfString(@Nullable List> listOfListOfString) { - this.listOfListOfString = Input.fromNullable(listOfListOfString); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfEnum(@Nullable List> listOfListOfEnum) { - this.listOfListOfEnum = Input.fromNullable(listOfListOfEnum); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfCustom(@Nullable List> listOfListOfCustom) { - this.listOfListOfCustom = Input.fromNullable(listOfListOfCustom); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfObject(@Nullable List> listOfListOfObject) { - this.listOfListOfObject = Input.fromNullable(listOfListOfObject); - return this; - } - - /** - * for test purpose only - */ - public Builder capitalizedField(@Nullable String capitalizedField) { - this.capitalizedField = Input.fromNullable(capitalizedField); - return this; - } - - /** - * for test purpose only - */ - public Builder capitalizedInt(@Nullable Integer capitalizedInt) { - this.capitalizedInt = Input.fromNullable(capitalizedInt); - return this; - } - - /** - * for test purpose only - */ - public Builder nullableIntFieldWithDefaultValueInput(@NotNull Input nullableIntFieldWithDefaultValue) { - this.nullableIntFieldWithDefaultValue = Utils.checkNotNull(nullableIntFieldWithDefaultValue, "nullableIntFieldWithDefaultValue == null"); - return this; - } - - /** - * Comment about the movie, optional - */ - public Builder commentaryInput(@NotNull Input commentary) { - this.commentary = Utils.checkNotNull(commentary, "commentary == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder enumWithDefaultValueInput(@NotNull Input enumWithDefaultValue) { - this.enumWithDefaultValue = Utils.checkNotNull(enumWithDefaultValue, "enumWithDefaultValue == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder nullableEnumInput(@NotNull Input nullableEnum) { - this.nullableEnum = Utils.checkNotNull(nullableEnum, "nullableEnum == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfCustomScalarInput(@NotNull Input> listOfCustomScalar) { - this.listOfCustomScalar = Utils.checkNotNull(listOfCustomScalar, "listOfCustomScalar == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder customScalarInput(@NotNull Input customScalar) { - this.customScalar = Utils.checkNotNull(customScalar, "customScalar == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfEnumsInput(@NotNull Input> listOfEnums) { - this.listOfEnums = Utils.checkNotNull(listOfEnums, "listOfEnums == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfIntInput(@NotNull Input> listOfInt) { - this.listOfInt = Utils.checkNotNull(listOfInt, "listOfInt == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfStringInput(@NotNull Input> listOfString) { - this.listOfString = Utils.checkNotNull(listOfString, "listOfString == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfInputTypesInput(@NotNull Input> listOfInputTypes) { - this.listOfInputTypes = Utils.checkNotNull(listOfInputTypes, "listOfInputTypes == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder booleanWithDefaultValueInput(@NotNull Input booleanWithDefaultValue) { - this.booleanWithDefaultValue = Utils.checkNotNull(booleanWithDefaultValue, "booleanWithDefaultValue == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder booleanNonOptionalInput(@NotNull Input booleanNonOptional) { - this.booleanNonOptional = Utils.checkNotNull(booleanNonOptional, "booleanNonOptional == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfStringInput(@NotNull Input>> listOfListOfString) { - this.listOfListOfString = Utils.checkNotNull(listOfListOfString, "listOfListOfString == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfEnumInput(@NotNull Input>> listOfListOfEnum) { - this.listOfListOfEnum = Utils.checkNotNull(listOfListOfEnum, "listOfListOfEnum == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfCustomInput(@NotNull Input>> listOfListOfCustom) { - this.listOfListOfCustom = Utils.checkNotNull(listOfListOfCustom, "listOfListOfCustom == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfObjectInput(@NotNull Input>> listOfListOfObject) { - this.listOfListOfObject = Utils.checkNotNull(listOfListOfObject, "listOfListOfObject == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder capitalizedFieldInput(@NotNull Input capitalizedField) { - this.capitalizedField = Utils.checkNotNull(capitalizedField, "capitalizedField == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder capitalizedIntInput(@NotNull Input capitalizedInt) { - this.capitalizedInt = Utils.checkNotNull(capitalizedInt, "capitalizedInt == null"); - return this; - } - - public ReviewInput build() { - Utils.checkNotNull(favoriteColor, "favoriteColor == null"); - Utils.checkNotNull(nonNullableEnumWithDefaultValue, "nonNullableEnumWithDefaultValue == null"); - Utils.checkNotNull(listOfStringNonOptional, "listOfStringNonOptional == null"); - return new ReviewInput(stars, nullableIntFieldWithDefaultValue, commentary, favoriteColor, enumWithDefaultValue, nonNullableEnumWithDefaultValue, nullableEnum, listOfCustomScalar, customScalar, listOfEnums, listOfInt, listOfString, listOfStringNonOptional, listOfInputTypes, booleanWithDefaultValue, booleanNonOptional, listOfListOfString, listOfListOfEnum, listOfListOfCustom, listOfListOfObject, capitalizedField, capitalizedInt); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ReviewInput.kt b/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ReviewInput.kt deleted file mode 100644 index e0a88f67705..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ReviewInput.kt +++ /dev/null @@ -1,256 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.input_object_type.type - -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.InputType -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.InputFieldWriter -import java.util.Date -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List - -/** - * The input object sent when someone is creating a new review - */ -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class ReviewInput( - /** - * 0-5 stars - */ - val stars: Int, - /** - * for test purpose only - */ - val nullableIntFieldWithDefaultValue: Input = Input.optional(10), - /** - * Comment about the movie, optional - */ - val commentary: Input = Input.absent(), - /** - * Favorite color, optional - */ - val favoriteColor: ColorInput, - /** - * for test purpose only - */ - val enumWithDefaultValue: Input = Input.optional(Episode.safeValueOf("JEDI")), - /** - * for test purpose only - */ - val nonNullableEnumWithDefaultValue: Episode = Episode.safeValueOf("JEDI"), - /** - * for test purpose only - */ - val nullableEnum: Input = Input.absent(), - /** - * for test purpose only - */ - val listOfCustomScalar: Input> = Input.absent(), - /** - * for test purpose only - */ - val customScalar: Input = Input.absent(), - /** - * for test purpose only - */ - val listOfEnums: Input> = Input.optional(listOf(Episode.safeValueOf("NEWHOPE"), - Episode.safeValueOf("EMPIRE"))), - /** - * for test purpose only - */ - val listOfInt: Input> = Input.optional(listOf(1, 2, 3)), - /** - * for test purpose only - */ - val listOfString: Input> = Input.optional(listOf("test1", "test2", "test3")), - /** - * for test purpose only - */ - val listOfStringNonOptional: List, - /** - * for test purpose only - */ - val listOfInputTypes: Input> = Input.optional(emptyList()), - /** - * for test purpose only - */ - val booleanWithDefaultValue: Input = Input.optional(true), - /** - * for test purpose only - */ - val booleanNonOptional: Input = Input.absent(), - /** - * for test purpose only - */ - val listOfListOfString: Input>> = Input.absent(), - /** - * for test purpose only - */ - val listOfListOfEnum: Input>> = Input.absent(), - /** - * for test purpose only - */ - val listOfListOfCustom: Input>> = Input.absent(), - /** - * for test purpose only - */ - val listOfListOfObject: Input>> = Input.absent(), - /** - * for test purpose only - */ - val capitalizedField: Input = Input.absent(), - /** - * for test purpose only - */ - val capitalizedInt: Input = Input.absent() -) : InputType { - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - writer.writeInt("stars", this@ReviewInput.stars) - if (this@ReviewInput.nullableIntFieldWithDefaultValue.defined) { - writer.writeInt("nullableIntFieldWithDefaultValue", - this@ReviewInput.nullableIntFieldWithDefaultValue.value) - } - if (this@ReviewInput.commentary.defined) { - writer.writeString("commentary", this@ReviewInput.commentary.value) - } - writer.writeObject("favoriteColor", this@ReviewInput.favoriteColor.marshaller()) - if (this@ReviewInput.enumWithDefaultValue.defined) { - writer.writeString("enumWithDefaultValue", - this@ReviewInput.enumWithDefaultValue.value?.rawValue) - } - writer.writeString("nonNullableEnumWithDefaultValue", - this@ReviewInput.nonNullableEnumWithDefaultValue.rawValue) - if (this@ReviewInput.nullableEnum.defined) { - writer.writeString("nullableEnum", this@ReviewInput.nullableEnum.value?.rawValue) - } - if (this@ReviewInput.listOfCustomScalar.defined) { - writer.writeList("listOfCustomScalar", this@ReviewInput.listOfCustomScalar.value?.let { - value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeCustom(CustomType.DATE, value) - } - } - }) - } - if (this@ReviewInput.customScalar.defined) { - writer.writeCustom("customScalar", CustomType.DATE, this@ReviewInput.customScalar.value) - } - if (this@ReviewInput.listOfEnums.defined) { - writer.writeList("listOfEnums", this@ReviewInput.listOfEnums.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeString(value?.rawValue) - } - } - }) - } - if (this@ReviewInput.listOfInt.defined) { - writer.writeList("listOfInt", this@ReviewInput.listOfInt.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeInt(value) - } - } - }) - } - if (this@ReviewInput.listOfString.defined) { - writer.writeList("listOfString", this@ReviewInput.listOfString.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeString(value) - } - } - }) - } - writer.writeList("listOfStringNonOptional") { listItemWriter -> - this@ReviewInput.listOfStringNonOptional.forEach { value -> - listItemWriter.writeString(value) - } - } - if (this@ReviewInput.listOfInputTypes.defined) { - writer.writeList("listOfInputTypes", this@ReviewInput.listOfInputTypes.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeObject(value?.marshaller()) - } - } - }) - } - if (this@ReviewInput.booleanWithDefaultValue.defined) { - writer.writeBoolean("booleanWithDefaultValue", this@ReviewInput.booleanWithDefaultValue.value) - } - if (this@ReviewInput.booleanNonOptional.defined) { - writer.writeBoolean("booleanNonOptional", this@ReviewInput.booleanNonOptional.value) - } - if (this@ReviewInput.listOfListOfString.defined) { - writer.writeList("listOfListOfString", this@ReviewInput.listOfListOfString.value?.let { - value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeList { listItemWriter -> - value.forEach { value -> - listItemWriter.writeString(value) - } - } - } - } - }) - } - if (this@ReviewInput.listOfListOfEnum.defined) { - writer.writeList("listOfListOfEnum", this@ReviewInput.listOfListOfEnum.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeList { listItemWriter -> - value.forEach { value -> - listItemWriter.writeString(value.rawValue) - } - } - } - } - }) - } - if (this@ReviewInput.listOfListOfCustom.defined) { - writer.writeList("listOfListOfCustom", this@ReviewInput.listOfListOfCustom.value?.let { - value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeList { listItemWriter -> - value.forEach { value -> - listItemWriter.writeCustom(CustomType.DATE, value) - } - } - } - } - }) - } - if (this@ReviewInput.listOfListOfObject.defined) { - writer.writeList("listOfListOfObject", this@ReviewInput.listOfListOfObject.value?.let { - value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeList { listItemWriter -> - value.forEach { value -> - listItemWriter.writeObject(value.marshaller()) - } - } - } - } - }) - } - if (this@ReviewInput.capitalizedField.defined) { - writer.writeString("CapitalizedField", this@ReviewInput.capitalizedField.value) - } - if (this@ReviewInput.capitalizedInt.defined) { - writer.writeInt("CapitalizedInt", this@ReviewInput.capitalizedInt.value) - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ReviewRefInput.java b/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ReviewRefInput.java deleted file mode 100644 index 0932414d48a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ReviewRefInput.java +++ /dev/null @@ -1,94 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.input_object_type.type; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.InputType; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class ReviewRefInput implements InputType { - private final Input reviewInput; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - ReviewRefInput(Input reviewInput) { - this.reviewInput = reviewInput; - } - - public @Nullable ReviewInput reviewInput() { - return this.reviewInput.value; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - if (reviewInput.defined) { - writer.writeObject("reviewInput", reviewInput.value != null ? reviewInput.value.marshaller() : null); - } - } - }; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= reviewInput.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof ReviewRefInput) { - ReviewRefInput that = (ReviewRefInput) o; - return this.reviewInput.equals(that.reviewInput); - } - return false; - } - - public static final class Builder { - private Input reviewInput = Input.absent(); - - Builder() { - } - - public Builder reviewInput(@Nullable ReviewInput reviewInput) { - this.reviewInput = Input.fromNullable(reviewInput); - return this; - } - - public Builder reviewInputInput(@NotNull Input reviewInput) { - this.reviewInput = Utils.checkNotNull(reviewInput, "reviewInput == null"); - return this; - } - - public ReviewRefInput build() { - return new ReviewRefInput(reviewInput); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ReviewRefInput.kt b/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ReviewRefInput.kt deleted file mode 100644 index ac5da5b2d92..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/input_object_type/type/ReviewRefInput.kt +++ /dev/null @@ -1,26 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.input_object_type.type - -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.InputType -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import kotlin.Suppress - -/** - * Circle ref to review input - */ -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class ReviewRefInput( - val reviewInput: Input = Input.absent() -) : InputType { - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - if (this@ReviewRefInput.reviewInput.defined) { - writer.writeObject("reviewInput", this@ReviewRefInput.reviewInput.value?.marshaller()) - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/introspection_query/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/introspection_query/TestOperation.graphql deleted file mode 100644 index 1a2927ce030..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/introspection_query/TestOperation.graphql +++ /dev/null @@ -1,13 +0,0 @@ -query TestQuery { - __schema { - queryType { - name - } - types { - name - } - } - __type(name: "Vehicle") { - name - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/introspection_query/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/introspection_query/TestQuery.java deleted file mode 100644 index af77ce9f53b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/introspection_query/TestQuery.java +++ /dev/null @@ -1,686 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.introspection_query; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "08518fde8892d59c699c4d48f384d7199d933a5846e6936d910cb492b8f84684"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " __schema {\n" - + " __typename\n" - + " queryType {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " types {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " __type(name: \"Vehicle\") {\n" - + " __typename\n" - + " name\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("__schema", "__schema", null, false, Collections.emptyList()), - ResponseField.forObject("__type", "__type", new UnmodifiableMapBuilder(1) - .put("name", "Vehicle") - .build(), true, Collections.emptyList()) - }; - - final @NotNull __Schema __schema; - - final Optional<__Type> __type; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@NotNull __Schema __schema, @Nullable __Type __type) { - this.__schema = Utils.checkNotNull(__schema, "__schema == null"); - this.__type = Optional.fromNullable(__type); - } - - public @NotNull __Schema __schema() { - return this.__schema; - } - - public Optional<__Type> __type() { - return this.__type; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], __schema.marshaller()); - writer.writeObject($responseFields[1], __type.isPresent() ? __type.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "__schema=" + __schema + ", " - + "__type=" + __type - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.__schema.equals(that.__schema) - && this.__type.equals(that.__type); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __schema.hashCode(); - h *= 1000003; - h ^= __type.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final __Schema.Mapper __SchemaFieldMapper = new __Schema.Mapper(); - - final __Type.Mapper __TypeFieldMapper = new __Type.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final __Schema __schema = reader.readObject($responseFields[0], new ResponseReader.ObjectReader<__Schema>() { - @Override - public __Schema read(ResponseReader reader) { - return __SchemaFieldMapper.map(reader); - } - }); - final __Type __type = reader.readObject($responseFields[1], new ResponseReader.ObjectReader<__Type>() { - @Override - public __Type read(ResponseReader reader) { - return __TypeFieldMapper.map(reader); - } - }); - return new Data(__schema, __type); - } - } - } - - /** - * A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations. - */ - public static class __Schema { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("queryType", "queryType", null, false, Collections.emptyList()), - ResponseField.forList("types", "types", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull QueryType queryType; - - final @NotNull List types; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public __Schema(@NotNull String __typename, @NotNull QueryType queryType, - @NotNull List types) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.queryType = Utils.checkNotNull(queryType, "queryType == null"); - this.types = Utils.checkNotNull(types, "types == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The type that query operations will be rooted at. - */ - public @NotNull QueryType queryType() { - return this.queryType; - } - - /** - * A list of all types supported by this server. - */ - public @NotNull List types() { - return this.types; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], queryType.marshaller()); - writer.writeList($responseFields[2], types, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Type) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "__Schema{" - + "__typename=" + __typename + ", " - + "queryType=" + queryType + ", " - + "types=" + types - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof __Schema) { - __Schema that = (__Schema) o; - return this.__typename.equals(that.__typename) - && this.queryType.equals(that.queryType) - && this.types.equals(that.types); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= queryType.hashCode(); - h *= 1000003; - h ^= types.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper<__Schema> { - final QueryType.Mapper queryTypeFieldMapper = new QueryType.Mapper(); - - final Type.Mapper typeFieldMapper = new Type.Mapper(); - - @Override - public __Schema map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final QueryType queryType = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public QueryType read(ResponseReader reader) { - return queryTypeFieldMapper.map(reader); - } - }); - final List types = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Type read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Type read(ResponseReader reader) { - return typeFieldMapper.map(reader); - } - }); - } - }); - return new __Schema(__typename, queryType, types); - } - } - } - - /** - * The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum. - * - * Depending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types. - */ - public static class QueryType { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public QueryType(@NotNull String __typename, @Nullable String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Optional.fromNullable(name); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public Optional name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name.isPresent() ? name.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "QueryType{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof QueryType) { - QueryType that = (QueryType) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public QueryType map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new QueryType(__typename, name); - } - } - } - - /** - * The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum. - * - * Depending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types. - */ - public static class Type { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Type(@NotNull String __typename, @Nullable String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Optional.fromNullable(name); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public Optional name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name.isPresent() ? name.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Type{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Type) { - Type that = (Type) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Type map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Type(__typename, name); - } - } - } - - /** - * The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum. - * - * Depending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types. - */ - public static class __Type { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public __Type(@NotNull String __typename, @Nullable String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Optional.fromNullable(name); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public Optional name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name.isPresent() ? name.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "__Type{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof __Type) { - __Type that = (__Type) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper<__Type> { - @Override - public __Type map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new __Type(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/introspection_query/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/introspection_query/TestQuery.kt deleted file mode 100644 index ef2b91c769c..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/introspection_query/TestQuery.kt +++ /dev/null @@ -1,319 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.introspection_query - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in - * GraphQL as represented by the `__TypeKind` enum. - * - * Depending on the kind of a type, certain fields describe information about that type. Scalar - * types provide no information beyond a name and description, while Enum types provide their values. - * Object and Interface types provide the fields they describe. Abstract types, Union and Interface, - * provide the Object types possible at runtime. List and NonNull types compose other types. - */ - data class QueryType( - val __typename: String = "__Type", - val name: String? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@QueryType.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@QueryType.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): QueryType = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1]) - QueryType( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in - * GraphQL as represented by the `__TypeKind` enum. - * - * Depending on the kind of a type, certain fields describe information about that type. Scalar - * types provide no information beyond a name and description, while Enum types provide their values. - * Object and Interface types provide the fields they describe. Abstract types, Union and Interface, - * provide the Object types possible at runtime. List and NonNull types compose other types. - */ - data class Type( - val __typename: String = "__Type", - val name: String? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Type.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Type.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Type = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1]) - Type( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types - * and directives on the server, as well as the entry points for query, mutation, and subscription - * operations. - */ - data class __Schema( - val __typename: String = "__Schema", - /** - * The type that query operations will be rooted at. - */ - val queryType: QueryType, - /** - * A list of all types supported by this server. - */ - val types: List - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@__Schema.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@__Schema.queryType.marshaller()) - writer.writeList(RESPONSE_FIELDS[2], this@__Schema.types) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value.marshaller())} - } - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("queryType", "queryType", null, false, null), - ResponseField.forList("types", "types", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): __Schema = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val queryType = readObject(RESPONSE_FIELDS[1]) { reader -> - QueryType(reader) - }!! - val types = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Type(reader) - } - }!!.map { it!! } - __Schema( - __typename = __typename, - queryType = queryType, - types = types - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper<__Schema> = ResponseFieldMapper { invoke(it) } - } - } - - /** - * The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in - * GraphQL as represented by the `__TypeKind` enum. - * - * Depending on the kind of a type, certain fields describe information about that type. Scalar - * types provide no information beyond a name and description, while Enum types provide their values. - * Object and Interface types provide the fields they describe. Abstract types, Union and Interface, - * provide the Object types possible at runtime. List and NonNull types compose other types. - */ - data class __Type( - val __typename: String = "__Type", - val name: String? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@__Type.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@__Type.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): __Type = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1]) - __Type( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper<__Type> = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val __schema: __Schema, - val __type: __Type? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.__schema.marshaller()) - writer.writeObject(RESPONSE_FIELDS[1], this@Data.__type?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("__schema", "__schema", null, false, null), - ResponseField.forObject("__type", "__type", mapOf( - "name" to "Vehicle"), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val __schema = readObject<__Schema>(RESPONSE_FIELDS[0]) { reader -> - __Schema(reader) - }!! - val __type = readObject<__Type>(RESPONSE_FIELDS[1]) { reader -> - __Type(reader) - } - Data( - __schema = __schema, - __type = __type - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "08518fde8892d59c699c4d48f384d7199d933a5846e6936d910cb492b8f84684" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | __schema { - | __typename - | queryType { - | __typename - | name - | } - | types { - | __typename - | name - | } - | } - | __type(name: "Vehicle") { - | __typename - | name - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/introspection_query/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/introspection_query/type/CustomType.java deleted file mode 100644 index 54f21bfda64..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/introspection_query/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.introspection_query.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/introspection_query/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/introspection_query/type/CustomType.kt deleted file mode 100644 index facdd7f2b65..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/introspection_query/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.introspection_query.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/TestOperation.graphql deleted file mode 100644 index 3fe8c09dcc0..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/TestOperation.graphql +++ /dev/null @@ -1,27 +0,0 @@ -query TestQuery { - hero { - name - ...HeroDetails - appearsIn - } -} - -fragment HeroDetails on Character { - name - friendsConnection { - totalCount - edges { - node { - name - } - } - pageInfo { - hasNextPage - } - isEmpty - } - ... on Droid { - name - primaryFunction - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/TestQuery.java deleted file mode 100644 index 7306d01e02f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/TestQuery.java +++ /dev/null @@ -1,482 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.java_beans_semantic_naming; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.java_beans_semantic_naming.fragment.HeroDetails; -import com.example.java_beans_semantic_naming.type.Episode; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "a2bc6502baa27d33261b6be530fcaecea248e26e4522c359e8dc6c62c10cafdc"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " ...HeroDetails\n" - + " appearsIn\n" - + " }\n" - + "}\n" - + "fragment HeroDetails on Character {\n" - + " __typename\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " pageInfo {\n" - + " __typename\n" - + " hasNextPage\n" - + " }\n" - + " isEmpty\n" - + " }\n" - + " ... on Droid {\n" - + " name\n" - + " primaryFunction\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional getHero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forList("appearsIn", "appearsIn", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull List appearsIn; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull String name, @NotNull List appearsIn, - @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.appearsIn = Utils.checkNotNull(appearsIn, "appearsIn == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String get__typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String getName() { - return this.name; - } - - /** - * The movies this character appears in - */ - public @NotNull List getAppearsIn() { - return this.appearsIn; - } - - public @NotNull Fragments getFragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeList($responseFields[2], appearsIn, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeString(((Episode) item).rawValue()); - } - } - }); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "appearsIn=" + appearsIn + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.appearsIn.equals(that.appearsIn) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= appearsIn.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @NotNull HeroDetails heroDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@NotNull HeroDetails heroDetails) { - this.heroDetails = Utils.checkNotNull(heroDetails, "heroDetails == null"); - } - - public @NotNull HeroDetails getHeroDetails() { - return this.heroDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeFragment(heroDetails.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "heroDetails=" + heroDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.heroDetails.equals(that.heroDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= heroDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Collections.emptyList()) - }; - - final HeroDetails.Mapper heroDetailsFieldMapper = new HeroDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HeroDetails heroDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HeroDetails read(ResponseReader reader) { - return heroDetailsFieldMapper.map(reader); - } - }); - return new Fragments(heroDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final List appearsIn = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Episode read(ResponseReader.ListItemReader listItemReader) { - return Episode.safeValueOf(listItemReader.readString()); - } - }); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Hero(__typename, name, appearsIn, fragments); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/TestQuery.kt deleted file mode 100644 index 29d60b68c17..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/TestQuery.kt +++ /dev/null @@ -1,241 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.java_beans_semantic_naming - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.java_beans_semantic_naming.fragment.HeroDetails -import com.example.java_beans_semantic_naming.type.Episode -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The movies this character appears in - */ - val appearsIn: List, - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeList(RESPONSE_FIELDS[2], this@Hero.appearsIn) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeString(value?.rawValue)} - } - this@Hero.fragments.marshaller().marshal(writer) - } - - fun appearsInFilterNotNull(): List = appearsIn.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forList("appearsIn", "appearsIn", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val appearsIn = readList(RESPONSE_FIELDS[2]) { reader -> - Episode.safeValueOf(reader.readString()) - }!! - val fragments = Fragments(reader) - Hero( - __typename = __typename, - name = name, - appearsIn = appearsIn, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val heroDetails: HeroDetails - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.heroDetails.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", null) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val heroDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - HeroDetails(reader) - }!! - Fragments( - heroDetails = heroDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "a2bc6502baa27d33261b6be530fcaecea248e26e4522c359e8dc6c62c10cafdc" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | name - | ...HeroDetails - | appearsIn - | } - |} - |fragment HeroDetails on Character { - | __typename - | name - | friendsConnection { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | pageInfo { - | __typename - | hasNextPage - | } - | isEmpty - | } - | ... on Droid { - | name - | primaryFunction - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/fragment/HeroDetails.java b/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/fragment/HeroDetails.java deleted file mode 100644 index ef28e5e8013..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/fragment/HeroDetails.java +++ /dev/null @@ -1,1328 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.java_beans_semantic_naming.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public interface HeroDetails extends GraphqlFragment { - String FRAGMENT_DEFINITION = "fragment HeroDetails on Character {\n" - + " __typename\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " pageInfo {\n" - + " __typename\n" - + " hasNextPage\n" - + " }\n" - + " isEmpty\n" - + " }\n" - + " ... on Droid {\n" - + " name\n" - + " primaryFunction\n" - + " }\n" - + "}"; - - @NotNull String get__typename(); - - /** - * The name of the character - */ - @NotNull String getName(); - - /** - * The friends of the character exposed as a connection with edges - */ - @NotNull FriendsConnection getFriendsConnection(); - - ResponseFieldMarshaller marshaller(); - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid"}) - )) - }; - - final AsDroid.Mapper asDroidFieldMapper = new AsDroid.Mapper(); - - final AsCharacter.Mapper asCharacterFieldMapper = new AsCharacter.Mapper(); - - @Override - public HeroDetails map(ResponseReader reader) { - final AsDroid asDroid = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsDroid read(ResponseReader reader) { - return asDroidFieldMapper.map(reader); - } - }); - if (asDroid != null) { - return asDroid; - } - return asCharacterFieldMapper.map(reader); - } - } - - /** - * A connection object for a character's friends - */ - interface FriendsConnection { - @NotNull String get__typename(); - - /** - * The total number of friends - */ - Optional getTotalCount(); - - /** - * The edges for each of the character's friends. - */ - Optional> getEdges(); - - /** - * Information for paginating this connection - */ - @NotNull PageInfo getPageInfo(); - - /** - * For test java beans semantic naming only - */ - boolean isEmpty(); - - ResponseFieldMarshaller marshaller(); - } - - /** - * An edge object for a character's friends - */ - interface Edge { - @NotNull String get__typename(); - - /** - * The character represented by this friendship edge - */ - Optional getNode(); - - ResponseFieldMarshaller marshaller(); - } - - /** - * A character from the Star Wars universe - */ - interface Node { - @NotNull String get__typename(); - - /** - * The name of the character - */ - @NotNull String getName(); - - ResponseFieldMarshaller marshaller(); - } - - /** - * Information for paginating this connection - */ - interface PageInfo { - @NotNull String get__typename(); - - boolean isHasNextPage(); - - ResponseFieldMarshaller marshaller(); - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - class AsDroid implements HeroDetails { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, Collections.emptyList()), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull FriendsConnection1 friendsConnection; - - final Optional primaryFunction; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsDroid(@NotNull String __typename, @NotNull String name, - @NotNull FriendsConnection1 friendsConnection, @Nullable String primaryFunction) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - this.primaryFunction = Optional.fromNullable(primaryFunction); - } - - public @NotNull String get__typename() { - return this.__typename; - } - - /** - * What others call this droid - */ - public @NotNull String getName() { - return this.name; - } - - /** - * The friends of the droid exposed as a connection with edges - */ - public @NotNull FriendsConnection1 getFriendsConnection() { - return this.friendsConnection; - } - - /** - * This droid's primary function - */ - public Optional getPrimaryFunction() { - return this.primaryFunction; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeObject($responseFields[2], friendsConnection.marshaller()); - writer.writeString($responseFields[3], primaryFunction.isPresent() ? primaryFunction.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsDroid{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection + ", " - + "primaryFunction=" + primaryFunction - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsDroid) { - AsDroid that = (AsDroid) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection) - && this.primaryFunction.equals(that.primaryFunction); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - h *= 1000003; - h ^= primaryFunction.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection1.Mapper friendsConnection1FieldMapper = new FriendsConnection1.Mapper(); - - @Override - public AsDroid map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final FriendsConnection1 friendsConnection = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection1 read(ResponseReader reader) { - return friendsConnection1FieldMapper.map(reader); - } - }); - final String primaryFunction = reader.readString($responseFields[3]); - return new AsDroid(__typename, name, friendsConnection, primaryFunction); - } - } - } - - /** - * A connection object for a character's friends - */ - class FriendsConnection1 implements FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()), - ResponseField.forObject("pageInfo", "pageInfo", null, false, Collections.emptyList()), - ResponseField.forBoolean("isEmpty", "isEmpty", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - final Optional> edges; - - final @NotNull PageInfo1 pageInfo; - - final boolean isEmpty; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection1(@NotNull String __typename, @Nullable Integer totalCount, - @Nullable List edges, @NotNull PageInfo1 pageInfo, boolean isEmpty) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.fromNullable(totalCount); - this.edges = Optional.fromNullable(edges); - this.pageInfo = Utils.checkNotNull(pageInfo, "pageInfo == null"); - this.isEmpty = isEmpty; - } - - public @NotNull String get__typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional getTotalCount() { - return this.totalCount; - } - - /** - * The edges for each of the character's friends. - */ - public Optional> getEdges() { - return this.edges; - } - - /** - * Information for paginating this connection - */ - public @NotNull PageInfo1 getPageInfo() { - return this.pageInfo; - } - - /** - * For test java beans semantic naming only - */ - public boolean isEmpty() { - return this.isEmpty; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - writer.writeList($responseFields[2], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge1) item).marshaller()); - } - } - }); - writer.writeObject($responseFields[3], pageInfo.marshaller()); - writer.writeBoolean($responseFields[4], isEmpty); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection1{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount + ", " - + "edges=" + edges + ", " - + "pageInfo=" + pageInfo + ", " - + "isEmpty=" + isEmpty - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection1) { - FriendsConnection1 that = (FriendsConnection1) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount) - && this.edges.equals(that.edges) - && this.pageInfo.equals(that.pageInfo) - && this.isEmpty == that.isEmpty; - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - h *= 1000003; - h ^= pageInfo.hashCode(); - h *= 1000003; - h ^= Boolean.valueOf(isEmpty).hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge1.Mapper edge1FieldMapper = new Edge1.Mapper(); - - final PageInfo1.Mapper pageInfo1FieldMapper = new PageInfo1.Mapper(); - - @Override - public FriendsConnection1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - final List edges = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Edge1 read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge1 read(ResponseReader reader) { - return edge1FieldMapper.map(reader); - } - }); - } - }); - final PageInfo1 pageInfo = reader.readObject($responseFields[3], new ResponseReader.ObjectReader() { - @Override - public PageInfo1 read(ResponseReader reader) { - return pageInfo1FieldMapper.map(reader); - } - }); - final boolean isEmpty = reader.readBoolean($responseFields[4]); - return new FriendsConnection1(__typename, totalCount, edges, pageInfo, isEmpty); - } - } - } - - /** - * An edge object for a character's friends - */ - class Edge1 implements Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge1(@NotNull String __typename, @Nullable Node1 node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.fromNullable(node); - } - - public @NotNull String get__typename() { - return this.__typename; - } - - /** - * The character represented by this friendship edge - */ - public Optional getNode() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge1{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge1) { - Edge1 that = (Edge1) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Node1.Mapper node1FieldMapper = new Node1.Mapper(); - - @Override - public Edge1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node1 node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node1 read(ResponseReader reader) { - return node1FieldMapper.map(reader); - } - }); - return new Edge1(__typename, node); - } - } - } - - /** - * A character from the Star Wars universe - */ - class Node1 implements Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node1(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String get__typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String getName() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node1{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node1) { - Node1 that = (Node1) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Node1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Node1(__typename, name); - } - } - } - - /** - * Information for paginating this connection - */ - class PageInfo1 implements PageInfo { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forBoolean("hasNextPage", "hasNextPage", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final boolean hasNextPage; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public PageInfo1(@NotNull String __typename, boolean hasNextPage) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.hasNextPage = hasNextPage; - } - - public @NotNull String get__typename() { - return this.__typename; - } - - public boolean isHasNextPage() { - return this.hasNextPage; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeBoolean($responseFields[1], hasNextPage); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "PageInfo1{" - + "__typename=" + __typename + ", " - + "hasNextPage=" + hasNextPage - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof PageInfo1) { - PageInfo1 that = (PageInfo1) o; - return this.__typename.equals(that.__typename) - && this.hasNextPage == that.hasNextPage; - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= Boolean.valueOf(hasNextPage).hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public PageInfo1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final boolean hasNextPage = reader.readBoolean($responseFields[1]); - return new PageInfo1(__typename, hasNextPage); - } - } - } - - class AsCharacter implements HeroDetails { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull FriendsConnection2 friendsConnection; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter(@NotNull String __typename, @NotNull String name, - @NotNull FriendsConnection2 friendsConnection) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - } - - public @NotNull String get__typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String getName() { - return this.name; - } - - /** - * The friends of the character exposed as a connection with edges - */ - public @NotNull FriendsConnection2 getFriendsConnection() { - return this.friendsConnection; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeObject($responseFields[2], friendsConnection.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter) { - AsCharacter that = (AsCharacter) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection2.Mapper friendsConnection2FieldMapper = new FriendsConnection2.Mapper(); - - @Override - public AsCharacter map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final FriendsConnection2 friendsConnection = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection2 read(ResponseReader reader) { - return friendsConnection2FieldMapper.map(reader); - } - }); - return new AsCharacter(__typename, name, friendsConnection); - } - } - } - - /** - * A connection object for a character's friends - */ - class FriendsConnection2 implements FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()), - ResponseField.forObject("pageInfo", "pageInfo", null, false, Collections.emptyList()), - ResponseField.forBoolean("isEmpty", "isEmpty", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - final Optional> edges; - - final @NotNull PageInfo2 pageInfo; - - final boolean isEmpty; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection2(@NotNull String __typename, @Nullable Integer totalCount, - @Nullable List edges, @NotNull PageInfo2 pageInfo, boolean isEmpty) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.fromNullable(totalCount); - this.edges = Optional.fromNullable(edges); - this.pageInfo = Utils.checkNotNull(pageInfo, "pageInfo == null"); - this.isEmpty = isEmpty; - } - - public @NotNull String get__typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional getTotalCount() { - return this.totalCount; - } - - /** - * The edges for each of the character's friends. - */ - public Optional> getEdges() { - return this.edges; - } - - /** - * Information for paginating this connection - */ - public @NotNull PageInfo2 getPageInfo() { - return this.pageInfo; - } - - /** - * For test java beans semantic naming only - */ - public boolean isEmpty() { - return this.isEmpty; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - writer.writeList($responseFields[2], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge2) item).marshaller()); - } - } - }); - writer.writeObject($responseFields[3], pageInfo.marshaller()); - writer.writeBoolean($responseFields[4], isEmpty); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection2{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount + ", " - + "edges=" + edges + ", " - + "pageInfo=" + pageInfo + ", " - + "isEmpty=" + isEmpty - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection2) { - FriendsConnection2 that = (FriendsConnection2) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount) - && this.edges.equals(that.edges) - && this.pageInfo.equals(that.pageInfo) - && this.isEmpty == that.isEmpty; - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - h *= 1000003; - h ^= pageInfo.hashCode(); - h *= 1000003; - h ^= Boolean.valueOf(isEmpty).hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge2.Mapper edge2FieldMapper = new Edge2.Mapper(); - - final PageInfo2.Mapper pageInfo2FieldMapper = new PageInfo2.Mapper(); - - @Override - public FriendsConnection2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - final List edges = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Edge2 read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge2 read(ResponseReader reader) { - return edge2FieldMapper.map(reader); - } - }); - } - }); - final PageInfo2 pageInfo = reader.readObject($responseFields[3], new ResponseReader.ObjectReader() { - @Override - public PageInfo2 read(ResponseReader reader) { - return pageInfo2FieldMapper.map(reader); - } - }); - final boolean isEmpty = reader.readBoolean($responseFields[4]); - return new FriendsConnection2(__typename, totalCount, edges, pageInfo, isEmpty); - } - } - } - - /** - * An edge object for a character's friends - */ - class Edge2 implements Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge2(@NotNull String __typename, @Nullable Node2 node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.fromNullable(node); - } - - public @NotNull String get__typename() { - return this.__typename; - } - - /** - * The character represented by this friendship edge - */ - public Optional getNode() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge2{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge2) { - Edge2 that = (Edge2) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Node2.Mapper node2FieldMapper = new Node2.Mapper(); - - @Override - public Edge2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node2 node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node2 read(ResponseReader reader) { - return node2FieldMapper.map(reader); - } - }); - return new Edge2(__typename, node); - } - } - } - - /** - * A character from the Star Wars universe - */ - class Node2 implements Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node2(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String get__typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String getName() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node2{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node2) { - Node2 that = (Node2) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Node2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Node2(__typename, name); - } - } - } - - /** - * Information for paginating this connection - */ - class PageInfo2 implements PageInfo { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forBoolean("hasNextPage", "hasNextPage", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final boolean hasNextPage; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public PageInfo2(@NotNull String __typename, boolean hasNextPage) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.hasNextPage = hasNextPage; - } - - public @NotNull String get__typename() { - return this.__typename; - } - - public boolean isHasNextPage() { - return this.hasNextPage; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeBoolean($responseFields[1], hasNextPage); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "PageInfo2{" - + "__typename=" + __typename + ", " - + "hasNextPage=" + hasNextPage - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof PageInfo2) { - PageInfo2 that = (PageInfo2) o; - return this.__typename.equals(that.__typename) - && this.hasNextPage == that.hasNextPage; - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= Boolean.valueOf(hasNextPage).hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public PageInfo2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final boolean hasNextPage = reader.readBoolean($responseFields[1]); - return new PageInfo2(__typename, hasNextPage); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/fragment/HeroDetails.kt b/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/fragment/HeroDetails.kt deleted file mode 100644 index c6a06cb6e0e..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/fragment/HeroDetails.kt +++ /dev/null @@ -1,503 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.java_beans_semantic_naming.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class HeroDetails( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The friends of the character exposed as a connection with edges - */ - val friendsConnection: FriendsConnection, - val asDroid: AsDroid? -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HeroDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HeroDetails.name) - writer.writeObject(RESPONSE_FIELDS[2], this@HeroDetails.friendsConnection.marshaller()) - writer.writeFragment(this@HeroDetails.asDroid?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid")) - )) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment HeroDetails on Character { - | __typename - | name - | friendsConnection { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | pageInfo { - | __typename - | hasNextPage - | } - | isEmpty - | } - | ... on Droid { - | name - | primaryFunction - | } - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HeroDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friendsConnection = readObject(RESPONSE_FIELDS[2]) { reader -> - FriendsConnection(reader) - }!! - val asDroid = readFragment(RESPONSE_FIELDS[3]) { reader -> - AsDroid(reader) - } - HeroDetails( - __typename = __typename, - name = name, - friendsConnection = friendsConnection, - asDroid = asDroid - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - /** - * A character from the Star Wars universe - */ - data class Node( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Node.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Node( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An edge object for a character's friends - */ - data class Edge( - val __typename: String = "FriendsEdge", - /** - * The character represented by this friendship edge - */ - val node: Node? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node(reader) - } - Edge( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Information for paginating this connection - */ - data class PageInfo( - val __typename: String = "PageInfo", - val hasNextPage: Boolean - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@PageInfo.__typename) - writer.writeBoolean(RESPONSE_FIELDS[1], this@PageInfo.hasNextPage) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forBoolean("hasNextPage", "hasNextPage", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): PageInfo = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val hasNextPage = readBoolean(RESPONSE_FIELDS[1])!! - PageInfo( - __typename = __typename, - hasNextPage = hasNextPage - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int?, - /** - * The edges for each of the character's friends. - */ - val edges: List?, - /** - * Information for paginating this connection - */ - val pageInfo: PageInfo, - /** - * For test java beans semantic naming only - */ - val isEmpty: Boolean - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection.totalCount) - writer.writeList(RESPONSE_FIELDS[2], this@FriendsConnection.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - writer.writeObject(RESPONSE_FIELDS[3], this@FriendsConnection.pageInfo.marshaller()) - writer.writeBoolean(RESPONSE_FIELDS[4], this@FriendsConnection.isEmpty) - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null), - ResponseField.forList("edges", "edges", null, true, null), - ResponseField.forObject("pageInfo", "pageInfo", null, false, null), - ResponseField.forBoolean("isEmpty", "isEmpty", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - val edges = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Edge(reader) - } - } - val pageInfo = readObject(RESPONSE_FIELDS[3]) { reader -> - PageInfo(reader) - }!! - val isEmpty = readBoolean(RESPONSE_FIELDS[4])!! - FriendsConnection( - __typename = __typename, - totalCount = totalCount, - edges = edges, - pageInfo = pageInfo, - isEmpty = isEmpty - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - interface HeroDetailCharacter { - fun marshaller(): ResponseFieldMarshaller - } - - /** - * A character from the Star Wars universe - */ - data class Node1( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node1.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Node1.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Node1( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An edge object for a character's friends - */ - data class Edge1( - val __typename: String = "FriendsEdge", - /** - * The character represented by this friendship edge - */ - val node: Node1? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge1.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge1.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node1(reader) - } - Edge1( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Information for paginating this connection - */ - data class PageInfo1( - val __typename: String = "PageInfo", - val hasNextPage: Boolean - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@PageInfo1.__typename) - writer.writeBoolean(RESPONSE_FIELDS[1], this@PageInfo1.hasNextPage) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forBoolean("hasNextPage", "hasNextPage", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): PageInfo1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val hasNextPage = readBoolean(RESPONSE_FIELDS[1])!! - PageInfo1( - __typename = __typename, - hasNextPage = hasNextPage - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection1( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int?, - /** - * The edges for each of the character's friends. - */ - val edges: List?, - /** - * Information for paginating this connection - */ - val pageInfo: PageInfo1, - /** - * For test java beans semantic naming only - */ - val isEmpty: Boolean - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection1.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection1.totalCount) - writer.writeList(RESPONSE_FIELDS[2], this@FriendsConnection1.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - writer.writeObject(RESPONSE_FIELDS[3], this@FriendsConnection1.pageInfo.marshaller()) - writer.writeBoolean(RESPONSE_FIELDS[4], this@FriendsConnection1.isEmpty) - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null), - ResponseField.forList("edges", "edges", null, true, null), - ResponseField.forObject("pageInfo", "pageInfo", null, false, null), - ResponseField.forBoolean("isEmpty", "isEmpty", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - val edges = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Edge1(reader) - } - } - val pageInfo = readObject(RESPONSE_FIELDS[3]) { reader -> - PageInfo1(reader) - }!! - val isEmpty = readBoolean(RESPONSE_FIELDS[4])!! - FriendsConnection1( - __typename = __typename, - totalCount = totalCount, - edges = edges, - pageInfo = pageInfo, - isEmpty = isEmpty - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - data class AsDroid( - val __typename: String = "Droid", - /** - * What others call this droid - */ - val name: String, - /** - * The friends of the droid exposed as a connection with edges - */ - val friendsConnection: FriendsConnection1, - /** - * This droid's primary function - */ - val primaryFunction: String? - ) : HeroDetailCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsDroid.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsDroid.name) - writer.writeObject(RESPONSE_FIELDS[2], this@AsDroid.friendsConnection.marshaller()) - writer.writeString(RESPONSE_FIELDS[3], this@AsDroid.primaryFunction) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, null), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): AsDroid = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friendsConnection = readObject(RESPONSE_FIELDS[2]) { reader -> - FriendsConnection1(reader) - }!! - val primaryFunction = readString(RESPONSE_FIELDS[3]) - AsDroid( - __typename = __typename, - name = name, - friendsConnection = friendsConnection, - primaryFunction = primaryFunction - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/type/CustomType.java deleted file mode 100644 index 74d789dd451..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.java_beans_semantic_naming.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/type/CustomType.kt deleted file mode 100644 index 5b15cf16622..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.java_beans_semantic_naming.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/type/Episode.java b/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/type/Episode.java deleted file mode 100644 index 47961197ccf..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/type/Episode.java +++ /dev/null @@ -1,67 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.java_beans_semantic_naming.type; - -import java.lang.Deprecated; -import java.lang.String; - -/** - * The episodes in the Star Wars trilogy - */ -public enum Episode { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - * @deprecated For test purpose only - */ - @Deprecated - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - * @deprecated For test purpose only - */ - @Deprecated - NEW_("new"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Episode(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Episode safeValueOf(String rawValue) { - for (Episode enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Episode.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/type/Episode.kt b/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/type/Episode.kt deleted file mode 100644 index 0c9f71839a5..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/java_beans_semantic_naming/type/Episode.kt +++ /dev/null @@ -1,54 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.java_beans_semantic_naming.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.Deprecated -import kotlin.String - -/** - * The episodes in the Star Wars trilogy - */ -enum class Episode( - override val rawValue: String -) : EnumValue { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - */ - @Deprecated(message = "For test purpose only") - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - */ - @Deprecated(message = "For test purpose only") - NEW("new"), - - /** - * Auto generated constant for unknown enum values - */ - UNKNOWN__("UNKNOWN__"); - - companion object { - fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: - UNKNOWN__ - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/CreateReviewForEpisode.java b/apollo-compiler/src/test/graphql/com/example/mutation_create_review/CreateReviewForEpisode.java deleted file mode 100644 index 570089ca05f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/CreateReviewForEpisode.java +++ /dev/null @@ -1,731 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review; - -import com.apollographql.apollo.api.Mutation; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.mutation_create_review.type.CustomType; -import com.example.mutation_create_review.type.Episode; -import com.example.mutation_create_review.type.ReviewInput; -import java.io.IOException; -import java.lang.Boolean; -import java.lang.Deprecated; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class CreateReviewForEpisode implements Mutation, CreateReviewForEpisode.Variables> { - public static final String OPERATION_ID = "ddb5b88794340f1233d8b0d93bf51320b4e285a912f0914ddbaba8fc430e6db7"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) {\n" - + " createReview(episode: $ep, review: $review) {\n" - + " __typename\n" - + " stars\n" - + " commentary\n" - + " listOfListOfString\n" - + " listOfListOfEnum\n" - + " listOfListOfCustom\n" - + " listOfListOfObject {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " stat_collect\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "CreateReviewForEpisode"; - } - }; - - private final CreateReviewForEpisode.Variables variables; - - public CreateReviewForEpisode(@NotNull Episode ep, @NotNull ReviewInput review) { - Utils.checkNotNull(ep, "ep == null"); - Utils.checkNotNull(review, "review == null"); - variables = new CreateReviewForEpisode.Variables(ep, review); - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(CreateReviewForEpisode.Data data) { - return Optional.fromNullable(data); - } - - @Override - public CreateReviewForEpisode.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) - throws IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) - throws IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - private @NotNull Episode ep; - - private @NotNull ReviewInput review; - - Builder() { - } - - public Builder ep(@NotNull Episode ep) { - this.ep = ep; - return this; - } - - public Builder review(@NotNull ReviewInput review) { - this.review = review; - return this; - } - - public CreateReviewForEpisode build() { - Utils.checkNotNull(ep, "ep == null"); - Utils.checkNotNull(review, "review == null"); - return new CreateReviewForEpisode(ep, review); - } - } - - public static final class Variables extends Operation.Variables { - private final @NotNull Episode ep; - - private final @NotNull ReviewInput review; - - private final transient Map valueMap = new LinkedHashMap<>(); - - Variables(@NotNull Episode ep, @NotNull ReviewInput review) { - this.ep = ep; - this.review = review; - this.valueMap.put("ep", ep); - this.valueMap.put("review", review); - } - - public @NotNull Episode ep() { - return ep; - } - - public @NotNull ReviewInput review() { - return review; - } - - @Override - public Map valueMap() { - return Collections.unmodifiableMap(valueMap); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - writer.writeString("ep", ep.rawValue()); - writer.writeObject("review", review.marshaller()); - } - }; - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("createReview", "createReview", new UnmodifiableMapBuilder(2) - .put("episode", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "ep") - .build()) - .put("review", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "review") - .build()) - .build(), true, Collections.emptyList()), - ResponseField.forList("stat_collect", "stat_collect", null, false, Collections.emptyList()) - }; - - final Optional createReview; - - final @NotNull @Deprecated List stat_collect; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable CreateReview createReview, - @NotNull @Deprecated List stat_collect) { - this.createReview = Optional.fromNullable(createReview); - this.stat_collect = Utils.checkNotNull(stat_collect, "stat_collect == null"); - } - - public Optional createReview() { - return this.createReview; - } - - /** - * For testing https://github.com/apollographql/apollo-android/issues/2660 - * @deprecated Deprecated - */ - public @NotNull @Deprecated List stat_collect() { - return this.stat_collect; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], createReview.isPresent() ? createReview.get().marshaller() : null); - writer.writeList($responseFields[1], stat_collect, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeBoolean((Boolean) item); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "createReview=" + createReview + ", " - + "stat_collect=" + stat_collect - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.createReview.equals(that.createReview) - && this.stat_collect.equals(that.stat_collect); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= createReview.hashCode(); - h *= 1000003; - h ^= stat_collect.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final CreateReview.Mapper createReviewFieldMapper = new CreateReview.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final CreateReview createReview = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public CreateReview read(ResponseReader reader) { - return createReviewFieldMapper.map(reader); - } - }); - final List stat_collect = reader.readList($responseFields[1], new ResponseReader.ListReader() { - @Override - public Boolean read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readBoolean(); - } - }); - return new Data(createReview, stat_collect); - } - } - } - - /** - * Represents a review for a movie - */ - public static class CreateReview { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("stars", "stars", null, false, Collections.emptyList()), - ResponseField.forString("commentary", "commentary", null, true, Collections.emptyList()), - ResponseField.forList("listOfListOfString", "listOfListOfString", null, true, Collections.emptyList()), - ResponseField.forList("listOfListOfEnum", "listOfListOfEnum", null, true, Collections.emptyList()), - ResponseField.forList("listOfListOfCustom", "listOfListOfCustom", null, true, Collections.emptyList()), - ResponseField.forList("listOfListOfObject", "listOfListOfObject", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final int stars; - - final Optional commentary; - - final Optional>> listOfListOfString; - - final Optional>> listOfListOfEnum; - - final Optional>> listOfListOfCustom; - - final Optional>> listOfListOfObject; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public CreateReview(@NotNull String __typename, int stars, @Nullable String commentary, - @Nullable List> listOfListOfString, - @Nullable List> listOfListOfEnum, - @Nullable List> listOfListOfCustom, - @Nullable List> listOfListOfObject) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.stars = stars; - this.commentary = Optional.fromNullable(commentary); - this.listOfListOfString = Optional.fromNullable(listOfListOfString); - this.listOfListOfEnum = Optional.fromNullable(listOfListOfEnum); - this.listOfListOfCustom = Optional.fromNullable(listOfListOfCustom); - this.listOfListOfObject = Optional.fromNullable(listOfListOfObject); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The number of stars this review gave, 1-5 - */ - public int stars() { - return this.stars; - } - - /** - * Comment about the movie - */ - public Optional commentary() { - return this.commentary; - } - - /** - * for test purpose only - */ - public Optional>> listOfListOfString() { - return this.listOfListOfString; - } - - /** - * for test purpose only - */ - public Optional>> listOfListOfEnum() { - return this.listOfListOfEnum; - } - - /** - * for test purpose only - */ - public Optional>> listOfListOfCustom() { - return this.listOfListOfCustom; - } - - /** - * for test purpose only - */ - public Optional>> listOfListOfObject() { - return this.listOfListOfObject; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], stars); - writer.writeString($responseFields[2], commentary.isPresent() ? commentary.get() : null); - writer.writeList($responseFields[3], listOfListOfString.isPresent() ? listOfListOfString.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeList((List) item, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeString((String) item); - } - } - }); - } - } - }); - writer.writeList($responseFields[4], listOfListOfEnum.isPresent() ? listOfListOfEnum.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeList((List) item, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeString(((Episode) item).rawValue()); - } - } - }); - } - } - }); - writer.writeList($responseFields[5], listOfListOfCustom.isPresent() ? listOfListOfCustom.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeList((List) item, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeCustom(CustomType.DATE, item); - } - } - }); - } - } - }); - writer.writeList($responseFields[6], listOfListOfObject.isPresent() ? listOfListOfObject.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeList((List) item, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((ListOfListOfObject) item).marshaller()); - } - } - }); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "CreateReview{" - + "__typename=" + __typename + ", " - + "stars=" + stars + ", " - + "commentary=" + commentary + ", " - + "listOfListOfString=" + listOfListOfString + ", " - + "listOfListOfEnum=" + listOfListOfEnum + ", " - + "listOfListOfCustom=" + listOfListOfCustom + ", " - + "listOfListOfObject=" + listOfListOfObject - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof CreateReview) { - CreateReview that = (CreateReview) o; - return this.__typename.equals(that.__typename) - && this.stars == that.stars - && this.commentary.equals(that.commentary) - && this.listOfListOfString.equals(that.listOfListOfString) - && this.listOfListOfEnum.equals(that.listOfListOfEnum) - && this.listOfListOfCustom.equals(that.listOfListOfCustom) - && this.listOfListOfObject.equals(that.listOfListOfObject); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= stars; - h *= 1000003; - h ^= commentary.hashCode(); - h *= 1000003; - h ^= listOfListOfString.hashCode(); - h *= 1000003; - h ^= listOfListOfEnum.hashCode(); - h *= 1000003; - h ^= listOfListOfCustom.hashCode(); - h *= 1000003; - h ^= listOfListOfObject.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final ListOfListOfObject.Mapper listOfListOfObjectFieldMapper = new ListOfListOfObject.Mapper(); - - @Override - public CreateReview map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final int stars = reader.readInt($responseFields[1]); - final String commentary = reader.readString($responseFields[2]); - final List> listOfListOfString = reader.readList($responseFields[3], new ResponseReader.ListReader>() { - @Override - public List read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readList(new ResponseReader.ListReader() { - @Override - public String read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readString(); - } - }); - } - }); - final List> listOfListOfEnum = reader.readList($responseFields[4], new ResponseReader.ListReader>() { - @Override - public List read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readList(new ResponseReader.ListReader() { - @Override - public Episode read(ResponseReader.ListItemReader listItemReader) { - return Episode.safeValueOf(listItemReader.readString()); - } - }); - } - }); - final List> listOfListOfCustom = reader.readList($responseFields[5], new ResponseReader.ListReader>() { - @Override - public List read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readList(new ResponseReader.ListReader() { - @Override - public Date read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readCustomType(CustomType.DATE); - } - }); - } - }); - final List> listOfListOfObject = reader.readList($responseFields[6], new ResponseReader.ListReader>() { - @Override - public List read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readList(new ResponseReader.ListReader() { - @Override - public ListOfListOfObject read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public ListOfListOfObject read(ResponseReader reader) { - return listOfListOfObjectFieldMapper.map(reader); - } - }); - } - }); - } - }); - return new CreateReview(__typename, stars, commentary, listOfListOfString, listOfListOfEnum, listOfListOfCustom, listOfListOfObject); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class ListOfListOfObject { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public ListOfListOfObject(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "ListOfListOfObject{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof ListOfListOfObject) { - ListOfListOfObject that = (ListOfListOfObject) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public ListOfListOfObject map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new ListOfListOfObject(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/CreateReviewForEpisode.kt b/apollo-compiler/src/test/graphql/com/example/mutation_create_review/CreateReviewForEpisode.kt deleted file mode 100644 index 9970202184c..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/CreateReviewForEpisode.kt +++ /dev/null @@ -1,347 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review - -import com.apollographql.apollo.api.Mutation -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.mutation_create_review.type.CustomType -import com.example.mutation_create_review.type.Episode -import com.example.mutation_create_review.type.ReviewInput -import java.util.Date -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.Deprecated -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlin.collections.Map -import kotlin.jvm.Transient -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -internal data class CreateReviewForEpisode( - val ep: Episode, - val review: ReviewInput -) : Mutation { - @Transient - private val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = mutableMapOf().apply { - this["ep"] = this@CreateReviewForEpisode.ep - this["review"] = this@CreateReviewForEpisode.review - } - - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - writer.writeString("ep", this@CreateReviewForEpisode.ep.rawValue) - writer.writeObject("review", this@CreateReviewForEpisode.review.marshaller()) - } - } - - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = variables - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class ListOfListOfObject( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@ListOfListOfObject.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@ListOfListOfObject.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): ListOfListOfObject = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - ListOfListOfObject( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Represents a review for a movie - */ - data class CreateReview( - val __typename: String = "Review", - /** - * The number of stars this review gave, 1-5 - */ - val stars: Int, - /** - * Comment about the movie - */ - val commentary: String?, - /** - * for test purpose only - */ - val listOfListOfString: List>?, - /** - * for test purpose only - */ - val listOfListOfEnum: List>?, - /** - * for test purpose only - */ - val listOfListOfCustom: List>?, - /** - * for test purpose only - */ - val listOfListOfObject: List>? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@CreateReview.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@CreateReview.stars) - writer.writeString(RESPONSE_FIELDS[2], this@CreateReview.commentary) - writer.writeList(RESPONSE_FIELDS[3], this@CreateReview.listOfListOfString) { value, - listItemWriter -> - value?.forEach { value -> - listItemWriter.writeList(value) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeString(value)} - } - } - } - writer.writeList(RESPONSE_FIELDS[4], this@CreateReview.listOfListOfEnum) { value, - listItemWriter -> - value?.forEach { value -> - listItemWriter.writeList(value) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeString(value.rawValue)} - } - } - } - writer.writeList(RESPONSE_FIELDS[5], this@CreateReview.listOfListOfCustom) { value, - listItemWriter -> - value?.forEach { value -> - listItemWriter.writeList(value) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeCustom(CustomType.DATE, value)} - } - } - } - writer.writeList(RESPONSE_FIELDS[6], this@CreateReview.listOfListOfObject) { value, - listItemWriter -> - value?.forEach { value -> - listItemWriter.writeList(value) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value.marshaller())} - } - } - } - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("stars", "stars", null, false, null), - ResponseField.forString("commentary", "commentary", null, true, null), - ResponseField.forList("listOfListOfString", "listOfListOfString", null, true, null), - ResponseField.forList("listOfListOfEnum", "listOfListOfEnum", null, true, null), - ResponseField.forList("listOfListOfCustom", "listOfListOfCustom", null, true, null), - ResponseField.forList("listOfListOfObject", "listOfListOfObject", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): CreateReview = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val stars = readInt(RESPONSE_FIELDS[1])!! - val commentary = readString(RESPONSE_FIELDS[2]) - val listOfListOfString = readList>(RESPONSE_FIELDS[3]) { reader -> - reader.readList { reader -> - reader.readString() - }.map { it!! } - }?.map { it!! } - val listOfListOfEnum = readList>(RESPONSE_FIELDS[4]) { reader -> - reader.readList { reader -> - Episode.safeValueOf(reader.readString()) - }.map { it!! } - }?.map { it!! } - val listOfListOfCustom = readList>(RESPONSE_FIELDS[5]) { reader -> - reader.readList { reader -> - reader.readCustomType(CustomType.DATE) - }.map { it!! } - }?.map { it!! } - val listOfListOfObject = readList>(RESPONSE_FIELDS[6]) { reader -> - reader.readList { reader -> - reader.readObject { reader -> - ListOfListOfObject(reader) - } - }.map { it!! } - }?.map { it!! } - CreateReview( - __typename = __typename, - stars = stars, - commentary = commentary, - listOfListOfString = listOfListOfString, - listOfListOfEnum = listOfListOfEnum, - listOfListOfCustom = listOfListOfCustom, - listOfListOfObject = listOfListOfObject - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val createReview: CreateReview?, - /** - * For testing https://github.com/apollographql/apollo-android/issues/2660 - */ - @Deprecated(message = "Deprecated") - val stat_collect: List - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.createReview?.marshaller()) - writer.writeList(RESPONSE_FIELDS[1], this@Data.stat_collect) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeBoolean(value)} - } - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("createReview", "createReview", mapOf( - "episode" to mapOf( - "kind" to "Variable", - "variableName" to "ep"), - "review" to mapOf( - "kind" to "Variable", - "variableName" to "review")), true, null), - ResponseField.forList("stat_collect", "stat_collect", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val createReview = readObject(RESPONSE_FIELDS[0]) { reader -> - CreateReview(reader) - } - val stat_collect = readList(RESPONSE_FIELDS[1]) { reader -> - reader.readBoolean() - }!!.map { it!! } - Data( - createReview = createReview, - stat_collect = stat_collect - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "ddb5b88794340f1233d8b0d93bf51320b4e285a912f0914ddbaba8fc430e6db7" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |mutation CreateReviewForEpisode(${'$'}ep: Episode!, ${'$'}review: ReviewInput!) { - | createReview(episode: ${'$'}ep, review: ${'$'}review) { - | __typename - | stars - | commentary - | listOfListOfString - | listOfListOfEnum - | listOfListOfCustom - | listOfListOfObject { - | __typename - | name - | } - | } - | stat_collect - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "CreateReviewForEpisode" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/mutation_create_review/TestOperation.graphql deleted file mode 100644 index cc23504e845..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/TestOperation.graphql +++ /dev/null @@ -1,13 +0,0 @@ -mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) { - createReview(episode: $ep, review: $review) { - stars - commentary - listOfListOfString, - listOfListOfEnum, - listOfListOfCustom, - listOfListOfObject { - name - } - } - stat_collect -} \ No newline at end of file diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ColorInput.java b/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ColorInput.java deleted file mode 100644 index 3064b328aec..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ColorInput.java +++ /dev/null @@ -1,221 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review.type; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.InputType; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class ColorInput implements InputType { - private final int red; - - private final Input green; - - private final double blue; - - private final Input enumWithDefaultValue; - - private final Input reviewRefInput; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - ColorInput(int red, Input green, double blue, Input enumWithDefaultValue, - Input reviewRefInput) { - this.red = red; - this.green = green; - this.blue = blue; - this.enumWithDefaultValue = enumWithDefaultValue; - this.reviewRefInput = reviewRefInput; - } - - /** - * Red color - */ - public int red() { - return this.red; - } - - /** - * Green color - */ - public @Nullable Double green() { - return this.green.value; - } - - /** - * Blue color - */ - public double blue() { - return this.blue; - } - - /** - * for test purpose only - */ - public @Nullable Episode enumWithDefaultValue() { - return this.enumWithDefaultValue.value; - } - - /** - * Circle ref to review input - */ - public @Nullable ReviewRefInput reviewRefInput() { - return this.reviewRefInput.value; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - writer.writeInt("red", red); - if (green.defined) { - writer.writeDouble("green", green.value); - } - writer.writeDouble("blue", blue); - if (enumWithDefaultValue.defined) { - writer.writeString("enumWithDefaultValue", enumWithDefaultValue.value != null ? enumWithDefaultValue.value.rawValue() : null); - } - if (reviewRefInput.defined) { - writer.writeObject("reviewRefInput", reviewRefInput.value != null ? reviewRefInput.value.marshaller() : null); - } - } - }; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= red; - h *= 1000003; - h ^= green.hashCode(); - h *= 1000003; - h ^= Double.valueOf(blue).hashCode(); - h *= 1000003; - h ^= enumWithDefaultValue.hashCode(); - h *= 1000003; - h ^= reviewRefInput.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof ColorInput) { - ColorInput that = (ColorInput) o; - return this.red == that.red - && this.green.equals(that.green) - && Double.doubleToLongBits(this.blue) == Double.doubleToLongBits(that.blue) - && this.enumWithDefaultValue.equals(that.enumWithDefaultValue) - && this.reviewRefInput.equals(that.reviewRefInput); - } - return false; - } - - public static final class Builder { - private int red = 1; - - private Input green = Input.fromNullable(0.0); - - private double blue = 1.5; - - private Input enumWithDefaultValue = Input.fromNullable(Episode.safeValueOf("new")); - - private Input reviewRefInput = Input.absent(); - - Builder() { - } - - /** - * Red color - */ - public Builder red(int red) { - this.red = red; - return this; - } - - /** - * Green color - */ - public Builder green(@Nullable Double green) { - this.green = Input.fromNullable(green); - return this; - } - - /** - * Blue color - */ - public Builder blue(double blue) { - this.blue = blue; - return this; - } - - /** - * for test purpose only - */ - public Builder enumWithDefaultValue(@Nullable Episode enumWithDefaultValue) { - this.enumWithDefaultValue = Input.fromNullable(enumWithDefaultValue); - return this; - } - - /** - * Circle ref to review input - */ - public Builder reviewRefInput(@Nullable ReviewRefInput reviewRefInput) { - this.reviewRefInput = Input.fromNullable(reviewRefInput); - return this; - } - - /** - * Green color - */ - public Builder greenInput(@NotNull Input green) { - this.green = Utils.checkNotNull(green, "green == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder enumWithDefaultValueInput(@NotNull Input enumWithDefaultValue) { - this.enumWithDefaultValue = Utils.checkNotNull(enumWithDefaultValue, "enumWithDefaultValue == null"); - return this; - } - - /** - * Circle ref to review input - */ - public Builder reviewRefInputInput(@NotNull Input reviewRefInput) { - this.reviewRefInput = Utils.checkNotNull(reviewRefInput, "reviewRefInput == null"); - return this; - } - - public ColorInput build() { - return new ColorInput(red, green, blue, enumWithDefaultValue, reviewRefInput); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ColorInput.kt b/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ColorInput.kt deleted file mode 100644 index b503d38f797..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ColorInput.kt +++ /dev/null @@ -1,56 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review.type - -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.InputType -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import kotlin.Double -import kotlin.Int -import kotlin.Suppress - -/** - * The input object sent when passing in a color - */ -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -internal data class ColorInput( - /** - * Red color - */ - val red: Int = 1, - /** - * Green color - */ - val green: Input = Input.optional(0.0), - /** - * Blue color - */ - val blue: Double = 1.5, - /** - * for test purpose only - */ - val enumWithDefaultValue: Input = Input.optional(Episode.safeValueOf("new")), - /** - * Circle ref to review input - */ - val reviewRefInput: Input = Input.absent() -) : InputType { - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - writer.writeInt("red", this@ColorInput.red) - if (this@ColorInput.green.defined) { - writer.writeDouble("green", this@ColorInput.green.value) - } - writer.writeDouble("blue", this@ColorInput.blue) - if (this@ColorInput.enumWithDefaultValue.defined) { - writer.writeString("enumWithDefaultValue", - this@ColorInput.enumWithDefaultValue.value?.rawValue) - } - if (this@ColorInput.reviewRefInput.defined) { - writer.writeObject("reviewRefInput", this@ColorInput.reviewRefInput.value?.marshaller()) - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/CustomType.java deleted file mode 100644 index bdd88ff501d..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/CustomType.java +++ /dev/null @@ -1,36 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - DATE { - @Override - public String typeName() { - return "Date"; - } - - @Override - public String className() { - return "java.util.Date"; - } - }, - - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.Integer"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/CustomType.kt deleted file mode 100644 index 0d48a9ec2d2..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/CustomType.kt +++ /dev/null @@ -1,23 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -internal enum class CustomType : ScalarType { - DATE { - override fun typeName(): String = "Date" - - override fun className(): String = "java.util.Date" - }, - - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.Int" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/Episode.java b/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/Episode.java deleted file mode 100644 index 456d5d5daa4..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/Episode.java +++ /dev/null @@ -1,67 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review.type; - -import java.lang.Deprecated; -import java.lang.String; - -/** - * The episodes in the Star Wars trilogy - */ -public enum Episode { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - * @deprecated For test purpose only - */ - @Deprecated - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - * @deprecated For test purpose only - */ - @Deprecated - NEW_("new"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Episode(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Episode safeValueOf(String rawValue) { - for (Episode enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Episode.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/Episode.kt b/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/Episode.kt deleted file mode 100644 index c9b5ad6da8c..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/Episode.kt +++ /dev/null @@ -1,54 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.Deprecated -import kotlin.String - -/** - * The episodes in the Star Wars trilogy - */ -internal enum class Episode( - override val rawValue: String -) : EnumValue { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - */ - @Deprecated(message = "For test purpose only") - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - */ - @Deprecated(message = "For test purpose only") - NEW("new"), - - /** - * Auto generated constant for unknown enum values - */ - UNKNOWN__("UNKNOWN__"); - - companion object { - fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: - UNKNOWN__ - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ReviewInput.java b/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ReviewInput.java deleted file mode 100644 index 8607f080bb8..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ReviewInput.java +++ /dev/null @@ -1,898 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review.type; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.InputType; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Boolean; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class ReviewInput implements InputType { - private final int stars; - - private final Input nullableIntFieldWithDefaultValue; - - private final Input commentary; - - private final @NotNull ColorInput favoriteColor; - - private final Input enumWithDefaultValue; - - private final @NotNull Episode nonNullableEnumWithDefaultValue; - - private final Input nullableEnum; - - private final Input> listOfCustomScalar; - - private final Input customScalar; - - private final Input> listOfEnums; - - private final Input> listOfInt; - - private final Input> listOfString; - - private final @NotNull List listOfStringNonOptional; - - private final Input> listOfInputTypes; - - private final Input booleanWithDefaultValue; - - private final Input booleanNonOptional; - - private final Input>> listOfListOfString; - - private final Input>> listOfListOfEnum; - - private final Input>> listOfListOfCustom; - - private final Input>> listOfListOfObject; - - private final Input capitalizedField; - - private final Input capitalizedInt; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - ReviewInput(int stars, Input nullableIntFieldWithDefaultValue, Input commentary, - @NotNull ColorInput favoriteColor, Input enumWithDefaultValue, - @NotNull Episode nonNullableEnumWithDefaultValue, Input nullableEnum, - Input> listOfCustomScalar, Input customScalar, - Input> listOfEnums, Input> listOfInt, - Input> listOfString, @NotNull List listOfStringNonOptional, - Input> listOfInputTypes, Input booleanWithDefaultValue, - Input booleanNonOptional, Input>> listOfListOfString, - Input>> listOfListOfEnum, Input>> listOfListOfCustom, - Input>> listOfListOfObject, Input capitalizedField, - Input capitalizedInt) { - this.stars = stars; - this.nullableIntFieldWithDefaultValue = nullableIntFieldWithDefaultValue; - this.commentary = commentary; - this.favoriteColor = favoriteColor; - this.enumWithDefaultValue = enumWithDefaultValue; - this.nonNullableEnumWithDefaultValue = nonNullableEnumWithDefaultValue; - this.nullableEnum = nullableEnum; - this.listOfCustomScalar = listOfCustomScalar; - this.customScalar = customScalar; - this.listOfEnums = listOfEnums; - this.listOfInt = listOfInt; - this.listOfString = listOfString; - this.listOfStringNonOptional = listOfStringNonOptional; - this.listOfInputTypes = listOfInputTypes; - this.booleanWithDefaultValue = booleanWithDefaultValue; - this.booleanNonOptional = booleanNonOptional; - this.listOfListOfString = listOfListOfString; - this.listOfListOfEnum = listOfListOfEnum; - this.listOfListOfCustom = listOfListOfCustom; - this.listOfListOfObject = listOfListOfObject; - this.capitalizedField = capitalizedField; - this.capitalizedInt = capitalizedInt; - } - - /** - * 0-5 stars - */ - public int stars() { - return this.stars; - } - - /** - * for test purpose only - */ - public @Nullable Integer nullableIntFieldWithDefaultValue() { - return this.nullableIntFieldWithDefaultValue.value; - } - - /** - * Comment about the movie, optional - */ - public @Nullable String commentary() { - return this.commentary.value; - } - - /** - * Favorite color, optional - */ - public @NotNull ColorInput favoriteColor() { - return this.favoriteColor; - } - - /** - * for test purpose only - */ - public @Nullable Episode enumWithDefaultValue() { - return this.enumWithDefaultValue.value; - } - - /** - * for test purpose only - */ - public @NotNull Episode nonNullableEnumWithDefaultValue() { - return this.nonNullableEnumWithDefaultValue; - } - - /** - * for test purpose only - */ - public @Nullable Episode nullableEnum() { - return this.nullableEnum.value; - } - - /** - * for test purpose only - */ - public @Nullable List listOfCustomScalar() { - return this.listOfCustomScalar.value; - } - - /** - * for test purpose only - */ - public @Nullable Date customScalar() { - return this.customScalar.value; - } - - /** - * for test purpose only - */ - public @Nullable List listOfEnums() { - return this.listOfEnums.value; - } - - /** - * for test purpose only - */ - public @Nullable List listOfInt() { - return this.listOfInt.value; - } - - /** - * for test purpose only - */ - public @Nullable List listOfString() { - return this.listOfString.value; - } - - /** - * for test purpose only - */ - public @NotNull List listOfStringNonOptional() { - return this.listOfStringNonOptional; - } - - /** - * for test purpose only - */ - public @Nullable List listOfInputTypes() { - return this.listOfInputTypes.value; - } - - /** - * for test purpose only - */ - public @Nullable Boolean booleanWithDefaultValue() { - return this.booleanWithDefaultValue.value; - } - - /** - * for test purpose only - */ - public @Nullable Boolean booleanNonOptional() { - return this.booleanNonOptional.value; - } - - /** - * for test purpose only - */ - public @Nullable List> listOfListOfString() { - return this.listOfListOfString.value; - } - - /** - * for test purpose only - */ - public @Nullable List> listOfListOfEnum() { - return this.listOfListOfEnum.value; - } - - /** - * for test purpose only - */ - public @Nullable List> listOfListOfCustom() { - return this.listOfListOfCustom.value; - } - - /** - * for test purpose only - */ - public @Nullable List> listOfListOfObject() { - return this.listOfListOfObject.value; - } - - /** - * for test purpose only - */ - public @Nullable String capitalizedField() { - return this.capitalizedField.value; - } - - /** - * for test purpose only - */ - public @Nullable Integer capitalizedInt() { - return this.capitalizedInt.value; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - writer.writeInt("stars", stars); - if (nullableIntFieldWithDefaultValue.defined) { - writer.writeInt("nullableIntFieldWithDefaultValue", nullableIntFieldWithDefaultValue.value); - } - if (commentary.defined) { - writer.writeString("commentary", commentary.value); - } - writer.writeObject("favoriteColor", favoriteColor.marshaller()); - if (enumWithDefaultValue.defined) { - writer.writeString("enumWithDefaultValue", enumWithDefaultValue.value != null ? enumWithDefaultValue.value.rawValue() : null); - } - writer.writeString("nonNullableEnumWithDefaultValue", nonNullableEnumWithDefaultValue.rawValue()); - if (nullableEnum.defined) { - writer.writeString("nullableEnum", nullableEnum.value != null ? nullableEnum.value.rawValue() : null); - } - if (listOfCustomScalar.defined) { - writer.writeList("listOfCustomScalar", listOfCustomScalar.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final Date $item : listOfCustomScalar.value) { - listItemWriter.writeCustom(CustomType.DATE, $item); - } - } - } : null); - } - if (customScalar.defined) { - writer.writeCustom("customScalar", com.example.mutation_create_review.type.CustomType.DATE, customScalar.value != null ? customScalar.value : null); - } - if (listOfEnums.defined) { - writer.writeList("listOfEnums", listOfEnums.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final Episode $item : listOfEnums.value) { - listItemWriter.writeString($item != null ? $item.rawValue() : null); - } - } - } : null); - } - if (listOfInt.defined) { - writer.writeList("listOfInt", listOfInt.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final Integer $item : listOfInt.value) { - listItemWriter.writeInt($item); - } - } - } : null); - } - if (listOfString.defined) { - writer.writeList("listOfString", listOfString.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final String $item : listOfString.value) { - listItemWriter.writeString($item); - } - } - } : null); - } - writer.writeList("listOfStringNonOptional", new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final String $item : listOfStringNonOptional) { - listItemWriter.writeString($item); - } - } - }); - if (listOfInputTypes.defined) { - writer.writeList("listOfInputTypes", listOfInputTypes.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final ColorInput $item : listOfInputTypes.value) { - listItemWriter.writeObject($item != null ? $item.marshaller() : null); - } - } - } : null); - } - if (booleanWithDefaultValue.defined) { - writer.writeBoolean("booleanWithDefaultValue", booleanWithDefaultValue.value); - } - if (booleanNonOptional.defined) { - writer.writeBoolean("booleanNonOptional", booleanNonOptional.value); - } - if (listOfListOfString.defined) { - writer.writeList("listOfListOfString", listOfListOfString.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final List $item : listOfListOfString.value) { - listItemWriter.writeList($item != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws - IOException { - for (final String $$item : $item) { - listItemWriter.writeString($$item); - } - } - } : null); - } - } - } : null); - } - if (listOfListOfEnum.defined) { - writer.writeList("listOfListOfEnum", listOfListOfEnum.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final List $item : listOfListOfEnum.value) { - listItemWriter.writeList($item != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws - IOException { - for (final Episode $$item : $item) { - listItemWriter.writeString($$item != null ? $$item.rawValue() : null); - } - } - } : null); - } - } - } : null); - } - if (listOfListOfCustom.defined) { - writer.writeList("listOfListOfCustom", listOfListOfCustom.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final List $item : listOfListOfCustom.value) { - listItemWriter.writeList($item != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws - IOException { - for (final Date $$item : $item) { - listItemWriter.writeCustom(CustomType.DATE, $$item); - } - } - } : null); - } - } - } : null); - } - if (listOfListOfObject.defined) { - writer.writeList("listOfListOfObject", listOfListOfObject.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final List $item : listOfListOfObject.value) { - listItemWriter.writeList($item != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws - IOException { - for (final ColorInput $$item : $item) { - listItemWriter.writeObject($$item != null ? $$item.marshaller() : null); - } - } - } : null); - } - } - } : null); - } - if (capitalizedField.defined) { - writer.writeString("CapitalizedField", capitalizedField.value); - } - if (capitalizedInt.defined) { - writer.writeInt("CapitalizedInt", capitalizedInt.value); - } - } - }; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= stars; - h *= 1000003; - h ^= nullableIntFieldWithDefaultValue.hashCode(); - h *= 1000003; - h ^= commentary.hashCode(); - h *= 1000003; - h ^= favoriteColor.hashCode(); - h *= 1000003; - h ^= enumWithDefaultValue.hashCode(); - h *= 1000003; - h ^= nonNullableEnumWithDefaultValue.hashCode(); - h *= 1000003; - h ^= nullableEnum.hashCode(); - h *= 1000003; - h ^= listOfCustomScalar.hashCode(); - h *= 1000003; - h ^= customScalar.hashCode(); - h *= 1000003; - h ^= listOfEnums.hashCode(); - h *= 1000003; - h ^= listOfInt.hashCode(); - h *= 1000003; - h ^= listOfString.hashCode(); - h *= 1000003; - h ^= listOfStringNonOptional.hashCode(); - h *= 1000003; - h ^= listOfInputTypes.hashCode(); - h *= 1000003; - h ^= booleanWithDefaultValue.hashCode(); - h *= 1000003; - h ^= booleanNonOptional.hashCode(); - h *= 1000003; - h ^= listOfListOfString.hashCode(); - h *= 1000003; - h ^= listOfListOfEnum.hashCode(); - h *= 1000003; - h ^= listOfListOfCustom.hashCode(); - h *= 1000003; - h ^= listOfListOfObject.hashCode(); - h *= 1000003; - h ^= capitalizedField.hashCode(); - h *= 1000003; - h ^= capitalizedInt.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof ReviewInput) { - ReviewInput that = (ReviewInput) o; - return this.stars == that.stars - && this.nullableIntFieldWithDefaultValue.equals(that.nullableIntFieldWithDefaultValue) - && this.commentary.equals(that.commentary) - && this.favoriteColor.equals(that.favoriteColor) - && this.enumWithDefaultValue.equals(that.enumWithDefaultValue) - && this.nonNullableEnumWithDefaultValue.equals(that.nonNullableEnumWithDefaultValue) - && this.nullableEnum.equals(that.nullableEnum) - && this.listOfCustomScalar.equals(that.listOfCustomScalar) - && this.customScalar.equals(that.customScalar) - && this.listOfEnums.equals(that.listOfEnums) - && this.listOfInt.equals(that.listOfInt) - && this.listOfString.equals(that.listOfString) - && this.listOfStringNonOptional.equals(that.listOfStringNonOptional) - && this.listOfInputTypes.equals(that.listOfInputTypes) - && this.booleanWithDefaultValue.equals(that.booleanWithDefaultValue) - && this.booleanNonOptional.equals(that.booleanNonOptional) - && this.listOfListOfString.equals(that.listOfListOfString) - && this.listOfListOfEnum.equals(that.listOfListOfEnum) - && this.listOfListOfCustom.equals(that.listOfListOfCustom) - && this.listOfListOfObject.equals(that.listOfListOfObject) - && this.capitalizedField.equals(that.capitalizedField) - && this.capitalizedInt.equals(that.capitalizedInt); - } - return false; - } - - public static final class Builder { - private int stars; - - private Input nullableIntFieldWithDefaultValue = Input.fromNullable(10); - - private Input commentary = Input.absent(); - - private @NotNull ColorInput favoriteColor; - - private Input enumWithDefaultValue = Input.fromNullable(Episode.safeValueOf("JEDI")); - - private @NotNull Episode nonNullableEnumWithDefaultValue = Episode.safeValueOf("JEDI"); - - private Input nullableEnum = Input.absent(); - - private Input> listOfCustomScalar = Input.absent(); - - private Input customScalar = Input.absent(); - - private Input> listOfEnums = Input.fromNullable(Arrays.asList(Episode.safeValueOf("NEWHOPE"), Episode.safeValueOf("EMPIRE"))); - - private Input> listOfInt = Input.fromNullable(Arrays.asList(1, 2, 3)); - - private Input> listOfString = Input.fromNullable(Arrays.asList("test1", "test2", "test3")); - - private @NotNull List listOfStringNonOptional; - - private Input> listOfInputTypes = Input.fromNullable(Arrays.asList()); - - private Input booleanWithDefaultValue = Input.fromNullable(true); - - private Input booleanNonOptional = Input.absent(); - - private Input>> listOfListOfString = Input.absent(); - - private Input>> listOfListOfEnum = Input.absent(); - - private Input>> listOfListOfCustom = Input.absent(); - - private Input>> listOfListOfObject = Input.absent(); - - private Input capitalizedField = Input.absent(); - - private Input capitalizedInt = Input.absent(); - - Builder() { - } - - /** - * 0-5 stars - */ - public Builder stars(int stars) { - this.stars = stars; - return this; - } - - /** - * for test purpose only - */ - public Builder nullableIntFieldWithDefaultValue(@Nullable Integer nullableIntFieldWithDefaultValue) { - this.nullableIntFieldWithDefaultValue = Input.fromNullable(nullableIntFieldWithDefaultValue); - return this; - } - - /** - * Comment about the movie, optional - */ - public Builder commentary(@Nullable String commentary) { - this.commentary = Input.fromNullable(commentary); - return this; - } - - /** - * Favorite color, optional - */ - public Builder favoriteColor(@NotNull ColorInput favoriteColor) { - this.favoriteColor = favoriteColor; - return this; - } - - /** - * for test purpose only - */ - public Builder enumWithDefaultValue(@Nullable Episode enumWithDefaultValue) { - this.enumWithDefaultValue = Input.fromNullable(enumWithDefaultValue); - return this; - } - - /** - * for test purpose only - */ - public Builder nonNullableEnumWithDefaultValue(@NotNull Episode nonNullableEnumWithDefaultValue) { - this.nonNullableEnumWithDefaultValue = nonNullableEnumWithDefaultValue; - return this; - } - - /** - * for test purpose only - */ - public Builder nullableEnum(@Nullable Episode nullableEnum) { - this.nullableEnum = Input.fromNullable(nullableEnum); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfCustomScalar(@Nullable List listOfCustomScalar) { - this.listOfCustomScalar = Input.fromNullable(listOfCustomScalar); - return this; - } - - /** - * for test purpose only - */ - public Builder customScalar(@Nullable Date customScalar) { - this.customScalar = Input.fromNullable(customScalar); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfEnums(@Nullable List listOfEnums) { - this.listOfEnums = Input.fromNullable(listOfEnums); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfInt(@Nullable List listOfInt) { - this.listOfInt = Input.fromNullable(listOfInt); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfString(@Nullable List listOfString) { - this.listOfString = Input.fromNullable(listOfString); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfStringNonOptional(@NotNull List listOfStringNonOptional) { - this.listOfStringNonOptional = listOfStringNonOptional; - return this; - } - - /** - * for test purpose only - */ - public Builder listOfInputTypes(@Nullable List listOfInputTypes) { - this.listOfInputTypes = Input.fromNullable(listOfInputTypes); - return this; - } - - /** - * for test purpose only - */ - public Builder booleanWithDefaultValue(@Nullable Boolean booleanWithDefaultValue) { - this.booleanWithDefaultValue = Input.fromNullable(booleanWithDefaultValue); - return this; - } - - /** - * for test purpose only - */ - public Builder booleanNonOptional(@Nullable Boolean booleanNonOptional) { - this.booleanNonOptional = Input.fromNullable(booleanNonOptional); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfString(@Nullable List> listOfListOfString) { - this.listOfListOfString = Input.fromNullable(listOfListOfString); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfEnum(@Nullable List> listOfListOfEnum) { - this.listOfListOfEnum = Input.fromNullable(listOfListOfEnum); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfCustom(@Nullable List> listOfListOfCustom) { - this.listOfListOfCustom = Input.fromNullable(listOfListOfCustom); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfObject(@Nullable List> listOfListOfObject) { - this.listOfListOfObject = Input.fromNullable(listOfListOfObject); - return this; - } - - /** - * for test purpose only - */ - public Builder capitalizedField(@Nullable String capitalizedField) { - this.capitalizedField = Input.fromNullable(capitalizedField); - return this; - } - - /** - * for test purpose only - */ - public Builder capitalizedInt(@Nullable Integer capitalizedInt) { - this.capitalizedInt = Input.fromNullable(capitalizedInt); - return this; - } - - /** - * for test purpose only - */ - public Builder nullableIntFieldWithDefaultValueInput(@NotNull Input nullableIntFieldWithDefaultValue) { - this.nullableIntFieldWithDefaultValue = Utils.checkNotNull(nullableIntFieldWithDefaultValue, "nullableIntFieldWithDefaultValue == null"); - return this; - } - - /** - * Comment about the movie, optional - */ - public Builder commentaryInput(@NotNull Input commentary) { - this.commentary = Utils.checkNotNull(commentary, "commentary == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder enumWithDefaultValueInput(@NotNull Input enumWithDefaultValue) { - this.enumWithDefaultValue = Utils.checkNotNull(enumWithDefaultValue, "enumWithDefaultValue == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder nullableEnumInput(@NotNull Input nullableEnum) { - this.nullableEnum = Utils.checkNotNull(nullableEnum, "nullableEnum == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfCustomScalarInput(@NotNull Input> listOfCustomScalar) { - this.listOfCustomScalar = Utils.checkNotNull(listOfCustomScalar, "listOfCustomScalar == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder customScalarInput(@NotNull Input customScalar) { - this.customScalar = Utils.checkNotNull(customScalar, "customScalar == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfEnumsInput(@NotNull Input> listOfEnums) { - this.listOfEnums = Utils.checkNotNull(listOfEnums, "listOfEnums == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfIntInput(@NotNull Input> listOfInt) { - this.listOfInt = Utils.checkNotNull(listOfInt, "listOfInt == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfStringInput(@NotNull Input> listOfString) { - this.listOfString = Utils.checkNotNull(listOfString, "listOfString == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfInputTypesInput(@NotNull Input> listOfInputTypes) { - this.listOfInputTypes = Utils.checkNotNull(listOfInputTypes, "listOfInputTypes == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder booleanWithDefaultValueInput(@NotNull Input booleanWithDefaultValue) { - this.booleanWithDefaultValue = Utils.checkNotNull(booleanWithDefaultValue, "booleanWithDefaultValue == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder booleanNonOptionalInput(@NotNull Input booleanNonOptional) { - this.booleanNonOptional = Utils.checkNotNull(booleanNonOptional, "booleanNonOptional == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfStringInput(@NotNull Input>> listOfListOfString) { - this.listOfListOfString = Utils.checkNotNull(listOfListOfString, "listOfListOfString == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfEnumInput(@NotNull Input>> listOfListOfEnum) { - this.listOfListOfEnum = Utils.checkNotNull(listOfListOfEnum, "listOfListOfEnum == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfCustomInput(@NotNull Input>> listOfListOfCustom) { - this.listOfListOfCustom = Utils.checkNotNull(listOfListOfCustom, "listOfListOfCustom == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfObjectInput(@NotNull Input>> listOfListOfObject) { - this.listOfListOfObject = Utils.checkNotNull(listOfListOfObject, "listOfListOfObject == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder capitalizedFieldInput(@NotNull Input capitalizedField) { - this.capitalizedField = Utils.checkNotNull(capitalizedField, "capitalizedField == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder capitalizedIntInput(@NotNull Input capitalizedInt) { - this.capitalizedInt = Utils.checkNotNull(capitalizedInt, "capitalizedInt == null"); - return this; - } - - public ReviewInput build() { - Utils.checkNotNull(favoriteColor, "favoriteColor == null"); - Utils.checkNotNull(nonNullableEnumWithDefaultValue, "nonNullableEnumWithDefaultValue == null"); - Utils.checkNotNull(listOfStringNonOptional, "listOfStringNonOptional == null"); - return new ReviewInput(stars, nullableIntFieldWithDefaultValue, commentary, favoriteColor, enumWithDefaultValue, nonNullableEnumWithDefaultValue, nullableEnum, listOfCustomScalar, customScalar, listOfEnums, listOfInt, listOfString, listOfStringNonOptional, listOfInputTypes, booleanWithDefaultValue, booleanNonOptional, listOfListOfString, listOfListOfEnum, listOfListOfCustom, listOfListOfObject, capitalizedField, capitalizedInt); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ReviewInput.kt b/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ReviewInput.kt deleted file mode 100644 index a345be06333..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ReviewInput.kt +++ /dev/null @@ -1,256 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review.type - -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.InputType -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.InputFieldWriter -import java.util.Date -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List - -/** - * The input object sent when someone is creating a new review - */ -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -internal data class ReviewInput( - /** - * 0-5 stars - */ - val stars: Int, - /** - * for test purpose only - */ - val nullableIntFieldWithDefaultValue: Input = Input.optional(10), - /** - * Comment about the movie, optional - */ - val commentary: Input = Input.absent(), - /** - * Favorite color, optional - */ - val favoriteColor: ColorInput, - /** - * for test purpose only - */ - val enumWithDefaultValue: Input = Input.optional(Episode.safeValueOf("JEDI")), - /** - * for test purpose only - */ - val nonNullableEnumWithDefaultValue: Episode = Episode.safeValueOf("JEDI"), - /** - * for test purpose only - */ - val nullableEnum: Input = Input.absent(), - /** - * for test purpose only - */ - val listOfCustomScalar: Input> = Input.absent(), - /** - * for test purpose only - */ - val customScalar: Input = Input.absent(), - /** - * for test purpose only - */ - val listOfEnums: Input> = Input.optional(listOf(Episode.safeValueOf("NEWHOPE"), - Episode.safeValueOf("EMPIRE"))), - /** - * for test purpose only - */ - val listOfInt: Input> = Input.optional(listOf(1, 2, 3)), - /** - * for test purpose only - */ - val listOfString: Input> = Input.optional(listOf("test1", "test2", "test3")), - /** - * for test purpose only - */ - val listOfStringNonOptional: List, - /** - * for test purpose only - */ - val listOfInputTypes: Input> = Input.optional(emptyList()), - /** - * for test purpose only - */ - val booleanWithDefaultValue: Input = Input.optional(true), - /** - * for test purpose only - */ - val booleanNonOptional: Input = Input.absent(), - /** - * for test purpose only - */ - val listOfListOfString: Input>> = Input.absent(), - /** - * for test purpose only - */ - val listOfListOfEnum: Input>> = Input.absent(), - /** - * for test purpose only - */ - val listOfListOfCustom: Input>> = Input.absent(), - /** - * for test purpose only - */ - val listOfListOfObject: Input>> = Input.absent(), - /** - * for test purpose only - */ - val capitalizedField: Input = Input.absent(), - /** - * for test purpose only - */ - val capitalizedInt: Input = Input.absent() -) : InputType { - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - writer.writeInt("stars", this@ReviewInput.stars) - if (this@ReviewInput.nullableIntFieldWithDefaultValue.defined) { - writer.writeInt("nullableIntFieldWithDefaultValue", - this@ReviewInput.nullableIntFieldWithDefaultValue.value) - } - if (this@ReviewInput.commentary.defined) { - writer.writeString("commentary", this@ReviewInput.commentary.value) - } - writer.writeObject("favoriteColor", this@ReviewInput.favoriteColor.marshaller()) - if (this@ReviewInput.enumWithDefaultValue.defined) { - writer.writeString("enumWithDefaultValue", - this@ReviewInput.enumWithDefaultValue.value?.rawValue) - } - writer.writeString("nonNullableEnumWithDefaultValue", - this@ReviewInput.nonNullableEnumWithDefaultValue.rawValue) - if (this@ReviewInput.nullableEnum.defined) { - writer.writeString("nullableEnum", this@ReviewInput.nullableEnum.value?.rawValue) - } - if (this@ReviewInput.listOfCustomScalar.defined) { - writer.writeList("listOfCustomScalar", this@ReviewInput.listOfCustomScalar.value?.let { - value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeCustom(CustomType.DATE, value) - } - } - }) - } - if (this@ReviewInput.customScalar.defined) { - writer.writeCustom("customScalar", CustomType.DATE, this@ReviewInput.customScalar.value) - } - if (this@ReviewInput.listOfEnums.defined) { - writer.writeList("listOfEnums", this@ReviewInput.listOfEnums.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeString(value?.rawValue) - } - } - }) - } - if (this@ReviewInput.listOfInt.defined) { - writer.writeList("listOfInt", this@ReviewInput.listOfInt.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeInt(value) - } - } - }) - } - if (this@ReviewInput.listOfString.defined) { - writer.writeList("listOfString", this@ReviewInput.listOfString.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeString(value) - } - } - }) - } - writer.writeList("listOfStringNonOptional") { listItemWriter -> - this@ReviewInput.listOfStringNonOptional.forEach { value -> - listItemWriter.writeString(value) - } - } - if (this@ReviewInput.listOfInputTypes.defined) { - writer.writeList("listOfInputTypes", this@ReviewInput.listOfInputTypes.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeObject(value?.marshaller()) - } - } - }) - } - if (this@ReviewInput.booleanWithDefaultValue.defined) { - writer.writeBoolean("booleanWithDefaultValue", this@ReviewInput.booleanWithDefaultValue.value) - } - if (this@ReviewInput.booleanNonOptional.defined) { - writer.writeBoolean("booleanNonOptional", this@ReviewInput.booleanNonOptional.value) - } - if (this@ReviewInput.listOfListOfString.defined) { - writer.writeList("listOfListOfString", this@ReviewInput.listOfListOfString.value?.let { - value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeList { listItemWriter -> - value.forEach { value -> - listItemWriter.writeString(value) - } - } - } - } - }) - } - if (this@ReviewInput.listOfListOfEnum.defined) { - writer.writeList("listOfListOfEnum", this@ReviewInput.listOfListOfEnum.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeList { listItemWriter -> - value.forEach { value -> - listItemWriter.writeString(value.rawValue) - } - } - } - } - }) - } - if (this@ReviewInput.listOfListOfCustom.defined) { - writer.writeList("listOfListOfCustom", this@ReviewInput.listOfListOfCustom.value?.let { - value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeList { listItemWriter -> - value.forEach { value -> - listItemWriter.writeCustom(CustomType.DATE, value) - } - } - } - } - }) - } - if (this@ReviewInput.listOfListOfObject.defined) { - writer.writeList("listOfListOfObject", this@ReviewInput.listOfListOfObject.value?.let { - value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeList { listItemWriter -> - value.forEach { value -> - listItemWriter.writeObject(value.marshaller()) - } - } - } - } - }) - } - if (this@ReviewInput.capitalizedField.defined) { - writer.writeString("CapitalizedField", this@ReviewInput.capitalizedField.value) - } - if (this@ReviewInput.capitalizedInt.defined) { - writer.writeInt("CapitalizedInt", this@ReviewInput.capitalizedInt.value) - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ReviewRefInput.java b/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ReviewRefInput.java deleted file mode 100644 index f95a83ca30d..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ReviewRefInput.java +++ /dev/null @@ -1,94 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review.type; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.InputType; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class ReviewRefInput implements InputType { - private final Input reviewInput; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - ReviewRefInput(Input reviewInput) { - this.reviewInput = reviewInput; - } - - public @Nullable ReviewInput reviewInput() { - return this.reviewInput.value; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - if (reviewInput.defined) { - writer.writeObject("reviewInput", reviewInput.value != null ? reviewInput.value.marshaller() : null); - } - } - }; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= reviewInput.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof ReviewRefInput) { - ReviewRefInput that = (ReviewRefInput) o; - return this.reviewInput.equals(that.reviewInput); - } - return false; - } - - public static final class Builder { - private Input reviewInput = Input.absent(); - - Builder() { - } - - public Builder reviewInput(@Nullable ReviewInput reviewInput) { - this.reviewInput = Input.fromNullable(reviewInput); - return this; - } - - public Builder reviewInputInput(@NotNull Input reviewInput) { - this.reviewInput = Utils.checkNotNull(reviewInput, "reviewInput == null"); - return this; - } - - public ReviewRefInput build() { - return new ReviewRefInput(reviewInput); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ReviewRefInput.kt b/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ReviewRefInput.kt deleted file mode 100644 index 4ebc82610eb..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review/type/ReviewRefInput.kt +++ /dev/null @@ -1,26 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review.type - -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.InputType -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import kotlin.Suppress - -/** - * Circle ref to review input - */ -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -internal data class ReviewRefInput( - val reviewInput: Input = Input.absent() -) : InputType { - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - if (this@ReviewRefInput.reviewInput.defined) { - writer.writeObject("reviewInput", this@ReviewRefInput.reviewInput.value?.marshaller()) - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/CreateReviewForEpisodeMutation.java b/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/CreateReviewForEpisodeMutation.java deleted file mode 100644 index d290424ae59..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/CreateReviewForEpisodeMutation.java +++ /dev/null @@ -1,418 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review_semantic_naming; - -import com.apollographql.apollo.api.Mutation; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.mutation_create_review_semantic_naming.type.Episode; -import com.example.mutation_create_review_semantic_naming.type.ReviewInput; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class CreateReviewForEpisodeMutation implements Mutation, CreateReviewForEpisodeMutation.Variables> { - public static final String OPERATION_ID = "0cd4b32f15788d426344f5f8d2ee1a3cebb72c167005cb147d2a47761c120a41"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) {\n" - + " createReview(episode: $ep, review: $review) {\n" - + " __typename\n" - + " stars\n" - + " commentary\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "CreateReviewForEpisode"; - } - }; - - private final CreateReviewForEpisodeMutation.Variables variables; - - public CreateReviewForEpisodeMutation(@NotNull Episode ep, @NotNull ReviewInput review) { - Utils.checkNotNull(ep, "ep == null"); - Utils.checkNotNull(review, "review == null"); - variables = new CreateReviewForEpisodeMutation.Variables(ep, review); - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(CreateReviewForEpisodeMutation.Data data) { - return Optional.fromNullable(data); - } - - @Override - public CreateReviewForEpisodeMutation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) - throws IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) - throws IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - private @NotNull Episode ep; - - private @NotNull ReviewInput review; - - Builder() { - } - - public Builder ep(@NotNull Episode ep) { - this.ep = ep; - return this; - } - - public Builder review(@NotNull ReviewInput review) { - this.review = review; - return this; - } - - public CreateReviewForEpisodeMutation build() { - Utils.checkNotNull(ep, "ep == null"); - Utils.checkNotNull(review, "review == null"); - return new CreateReviewForEpisodeMutation(ep, review); - } - } - - public static final class Variables extends Operation.Variables { - private final @NotNull Episode ep; - - private final @NotNull ReviewInput review; - - private final transient Map valueMap = new LinkedHashMap<>(); - - Variables(@NotNull Episode ep, @NotNull ReviewInput review) { - this.ep = ep; - this.review = review; - this.valueMap.put("ep", ep); - this.valueMap.put("review", review); - } - - public @NotNull Episode ep() { - return ep; - } - - public @NotNull ReviewInput review() { - return review; - } - - @Override - public Map valueMap() { - return Collections.unmodifiableMap(valueMap); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - writer.writeString("ep", ep.rawValue()); - writer.writeObject("review", review.marshaller()); - } - }; - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("createReview", "createReview", new UnmodifiableMapBuilder(2) - .put("episode", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "ep") - .build()) - .put("review", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "review") - .build()) - .build(), true, Collections.emptyList()) - }; - - final Optional createReview; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable CreateReview createReview) { - this.createReview = Optional.fromNullable(createReview); - } - - public Optional createReview() { - return this.createReview; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], createReview.isPresent() ? createReview.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "createReview=" + createReview - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.createReview.equals(that.createReview); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= createReview.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final CreateReview.Mapper createReviewFieldMapper = new CreateReview.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final CreateReview createReview = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public CreateReview read(ResponseReader reader) { - return createReviewFieldMapper.map(reader); - } - }); - return new Data(createReview); - } - } - } - - /** - * Represents a review for a movie - */ - public static class CreateReview { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("stars", "stars", null, false, Collections.emptyList()), - ResponseField.forString("commentary", "commentary", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final int stars; - - final Optional commentary; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public CreateReview(@NotNull String __typename, int stars, @Nullable String commentary) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.stars = stars; - this.commentary = Optional.fromNullable(commentary); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The number of stars this review gave, 1-5 - */ - public int stars() { - return this.stars; - } - - /** - * Comment about the movie - */ - public Optional commentary() { - return this.commentary; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], stars); - writer.writeString($responseFields[2], commentary.isPresent() ? commentary.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "CreateReview{" - + "__typename=" + __typename + ", " - + "stars=" + stars + ", " - + "commentary=" + commentary - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof CreateReview) { - CreateReview that = (CreateReview) o; - return this.__typename.equals(that.__typename) - && this.stars == that.stars - && this.commentary.equals(that.commentary); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= stars; - h *= 1000003; - h ^= commentary.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public CreateReview map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final int stars = reader.readInt($responseFields[1]); - final String commentary = reader.readString($responseFields[2]); - return new CreateReview(__typename, stars, commentary); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/CreateReviewForEpisodeMutation.kt b/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/CreateReviewForEpisodeMutation.kt deleted file mode 100644 index ba30b19c955..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/CreateReviewForEpisodeMutation.kt +++ /dev/null @@ -1,205 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review_semantic_naming - -import com.apollographql.apollo.api.Mutation -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.mutation_create_review_semantic_naming.type.Episode -import com.example.mutation_create_review_semantic_naming.type.ReviewInput -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.Map -import kotlin.jvm.Transient -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class CreateReviewForEpisodeMutation( - val ep: Episode, - val review: ReviewInput -) : Mutation { - @Transient - private val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = mutableMapOf().apply { - this["ep"] = this@CreateReviewForEpisodeMutation.ep - this["review"] = this@CreateReviewForEpisodeMutation.review - } - - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - writer.writeString("ep", this@CreateReviewForEpisodeMutation.ep.rawValue) - writer.writeObject("review", this@CreateReviewForEpisodeMutation.review.marshaller()) - } - } - - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = variables - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * Represents a review for a movie - */ - data class CreateReview( - val __typename: String = "Review", - /** - * The number of stars this review gave, 1-5 - */ - val stars: Int, - /** - * Comment about the movie - */ - val commentary: String? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@CreateReview.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@CreateReview.stars) - writer.writeString(RESPONSE_FIELDS[2], this@CreateReview.commentary) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("stars", "stars", null, false, null), - ResponseField.forString("commentary", "commentary", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): CreateReview = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val stars = readInt(RESPONSE_FIELDS[1])!! - val commentary = readString(RESPONSE_FIELDS[2]) - CreateReview( - __typename = __typename, - stars = stars, - commentary = commentary - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val createReview: CreateReview? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.createReview?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("createReview", "createReview", mapOf( - "episode" to mapOf( - "kind" to "Variable", - "variableName" to "ep"), - "review" to mapOf( - "kind" to "Variable", - "variableName" to "review")), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val createReview = readObject(RESPONSE_FIELDS[0]) { reader -> - CreateReview(reader) - } - Data( - createReview = createReview - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "0cd4b32f15788d426344f5f8d2ee1a3cebb72c167005cb147d2a47761c120a41" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |mutation CreateReviewForEpisode(${'$'}ep: Episode!, ${'$'}review: ReviewInput!) { - | createReview(episode: ${'$'}ep, review: ${'$'}review) { - | __typename - | stars - | commentary - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "CreateReviewForEpisode" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/TestOperation.graphql deleted file mode 100644 index 84a00b4a092..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/TestOperation.graphql +++ /dev/null @@ -1,6 +0,0 @@ -mutation CreateReviewForEpisode($ep: Episode!, $review: ReviewInput!) { - createReview(episode: $ep, review: $review) { - stars - commentary - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ColorInput.java b/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ColorInput.java deleted file mode 100644 index da7f0254817..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ColorInput.java +++ /dev/null @@ -1,221 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review_semantic_naming.type; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.InputType; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class ColorInput implements InputType { - private final int red; - - private final Input green; - - private final double blue; - - private final Input enumWithDefaultValue; - - private final Input reviewRefInput; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - ColorInput(int red, Input green, double blue, Input enumWithDefaultValue, - Input reviewRefInput) { - this.red = red; - this.green = green; - this.blue = blue; - this.enumWithDefaultValue = enumWithDefaultValue; - this.reviewRefInput = reviewRefInput; - } - - /** - * Red color - */ - public int red() { - return this.red; - } - - /** - * Green color - */ - public @Nullable Double green() { - return this.green.value; - } - - /** - * Blue color - */ - public double blue() { - return this.blue; - } - - /** - * for test purpose only - */ - public @Nullable Episode enumWithDefaultValue() { - return this.enumWithDefaultValue.value; - } - - /** - * Circle ref to review input - */ - public @Nullable ReviewRefInput reviewRefInput() { - return this.reviewRefInput.value; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - writer.writeInt("red", red); - if (green.defined) { - writer.writeDouble("green", green.value); - } - writer.writeDouble("blue", blue); - if (enumWithDefaultValue.defined) { - writer.writeString("enumWithDefaultValue", enumWithDefaultValue.value != null ? enumWithDefaultValue.value.rawValue() : null); - } - if (reviewRefInput.defined) { - writer.writeObject("reviewRefInput", reviewRefInput.value != null ? reviewRefInput.value.marshaller() : null); - } - } - }; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= red; - h *= 1000003; - h ^= green.hashCode(); - h *= 1000003; - h ^= Double.valueOf(blue).hashCode(); - h *= 1000003; - h ^= enumWithDefaultValue.hashCode(); - h *= 1000003; - h ^= reviewRefInput.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof ColorInput) { - ColorInput that = (ColorInput) o; - return this.red == that.red - && this.green.equals(that.green) - && Double.doubleToLongBits(this.blue) == Double.doubleToLongBits(that.blue) - && this.enumWithDefaultValue.equals(that.enumWithDefaultValue) - && this.reviewRefInput.equals(that.reviewRefInput); - } - return false; - } - - public static final class Builder { - private int red = 1; - - private Input green = Input.fromNullable(0.0); - - private double blue = 1.5; - - private Input enumWithDefaultValue = Input.fromNullable(Episode.safeValueOf("new")); - - private Input reviewRefInput = Input.absent(); - - Builder() { - } - - /** - * Red color - */ - public Builder red(int red) { - this.red = red; - return this; - } - - /** - * Green color - */ - public Builder green(@Nullable Double green) { - this.green = Input.fromNullable(green); - return this; - } - - /** - * Blue color - */ - public Builder blue(double blue) { - this.blue = blue; - return this; - } - - /** - * for test purpose only - */ - public Builder enumWithDefaultValue(@Nullable Episode enumWithDefaultValue) { - this.enumWithDefaultValue = Input.fromNullable(enumWithDefaultValue); - return this; - } - - /** - * Circle ref to review input - */ - public Builder reviewRefInput(@Nullable ReviewRefInput reviewRefInput) { - this.reviewRefInput = Input.fromNullable(reviewRefInput); - return this; - } - - /** - * Green color - */ - public Builder greenInput(@NotNull Input green) { - this.green = Utils.checkNotNull(green, "green == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder enumWithDefaultValueInput(@NotNull Input enumWithDefaultValue) { - this.enumWithDefaultValue = Utils.checkNotNull(enumWithDefaultValue, "enumWithDefaultValue == null"); - return this; - } - - /** - * Circle ref to review input - */ - public Builder reviewRefInputInput(@NotNull Input reviewRefInput) { - this.reviewRefInput = Utils.checkNotNull(reviewRefInput, "reviewRefInput == null"); - return this; - } - - public ColorInput build() { - return new ColorInput(red, green, blue, enumWithDefaultValue, reviewRefInput); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ColorInput.kt b/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ColorInput.kt deleted file mode 100644 index 5b24aead14d..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ColorInput.kt +++ /dev/null @@ -1,56 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review_semantic_naming.type - -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.InputType -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import kotlin.Double -import kotlin.Int -import kotlin.Suppress - -/** - * The input object sent when passing in a color - */ -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class ColorInput( - /** - * Red color - */ - val red: Int = 1, - /** - * Green color - */ - val green: Input = Input.optional(0.0), - /** - * Blue color - */ - val blue: Double = 1.5, - /** - * for test purpose only - */ - val enumWithDefaultValue: Input = Input.optional(Episode.safeValueOf("new")), - /** - * Circle ref to review input - */ - val reviewRefInput: Input = Input.absent() -) : InputType { - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - writer.writeInt("red", this@ColorInput.red) - if (this@ColorInput.green.defined) { - writer.writeDouble("green", this@ColorInput.green.value) - } - writer.writeDouble("blue", this@ColorInput.blue) - if (this@ColorInput.enumWithDefaultValue.defined) { - writer.writeString("enumWithDefaultValue", - this@ColorInput.enumWithDefaultValue.value?.rawValue) - } - if (this@ColorInput.reviewRefInput.defined) { - writer.writeObject("reviewRefInput", this@ColorInput.reviewRefInput.value?.marshaller()) - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/CustomType.java deleted file mode 100644 index 653851f8181..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/CustomType.java +++ /dev/null @@ -1,36 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review_semantic_naming.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - DATE { - @Override - public String typeName() { - return "Date"; - } - - @Override - public String className() { - return "java.lang.Object"; - } - }, - - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/CustomType.kt deleted file mode 100644 index cc342e432d4..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/CustomType.kt +++ /dev/null @@ -1,23 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review_semantic_naming.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - DATE { - override fun typeName(): String = "Date" - - override fun className(): String = "kotlin.Any" - }, - - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/Episode.java b/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/Episode.java deleted file mode 100644 index 7e46f08094a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/Episode.java +++ /dev/null @@ -1,67 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review_semantic_naming.type; - -import java.lang.Deprecated; -import java.lang.String; - -/** - * The episodes in the Star Wars trilogy - */ -public enum Episode { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - * @deprecated For test purpose only - */ - @Deprecated - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - * @deprecated For test purpose only - */ - @Deprecated - NEW_("new"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Episode(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Episode safeValueOf(String rawValue) { - for (Episode enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Episode.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/Episode.kt b/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/Episode.kt deleted file mode 100644 index 6bbdc8db0b1..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/Episode.kt +++ /dev/null @@ -1,54 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review_semantic_naming.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.Deprecated -import kotlin.String - -/** - * The episodes in the Star Wars trilogy - */ -enum class Episode( - override val rawValue: String -) : EnumValue { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - */ - @Deprecated(message = "For test purpose only") - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - */ - @Deprecated(message = "For test purpose only") - NEW("new"), - - /** - * Auto generated constant for unknown enum values - */ - UNKNOWN__("UNKNOWN__"); - - companion object { - fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: - UNKNOWN__ - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ReviewInput.java b/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ReviewInput.java deleted file mode 100644 index db5d3328975..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ReviewInput.java +++ /dev/null @@ -1,897 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review_semantic_naming.type; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.InputType; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Boolean; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.util.Arrays; -import java.util.List; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class ReviewInput implements InputType { - private final int stars; - - private final Input nullableIntFieldWithDefaultValue; - - private final Input commentary; - - private final @NotNull ColorInput favoriteColor; - - private final Input enumWithDefaultValue; - - private final @NotNull Episode nonNullableEnumWithDefaultValue; - - private final Input nullableEnum; - - private final Input> listOfCustomScalar; - - private final Input customScalar; - - private final Input> listOfEnums; - - private final Input> listOfInt; - - private final Input> listOfString; - - private final @NotNull List listOfStringNonOptional; - - private final Input> listOfInputTypes; - - private final Input booleanWithDefaultValue; - - private final Input booleanNonOptional; - - private final Input>> listOfListOfString; - - private final Input>> listOfListOfEnum; - - private final Input>> listOfListOfCustom; - - private final Input>> listOfListOfObject; - - private final Input capitalizedField; - - private final Input capitalizedInt; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - ReviewInput(int stars, Input nullableIntFieldWithDefaultValue, Input commentary, - @NotNull ColorInput favoriteColor, Input enumWithDefaultValue, - @NotNull Episode nonNullableEnumWithDefaultValue, Input nullableEnum, - Input> listOfCustomScalar, Input customScalar, - Input> listOfEnums, Input> listOfInt, - Input> listOfString, @NotNull List listOfStringNonOptional, - Input> listOfInputTypes, Input booleanWithDefaultValue, - Input booleanNonOptional, Input>> listOfListOfString, - Input>> listOfListOfEnum, Input>> listOfListOfCustom, - Input>> listOfListOfObject, Input capitalizedField, - Input capitalizedInt) { - this.stars = stars; - this.nullableIntFieldWithDefaultValue = nullableIntFieldWithDefaultValue; - this.commentary = commentary; - this.favoriteColor = favoriteColor; - this.enumWithDefaultValue = enumWithDefaultValue; - this.nonNullableEnumWithDefaultValue = nonNullableEnumWithDefaultValue; - this.nullableEnum = nullableEnum; - this.listOfCustomScalar = listOfCustomScalar; - this.customScalar = customScalar; - this.listOfEnums = listOfEnums; - this.listOfInt = listOfInt; - this.listOfString = listOfString; - this.listOfStringNonOptional = listOfStringNonOptional; - this.listOfInputTypes = listOfInputTypes; - this.booleanWithDefaultValue = booleanWithDefaultValue; - this.booleanNonOptional = booleanNonOptional; - this.listOfListOfString = listOfListOfString; - this.listOfListOfEnum = listOfListOfEnum; - this.listOfListOfCustom = listOfListOfCustom; - this.listOfListOfObject = listOfListOfObject; - this.capitalizedField = capitalizedField; - this.capitalizedInt = capitalizedInt; - } - - /** - * 0-5 stars - */ - public int stars() { - return this.stars; - } - - /** - * for test purpose only - */ - public @Nullable Integer nullableIntFieldWithDefaultValue() { - return this.nullableIntFieldWithDefaultValue.value; - } - - /** - * Comment about the movie, optional - */ - public @Nullable String commentary() { - return this.commentary.value; - } - - /** - * Favorite color, optional - */ - public @NotNull ColorInput favoriteColor() { - return this.favoriteColor; - } - - /** - * for test purpose only - */ - public @Nullable Episode enumWithDefaultValue() { - return this.enumWithDefaultValue.value; - } - - /** - * for test purpose only - */ - public @NotNull Episode nonNullableEnumWithDefaultValue() { - return this.nonNullableEnumWithDefaultValue; - } - - /** - * for test purpose only - */ - public @Nullable Episode nullableEnum() { - return this.nullableEnum.value; - } - - /** - * for test purpose only - */ - public @Nullable List listOfCustomScalar() { - return this.listOfCustomScalar.value; - } - - /** - * for test purpose only - */ - public @Nullable Object customScalar() { - return this.customScalar.value; - } - - /** - * for test purpose only - */ - public @Nullable List listOfEnums() { - return this.listOfEnums.value; - } - - /** - * for test purpose only - */ - public @Nullable List listOfInt() { - return this.listOfInt.value; - } - - /** - * for test purpose only - */ - public @Nullable List listOfString() { - return this.listOfString.value; - } - - /** - * for test purpose only - */ - public @NotNull List listOfStringNonOptional() { - return this.listOfStringNonOptional; - } - - /** - * for test purpose only - */ - public @Nullable List listOfInputTypes() { - return this.listOfInputTypes.value; - } - - /** - * for test purpose only - */ - public @Nullable Boolean booleanWithDefaultValue() { - return this.booleanWithDefaultValue.value; - } - - /** - * for test purpose only - */ - public @Nullable Boolean booleanNonOptional() { - return this.booleanNonOptional.value; - } - - /** - * for test purpose only - */ - public @Nullable List> listOfListOfString() { - return this.listOfListOfString.value; - } - - /** - * for test purpose only - */ - public @Nullable List> listOfListOfEnum() { - return this.listOfListOfEnum.value; - } - - /** - * for test purpose only - */ - public @Nullable List> listOfListOfCustom() { - return this.listOfListOfCustom.value; - } - - /** - * for test purpose only - */ - public @Nullable List> listOfListOfObject() { - return this.listOfListOfObject.value; - } - - /** - * for test purpose only - */ - public @Nullable String capitalizedField() { - return this.capitalizedField.value; - } - - /** - * for test purpose only - */ - public @Nullable Integer capitalizedInt() { - return this.capitalizedInt.value; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - writer.writeInt("stars", stars); - if (nullableIntFieldWithDefaultValue.defined) { - writer.writeInt("nullableIntFieldWithDefaultValue", nullableIntFieldWithDefaultValue.value); - } - if (commentary.defined) { - writer.writeString("commentary", commentary.value); - } - writer.writeObject("favoriteColor", favoriteColor.marshaller()); - if (enumWithDefaultValue.defined) { - writer.writeString("enumWithDefaultValue", enumWithDefaultValue.value != null ? enumWithDefaultValue.value.rawValue() : null); - } - writer.writeString("nonNullableEnumWithDefaultValue", nonNullableEnumWithDefaultValue.rawValue()); - if (nullableEnum.defined) { - writer.writeString("nullableEnum", nullableEnum.value != null ? nullableEnum.value.rawValue() : null); - } - if (listOfCustomScalar.defined) { - writer.writeList("listOfCustomScalar", listOfCustomScalar.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final Object $item : listOfCustomScalar.value) { - listItemWriter.writeCustom(CustomType.DATE, $item); - } - } - } : null); - } - if (customScalar.defined) { - writer.writeCustom("customScalar", com.example.mutation_create_review_semantic_naming.type.CustomType.DATE, customScalar.value != null ? customScalar.value : null); - } - if (listOfEnums.defined) { - writer.writeList("listOfEnums", listOfEnums.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final Episode $item : listOfEnums.value) { - listItemWriter.writeString($item != null ? $item.rawValue() : null); - } - } - } : null); - } - if (listOfInt.defined) { - writer.writeList("listOfInt", listOfInt.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final Integer $item : listOfInt.value) { - listItemWriter.writeInt($item); - } - } - } : null); - } - if (listOfString.defined) { - writer.writeList("listOfString", listOfString.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final String $item : listOfString.value) { - listItemWriter.writeString($item); - } - } - } : null); - } - writer.writeList("listOfStringNonOptional", new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final String $item : listOfStringNonOptional) { - listItemWriter.writeString($item); - } - } - }); - if (listOfInputTypes.defined) { - writer.writeList("listOfInputTypes", listOfInputTypes.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final ColorInput $item : listOfInputTypes.value) { - listItemWriter.writeObject($item != null ? $item.marshaller() : null); - } - } - } : null); - } - if (booleanWithDefaultValue.defined) { - writer.writeBoolean("booleanWithDefaultValue", booleanWithDefaultValue.value); - } - if (booleanNonOptional.defined) { - writer.writeBoolean("booleanNonOptional", booleanNonOptional.value); - } - if (listOfListOfString.defined) { - writer.writeList("listOfListOfString", listOfListOfString.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final List $item : listOfListOfString.value) { - listItemWriter.writeList($item != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws - IOException { - for (final String $$item : $item) { - listItemWriter.writeString($$item); - } - } - } : null); - } - } - } : null); - } - if (listOfListOfEnum.defined) { - writer.writeList("listOfListOfEnum", listOfListOfEnum.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final List $item : listOfListOfEnum.value) { - listItemWriter.writeList($item != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws - IOException { - for (final Episode $$item : $item) { - listItemWriter.writeString($$item != null ? $$item.rawValue() : null); - } - } - } : null); - } - } - } : null); - } - if (listOfListOfCustom.defined) { - writer.writeList("listOfListOfCustom", listOfListOfCustom.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final List $item : listOfListOfCustom.value) { - listItemWriter.writeList($item != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws - IOException { - for (final Object $$item : $item) { - listItemWriter.writeCustom(CustomType.DATE, $$item); - } - } - } : null); - } - } - } : null); - } - if (listOfListOfObject.defined) { - writer.writeList("listOfListOfObject", listOfListOfObject.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final List $item : listOfListOfObject.value) { - listItemWriter.writeList($item != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws - IOException { - for (final ColorInput $$item : $item) { - listItemWriter.writeObject($$item != null ? $$item.marshaller() : null); - } - } - } : null); - } - } - } : null); - } - if (capitalizedField.defined) { - writer.writeString("CapitalizedField", capitalizedField.value); - } - if (capitalizedInt.defined) { - writer.writeInt("CapitalizedInt", capitalizedInt.value); - } - } - }; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= stars; - h *= 1000003; - h ^= nullableIntFieldWithDefaultValue.hashCode(); - h *= 1000003; - h ^= commentary.hashCode(); - h *= 1000003; - h ^= favoriteColor.hashCode(); - h *= 1000003; - h ^= enumWithDefaultValue.hashCode(); - h *= 1000003; - h ^= nonNullableEnumWithDefaultValue.hashCode(); - h *= 1000003; - h ^= nullableEnum.hashCode(); - h *= 1000003; - h ^= listOfCustomScalar.hashCode(); - h *= 1000003; - h ^= customScalar.hashCode(); - h *= 1000003; - h ^= listOfEnums.hashCode(); - h *= 1000003; - h ^= listOfInt.hashCode(); - h *= 1000003; - h ^= listOfString.hashCode(); - h *= 1000003; - h ^= listOfStringNonOptional.hashCode(); - h *= 1000003; - h ^= listOfInputTypes.hashCode(); - h *= 1000003; - h ^= booleanWithDefaultValue.hashCode(); - h *= 1000003; - h ^= booleanNonOptional.hashCode(); - h *= 1000003; - h ^= listOfListOfString.hashCode(); - h *= 1000003; - h ^= listOfListOfEnum.hashCode(); - h *= 1000003; - h ^= listOfListOfCustom.hashCode(); - h *= 1000003; - h ^= listOfListOfObject.hashCode(); - h *= 1000003; - h ^= capitalizedField.hashCode(); - h *= 1000003; - h ^= capitalizedInt.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof ReviewInput) { - ReviewInput that = (ReviewInput) o; - return this.stars == that.stars - && this.nullableIntFieldWithDefaultValue.equals(that.nullableIntFieldWithDefaultValue) - && this.commentary.equals(that.commentary) - && this.favoriteColor.equals(that.favoriteColor) - && this.enumWithDefaultValue.equals(that.enumWithDefaultValue) - && this.nonNullableEnumWithDefaultValue.equals(that.nonNullableEnumWithDefaultValue) - && this.nullableEnum.equals(that.nullableEnum) - && this.listOfCustomScalar.equals(that.listOfCustomScalar) - && this.customScalar.equals(that.customScalar) - && this.listOfEnums.equals(that.listOfEnums) - && this.listOfInt.equals(that.listOfInt) - && this.listOfString.equals(that.listOfString) - && this.listOfStringNonOptional.equals(that.listOfStringNonOptional) - && this.listOfInputTypes.equals(that.listOfInputTypes) - && this.booleanWithDefaultValue.equals(that.booleanWithDefaultValue) - && this.booleanNonOptional.equals(that.booleanNonOptional) - && this.listOfListOfString.equals(that.listOfListOfString) - && this.listOfListOfEnum.equals(that.listOfListOfEnum) - && this.listOfListOfCustom.equals(that.listOfListOfCustom) - && this.listOfListOfObject.equals(that.listOfListOfObject) - && this.capitalizedField.equals(that.capitalizedField) - && this.capitalizedInt.equals(that.capitalizedInt); - } - return false; - } - - public static final class Builder { - private int stars; - - private Input nullableIntFieldWithDefaultValue = Input.fromNullable(10); - - private Input commentary = Input.absent(); - - private @NotNull ColorInput favoriteColor; - - private Input enumWithDefaultValue = Input.fromNullable(Episode.safeValueOf("JEDI")); - - private @NotNull Episode nonNullableEnumWithDefaultValue = Episode.safeValueOf("JEDI"); - - private Input nullableEnum = Input.absent(); - - private Input> listOfCustomScalar = Input.absent(); - - private Input customScalar = Input.absent(); - - private Input> listOfEnums = Input.fromNullable(Arrays.asList(Episode.safeValueOf("NEWHOPE"), Episode.safeValueOf("EMPIRE"))); - - private Input> listOfInt = Input.fromNullable(Arrays.asList(1, 2, 3)); - - private Input> listOfString = Input.fromNullable(Arrays.asList("test1", "test2", "test3")); - - private @NotNull List listOfStringNonOptional; - - private Input> listOfInputTypes = Input.fromNullable(Arrays.asList()); - - private Input booleanWithDefaultValue = Input.fromNullable(true); - - private Input booleanNonOptional = Input.absent(); - - private Input>> listOfListOfString = Input.absent(); - - private Input>> listOfListOfEnum = Input.absent(); - - private Input>> listOfListOfCustom = Input.absent(); - - private Input>> listOfListOfObject = Input.absent(); - - private Input capitalizedField = Input.absent(); - - private Input capitalizedInt = Input.absent(); - - Builder() { - } - - /** - * 0-5 stars - */ - public Builder stars(int stars) { - this.stars = stars; - return this; - } - - /** - * for test purpose only - */ - public Builder nullableIntFieldWithDefaultValue(@Nullable Integer nullableIntFieldWithDefaultValue) { - this.nullableIntFieldWithDefaultValue = Input.fromNullable(nullableIntFieldWithDefaultValue); - return this; - } - - /** - * Comment about the movie, optional - */ - public Builder commentary(@Nullable String commentary) { - this.commentary = Input.fromNullable(commentary); - return this; - } - - /** - * Favorite color, optional - */ - public Builder favoriteColor(@NotNull ColorInput favoriteColor) { - this.favoriteColor = favoriteColor; - return this; - } - - /** - * for test purpose only - */ - public Builder enumWithDefaultValue(@Nullable Episode enumWithDefaultValue) { - this.enumWithDefaultValue = Input.fromNullable(enumWithDefaultValue); - return this; - } - - /** - * for test purpose only - */ - public Builder nonNullableEnumWithDefaultValue(@NotNull Episode nonNullableEnumWithDefaultValue) { - this.nonNullableEnumWithDefaultValue = nonNullableEnumWithDefaultValue; - return this; - } - - /** - * for test purpose only - */ - public Builder nullableEnum(@Nullable Episode nullableEnum) { - this.nullableEnum = Input.fromNullable(nullableEnum); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfCustomScalar(@Nullable List listOfCustomScalar) { - this.listOfCustomScalar = Input.fromNullable(listOfCustomScalar); - return this; - } - - /** - * for test purpose only - */ - public Builder customScalar(@Nullable Object customScalar) { - this.customScalar = Input.fromNullable(customScalar); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfEnums(@Nullable List listOfEnums) { - this.listOfEnums = Input.fromNullable(listOfEnums); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfInt(@Nullable List listOfInt) { - this.listOfInt = Input.fromNullable(listOfInt); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfString(@Nullable List listOfString) { - this.listOfString = Input.fromNullable(listOfString); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfStringNonOptional(@NotNull List listOfStringNonOptional) { - this.listOfStringNonOptional = listOfStringNonOptional; - return this; - } - - /** - * for test purpose only - */ - public Builder listOfInputTypes(@Nullable List listOfInputTypes) { - this.listOfInputTypes = Input.fromNullable(listOfInputTypes); - return this; - } - - /** - * for test purpose only - */ - public Builder booleanWithDefaultValue(@Nullable Boolean booleanWithDefaultValue) { - this.booleanWithDefaultValue = Input.fromNullable(booleanWithDefaultValue); - return this; - } - - /** - * for test purpose only - */ - public Builder booleanNonOptional(@Nullable Boolean booleanNonOptional) { - this.booleanNonOptional = Input.fromNullable(booleanNonOptional); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfString(@Nullable List> listOfListOfString) { - this.listOfListOfString = Input.fromNullable(listOfListOfString); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfEnum(@Nullable List> listOfListOfEnum) { - this.listOfListOfEnum = Input.fromNullable(listOfListOfEnum); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfCustom(@Nullable List> listOfListOfCustom) { - this.listOfListOfCustom = Input.fromNullable(listOfListOfCustom); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfObject(@Nullable List> listOfListOfObject) { - this.listOfListOfObject = Input.fromNullable(listOfListOfObject); - return this; - } - - /** - * for test purpose only - */ - public Builder capitalizedField(@Nullable String capitalizedField) { - this.capitalizedField = Input.fromNullable(capitalizedField); - return this; - } - - /** - * for test purpose only - */ - public Builder capitalizedInt(@Nullable Integer capitalizedInt) { - this.capitalizedInt = Input.fromNullable(capitalizedInt); - return this; - } - - /** - * for test purpose only - */ - public Builder nullableIntFieldWithDefaultValueInput(@NotNull Input nullableIntFieldWithDefaultValue) { - this.nullableIntFieldWithDefaultValue = Utils.checkNotNull(nullableIntFieldWithDefaultValue, "nullableIntFieldWithDefaultValue == null"); - return this; - } - - /** - * Comment about the movie, optional - */ - public Builder commentaryInput(@NotNull Input commentary) { - this.commentary = Utils.checkNotNull(commentary, "commentary == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder enumWithDefaultValueInput(@NotNull Input enumWithDefaultValue) { - this.enumWithDefaultValue = Utils.checkNotNull(enumWithDefaultValue, "enumWithDefaultValue == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder nullableEnumInput(@NotNull Input nullableEnum) { - this.nullableEnum = Utils.checkNotNull(nullableEnum, "nullableEnum == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfCustomScalarInput(@NotNull Input> listOfCustomScalar) { - this.listOfCustomScalar = Utils.checkNotNull(listOfCustomScalar, "listOfCustomScalar == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder customScalarInput(@NotNull Input customScalar) { - this.customScalar = Utils.checkNotNull(customScalar, "customScalar == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfEnumsInput(@NotNull Input> listOfEnums) { - this.listOfEnums = Utils.checkNotNull(listOfEnums, "listOfEnums == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfIntInput(@NotNull Input> listOfInt) { - this.listOfInt = Utils.checkNotNull(listOfInt, "listOfInt == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfStringInput(@NotNull Input> listOfString) { - this.listOfString = Utils.checkNotNull(listOfString, "listOfString == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfInputTypesInput(@NotNull Input> listOfInputTypes) { - this.listOfInputTypes = Utils.checkNotNull(listOfInputTypes, "listOfInputTypes == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder booleanWithDefaultValueInput(@NotNull Input booleanWithDefaultValue) { - this.booleanWithDefaultValue = Utils.checkNotNull(booleanWithDefaultValue, "booleanWithDefaultValue == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder booleanNonOptionalInput(@NotNull Input booleanNonOptional) { - this.booleanNonOptional = Utils.checkNotNull(booleanNonOptional, "booleanNonOptional == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfStringInput(@NotNull Input>> listOfListOfString) { - this.listOfListOfString = Utils.checkNotNull(listOfListOfString, "listOfListOfString == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfEnumInput(@NotNull Input>> listOfListOfEnum) { - this.listOfListOfEnum = Utils.checkNotNull(listOfListOfEnum, "listOfListOfEnum == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfCustomInput(@NotNull Input>> listOfListOfCustom) { - this.listOfListOfCustom = Utils.checkNotNull(listOfListOfCustom, "listOfListOfCustom == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder listOfListOfObjectInput(@NotNull Input>> listOfListOfObject) { - this.listOfListOfObject = Utils.checkNotNull(listOfListOfObject, "listOfListOfObject == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder capitalizedFieldInput(@NotNull Input capitalizedField) { - this.capitalizedField = Utils.checkNotNull(capitalizedField, "capitalizedField == null"); - return this; - } - - /** - * for test purpose only - */ - public Builder capitalizedIntInput(@NotNull Input capitalizedInt) { - this.capitalizedInt = Utils.checkNotNull(capitalizedInt, "capitalizedInt == null"); - return this; - } - - public ReviewInput build() { - Utils.checkNotNull(favoriteColor, "favoriteColor == null"); - Utils.checkNotNull(nonNullableEnumWithDefaultValue, "nonNullableEnumWithDefaultValue == null"); - Utils.checkNotNull(listOfStringNonOptional, "listOfStringNonOptional == null"); - return new ReviewInput(stars, nullableIntFieldWithDefaultValue, commentary, favoriteColor, enumWithDefaultValue, nonNullableEnumWithDefaultValue, nullableEnum, listOfCustomScalar, customScalar, listOfEnums, listOfInt, listOfString, listOfStringNonOptional, listOfInputTypes, booleanWithDefaultValue, booleanNonOptional, listOfListOfString, listOfListOfEnum, listOfListOfCustom, listOfListOfObject, capitalizedField, capitalizedInt); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ReviewInput.kt b/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ReviewInput.kt deleted file mode 100644 index 3dc6db6a6db..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ReviewInput.kt +++ /dev/null @@ -1,256 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review_semantic_naming.type - -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.InputType -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.InputFieldWriter -import kotlin.Any -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List - -/** - * The input object sent when someone is creating a new review - */ -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class ReviewInput( - /** - * 0-5 stars - */ - val stars: Int, - /** - * for test purpose only - */ - val nullableIntFieldWithDefaultValue: Input = Input.optional(10), - /** - * Comment about the movie, optional - */ - val commentary: Input = Input.absent(), - /** - * Favorite color, optional - */ - val favoriteColor: ColorInput, - /** - * for test purpose only - */ - val enumWithDefaultValue: Input = Input.optional(Episode.safeValueOf("JEDI")), - /** - * for test purpose only - */ - val nonNullableEnumWithDefaultValue: Episode = Episode.safeValueOf("JEDI"), - /** - * for test purpose only - */ - val nullableEnum: Input = Input.absent(), - /** - * for test purpose only - */ - val listOfCustomScalar: Input> = Input.absent(), - /** - * for test purpose only - */ - val customScalar: Input = Input.absent(), - /** - * for test purpose only - */ - val listOfEnums: Input> = Input.optional(listOf(Episode.safeValueOf("NEWHOPE"), - Episode.safeValueOf("EMPIRE"))), - /** - * for test purpose only - */ - val listOfInt: Input> = Input.optional(listOf(1, 2, 3)), - /** - * for test purpose only - */ - val listOfString: Input> = Input.optional(listOf("test1", "test2", "test3")), - /** - * for test purpose only - */ - val listOfStringNonOptional: List, - /** - * for test purpose only - */ - val listOfInputTypes: Input> = Input.optional(emptyList()), - /** - * for test purpose only - */ - val booleanWithDefaultValue: Input = Input.optional(true), - /** - * for test purpose only - */ - val booleanNonOptional: Input = Input.absent(), - /** - * for test purpose only - */ - val listOfListOfString: Input>> = Input.absent(), - /** - * for test purpose only - */ - val listOfListOfEnum: Input>> = Input.absent(), - /** - * for test purpose only - */ - val listOfListOfCustom: Input>> = Input.absent(), - /** - * for test purpose only - */ - val listOfListOfObject: Input>> = Input.absent(), - /** - * for test purpose only - */ - val capitalizedField: Input = Input.absent(), - /** - * for test purpose only - */ - val capitalizedInt: Input = Input.absent() -) : InputType { - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - writer.writeInt("stars", this@ReviewInput.stars) - if (this@ReviewInput.nullableIntFieldWithDefaultValue.defined) { - writer.writeInt("nullableIntFieldWithDefaultValue", - this@ReviewInput.nullableIntFieldWithDefaultValue.value) - } - if (this@ReviewInput.commentary.defined) { - writer.writeString("commentary", this@ReviewInput.commentary.value) - } - writer.writeObject("favoriteColor", this@ReviewInput.favoriteColor.marshaller()) - if (this@ReviewInput.enumWithDefaultValue.defined) { - writer.writeString("enumWithDefaultValue", - this@ReviewInput.enumWithDefaultValue.value?.rawValue) - } - writer.writeString("nonNullableEnumWithDefaultValue", - this@ReviewInput.nonNullableEnumWithDefaultValue.rawValue) - if (this@ReviewInput.nullableEnum.defined) { - writer.writeString("nullableEnum", this@ReviewInput.nullableEnum.value?.rawValue) - } - if (this@ReviewInput.listOfCustomScalar.defined) { - writer.writeList("listOfCustomScalar", this@ReviewInput.listOfCustomScalar.value?.let { - value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeCustom(CustomType.DATE, value) - } - } - }) - } - if (this@ReviewInput.customScalar.defined) { - writer.writeCustom("customScalar", CustomType.DATE, this@ReviewInput.customScalar.value) - } - if (this@ReviewInput.listOfEnums.defined) { - writer.writeList("listOfEnums", this@ReviewInput.listOfEnums.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeString(value?.rawValue) - } - } - }) - } - if (this@ReviewInput.listOfInt.defined) { - writer.writeList("listOfInt", this@ReviewInput.listOfInt.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeInt(value) - } - } - }) - } - if (this@ReviewInput.listOfString.defined) { - writer.writeList("listOfString", this@ReviewInput.listOfString.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeString(value) - } - } - }) - } - writer.writeList("listOfStringNonOptional") { listItemWriter -> - this@ReviewInput.listOfStringNonOptional.forEach { value -> - listItemWriter.writeString(value) - } - } - if (this@ReviewInput.listOfInputTypes.defined) { - writer.writeList("listOfInputTypes", this@ReviewInput.listOfInputTypes.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeObject(value?.marshaller()) - } - } - }) - } - if (this@ReviewInput.booleanWithDefaultValue.defined) { - writer.writeBoolean("booleanWithDefaultValue", this@ReviewInput.booleanWithDefaultValue.value) - } - if (this@ReviewInput.booleanNonOptional.defined) { - writer.writeBoolean("booleanNonOptional", this@ReviewInput.booleanNonOptional.value) - } - if (this@ReviewInput.listOfListOfString.defined) { - writer.writeList("listOfListOfString", this@ReviewInput.listOfListOfString.value?.let { - value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeList { listItemWriter -> - value.forEach { value -> - listItemWriter.writeString(value) - } - } - } - } - }) - } - if (this@ReviewInput.listOfListOfEnum.defined) { - writer.writeList("listOfListOfEnum", this@ReviewInput.listOfListOfEnum.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeList { listItemWriter -> - value.forEach { value -> - listItemWriter.writeString(value.rawValue) - } - } - } - } - }) - } - if (this@ReviewInput.listOfListOfCustom.defined) { - writer.writeList("listOfListOfCustom", this@ReviewInput.listOfListOfCustom.value?.let { - value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeList { listItemWriter -> - value.forEach { value -> - listItemWriter.writeCustom(CustomType.DATE, value) - } - } - } - } - }) - } - if (this@ReviewInput.listOfListOfObject.defined) { - writer.writeList("listOfListOfObject", this@ReviewInput.listOfListOfObject.value?.let { - value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeList { listItemWriter -> - value.forEach { value -> - listItemWriter.writeObject(value.marshaller()) - } - } - } - } - }) - } - if (this@ReviewInput.capitalizedField.defined) { - writer.writeString("CapitalizedField", this@ReviewInput.capitalizedField.value) - } - if (this@ReviewInput.capitalizedInt.defined) { - writer.writeInt("CapitalizedInt", this@ReviewInput.capitalizedInt.value) - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ReviewRefInput.java b/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ReviewRefInput.java deleted file mode 100644 index 4fd8a04c622..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ReviewRefInput.java +++ /dev/null @@ -1,94 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review_semantic_naming.type; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.InputType; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class ReviewRefInput implements InputType { - private final Input reviewInput; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - ReviewRefInput(Input reviewInput) { - this.reviewInput = reviewInput; - } - - public @Nullable ReviewInput reviewInput() { - return this.reviewInput.value; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - if (reviewInput.defined) { - writer.writeObject("reviewInput", reviewInput.value != null ? reviewInput.value.marshaller() : null); - } - } - }; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= reviewInput.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof ReviewRefInput) { - ReviewRefInput that = (ReviewRefInput) o; - return this.reviewInput.equals(that.reviewInput); - } - return false; - } - - public static final class Builder { - private Input reviewInput = Input.absent(); - - Builder() { - } - - public Builder reviewInput(@Nullable ReviewInput reviewInput) { - this.reviewInput = Input.fromNullable(reviewInput); - return this; - } - - public Builder reviewInputInput(@NotNull Input reviewInput) { - this.reviewInput = Utils.checkNotNull(reviewInput, "reviewInput == null"); - return this; - } - - public ReviewRefInput build() { - return new ReviewRefInput(reviewInput); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ReviewRefInput.kt b/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ReviewRefInput.kt deleted file mode 100644 index a090f5a262a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/mutation_create_review_semantic_naming/type/ReviewRefInput.kt +++ /dev/null @@ -1,26 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.mutation_create_review_semantic_naming.type - -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.InputType -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import kotlin.Suppress - -/** - * Circle ref to review input - */ -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class ReviewRefInput( - val reviewInput: Input = Input.absent() -) : InputType { - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - if (this@ReviewRefInput.reviewInput.defined) { - writer.writeObject("reviewInput", this@ReviewRefInput.reviewInput.value?.marshaller()) - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/TestOperation.graphql deleted file mode 100644 index 792fa12520f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/TestOperation.graphql +++ /dev/null @@ -1,21 +0,0 @@ -query TestQuery($episode: Episode) { - hero(episode: $episode) { - name - ... on Human { - friends { - name - ... on Human { - height(unit: FOOT) - } - } - } - ... on Droid { - friends { - name - ... on Human { - height(unit: METER) - } - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/TestQuery.java deleted file mode 100644 index 195175accb4..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/TestQuery.java +++ /dev/null @@ -1,1272 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.nested_conditional_inline; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.nested_conditional_inline.type.Episode; -import java.io.IOException; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, TestQuery.Variables> { - public static final String OPERATION_ID = "a9f066a7d1092096ab154f16f32114a4bd71e959b789f37879249cdf6309ea86"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery($episode: Episode) {\n" - + " hero(episode: $episode) {\n" - + " __typename\n" - + " name\n" - + " ... on Human {\n" - + " friends {\n" - + " __typename\n" - + " name\n" - + " ... on Human {\n" - + " height(unit: FOOT)\n" - + " }\n" - + " }\n" - + " }\n" - + " ... on Droid {\n" - + " friends {\n" - + " __typename\n" - + " name\n" - + " ... on Human {\n" - + " height(unit: METER)\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final TestQuery.Variables variables; - - public TestQuery(@NotNull Input episode) { - Utils.checkNotNull(episode, "episode == null"); - variables = new TestQuery.Variables(episode); - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public TestQuery.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - private Input episode = Input.absent(); - - Builder() { - } - - public Builder episode(@Nullable Episode episode) { - this.episode = Input.fromNullable(episode); - return this; - } - - public Builder episodeInput(@NotNull Input episode) { - this.episode = Utils.checkNotNull(episode, "episode == null"); - return this; - } - - public TestQuery build() { - return new TestQuery(episode); - } - } - - public static final class Variables extends Operation.Variables { - private final Input episode; - - private final transient Map valueMap = new LinkedHashMap<>(); - - Variables(Input episode) { - this.episode = episode; - if (episode.defined) { - this.valueMap.put("episode", episode.value); - } - } - - public Input episode() { - return episode; - } - - @Override - public Map valueMap() { - return Collections.unmodifiableMap(valueMap); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - if (episode.defined) { - writer.writeString("episode", episode.value != null ? episode.value.rawValue() : null); - } - } - }; - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", new UnmodifiableMapBuilder(1) - .put("episode", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "episode") - .build()) - .build(), true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public interface Hero { - @NotNull String __typename(); - - /** - * The name of the character - */ - @NotNull String name(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsHuman) { - return visitor.visit((AsHuman) this); - } else if (this instanceof AsDroid) { - return visitor.visit((AsDroid) this); - } else if (this instanceof AsCharacter2) { - return visitor.visit((AsCharacter2) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid"}) - )) - }; - - final AsHuman.Mapper asHumanFieldMapper = new AsHuman.Mapper(); - - final AsDroid.Mapper asDroidFieldMapper = new AsDroid.Mapper(); - - final AsCharacter2.Mapper asCharacter2FieldMapper = new AsCharacter2.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final AsHuman asHuman = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsHuman read(ResponseReader reader) { - return asHumanFieldMapper.map(reader); - } - }); - if (asHuman != null) { - return asHuman; - } - final AsDroid asDroid = reader.readFragment($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public AsDroid read(ResponseReader reader) { - return asDroidFieldMapper.map(reader); - } - }); - if (asDroid != null) { - return asDroid; - } - return asCharacter2FieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull Hero hero); - - T visit(@NotNull AsHuman asHuman); - - T visit(@NotNull AsDroid asDroid); - - T visit(@NotNull AsCharacter2 asCharacter2); - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - public static class AsHuman implements Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forList("friends", "friends", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional> friends; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsHuman(@NotNull String __typename, @NotNull String name, - @Nullable List friends) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friends = Optional.fromNullable(friends); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - /** - * This human's friends, or an empty list if they have none - */ - public Optional> friends() { - return this.friends; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeList($responseFields[2], friends.isPresent() ? friends.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Friend) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsHuman{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friends=" + friends - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsHuman) { - AsHuman that = (AsHuman) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friends.equals(that.friends); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friends.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Friend.Mapper friendFieldMapper = new Friend.Mapper(); - - @Override - public AsHuman map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final List friends = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Friend read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Friend read(ResponseReader reader) { - return friendFieldMapper.map(reader); - } - }); - } - }); - return new AsHuman(__typename, name, friends); - } - } - } - - /** - * A character from the Star Wars universe - */ - public interface Friend { - @NotNull String __typename(); - - /** - * The name of the character - */ - @NotNull String name(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsHuman1) { - return visitor.visit((AsHuman1) this); - } else if (this instanceof AsCharacter) { - return visitor.visit((AsCharacter) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )) - }; - - final AsHuman1.Mapper asHuman1FieldMapper = new AsHuman1.Mapper(); - - final AsCharacter.Mapper asCharacterFieldMapper = new AsCharacter.Mapper(); - - @Override - public Friend map(ResponseReader reader) { - final AsHuman1 asHuman = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsHuman1 read(ResponseReader reader) { - return asHuman1FieldMapper.map(reader); - } - }); - if (asHuman != null) { - return asHuman; - } - return asCharacterFieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull Friend friend); - - T visit(@NotNull AsHuman1 asHuman1); - - T visit(@NotNull AsCharacter asCharacter); - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - public static class AsHuman1 implements Friend { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forDouble("height", "height", new UnmodifiableMapBuilder(1) - .put("unit", "FOOT") - .build(), true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional height; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsHuman1(@NotNull String __typename, @NotNull String name, @Nullable Double height) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.height = Optional.fromNullable(height); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - /** - * Height in the preferred unit, default is meters - */ - public Optional height() { - return this.height; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeDouble($responseFields[2], height.isPresent() ? height.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsHuman1{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "height=" + height - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsHuman1) { - AsHuman1 that = (AsHuman1) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.height.equals(that.height); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= height.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsHuman1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final Double height = reader.readDouble($responseFields[2]); - return new AsHuman1(__typename, name, height); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class AsCharacter implements Friend { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter) { - AsCharacter that = (AsCharacter) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsCharacter map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new AsCharacter(__typename, name); - } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - public static class AsDroid implements Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forList("friends", "friends", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional> friends; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsDroid(@NotNull String __typename, @NotNull String name, - @Nullable List friends) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friends = Optional.fromNullable(friends); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What others call this droid - */ - public @NotNull String name() { - return this.name; - } - - /** - * This droid's friends, or an empty list if they have none - */ - public Optional> friends() { - return this.friends; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeList($responseFields[2], friends.isPresent() ? friends.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Friend1) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsDroid{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friends=" + friends - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsDroid) { - AsDroid that = (AsDroid) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friends.equals(that.friends); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friends.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Friend1.Mapper friend1FieldMapper = new Friend1.Mapper(); - - @Override - public AsDroid map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final List friends = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Friend1 read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Friend1 read(ResponseReader reader) { - return friend1FieldMapper.map(reader); - } - }); - } - }); - return new AsDroid(__typename, name, friends); - } - } - } - - /** - * A character from the Star Wars universe - */ - public interface Friend1 { - @NotNull String __typename(); - - /** - * The name of the character - */ - @NotNull String name(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsHuman2) { - return visitor.visit((AsHuman2) this); - } else if (this instanceof AsCharacter1) { - return visitor.visit((AsCharacter1) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )) - }; - - final AsHuman2.Mapper asHuman2FieldMapper = new AsHuman2.Mapper(); - - final AsCharacter1.Mapper asCharacter1FieldMapper = new AsCharacter1.Mapper(); - - @Override - public Friend1 map(ResponseReader reader) { - final AsHuman2 asHuman = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsHuman2 read(ResponseReader reader) { - return asHuman2FieldMapper.map(reader); - } - }); - if (asHuman != null) { - return asHuman; - } - return asCharacter1FieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull Friend1 friend1); - - T visit(@NotNull AsHuman2 asHuman2); - - T visit(@NotNull AsCharacter1 asCharacter1); - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - public static class AsHuman2 implements Friend1 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forDouble("height", "height", new UnmodifiableMapBuilder(1) - .put("unit", "METER") - .build(), true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional height; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsHuman2(@NotNull String __typename, @NotNull String name, @Nullable Double height) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.height = Optional.fromNullable(height); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - /** - * Height in the preferred unit, default is meters - */ - public Optional height() { - return this.height; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeDouble($responseFields[2], height.isPresent() ? height.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsHuman2{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "height=" + height - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsHuman2) { - AsHuman2 that = (AsHuman2) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.height.equals(that.height); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= height.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsHuman2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final Double height = reader.readDouble($responseFields[2]); - return new AsHuman2(__typename, name, height); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class AsCharacter1 implements Friend1 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter1(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter1{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter1) { - AsCharacter1 that = (AsCharacter1) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsCharacter1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new AsCharacter1(__typename, name); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class AsCharacter2 implements Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter2(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter2{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter2) { - AsCharacter2 that = (AsCharacter2) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsCharacter2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new AsCharacter2(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/TestQuery.kt deleted file mode 100644 index 0c02a974e60..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/TestQuery.kt +++ /dev/null @@ -1,522 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.nested_conditional_inline - -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.nested_conditional_inline.type.Episode -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.Double -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlin.collections.Map -import kotlin.jvm.Transient -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class TestQuery( - val episode: Input = Input.absent() -) : Query { - @Transient - private val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = mutableMapOf().apply { - if (this@TestQuery.episode.defined) { - this["episode"] = this@TestQuery.episode.value - } - } - - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - if (this@TestQuery.episode.defined) { - writer.writeString("episode", this@TestQuery.episode.value?.rawValue) - } - } - } - - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = variables - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - interface HeroCharacter { - fun marshaller(): ResponseFieldMarshaller - } - - interface FriendCharacter { - fun marshaller(): ResponseFieldMarshaller - } - - /** - * A humanoid creature from the Star Wars universe - */ - data class AsHuman1( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String, - /** - * Height in the preferred unit, default is meters - */ - val height: Double? - ) : FriendCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsHuman1.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsHuman1.name) - writer.writeDouble(RESPONSE_FIELDS[2], this@AsHuman1.height) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forDouble("height", "height", mapOf( - "unit" to "FOOT"), true, null) - ) - - operator fun invoke(reader: ResponseReader): AsHuman1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val height = readDouble(RESPONSE_FIELDS[2]) - AsHuman1( - __typename = __typename, - name = name, - height = height - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Friend( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - val asHuman1: AsHuman1? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Friend.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Friend.name) - writer.writeFragment(this@Friend.asHuman1?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )) - ) - - operator fun invoke(reader: ResponseReader): Friend = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val asHuman1 = readFragment(RESPONSE_FIELDS[2]) { reader -> - AsHuman1(reader) - } - Friend( - __typename = __typename, - name = name, - asHuman1 = asHuman1 - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - data class AsHuman( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String, - /** - * This human's friends, or an empty list if they have none - */ - val friends: List? - ) : HeroCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsHuman.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsHuman.name) - writer.writeList(RESPONSE_FIELDS[2], this@AsHuman.friends) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun friendsFilterNotNull(): List? = friends?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forList("friends", "friends", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): AsHuman = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friends = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Friend(reader) - } - } - AsHuman( - __typename = __typename, - name = name, - friends = friends - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - interface FriendCharacter1 { - fun marshaller(): ResponseFieldMarshaller - } - - /** - * A humanoid creature from the Star Wars universe - */ - data class AsHuman2( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String, - /** - * Height in the preferred unit, default is meters - */ - val height: Double? - ) : FriendCharacter1 { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsHuman2.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsHuman2.name) - writer.writeDouble(RESPONSE_FIELDS[2], this@AsHuman2.height) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forDouble("height", "height", mapOf( - "unit" to "METER"), true, null) - ) - - operator fun invoke(reader: ResponseReader): AsHuman2 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val height = readDouble(RESPONSE_FIELDS[2]) - AsHuman2( - __typename = __typename, - name = name, - height = height - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Friend1( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - val asHuman2: AsHuman2? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Friend1.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Friend1.name) - writer.writeFragment(this@Friend1.asHuman2?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )) - ) - - operator fun invoke(reader: ResponseReader): Friend1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val asHuman2 = readFragment(RESPONSE_FIELDS[2]) { reader -> - AsHuman2(reader) - } - Friend1( - __typename = __typename, - name = name, - asHuman2 = asHuman2 - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - data class AsDroid( - val __typename: String = "Droid", - /** - * What others call this droid - */ - val name: String, - /** - * This droid's friends, or an empty list if they have none - */ - val friends: List? - ) : HeroCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsDroid.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsDroid.name) - writer.writeList(RESPONSE_FIELDS[2], this@AsDroid.friends) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun friendsFilterNotNull(): List? = friends?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forList("friends", "friends", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): AsDroid = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friends = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Friend1(reader) - } - } - AsDroid( - __typename = __typename, - name = name, - friends = friends - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - val asHuman: AsHuman?, - val asDroid: AsDroid? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeFragment(this@Hero.asHuman?.marshaller()) - writer.writeFragment(this@Hero.asDroid?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid")) - )) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val asHuman = readFragment(RESPONSE_FIELDS[2]) { reader -> - AsHuman(reader) - } - val asDroid = readFragment(RESPONSE_FIELDS[3]) { reader -> - AsDroid(reader) - } - Hero( - __typename = __typename, - name = name, - asHuman = asHuman, - asDroid = asDroid - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", mapOf( - "episode" to mapOf( - "kind" to "Variable", - "variableName" to "episode")), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "a9f066a7d1092096ab154f16f32114a4bd71e959b789f37879249cdf6309ea86" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery(${'$'}episode: Episode) { - | hero(episode: ${'$'}episode) { - | __typename - | name - | ... on Human { - | friends { - | __typename - | name - | ... on Human { - | height(unit: FOOT) - | } - | } - | } - | ... on Droid { - | friends { - | __typename - | name - | ... on Human { - | height(unit: METER) - | } - | } - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/type/CustomType.java deleted file mode 100644 index 9dbf112d26f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.nested_conditional_inline.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/type/CustomType.kt deleted file mode 100644 index 3688b6c749d..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.nested_conditional_inline.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/type/Episode.java b/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/type/Episode.java deleted file mode 100644 index b98f880c5aa..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/type/Episode.java +++ /dev/null @@ -1,67 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.nested_conditional_inline.type; - -import java.lang.Deprecated; -import java.lang.String; - -/** - * The episodes in the Star Wars trilogy - */ -public enum Episode { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - * @deprecated For test purpose only - */ - @Deprecated - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - * @deprecated For test purpose only - */ - @Deprecated - NEW_("new"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Episode(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Episode safeValueOf(String rawValue) { - for (Episode enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Episode.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/type/Episode.kt b/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/type/Episode.kt deleted file mode 100644 index b96913fb757..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/nested_conditional_inline/type/Episode.kt +++ /dev/null @@ -1,54 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.nested_conditional_inline.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.Deprecated -import kotlin.String - -/** - * The episodes in the Star Wars trilogy - */ -enum class Episode( - override val rawValue: String -) : EnumValue { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - */ - @Deprecated(message = "For test purpose only") - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - */ - @Deprecated(message = "For test purpose only") - NEW("new"), - - /** - * Auto generated constant for unknown enum values - */ - UNKNOWN__("UNKNOWN__"); - - companion object { - fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: - UNKNOWN__ - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/operation_directive/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/operation_directive/TestOperation.graphql deleted file mode 100644 index 3f4e2d51f6d..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/operation_directive/TestOperation.graphql +++ /dev/null @@ -1,5 +0,0 @@ -query TestQuery @myModifier { - hero { - name - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/operation_directive/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/operation_directive/TestQuery.java deleted file mode 100644 index a89dd32c601..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/operation_directive/TestQuery.java +++ /dev/null @@ -1,327 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.operation_directive; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "808281d08c21f800ac5bce8f608bcd5958a01bd3466feb53399ee3b2bcc532d7"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery @myModifier {\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Hero(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/operation_directive/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/operation_directive/TestQuery.kt deleted file mode 100644 index 42105d7d9ed..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/operation_directive/TestQuery.kt +++ /dev/null @@ -1,166 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.operation_directive - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Hero( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "808281d08c21f800ac5bce8f608bcd5958a01bd3466feb53399ee3b2bcc532d7" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery @myModifier { - | hero { - | __typename - | name - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/operation_directive/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/operation_directive/type/CustomType.java deleted file mode 100644 index 904a6c6e363..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/operation_directive/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.operation_directive.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/operation_directive/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/operation_directive/type/CustomType.kt deleted file mode 100644 index 0776521d84c..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/operation_directive/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.operation_directive.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/operation_id_generator/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/operation_id_generator/TestOperation.graphql deleted file mode 100644 index ab4a5297550..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/operation_id_generator/TestOperation.graphql +++ /dev/null @@ -1,9 +0,0 @@ -query TestQuery { - hero { - name - } - hero { - id - name - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/operation_id_generator/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/operation_id_generator/TestQuery.java deleted file mode 100644 index 9823f9f3932..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/operation_id_generator/TestQuery.java +++ /dev/null @@ -1,350 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.operation_id_generator; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.operation_id_generator.type.CustomType; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "hash"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " hero {\n" - + " __typename\n" - + " id\n" - + " name\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull String id; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull String name, @NotNull String id) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.id = Utils.checkNotNull(id, "id == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The ID of the character - */ - public @NotNull String id() { - return this.id; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[2], id); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "id=" + id - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.id.equals(that.id); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= id.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[2]); - return new Hero(__typename, name, id); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/operation_id_generator/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/operation_id_generator/TestQuery.kt deleted file mode 100644 index 33e1bc7ea84..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/operation_id_generator/TestQuery.kt +++ /dev/null @@ -1,179 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.operation_id_generator - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.operation_id_generator.type.CustomType -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The ID of the character - */ - val id: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeCustom(RESPONSE_FIELDS[2] as ResponseField.CustomTypeField, this@Hero.id) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val id = readCustomType(RESPONSE_FIELDS[2] as ResponseField.CustomTypeField)!! - Hero( - __typename = __typename, - name = name, - id = id - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = "hash" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | name - | } - | hero { - | __typename - | id - | name - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/operation_id_generator/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/operation_id_generator/type/CustomType.java deleted file mode 100644 index 0fe6788e798..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/operation_id_generator/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.operation_id_generator.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/operation_id_generator/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/operation_id_generator/type/CustomType.kt deleted file mode 100644 index 842afd23f54..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/operation_id_generator/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.operation_id_generator.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/recursive_selection/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/recursive_selection/TestOperation.graphql deleted file mode 100644 index ac4d36ad3fb..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/recursive_selection/TestOperation.graphql +++ /dev/null @@ -1,11 +0,0 @@ -query TestQuery { - tree { - name - children { - name - } - parent { - name - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/recursive_selection/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/recursive_selection/TestQuery.java deleted file mode 100644 index b30505b43ca..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/recursive_selection/TestQuery.java +++ /dev/null @@ -1,570 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.recursive_selection; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "07319106b852dad03abe0214a7b144e074f234950939a6247d5233b590685b3a"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " tree {\n" - + " __typename\n" - + " name\n" - + " children {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " parent {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("tree", "tree", null, true, Collections.emptyList()) - }; - - final Optional tree; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Tree tree) { - this.tree = Optional.fromNullable(tree); - } - - public Optional tree() { - return this.tree; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], tree.isPresent() ? tree.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "tree=" + tree - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.tree.equals(that.tree); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= tree.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Tree.Mapper treeFieldMapper = new Tree.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Tree tree = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Tree read(ResponseReader reader) { - return treeFieldMapper.map(reader); - } - }); - return new Data(tree); - } - } - } - - /** - * To test recursive structures - */ - public static class Tree { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forList("children", "children", null, false, Collections.emptyList()), - ResponseField.forObject("parent", "parent", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull List children; - - final Optional parent; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Tree(@NotNull String __typename, @NotNull String name, @NotNull List children, - @Nullable Parent parent) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.children = Utils.checkNotNull(children, "children == null"); - this.parent = Optional.fromNullable(parent); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull String name() { - return this.name; - } - - public @NotNull List children() { - return this.children; - } - - public Optional parent() { - return this.parent; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeList($responseFields[2], children, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Child) item).marshaller()); - } - } - }); - writer.writeObject($responseFields[3], parent.isPresent() ? parent.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Tree{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "children=" + children + ", " - + "parent=" + parent - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Tree) { - Tree that = (Tree) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.children.equals(that.children) - && this.parent.equals(that.parent); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= children.hashCode(); - h *= 1000003; - h ^= parent.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Child.Mapper childFieldMapper = new Child.Mapper(); - - final Parent.Mapper parentFieldMapper = new Parent.Mapper(); - - @Override - public Tree map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final List children = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Child read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Child read(ResponseReader reader) { - return childFieldMapper.map(reader); - } - }); - } - }); - final Parent parent = reader.readObject($responseFields[3], new ResponseReader.ObjectReader() { - @Override - public Parent read(ResponseReader reader) { - return parentFieldMapper.map(reader); - } - }); - return new Tree(__typename, name, children, parent); - } - } - } - - /** - * To test recursive structures - */ - public static class Child { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Child(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Child{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Child) { - Child that = (Child) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Child map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Child(__typename, name); - } - } - } - - /** - * To test recursive structures - */ - public static class Parent { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Parent(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Parent{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Parent) { - Parent that = (Parent) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Parent map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Parent(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/recursive_selection/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/recursive_selection/TestQuery.kt deleted file mode 100644 index 860327f04a5..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/recursive_selection/TestQuery.kt +++ /dev/null @@ -1,255 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.recursive_selection - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * To test recursive structures - */ - data class Child( - val __typename: String = "Tree", - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Child.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Child.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Child = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Child( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * To test recursive structures - */ - data class Parent( - val __typename: String = "Tree", - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Parent.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Parent.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Parent = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Parent( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * To test recursive structures - */ - data class Tree( - val __typename: String = "Tree", - val name: String, - val children: List, - val parent: Parent? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Tree.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Tree.name) - writer.writeList(RESPONSE_FIELDS[2], this@Tree.children) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value.marshaller())} - } - writer.writeObject(RESPONSE_FIELDS[3], this@Tree.parent?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forList("children", "children", null, false, null), - ResponseField.forObject("parent", "parent", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Tree = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val children = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Child(reader) - } - }!!.map { it!! } - val parent = readObject(RESPONSE_FIELDS[3]) { reader -> - Parent(reader) - } - Tree( - __typename = __typename, - name = name, - children = children, - parent = parent - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val tree: Tree? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.tree?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("tree", "tree", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val tree = readObject(RESPONSE_FIELDS[0]) { reader -> - Tree(reader) - } - Data( - tree = tree - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "07319106b852dad03abe0214a7b144e074f234950939a6247d5233b590685b3a" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | tree { - | __typename - | name - | children { - | __typename - | name - | } - | parent { - | __typename - | name - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/recursive_selection/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/recursive_selection/type/CustomType.java deleted file mode 100644 index 8165b135a30..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/recursive_selection/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.recursive_selection.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/recursive_selection/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/recursive_selection/type/CustomType.kt deleted file mode 100644 index 6ee7c59c1e9..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/recursive_selection/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.recursive_selection.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestOperation.graphql deleted file mode 100644 index 6478af0b4f3..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestOperation.graphql +++ /dev/null @@ -1,12 +0,0 @@ -query TestQuery { - yield: hero { - it: id - name - } - - objects: search(text: "abc") { - ... on Character { - name - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestQuery.java deleted file mode 100644 index 083ac33f15b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestQuery.java +++ /dev/null @@ -1,606 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.reserved_keywords; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.reserved_keywords.type.CustomType; -import java.io.IOException; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "47d23fa9d7e9bf697a19f43297b1c422ae31ce1886f740e3982a5daf9b7e1ebd"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " yield: hero {\n" - + " __typename\n" - + " it: id\n" - + " name\n" - + " }\n" - + " objects: search(text: \"abc\") {\n" - + " __typename\n" - + " ... on Character {\n" - + " name\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("yield", "hero", null, true, Collections.emptyList()), - ResponseField.forList("objects", "search", new UnmodifiableMapBuilder(1) - .put("text", "abc") - .build(), true, Collections.emptyList()) - }; - - final Optional yield; - - final Optional> objects; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Yield yield, @Nullable List objects) { - this.yield = Optional.fromNullable(yield); - this.objects = Optional.fromNullable(objects); - } - - public Optional yield() { - return this.yield; - } - - public Optional> objects() { - return this.objects; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], yield.isPresent() ? yield.get().marshaller() : null); - writer.writeList($responseFields[1], objects.isPresent() ? objects.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (java.lang.Object item : items) { - listItemWriter.writeObject(((Object) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "yield=" + yield + ", " - + "objects=" + objects - + "}"; - } - return $toString; - } - - @Override - public boolean equals(java.lang.Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.yield.equals(that.yield) - && this.objects.equals(that.objects); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= yield.hashCode(); - h *= 1000003; - h ^= objects.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Yield.Mapper yieldFieldMapper = new Yield.Mapper(); - - final Object.Mapper objectFieldMapper = new Object.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Yield yield = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Yield read(ResponseReader reader) { - return yieldFieldMapper.map(reader); - } - }); - final List objects = reader.readList($responseFields[1], new ResponseReader.ListReader() { - @Override - public Object read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Object read(ResponseReader reader) { - return objectFieldMapper.map(reader); - } - }); - } - }); - return new Data(yield, objects); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Yield { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forCustomType("it", "id", null, false, CustomType.ID, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String it; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Yield(@NotNull String __typename, @NotNull String it, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.it = Utils.checkNotNull(it, "it == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The ID of the character - */ - public @NotNull String it() { - return this.it; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[1], it); - writer.writeString($responseFields[2], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Yield{" - + "__typename=" + __typename + ", " - + "it=" + it + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(java.lang.Object o) { - if (o == this) { - return true; - } - if (o instanceof Yield) { - Yield that = (Yield) o; - return this.__typename.equals(that.__typename) - && this.it.equals(that.it) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= it.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Yield map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String it = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]); - final String name = reader.readString($responseFields[2]); - return new Yield(__typename, it, name); - } - } - } - - public interface Object { - @NotNull String __typename(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsCharacter) { - return visitor.visit((AsCharacter) this); - } else if (this instanceof AsSearchResult) { - return visitor.visit((AsSearchResult) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid", "Human"}) - )) - }; - - final AsCharacter.Mapper asCharacterFieldMapper = new AsCharacter.Mapper(); - - final AsSearchResult.Mapper asSearchResultFieldMapper = new AsSearchResult.Mapper(); - - @Override - public Object map(ResponseReader reader) { - final AsCharacter asCharacter = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsCharacter read(ResponseReader reader) { - return asCharacterFieldMapper.map(reader); - } - }); - if (asCharacter != null) { - return asCharacter; - } - return asSearchResultFieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull Object object); - - T visit(@NotNull AsCharacter asCharacter); - - T visit(@NotNull AsSearchResult asSearchResult); - } - } - - /** - * A character from the Star Wars universe - */ - public static class AsCharacter implements Object { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(java.lang.Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter) { - AsCharacter that = (AsCharacter) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsCharacter map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new AsCharacter(__typename, name); - } - } - } - - public static class AsSearchResult implements Object { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsSearchResult(@NotNull String __typename) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsSearchResult{" - + "__typename=" + __typename - + "}"; - } - return $toString; - } - - @Override - public boolean equals(java.lang.Object o) { - if (o == this) { - return true; - } - if (o instanceof AsSearchResult) { - AsSearchResult that = (AsSearchResult) o; - return this.__typename.equals(that.__typename); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsSearchResult map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - return new AsSearchResult(__typename); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestQuery.kt deleted file mode 100644 index a8b46ee29d1..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/TestQuery.kt +++ /dev/null @@ -1,270 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.reserved_keywords - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.reserved_keywords.type.CustomType -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Yield_( - val __typename: String = "Character", - /** - * The ID of the character - */ - val it_: String, - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Yield_.__typename) - writer.writeCustom(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField, this@Yield_.it_) - writer.writeString(RESPONSE_FIELDS[2], this@Yield_.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forCustomType("it", "id", null, false, CustomType.ID, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Yield_ = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val it_ = readCustomType(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField)!! - val name = readString(RESPONSE_FIELDS[2])!! - Yield_( - __typename = __typename, - it_ = it_, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - interface ObjectSearchResult { - fun marshaller(): ResponseFieldMarshaller - } - - /** - * A character from the Star Wars universe - */ - data class AsCharacter( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) : ObjectSearchResult { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsCharacter.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsCharacter.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): AsCharacter = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - AsCharacter( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - data class Object( - val __typename: String = "SearchResult", - val asCharacter: AsCharacter? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Object.__typename) - writer.writeFragment(this@Object.asCharacter?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid", "Human")) - )) - ) - - operator fun invoke(reader: ResponseReader): Object = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val asCharacter = readFragment(RESPONSE_FIELDS[1]) { reader -> - AsCharacter(reader) - } - Object( - __typename = __typename, - asCharacter = asCharacter - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val yield_: Yield_?, - val objects: List? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.yield_?.marshaller()) - writer.writeList(RESPONSE_FIELDS[1], this@Data.objects) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun objectsFilterNotNull(): List? = objects?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("yield", "hero", null, true, null), - ResponseField.forList("objects", "search", mapOf( - "text" to "abc"), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val yield_ = readObject(RESPONSE_FIELDS[0]) { reader -> - Yield_(reader) - } - val objects = readList(RESPONSE_FIELDS[1]) { reader -> - reader.readObject { reader -> - Object(reader) - } - } - Data( - yield_ = yield_, - objects = objects - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "47d23fa9d7e9bf697a19f43297b1c422ae31ce1886f740e3982a5daf9b7e1ebd" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | yield: hero { - | __typename - | it: id - | name - | } - | objects: search(text: "abc") { - | __typename - | ... on Character { - | name - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/type/CustomType.java deleted file mode 100644 index d6e7dd02472..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.reserved_keywords.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/reserved_keywords/type/CustomType.kt deleted file mode 100644 index 86cafa9ee02..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/reserved_keywords/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.reserved_keywords.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/root_query_fragment/TestOperation.graphql deleted file mode 100644 index 8ab9e4034dd..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment/TestOperation.graphql +++ /dev/null @@ -1,10 +0,0 @@ -query TestQuery { - ...QueryFragment -} - -fragment QueryFragment on Query { - __typename - hero { - name - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/root_query_fragment/TestQuery.java deleted file mode 100644 index a08b90ffc86..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment/TestQuery.java +++ /dev/null @@ -1,319 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.root_query_fragment.fragment.QueryFragment; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "aa398544bf26cbb38315b1a35172c30b0e5fa0507770a4d9b5c420ee21a61fbb"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " ...QueryFragment\n" - + "}\n" - + "fragment QueryFragment on Query {\n" - + " __typename\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@NotNull Fragments fragments) { - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final Optional queryFragment; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@Nullable QueryFragment queryFragment) { - this.queryFragment = Optional.fromNullable(queryFragment); - } - - public Optional queryFragment() { - return this.queryFragment; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - final QueryFragment $queryFragment = queryFragment.isPresent() ? queryFragment.get() : null; - if ($queryFragment != null) { - writer.writeFragment($queryFragment.marshaller()); - } - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "queryFragment=" + queryFragment - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.queryFragment.equals(that.queryFragment); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= queryFragment.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Query"}) - )) - }; - - final QueryFragment.Mapper queryFragmentFieldMapper = new QueryFragment.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final QueryFragment queryFragment = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public QueryFragment read(ResponseReader reader) { - return queryFragmentFieldMapper.map(reader); - } - }); - return new Fragments(queryFragment); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Data(fragments); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/root_query_fragment/TestQuery.kt deleted file mode 100644 index 6de9c77d971..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment/TestQuery.kt +++ /dev/null @@ -1,162 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.root_query_fragment.fragment.QueryFragment -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val fragments: Fragments - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - this@Data.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val fragments = Fragments(reader) - Data( - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val queryFragment: QueryFragment? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.queryFragment?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Query")) - )) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val queryFragment = readFragment(RESPONSE_FIELDS[0]) { reader -> - QueryFragment(reader) - } - Fragments( - queryFragment = queryFragment - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - companion object { - const val OPERATION_ID: String = - "aa398544bf26cbb38315b1a35172c30b0e5fa0507770a4d9b5c420ee21a61fbb" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | ...QueryFragment - |} - |fragment QueryFragment on Query { - | __typename - | hero { - | __typename - | name - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment/fragment/QueryFragment.java b/apollo-compiler/src/test/graphql/com/example/root_query_fragment/fragment/QueryFragment.java deleted file mode 100644 index f67d77d5ee7..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment/fragment/QueryFragment.java +++ /dev/null @@ -1,219 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class QueryFragment implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment QueryFragment on Query {\n" - + " __typename\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " }\n" - + "}"; - - final @NotNull String __typename; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public QueryFragment(@NotNull String __typename, @Nullable Hero hero) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.hero = Optional.fromNullable(hero); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "QueryFragment{" - + "__typename=" + __typename + ", " - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof QueryFragment) { - QueryFragment that = (QueryFragment) o; - return this.__typename.equals(that.__typename) - && this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public QueryFragment map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Hero hero = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new QueryFragment(__typename, hero); - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Hero(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment/fragment/QueryFragment.kt b/apollo-compiler/src/test/graphql/com/example/root_query_fragment/fragment/QueryFragment.kt deleted file mode 100644 index de659e9c5dd..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment/fragment/QueryFragment.kt +++ /dev/null @@ -1,93 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class QueryFragment( - val __typename: String = "Query", - val hero: Hero? -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@QueryFragment.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@QueryFragment.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("hero", "hero", null, true, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment QueryFragment on Query { - | __typename - | hero { - | __typename - | name - | } - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): QueryFragment = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val hero = readObject(RESPONSE_FIELDS[1]) { reader -> - Hero(reader) - } - QueryFragment( - __typename = __typename, - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Hero( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/root_query_fragment/type/CustomType.java deleted file mode 100644 index ded55fedbfe..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/root_query_fragment/type/CustomType.kt deleted file mode 100644 index e6fb940969b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/TestOperation.graphql deleted file mode 100644 index e3c2ed55fb1..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/TestOperation.graphql +++ /dev/null @@ -1,28 +0,0 @@ -query TestQuery { - ...QueryFragment -} - -fragment QueryFragment on Query { - __typename - hero { - ...heroFragment - } - droid(id: 1) { - ...droidFragment - } - human(id: 1) { - ... on Human { - name - homePlanet - } - } -} - -fragment heroFragment on Character { - name -} - -fragment droidFragment on Droid { - name - primaryFunction -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/TestQuery.java deleted file mode 100644 index d91eefd9312..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/TestQuery.java +++ /dev/null @@ -1,339 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment_with_nested_fragments; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.root_query_fragment_with_nested_fragments.fragment.QueryFragment; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "ef6afa4b20c3dfe3455ed69f3f54badc60e02fc6965f4879aafd8eea42c0c319"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " ...QueryFragment\n" - + "}\n" - + "fragment QueryFragment on Query {\n" - + " __typename\n" - + " hero {\n" - + " __typename\n" - + " ...heroFragment\n" - + " }\n" - + " droid(id: 1) {\n" - + " __typename\n" - + " ...droidFragment\n" - + " }\n" - + " human(id: 1) {\n" - + " __typename\n" - + " ... on Human {\n" - + " name\n" - + " homePlanet\n" - + " }\n" - + " }\n" - + "}\n" - + "fragment heroFragment on Character {\n" - + " __typename\n" - + " name\n" - + "}\n" - + "fragment droidFragment on Droid {\n" - + " __typename\n" - + " name\n" - + " primaryFunction\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@NotNull Fragments fragments) { - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final Optional queryFragment; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@Nullable QueryFragment queryFragment) { - this.queryFragment = Optional.fromNullable(queryFragment); - } - - public Optional queryFragment() { - return this.queryFragment; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - final QueryFragment $queryFragment = queryFragment.isPresent() ? queryFragment.get() : null; - if ($queryFragment != null) { - writer.writeFragment($queryFragment.marshaller()); - } - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "queryFragment=" + queryFragment - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.queryFragment.equals(that.queryFragment); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= queryFragment.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Query"}) - )) - }; - - final QueryFragment.Mapper queryFragmentFieldMapper = new QueryFragment.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final QueryFragment queryFragment = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public QueryFragment read(ResponseReader reader) { - return queryFragmentFieldMapper.map(reader); - } - }); - return new Fragments(queryFragment); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Data(fragments); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/TestQuery.kt deleted file mode 100644 index bbdbb120705..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/TestQuery.kt +++ /dev/null @@ -1,182 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment_with_nested_fragments - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.root_query_fragment_with_nested_fragments.fragment.QueryFragment -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val fragments: Fragments - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - this@Data.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val fragments = Fragments(reader) - Data( - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val queryFragment: QueryFragment? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.queryFragment?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Query")) - )) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val queryFragment = readFragment(RESPONSE_FIELDS[0]) { reader -> - QueryFragment(reader) - } - Fragments( - queryFragment = queryFragment - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - companion object { - const val OPERATION_ID: String = - "ef6afa4b20c3dfe3455ed69f3f54badc60e02fc6965f4879aafd8eea42c0c319" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | ...QueryFragment - |} - |fragment QueryFragment on Query { - | __typename - | hero { - | __typename - | ...heroFragment - | } - | droid(id: 1) { - | __typename - | ...droidFragment - | } - | human(id: 1) { - | __typename - | ... on Human { - | name - | homePlanet - | } - | } - |} - |fragment heroFragment on Character { - | __typename - | name - |} - |fragment droidFragment on Droid { - | __typename - | name - | primaryFunction - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/DroidFragment.java b/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/DroidFragment.java deleted file mode 100644 index b844c2bc42e..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/DroidFragment.java +++ /dev/null @@ -1,137 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment_with_nested_fragments.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class DroidFragment implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment droidFragment on Droid {\n" - + " __typename\n" - + " name\n" - + " primaryFunction\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional primaryFunction; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public DroidFragment(@NotNull String __typename, @NotNull String name, - @Nullable String primaryFunction) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.primaryFunction = Optional.fromNullable(primaryFunction); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What others call this droid - */ - public @NotNull String name() { - return this.name; - } - - /** - * This droid's primary function - */ - public Optional primaryFunction() { - return this.primaryFunction; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeString($responseFields[2], primaryFunction.isPresent() ? primaryFunction.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "DroidFragment{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "primaryFunction=" + primaryFunction - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof DroidFragment) { - DroidFragment that = (DroidFragment) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.primaryFunction.equals(that.primaryFunction); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= primaryFunction.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public DroidFragment map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final String primaryFunction = reader.readString($responseFields[2]); - return new DroidFragment(__typename, name, primaryFunction); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/DroidFragment.kt b/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/DroidFragment.kt deleted file mode 100644 index bfd6d1f36d9..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/DroidFragment.kt +++ /dev/null @@ -1,65 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment_with_nested_fragments.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class DroidFragment( - val __typename: String = "Droid", - /** - * What others call this droid - */ - val name: String, - /** - * This droid's primary function - */ - val primaryFunction: String? -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@DroidFragment.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@DroidFragment.name) - writer.writeString(RESPONSE_FIELDS[2], this@DroidFragment.primaryFunction) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment droidFragment on Droid { - | __typename - | name - | primaryFunction - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): DroidFragment = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val primaryFunction = readString(RESPONSE_FIELDS[2]) - DroidFragment( - __typename = __typename, - name = name, - primaryFunction = primaryFunction - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/HeroFragment.java b/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/HeroFragment.java deleted file mode 100644 index 6d7ae585d79..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/HeroFragment.java +++ /dev/null @@ -1,116 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment_with_nested_fragments.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; - -public class HeroFragment implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment heroFragment on Character {\n" - + " __typename\n" - + " name\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HeroFragment(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HeroFragment{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HeroFragment) { - HeroFragment that = (HeroFragment) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public HeroFragment map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new HeroFragment(__typename, name); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/HeroFragment.kt b/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/HeroFragment.kt deleted file mode 100644 index 6c554dfe289..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/HeroFragment.kt +++ /dev/null @@ -1,56 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment_with_nested_fragments.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class HeroFragment( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HeroFragment.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HeroFragment.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment heroFragment on Character { - | __typename - | name - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HeroFragment = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - HeroFragment( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/QueryFragment.java b/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/QueryFragment.java deleted file mode 100644 index 058854646fe..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/QueryFragment.java +++ /dev/null @@ -1,641 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment_with_nested_fragments.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class QueryFragment implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()), - ResponseField.forObject("droid", "droid", new UnmodifiableMapBuilder(1) - .put("id", "1") - .build(), true, Collections.emptyList()), - ResponseField.forObject("human", "human", new UnmodifiableMapBuilder(1) - .put("id", "1") - .build(), true, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment QueryFragment on Query {\n" - + " __typename\n" - + " hero {\n" - + " __typename\n" - + " ...heroFragment\n" - + " }\n" - + " droid(id: 1) {\n" - + " __typename\n" - + " ...droidFragment\n" - + " }\n" - + " human(id: 1) {\n" - + " __typename\n" - + " ... on Human {\n" - + " name\n" - + " homePlanet\n" - + " }\n" - + " }\n" - + "}"; - - final @NotNull String __typename; - - final Optional hero; - - final Optional droid; - - final Optional human; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public QueryFragment(@NotNull String __typename, @Nullable Hero hero, @Nullable Droid droid, - @Nullable Human human) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.hero = Optional.fromNullable(hero); - this.droid = Optional.fromNullable(droid); - this.human = Optional.fromNullable(human); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public Optional hero() { - return this.hero; - } - - public Optional droid() { - return this.droid; - } - - public Optional human() { - return this.human; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], hero.isPresent() ? hero.get().marshaller() : null); - writer.writeObject($responseFields[2], droid.isPresent() ? droid.get().marshaller() : null); - writer.writeObject($responseFields[3], human.isPresent() ? human.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "QueryFragment{" - + "__typename=" + __typename + ", " - + "hero=" + hero + ", " - + "droid=" + droid + ", " - + "human=" + human - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof QueryFragment) { - QueryFragment that = (QueryFragment) o; - return this.__typename.equals(that.__typename) - && this.hero.equals(that.hero) - && this.droid.equals(that.droid) - && this.human.equals(that.human); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= hero.hashCode(); - h *= 1000003; - h ^= droid.hashCode(); - h *= 1000003; - h ^= human.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - final Droid.Mapper droidFieldMapper = new Droid.Mapper(); - - final Human.Mapper humanFieldMapper = new Human.Mapper(); - - @Override - public QueryFragment map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Hero hero = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - final Droid droid = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public Droid read(ResponseReader reader) { - return droidFieldMapper.map(reader); - } - }); - final Human human = reader.readObject($responseFields[3], new ResponseReader.ObjectReader() { - @Override - public Human read(ResponseReader reader) { - return humanFieldMapper.map(reader); - } - }); - return new QueryFragment(__typename, hero, droid, human); - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @NotNull HeroFragment heroFragment; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@NotNull HeroFragment heroFragment) { - this.heroFragment = Utils.checkNotNull(heroFragment, "heroFragment == null"); - } - - public @NotNull HeroFragment heroFragment() { - return this.heroFragment; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeFragment(heroFragment.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "heroFragment=" + heroFragment - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.heroFragment.equals(that.heroFragment); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= heroFragment.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Collections.emptyList()) - }; - - final HeroFragment.Mapper heroFragmentFieldMapper = new HeroFragment.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HeroFragment heroFragment = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HeroFragment read(ResponseReader reader) { - return heroFragmentFieldMapper.map(reader); - } - }); - return new Fragments(heroFragment); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Hero(__typename, fragments); - } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - public static class Droid { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Droid(@NotNull String __typename, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Droid{" - + "__typename=" + __typename + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Droid) { - Droid that = (Droid) o; - return this.__typename.equals(that.__typename) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @NotNull DroidFragment droidFragment; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@NotNull DroidFragment droidFragment) { - this.droidFragment = Utils.checkNotNull(droidFragment, "droidFragment == null"); - } - - public @NotNull DroidFragment droidFragment() { - return this.droidFragment; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeFragment(droidFragment.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "droidFragment=" + droidFragment - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.droidFragment.equals(that.droidFragment); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= droidFragment.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Collections.emptyList()) - }; - - final DroidFragment.Mapper droidFragmentFieldMapper = new DroidFragment.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final DroidFragment droidFragment = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public DroidFragment read(ResponseReader reader) { - return droidFragmentFieldMapper.map(reader); - } - }); - return new Fragments(droidFragment); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Droid map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Droid(__typename, fragments); - } - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - public static class Human { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forString("homePlanet", "homePlanet", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional homePlanet; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Human(@NotNull String __typename, @NotNull String name, @Nullable String homePlanet) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.homePlanet = Optional.fromNullable(homePlanet); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - /** - * The home planet of the human, or null if unknown - */ - public Optional homePlanet() { - return this.homePlanet; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeString($responseFields[2], homePlanet.isPresent() ? homePlanet.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Human{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "homePlanet=" + homePlanet - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Human) { - Human that = (Human) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.homePlanet.equals(that.homePlanet); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= homePlanet.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Human map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final String homePlanet = reader.readString($responseFields[2]); - return new Human(__typename, name, homePlanet); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/QueryFragment.kt b/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/QueryFragment.kt deleted file mode 100644 index 985993a18b5..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/fragment/QueryFragment.kt +++ /dev/null @@ -1,244 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment_with_nested_fragments.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class QueryFragment( - val __typename: String = "Query", - val hero: Hero?, - val droid: Droid?, - val human: Human? -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@QueryFragment.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@QueryFragment.hero?.marshaller()) - writer.writeObject(RESPONSE_FIELDS[2], this@QueryFragment.droid?.marshaller()) - writer.writeObject(RESPONSE_FIELDS[3], this@QueryFragment.human?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("hero", "hero", null, true, null), - ResponseField.forObject("droid", "droid", mapOf( - "id" to "1"), true, null), - ResponseField.forObject("human", "human", mapOf( - "id" to "1"), true, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment QueryFragment on Query { - | __typename - | hero { - | __typename - | ...heroFragment - | } - | droid(id: 1) { - | __typename - | ...droidFragment - | } - | human(id: 1) { - | __typename - | ... on Human { - | name - | homePlanet - | } - | } - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): QueryFragment = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val hero = readObject(RESPONSE_FIELDS[1]) { reader -> - Hero(reader) - } - val droid = readObject(RESPONSE_FIELDS[2]) { reader -> - Droid(reader) - } - val human = readObject(RESPONSE_FIELDS[3]) { reader -> - Human(reader) - } - QueryFragment( - __typename = __typename, - hero = hero, - droid = droid, - human = human - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - this@Hero.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val fragments = Fragments(reader) - Hero( - __typename = __typename, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val heroFragment: HeroFragment - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.heroFragment.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", null) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val heroFragment = readFragment(RESPONSE_FIELDS[0]) { reader -> - HeroFragment(reader) - }!! - Fragments( - heroFragment = heroFragment - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - data class Droid( - val __typename: String = "Droid", - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Droid.__typename) - this@Droid.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Droid = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val fragments = Fragments(reader) - Droid( - __typename = __typename, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val droidFragment: DroidFragment - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.droidFragment.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", null) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val droidFragment = readFragment(RESPONSE_FIELDS[0]) { reader -> - DroidFragment(reader) - }!! - Fragments( - droidFragment = droidFragment - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - data class Human( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String, - /** - * The home planet of the human, or null if unknown - */ - val homePlanet: String? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Human.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Human.name) - writer.writeString(RESPONSE_FIELDS[2], this@Human.homePlanet) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forString("homePlanet", "homePlanet", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Human = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val homePlanet = readString(RESPONSE_FIELDS[2]) - Human( - __typename = __typename, - name = name, - homePlanet = homePlanet - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/type/CustomType.java deleted file mode 100644 index ce8d2ba75f6..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment_with_nested_fragments.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/type/CustomType.kt deleted file mode 100644 index aa13ef3e10a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/root_query_fragment_with_nested_fragments/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.root_query_fragment_with_nested_fragments.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/simple_fragment/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/simple_fragment/TestOperation.graphql deleted file mode 100644 index f941706e396..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/simple_fragment/TestOperation.graphql +++ /dev/null @@ -1,23 +0,0 @@ -# Demonstration of Java / Kotlin docs generation -# for both query and fragments -query TestQuery { - hero { - __typename - ...HeroDetails - ...HumanDetails - } -} - -# Fragment with Java / Kotlin docs generation -# with multi lines support -fragment HeroDetails on Character { - __typename - name - ... HumanDetails -} - -# Fragment with Java / Kotlin docs generation -fragment HumanDetails on Human { - __typename - name -} diff --git a/apollo-compiler/src/test/graphql/com/example/simple_fragment/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/simple_fragment/TestQuery.java deleted file mode 100644 index cd98dc8890e..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/simple_fragment/TestQuery.java +++ /dev/null @@ -1,449 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.simple_fragment; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.simple_fragment.fragment.HeroDetails; -import com.example.simple_fragment.fragment.HumanDetails; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Demonstration of Java / Kotlin docs generation - * for both query and fragments - */ -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "11b6156b253df199195798f2de386724580e3882c9888f7e5d1685c42b64e0cf"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " ...HeroDetails\n" - + " ...HumanDetails\n" - + " }\n" - + "}\n" - + "fragment HeroDetails on Character {\n" - + " __typename\n" - + " name\n" - + " ... HumanDetails\n" - + "}\n" - + "fragment HumanDetails on Human {\n" - + " __typename\n" - + " name\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Hero(@NotNull String __typename, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Hero{" - + "__typename=" + __typename + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Hero) { - Hero that = (Hero) o; - return this.__typename.equals(that.__typename) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @NotNull HeroDetails heroDetails; - - final Optional humanDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@NotNull HeroDetails heroDetails, @Nullable HumanDetails humanDetails) { - this.heroDetails = Utils.checkNotNull(heroDetails, "heroDetails == null"); - this.humanDetails = Optional.fromNullable(humanDetails); - } - - public @NotNull HeroDetails heroDetails() { - return this.heroDetails; - } - - public Optional humanDetails() { - return this.humanDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeFragment(heroDetails.marshaller()); - final HumanDetails $humanDetails = humanDetails.isPresent() ? humanDetails.get() : null; - if ($humanDetails != null) { - writer.writeFragment($humanDetails.marshaller()); - } - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "heroDetails=" + heroDetails + ", " - + "humanDetails=" + humanDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.heroDetails.equals(that.heroDetails) - && this.humanDetails.equals(that.humanDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= heroDetails.hashCode(); - h *= 1000003; - h ^= humanDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Collections.emptyList()), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )) - }; - - final HeroDetails.Mapper heroDetailsFieldMapper = new HeroDetails.Mapper(); - - final HumanDetails.Mapper humanDetailsFieldMapper = new HumanDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HeroDetails heroDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HeroDetails read(ResponseReader reader) { - return heroDetailsFieldMapper.map(reader); - } - }); - final HumanDetails humanDetails = reader.readFragment($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public HumanDetails read(ResponseReader reader) { - return humanDetailsFieldMapper.map(reader); - } - }); - return new Fragments(heroDetails, humanDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Hero(__typename, fragments); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/simple_fragment/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/simple_fragment/TestQuery.kt deleted file mode 100644 index e03eef305da..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/simple_fragment/TestQuery.kt +++ /dev/null @@ -1,214 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.simple_fragment - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.simple_fragment.fragment.HeroDetails -import com.example.simple_fragment.fragment.HumanDetails -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -/** - * Demonstration of Java / Kotlin docs generation - * for both query and fragments - */ -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -internal class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - this@Hero.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val fragments = Fragments(reader) - Hero( - __typename = __typename, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val heroDetails: HeroDetails, - val humanDetails: HumanDetails? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.heroDetails.marshaller()) - writer.writeFragment(this@Fragments.humanDetails?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val heroDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - HeroDetails(reader) - }!! - val humanDetails = readFragment(RESPONSE_FIELDS[1]) { reader -> - HumanDetails(reader) - } - Fragments( - heroDetails = heroDetails, - humanDetails = humanDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "11b6156b253df199195798f2de386724580e3882c9888f7e5d1685c42b64e0cf" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | ...HeroDetails - | ...HumanDetails - | } - |} - |fragment HeroDetails on Character { - | __typename - | name - | ... HumanDetails - |} - |fragment HumanDetails on Human { - | __typename - | name - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/simple_fragment/fragment/HeroDetails.java b/apollo-compiler/src/test/graphql/com/example/simple_fragment/fragment/HeroDetails.java deleted file mode 100644 index 00999076bd0..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/simple_fragment/fragment/HeroDetails.java +++ /dev/null @@ -1,226 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.simple_fragment.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Fragment with Java / Kotlin docs generation - * with multi lines support - */ -public class HeroDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment HeroDetails on Character {\n" - + " __typename\n" - + " name\n" - + " ... HumanDetails\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HeroDetails(@NotNull String __typename, @NotNull String name, - @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HeroDetails{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HeroDetails) { - HeroDetails that = (HeroDetails) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final Optional humanDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@Nullable HumanDetails humanDetails) { - this.humanDetails = Optional.fromNullable(humanDetails); - } - - public Optional humanDetails() { - return this.humanDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - final HumanDetails $humanDetails = humanDetails.isPresent() ? humanDetails.get() : null; - if ($humanDetails != null) { - writer.writeFragment($humanDetails.marshaller()); - } - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "humanDetails=" + humanDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.humanDetails.equals(that.humanDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= humanDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )) - }; - - final HumanDetails.Mapper humanDetailsFieldMapper = new HumanDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HumanDetails humanDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HumanDetails read(ResponseReader reader) { - return humanDetailsFieldMapper.map(reader); - } - }); - return new Fragments(humanDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public HeroDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new HeroDetails(__typename, name, fragments); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/simple_fragment/fragment/HeroDetails.kt b/apollo-compiler/src/test/graphql/com/example/simple_fragment/fragment/HeroDetails.kt deleted file mode 100644 index d893f2f51c9..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/simple_fragment/fragment/HeroDetails.kt +++ /dev/null @@ -1,94 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.simple_fragment.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -/** - * Fragment with Java / Kotlin docs generation - * with multi lines support - */ -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -internal data class HeroDetails( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - val fragments: Fragments -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HeroDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HeroDetails.name) - this@HeroDetails.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment HeroDetails on Character { - | __typename - | name - | ... HumanDetails - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HeroDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val fragments = Fragments(reader) - HeroDetails( - __typename = __typename, - name = name, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - internal data class Fragments( - val humanDetails: HumanDetails? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.humanDetails?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val humanDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - HumanDetails(reader) - } - Fragments( - humanDetails = humanDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/simple_fragment/fragment/HumanDetails.java b/apollo-compiler/src/test/graphql/com/example/simple_fragment/fragment/HumanDetails.java deleted file mode 100644 index e996c36693c..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/simple_fragment/fragment/HumanDetails.java +++ /dev/null @@ -1,119 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.simple_fragment.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; - -/** - * Fragment with Java / Kotlin docs generation - */ -public class HumanDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment HumanDetails on Human {\n" - + " __typename\n" - + " name\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HumanDetails(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HumanDetails{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HumanDetails) { - HumanDetails that = (HumanDetails) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public HumanDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new HumanDetails(__typename, name); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/simple_fragment/fragment/HumanDetails.kt b/apollo-compiler/src/test/graphql/com/example/simple_fragment/fragment/HumanDetails.kt deleted file mode 100644 index 0178ca945ba..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/simple_fragment/fragment/HumanDetails.kt +++ /dev/null @@ -1,59 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.simple_fragment.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -/** - * Fragment with Java / Kotlin docs generation - */ -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -internal data class HumanDetails( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HumanDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HumanDetails.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment HumanDetails on Human { - | __typename - | name - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HumanDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - HumanDetails( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/simple_fragment/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/simple_fragment/type/CustomType.java deleted file mode 100644 index 68bf1af351b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/simple_fragment/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.simple_fragment.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/simple_fragment/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/simple_fragment/type/CustomType.kt deleted file mode 100644 index a64b60c913b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/simple_fragment/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.simple_fragment.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -internal enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/TestOperation.graphql deleted file mode 100644 index 68ea1003fbc..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/TestOperation.graphql +++ /dev/null @@ -1,11 +0,0 @@ -query TestQuery { - hero { - name - ... on Human { - height - } - ... on Droid { - primaryFunction - } - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/TestQuery.java deleted file mode 100644 index 5498d1a132c..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/TestQuery.java +++ /dev/null @@ -1,633 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.simple_inline_fragment; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "40e95b8824cd8b5da64969cc5fc32d89ee15fde55084fd41513967e521a8a687"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " hero {\n" - + " __typename\n" - + " name\n" - + " ... on Human {\n" - + " height\n" - + " }\n" - + " ... on Droid {\n" - + " primaryFunction\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()) - }; - - final Optional hero; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero) { - this.hero = Optional.fromNullable(hero); - } - - public Optional hero() { - return this.hero; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - return new Data(hero); - } - } - } - - /** - * A character from the Star Wars universe - */ - public interface Hero { - @NotNull String __typename(); - - /** - * The name of the character - */ - @NotNull String name(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsHuman) { - return visitor.visit((AsHuman) this); - } else if (this instanceof AsDroid) { - return visitor.visit((AsDroid) this); - } else if (this instanceof AsCharacter) { - return visitor.visit((AsCharacter) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid"}) - )) - }; - - final AsHuman.Mapper asHumanFieldMapper = new AsHuman.Mapper(); - - final AsDroid.Mapper asDroidFieldMapper = new AsDroid.Mapper(); - - final AsCharacter.Mapper asCharacterFieldMapper = new AsCharacter.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final AsHuman asHuman = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsHuman read(ResponseReader reader) { - return asHumanFieldMapper.map(reader); - } - }); - if (asHuman != null) { - return asHuman; - } - final AsDroid asDroid = reader.readFragment($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public AsDroid read(ResponseReader reader) { - return asDroidFieldMapper.map(reader); - } - }); - if (asDroid != null) { - return asDroid; - } - return asCharacterFieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull Hero hero); - - T visit(@NotNull AsHuman asHuman); - - T visit(@NotNull AsDroid asDroid); - - T visit(@NotNull AsCharacter asCharacter); - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - public static class AsHuman implements Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forDouble("height", "height", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional height; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsHuman(@NotNull String __typename, @NotNull String name, @Nullable Double height) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.height = Optional.fromNullable(height); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - /** - * Height in the preferred unit, default is meters - */ - public Optional height() { - return this.height; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeDouble($responseFields[2], height.isPresent() ? height.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsHuman{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "height=" + height - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsHuman) { - AsHuman that = (AsHuman) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.height.equals(that.height); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= height.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsHuman map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final Double height = reader.readDouble($responseFields[2]); - return new AsHuman(__typename, name, height); - } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - public static class AsDroid implements Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional primaryFunction; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsDroid(@NotNull String __typename, @NotNull String name, - @Nullable String primaryFunction) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.primaryFunction = Optional.fromNullable(primaryFunction); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What others call this droid - */ - public @NotNull String name() { - return this.name; - } - - /** - * This droid's primary function - */ - public Optional primaryFunction() { - return this.primaryFunction; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeString($responseFields[2], primaryFunction.isPresent() ? primaryFunction.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsDroid{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "primaryFunction=" + primaryFunction - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsDroid) { - AsDroid that = (AsDroid) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.primaryFunction.equals(that.primaryFunction); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= primaryFunction.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsDroid map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final String primaryFunction = reader.readString($responseFields[2]); - return new AsDroid(__typename, name, primaryFunction); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class AsCharacter implements Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter) { - AsCharacter that = (AsCharacter) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsCharacter map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new AsCharacter(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/TestQuery.kt deleted file mode 100644 index 9380f6eb9e6..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/TestQuery.kt +++ /dev/null @@ -1,281 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.simple_inline_fragment - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import kotlin.Array -import kotlin.Boolean -import kotlin.Double -import kotlin.String -import kotlin.Suppress -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - interface HeroCharacter { - fun marshaller(): ResponseFieldMarshaller - } - - /** - * A humanoid creature from the Star Wars universe - */ - data class AsHuman( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String, - /** - * Height in the preferred unit, default is meters - */ - val height: Double? - ) : HeroCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsHuman.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsHuman.name) - writer.writeDouble(RESPONSE_FIELDS[2], this@AsHuman.height) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forDouble("height", "height", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): AsHuman = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val height = readDouble(RESPONSE_FIELDS[2]) - AsHuman( - __typename = __typename, - name = name, - height = height - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - data class AsDroid( - val __typename: String = "Droid", - /** - * What others call this droid - */ - val name: String, - /** - * This droid's primary function - */ - val primaryFunction: String? - ) : HeroCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsDroid.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsDroid.name) - writer.writeString(RESPONSE_FIELDS[2], this@AsDroid.primaryFunction) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): AsDroid = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val primaryFunction = readString(RESPONSE_FIELDS[2]) - AsDroid( - __typename = __typename, - name = name, - primaryFunction = primaryFunction - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - val asHuman: AsHuman?, - val asDroid: AsDroid? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeFragment(this@Hero.asHuman?.marshaller()) - writer.writeFragment(this@Hero.asDroid?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid")) - )) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val asHuman = readFragment(RESPONSE_FIELDS[2]) { reader -> - AsHuman(reader) - } - val asDroid = readFragment(RESPONSE_FIELDS[3]) { reader -> - AsDroid(reader) - } - Hero( - __typename = __typename, - name = name, - asHuman = asHuman, - asDroid = asDroid - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - Data( - hero = hero - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "40e95b8824cd8b5da64969cc5fc32d89ee15fde55084fd41513967e521a8a687" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | hero { - | __typename - | name - | ... on Human { - | height - | } - | ... on Droid { - | primaryFunction - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/type/CustomType.java deleted file mode 100644 index 8df370403f2..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.simple_inline_fragment.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/type/CustomType.kt deleted file mode 100644 index 3081a546767..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/simple_inline_fragment/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.simple_inline_fragment.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/starships/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/starships/TestOperation.graphql deleted file mode 100644 index c07d57c788f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/starships/TestOperation.graphql +++ /dev/null @@ -1,8 +0,0 @@ -query TestQuery($id: ID!) { - starship(id: $id) { - id, - name, - coordinates - shieldLevel - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/starships/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/starships/TestQuery.java deleted file mode 100644 index ec48a08ef03..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/starships/TestQuery.java +++ /dev/null @@ -1,449 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.starships; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.starships.type.CustomType; -import java.io.IOException; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, TestQuery.Variables> { - public static final String OPERATION_ID = "d27812d04b877735a608f497de910d80edaa021cf018b2d9cb022c95fa1f90c7"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery($id: ID!) {\n" - + " starship(id: $id) {\n" - + " __typename\n" - + " id\n" - + " name\n" - + " coordinates\n" - + " shieldLevel\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final TestQuery.Variables variables; - - public TestQuery(@NotNull String id) { - Utils.checkNotNull(id, "id == null"); - variables = new TestQuery.Variables(id); - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public TestQuery.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - private @NotNull String id; - - Builder() { - } - - public Builder id(@NotNull String id) { - this.id = id; - return this; - } - - public TestQuery build() { - Utils.checkNotNull(id, "id == null"); - return new TestQuery(id); - } - } - - public static final class Variables extends Operation.Variables { - private final @NotNull String id; - - private final transient Map valueMap = new LinkedHashMap<>(); - - Variables(@NotNull String id) { - this.id = id; - this.valueMap.put("id", id); - } - - public @NotNull String id() { - return id; - } - - @Override - public Map valueMap() { - return Collections.unmodifiableMap(valueMap); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - writer.writeCustom("id", com.example.starships.type.CustomType.ID, id); - } - }; - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("starship", "starship", new UnmodifiableMapBuilder(1) - .put("id", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "id") - .build()) - .build(), true, Collections.emptyList()) - }; - - final Optional starship; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Starship starship) { - this.starship = Optional.fromNullable(starship); - } - - public Optional starship() { - return this.starship; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], starship.isPresent() ? starship.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "starship=" + starship - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.starship.equals(that.starship); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= starship.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Starship.Mapper starshipFieldMapper = new Starship.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Starship starship = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Starship read(ResponseReader reader) { - return starshipFieldMapper.map(reader); - } - }); - return new Data(starship); - } - } - } - - public static class Starship { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forList("coordinates", "coordinates", null, true, Collections.emptyList()), - ResponseField.forDouble("shieldLevel", "shieldLevel", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String id; - - final @NotNull String name; - - final Optional>> coordinates; - - final double shieldLevel; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Starship(@NotNull String __typename, @NotNull String id, @NotNull String name, - @Nullable List> coordinates, double shieldLevel) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.id = Utils.checkNotNull(id, "id == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.coordinates = Optional.fromNullable(coordinates); - this.shieldLevel = shieldLevel; - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The ID of the starship - */ - public @NotNull String id() { - return this.id; - } - - /** - * The name of the starship - */ - public @NotNull String name() { - return this.name; - } - - public Optional>> coordinates() { - return this.coordinates; - } - - public double shieldLevel() { - return this.shieldLevel; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[1], id); - writer.writeString($responseFields[2], name); - writer.writeList($responseFields[3], coordinates.isPresent() ? coordinates.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeList((List) item, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeDouble((Double) item); - } - } - }); - } - } - }); - writer.writeDouble($responseFields[4], shieldLevel); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Starship{" - + "__typename=" + __typename + ", " - + "id=" + id + ", " - + "name=" + name + ", " - + "coordinates=" + coordinates + ", " - + "shieldLevel=" + shieldLevel - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Starship) { - Starship that = (Starship) o; - return this.__typename.equals(that.__typename) - && this.id.equals(that.id) - && this.name.equals(that.name) - && this.coordinates.equals(that.coordinates) - && Double.doubleToLongBits(this.shieldLevel) == Double.doubleToLongBits(that.shieldLevel); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= id.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= coordinates.hashCode(); - h *= 1000003; - h ^= Double.valueOf(shieldLevel).hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Starship map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]); - final String name = reader.readString($responseFields[2]); - final List> coordinates = reader.readList($responseFields[3], new ResponseReader.ListReader>() { - @Override - public List read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readList(new ResponseReader.ListReader() { - @Override - public Double read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readDouble(); - } - }); - } - }); - final double shieldLevel = reader.readDouble($responseFields[4]); - return new Starship(__typename, id, name, coordinates, shieldLevel); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/starships/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/starships/TestQuery.kt deleted file mode 100644 index ebc1a2ad673..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/starships/TestQuery.kt +++ /dev/null @@ -1,218 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.starships - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.starships.type.CustomType -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.Double -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlin.collections.Map -import kotlin.jvm.Transient -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class TestQuery( - val id: String -) : Query { - @Transient - private val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = mutableMapOf().apply { - this["id"] = this@TestQuery.id - } - - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - writer.writeCustom("id", CustomType.ID, this@TestQuery.id) - } - } - - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = variables - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - data class Starship( - val __typename: String = "Starship", - /** - * The ID of the starship - */ - val id: String, - /** - * The name of the starship - */ - val name: String, - val coordinates: List>?, - val shieldLevel: Double - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Starship.__typename) - writer.writeCustom(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField, this@Starship.id) - writer.writeString(RESPONSE_FIELDS[2], this@Starship.name) - writer.writeList(RESPONSE_FIELDS[3], this@Starship.coordinates) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeList(value) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeDouble(value)} - } - } - } - writer.writeDouble(RESPONSE_FIELDS[4], this@Starship.shieldLevel) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forList("coordinates", "coordinates", null, true, null), - ResponseField.forDouble("shieldLevel", "shieldLevel", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Starship = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val id = readCustomType(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField)!! - val name = readString(RESPONSE_FIELDS[2])!! - val coordinates = readList>(RESPONSE_FIELDS[3]) { reader -> - reader.readList { reader -> - reader.readDouble() - }.map { it!! } - }?.map { it!! } - val shieldLevel = readDouble(RESPONSE_FIELDS[4])!! - Starship( - __typename = __typename, - id = id, - name = name, - coordinates = coordinates, - shieldLevel = shieldLevel - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val starship: Starship? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.starship?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("starship", "starship", mapOf( - "id" to mapOf( - "kind" to "Variable", - "variableName" to "id")), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val starship = readObject(RESPONSE_FIELDS[0]) { reader -> - Starship(reader) - } - Data( - starship = starship - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "d27812d04b877735a608f497de910d80edaa021cf018b2d9cb022c95fa1f90c7" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery(${'$'}id: ID!) { - | starship(id: ${'$'}id) { - | __typename - | id - | name - | coordinates - | shieldLevel - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/starships/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/starships/type/CustomType.java deleted file mode 100644 index 81ecdeeb8b9..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/starships/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.starships.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/starships/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/starships/type/CustomType.kt deleted file mode 100644 index 45740dba57b..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/starships/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.starships.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/subscriptions/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/subscriptions/TestOperation.graphql deleted file mode 100644 index 1727b6c7b46..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/subscriptions/TestOperation.graphql +++ /dev/null @@ -1,6 +0,0 @@ -subscription TestSubscription($repo: String!) { - commentAdded(repoFullName: $repo) { - id - content - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/graphql/com/example/subscriptions/TestSubscription.java b/apollo-compiler/src/test/graphql/com/example/subscriptions/TestSubscription.java deleted file mode 100644 index 34b08dfaf42..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/subscriptions/TestSubscription.java +++ /dev/null @@ -1,397 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.subscriptions; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.Subscription; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.Map; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestSubscription implements Subscription, TestSubscription.Variables> { - public static final String OPERATION_ID = "55460a650cce0aa4bb131446ec3e56225710e36940223934bee09e1723e41190"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "subscription TestSubscription($repo: String!) {\n" - + " commentAdded(repoFullName: $repo) {\n" - + " __typename\n" - + " id\n" - + " content\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestSubscription"; - } - }; - - private final TestSubscription.Variables variables; - - public TestSubscription(@NotNull String repo) { - Utils.checkNotNull(repo, "repo == null"); - variables = new TestSubscription.Variables(repo); - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestSubscription.Data data) { - return Optional.fromNullable(data); - } - - @Override - public TestSubscription.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) - throws IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) - throws IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - private @NotNull String repo; - - Builder() { - } - - public Builder repo(@NotNull String repo) { - this.repo = repo; - return this; - } - - public TestSubscription build() { - Utils.checkNotNull(repo, "repo == null"); - return new TestSubscription(repo); - } - } - - public static final class Variables extends Operation.Variables { - private final @NotNull String repo; - - private final transient Map valueMap = new LinkedHashMap<>(); - - Variables(@NotNull String repo) { - this.repo = repo; - this.valueMap.put("repo", repo); - } - - public @NotNull String repo() { - return repo; - } - - @Override - public Map valueMap() { - return Collections.unmodifiableMap(valueMap); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - writer.writeString("repo", repo); - } - }; - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("commentAdded", "commentAdded", new UnmodifiableMapBuilder(1) - .put("repoFullName", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "repo") - .build()) - .build(), true, Collections.emptyList()) - }; - - final Optional commentAdded; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable CommentAdded commentAdded) { - this.commentAdded = Optional.fromNullable(commentAdded); - } - - /** - * Subscription fires on every comment added - */ - public Optional commentAdded() { - return this.commentAdded; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], commentAdded.isPresent() ? commentAdded.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "commentAdded=" + commentAdded - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.commentAdded.equals(that.commentAdded); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= commentAdded.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final CommentAdded.Mapper commentAddedFieldMapper = new CommentAdded.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final CommentAdded commentAdded = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public CommentAdded read(ResponseReader reader) { - return commentAddedFieldMapper.map(reader); - } - }); - return new Data(commentAdded); - } - } - } - - /** - * A comment about an entry, submitted by a user - */ - public static class CommentAdded { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("id", "id", null, false, Collections.emptyList()), - ResponseField.forString("content", "content", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final int id; - - final @NotNull String content; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public CommentAdded(@NotNull String __typename, int id, @NotNull String content) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.id = id; - this.content = Utils.checkNotNull(content, "content == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The SQL ID of this entry - */ - public int id() { - return this.id; - } - - /** - * The text of the comment - */ - public @NotNull String content() { - return this.content; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], id); - writer.writeString($responseFields[2], content); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "CommentAdded{" - + "__typename=" + __typename + ", " - + "id=" + id + ", " - + "content=" + content - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof CommentAdded) { - CommentAdded that = (CommentAdded) o; - return this.__typename.equals(that.__typename) - && this.id == that.id - && this.content.equals(that.content); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= id; - h *= 1000003; - h ^= content.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public CommentAdded map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final int id = reader.readInt($responseFields[1]); - final String content = reader.readString($responseFields[2]); - return new CommentAdded(__typename, id, content); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/subscriptions/TestSubscription.kt b/apollo-compiler/src/test/graphql/com/example/subscriptions/TestSubscription.kt deleted file mode 100644 index 73b3fe38372..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/subscriptions/TestSubscription.kt +++ /dev/null @@ -1,199 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.subscriptions - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.Subscription -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.Map -import kotlin.jvm.Transient -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class TestSubscription( - val repo: String -) : Subscription { - @Transient - private val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = mutableMapOf().apply { - this["repo"] = this@TestSubscription.repo - } - - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - writer.writeString("repo", this@TestSubscription.repo) - } - } - - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = variables - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A comment about an entry, submitted by a user - */ - data class CommentAdded( - val __typename: String = "Comment", - /** - * The SQL ID of this entry - */ - val id: Int, - /** - * The text of the comment - */ - val content: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@CommentAdded.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@CommentAdded.id) - writer.writeString(RESPONSE_FIELDS[2], this@CommentAdded.content) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("id", "id", null, false, null), - ResponseField.forString("content", "content", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): CommentAdded = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val id = readInt(RESPONSE_FIELDS[1])!! - val content = readString(RESPONSE_FIELDS[2])!! - CommentAdded( - __typename = __typename, - id = id, - content = content - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - /** - * Subscription fires on every comment added - */ - val commentAdded: CommentAdded? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.commentAdded?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("commentAdded", "commentAdded", mapOf( - "repoFullName" to mapOf( - "kind" to "Variable", - "variableName" to "repo")), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val commentAdded = readObject(RESPONSE_FIELDS[0]) { reader -> - CommentAdded(reader) - } - Data( - commentAdded = commentAdded - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "55460a650cce0aa4bb131446ec3e56225710e36940223934bee09e1723e41190" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |subscription TestSubscription(${'$'}repo: String!) { - | commentAdded(repoFullName: ${'$'}repo) { - | __typename - | id - | content - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestSubscription" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/subscriptions/schema.sdl b/apollo-compiler/src/test/graphql/com/example/subscriptions/schema.sdl deleted file mode 100644 index f2bc23e3e6f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/subscriptions/schema.sdl +++ /dev/null @@ -1,178 +0,0 @@ -"""A comment about an entry, submitted by a user""" -type Comment { - """The text of the comment""" - content: String! - - """A timestamp of when the comment was posted""" - createdAt: Float! - - """The SQL ID of this entry""" - id: Int! - - """The GitHub user who posted the comment""" - postedBy: User - - """The repository which this comment is about""" - repoName: String! -} - -"""Information about a GitHub repository submitted to GitHunt""" -type Entry { - """The number of comments posted about this repository""" - commentCount: Int! - - """Comments posted about this repository""" - comments(limit: Int, offset: Int): [Comment]! - - """A timestamp of when the entry was submitted""" - createdAt: Float! - - """The hot score of this repository""" - hotScore: Float! - - """The SQL ID of this entry""" - id: Int! - - """The GitHub user who submitted this entry""" - postedBy: User - - """Information about the repository from GitHub""" - repository: Repository - - """The score of this repository, upvotes - downvotes""" - score: Int! - - """XXX to be changed""" - vote: Vote! -} - -"""A list of options for the sort order of the feed""" -enum FeedType { - """Sort by a combination of freshness and score, using Reddit's algorithm""" - HOT - - """Newest entries first""" - NEW - - """Highest score entries first""" - TOP -} - -type Mutation { - """Comment on a repository, returns the new comment""" - submitComment( - """ - The full repository name from GitHub, e.g. "apollostack/GitHunt-API" - """ - repoFullName: String! - - """The text content for the new comment""" - commentContent: String! - ): Comment - - """Submit a new repository, returns the new submission""" - submitRepository( - """ - The full repository name from GitHub, e.g. "apollostack/GitHunt-API" - """ - repoFullName: String! - ): Entry - - """ - Vote on a repository submission, returns the submission that was voted on - """ - vote( - """ - The full repository name from GitHub, e.g. "apollostack/GitHunt-API" - """ - repoFullName: String! - - """The type of vote - UP, DOWN, or CANCEL""" - type: VoteType! - ): Entry -} - -type Query { - """Return the currently logged in user, or null if nobody is logged in""" - currentUser: User - - """A single entry""" - entry( - """ - The full repository name from GitHub, e.g. "apollostack/GitHunt-API" - """ - repoFullName: String! - ): Entry - - """A feed of repository submissions""" - feed( - """The sort order for the feed""" - type: FeedType! - - """The number of items to skip, for pagination""" - offset: Int - - """The number of items to fetch starting from the offset, for pagination""" - limit: Int - ): [Entry] -} - -""" -A repository object from the GitHub API. This uses the exact field names returned by the -GitHub API for simplicity, even though the convention for GraphQL is usually to camel case. -""" -type Repository { - """The description of the repository""" - description: String - - """ - The full name of the repository with the username, e.g. apollostack/GitHunt-API - """ - full_name: String! - - """The link to the repository on GitHub""" - html_url: String! - - """Just the name of the repository, e.g. GitHunt-API""" - name: String! - - """The number of open issues on this repository on GitHub""" - open_issues_count: Int - - """The owner of this repository on GitHub, e.g. apollostack""" - owner: User - - """The number of people who have starred this repository on GitHub""" - stargazers_count: Int! -} - -type Subscription { - """Subscription fires on every comment added""" - commentAdded(repoFullName: String!): Comment -} - -""" -A user object from the GitHub API. This uses the exact field names returned from the GitHub API. -""" -type User { - """The URL to a directly embeddable image for this user's avatar""" - avatar_url: String! - - """The URL of this user's GitHub page""" - html_url: String! - - """The name of the user, e.g. apollostack""" - login: String! -} - -"""XXX to be removed""" -type Vote { - vote_value: Int! -} - -"""The type of vote to record, when submitting a vote""" -enum VoteType { - UP - DOWN - CANCEL -} diff --git a/apollo-compiler/src/test/graphql/com/example/subscriptions/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/subscriptions/type/CustomType.java deleted file mode 100644 index 07c2bedfca8..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/subscriptions/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.subscriptions.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/subscriptions/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/subscriptions/type/CustomType.kt deleted file mode 100644 index 6c93ce5cd95..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/subscriptions/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.subscriptions.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/test_inline/GetPage.kt b/apollo-compiler/src/test/graphql/com/example/test_inline/GetPage.kt deleted file mode 100644 index 81db0af9302..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/test_inline/GetPage.kt +++ /dev/null @@ -1,330 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.test_inline - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class GetPage : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - interface CollectionCollection { - fun marshaller(): ResponseFieldMarshaller - } - - interface ItemItem { - fun marshaller(): ResponseFieldMarshaller - } - - data class AsParticularItem( - val __typename: String = "ParticularItem", - val image: String - ) : ItemItem { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsParticularItem.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsParticularItem.image) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("image", "image", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): AsParticularItem = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val image = readString(RESPONSE_FIELDS[1])!! - AsParticularItem( - __typename = __typename, - image = image - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - data class Item( - val __typename: String = "Item", - val title: String, - val asParticularItem: AsParticularItem? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Item.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Item.title) - writer.writeFragment(this@Item.asParticularItem?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("title", "title", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("ParticularItem")) - )) - ) - - operator fun invoke(reader: ResponseReader): Item = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val title = readString(RESPONSE_FIELDS[1])!! - val asParticularItem = readFragment(RESPONSE_FIELDS[2]) { reader -> - AsParticularItem(reader) - } - Item( - __typename = __typename, - title = title, - asParticularItem = asParticularItem - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - data class AsParticularCollection( - val __typename: String = "ParticularCollection", - val items: List - ) : CollectionCollection { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsParticularCollection.__typename) - writer.writeList(RESPONSE_FIELDS[1], this@AsParticularCollection.items) { value, - listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value.marshaller())} - } - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forList("items", "items", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): AsParticularCollection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val items = readList(RESPONSE_FIELDS[1]) { reader -> - reader.readObject { reader -> - Item(reader) - } - }!!.map { it!! } - AsParticularCollection( - __typename = __typename, - items = items - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - data class Item1( - val __typename: String = "Item", - val title: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Item1.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Item1.title) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("title", "title", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Item1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val title = readString(RESPONSE_FIELDS[1])!! - Item1( - __typename = __typename, - title = title - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - data class Collection( - val __typename: String = "Collection", - val items: List, - val asParticularCollection: AsParticularCollection? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Collection.__typename) - writer.writeList(RESPONSE_FIELDS[1], this@Collection.items) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value.marshaller())} - } - writer.writeFragment(this@Collection.asParticularCollection?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forList("items", "items", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("ParticularCollection")) - )) - ) - - operator fun invoke(reader: ResponseReader): Collection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val items = readList(RESPONSE_FIELDS[1]) { reader -> - reader.readObject { reader -> - Item1(reader) - } - }!!.map { it!! } - val asParticularCollection = readFragment(RESPONSE_FIELDS[2]) { - reader -> - AsParticularCollection(reader) - } - Collection( - __typename = __typename, - items = items, - asParticularCollection = asParticularCollection - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val collection: Collection - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.collection.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("collection", "collection", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val collection = readObject(RESPONSE_FIELDS[0]) { reader -> - Collection(reader) - }!! - Data( - collection = collection - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "09c2f7755e4c0be866863ec0d0af37acd3cdedf89bb6384d838019477611707e" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query GetPage { - | collection { - | __typename - | items { - | __typename - | title - | } - | ... on ParticularCollection { - | items { - | __typename - | ... on ParticularItem { - | image - | } - | } - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "GetPage" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/test_inline/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/test_inline/TestOperation.graphql deleted file mode 100644 index e66a46238d7..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/test_inline/TestOperation.graphql +++ /dev/null @@ -1,15 +0,0 @@ -query GetPage { - collection { - items { - title - } - ... on ParticularCollection { - items { - ... on ParticularItem { - image - } - } - } - } -} - diff --git a/apollo-compiler/src/test/graphql/com/example/test_inline/schema.sdl b/apollo-compiler/src/test/graphql/com/example/test_inline/schema.sdl deleted file mode 100644 index aff92815a52..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/test_inline/schema.sdl +++ /dev/null @@ -1,26 +0,0 @@ -type Query { - collection: Collection! -} - -interface Collection { - items: [Item!]! -} - -type ParticularCollection implements Collection { - items: [Item!]! -} - -interface Item { - title: String! - description: String! -} - -type ParticularItem implements Item { - title: String! - image: String! -} - -type GenericItem implements Item { - title: String! - genericField: String! -} diff --git a/apollo-compiler/src/test/graphql/com/example/test_inline/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/test_inline/type/CustomType.kt deleted file mode 100644 index 5fe462ecc2f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/test_inline/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.test_inline.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/two_heroes_unique/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/two_heroes_unique/TestOperation.graphql deleted file mode 100644 index 7c3d9d1510f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/two_heroes_unique/TestOperation.graphql +++ /dev/null @@ -1,9 +0,0 @@ -query TestQuery { - r2: hero { - name - } - luke: hero(episode: EMPIRE) { - id - name - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/two_heroes_unique/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/two_heroes_unique/TestQuery.java deleted file mode 100644 index 58fefb39bff..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/two_heroes_unique/TestQuery.java +++ /dev/null @@ -1,468 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.two_heroes_unique; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.two_heroes_unique.type.CustomType; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "266f79f66749232e217afd9b47a628fd7096d4c48345bc245a7f63105be9e75d"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " r2: hero {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " luke: hero(episode: EMPIRE) {\n" - + " __typename\n" - + " id\n" - + " name\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("r2", "hero", null, true, Collections.emptyList()), - ResponseField.forObject("luke", "hero", new UnmodifiableMapBuilder(1) - .put("episode", "EMPIRE") - .build(), true, Collections.emptyList()) - }; - - final Optional r2; - - final Optional luke; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable R2 r2, @Nullable Luke luke) { - this.r2 = Optional.fromNullable(r2); - this.luke = Optional.fromNullable(luke); - } - - public Optional r2() { - return this.r2; - } - - public Optional luke() { - return this.luke; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], r2.isPresent() ? r2.get().marshaller() : null); - writer.writeObject($responseFields[1], luke.isPresent() ? luke.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "r2=" + r2 + ", " - + "luke=" + luke - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.r2.equals(that.r2) - && this.luke.equals(that.luke); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= r2.hashCode(); - h *= 1000003; - h ^= luke.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final R2.Mapper r2FieldMapper = new R2.Mapper(); - - final Luke.Mapper lukeFieldMapper = new Luke.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final R2 r2 = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public R2 read(ResponseReader reader) { - return r2FieldMapper.map(reader); - } - }); - final Luke luke = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Luke read(ResponseReader reader) { - return lukeFieldMapper.map(reader); - } - }); - return new Data(r2, luke); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class R2 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public R2(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "R2{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof R2) { - R2 that = (R2) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public R2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new R2(__typename, name); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Luke { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String id; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Luke(@NotNull String __typename, @NotNull String id, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.id = Utils.checkNotNull(id, "id == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The ID of the character - */ - public @NotNull String id() { - return this.id; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[1], id); - writer.writeString($responseFields[2], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Luke{" - + "__typename=" + __typename + ", " - + "id=" + id + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Luke) { - Luke that = (Luke) o; - return this.__typename.equals(that.__typename) - && this.id.equals(that.id) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= id.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Luke map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]); - final String name = reader.readString($responseFields[2]); - return new Luke(__typename, id, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/two_heroes_unique/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/two_heroes_unique/TestQuery.kt deleted file mode 100644 index d1cf9b92577..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/two_heroes_unique/TestQuery.kt +++ /dev/null @@ -1,223 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.two_heroes_unique - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.two_heroes_unique.type.CustomType -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class R2( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@R2.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@R2.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): R2 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - R2( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Luke( - val __typename: String = "Character", - /** - * The ID of the character - */ - val id: String, - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Luke.__typename) - writer.writeCustom(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField, this@Luke.id) - writer.writeString(RESPONSE_FIELDS[2], this@Luke.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Luke = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val id = readCustomType(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField)!! - val name = readString(RESPONSE_FIELDS[2])!! - Luke( - __typename = __typename, - id = id, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val r2: R2?, - val luke: Luke? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.r2?.marshaller()) - writer.writeObject(RESPONSE_FIELDS[1], this@Data.luke?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("r2", "hero", null, true, null), - ResponseField.forObject("luke", "hero", mapOf( - "episode" to "EMPIRE"), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val r2 = readObject(RESPONSE_FIELDS[0]) { reader -> - R2(reader) - } - val luke = readObject(RESPONSE_FIELDS[1]) { reader -> - Luke(reader) - } - Data( - r2 = r2, - luke = luke - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "266f79f66749232e217afd9b47a628fd7096d4c48345bc245a7f63105be9e75d" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | r2: hero { - | __typename - | name - | } - | luke: hero(episode: EMPIRE) { - | __typename - | id - | name - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/two_heroes_unique/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/two_heroes_unique/type/CustomType.java deleted file mode 100644 index e53876ea86a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/two_heroes_unique/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.two_heroes_unique.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/two_heroes_unique/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/two_heroes_unique/type/CustomType.kt deleted file mode 100644 index 71661925e66..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/two_heroes_unique/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.two_heroes_unique.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/two_heroes_with_friends/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/two_heroes_with_friends/TestOperation.graphql deleted file mode 100644 index ec9fbeefc37..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/two_heroes_with_friends/TestOperation.graphql +++ /dev/null @@ -1,25 +0,0 @@ -query TestQuery { - r2: hero { - name - friendsConnection { - totalCount - edges { - node { - name - } - } - } - } - luke: hero(episode: EMPIRE) { - id - name - friendsConnection { - totalCount - edges { - node { - name - } - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/two_heroes_with_friends/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/two_heroes_with_friends/TestQuery.java deleted file mode 100644 index 4d82394efc0..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/two_heroes_with_friends/TestQuery.java +++ /dev/null @@ -1,1194 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.two_heroes_with_friends; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.two_heroes_with_friends.type.CustomType; -import java.io.IOException; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "21133941aec3d5db7db82cc2688faa410a90b34e7cb283efa038fe67526b6b4b"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " r2: hero {\n" - + " __typename\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + " luke: hero(episode: EMPIRE) {\n" - + " __typename\n" - + " id\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("r2", "hero", null, true, Collections.emptyList()), - ResponseField.forObject("luke", "hero", new UnmodifiableMapBuilder(1) - .put("episode", "EMPIRE") - .build(), true, Collections.emptyList()) - }; - - final Optional r2; - - final Optional luke; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable R2 r2, @Nullable Luke luke) { - this.r2 = Optional.fromNullable(r2); - this.luke = Optional.fromNullable(luke); - } - - public Optional r2() { - return this.r2; - } - - public Optional luke() { - return this.luke; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], r2.isPresent() ? r2.get().marshaller() : null); - writer.writeObject($responseFields[1], luke.isPresent() ? luke.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "r2=" + r2 + ", " - + "luke=" + luke - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.r2.equals(that.r2) - && this.luke.equals(that.luke); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= r2.hashCode(); - h *= 1000003; - h ^= luke.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final R2.Mapper r2FieldMapper = new R2.Mapper(); - - final Luke.Mapper lukeFieldMapper = new Luke.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final R2 r2 = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public R2 read(ResponseReader reader) { - return r2FieldMapper.map(reader); - } - }); - final Luke luke = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Luke read(ResponseReader reader) { - return lukeFieldMapper.map(reader); - } - }); - return new Data(r2, luke); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class R2 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull FriendsConnection friendsConnection; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public R2(@NotNull String __typename, @NotNull String name, - @NotNull FriendsConnection friendsConnection) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The friends of the character exposed as a connection with edges - */ - public @NotNull FriendsConnection friendsConnection() { - return this.friendsConnection; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeObject($responseFields[2], friendsConnection.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "R2{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof R2) { - R2 that = (R2) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection.Mapper friendsConnectionFieldMapper = new FriendsConnection.Mapper(); - - @Override - public R2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final FriendsConnection friendsConnection = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection read(ResponseReader reader) { - return friendsConnectionFieldMapper.map(reader); - } - }); - return new R2(__typename, name, friendsConnection); - } - } - } - - /** - * A connection object for a character's friends - */ - public static class FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - final Optional> edges; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection(@NotNull String __typename, @Nullable Integer totalCount, - @Nullable List edges) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.fromNullable(totalCount); - this.edges = Optional.fromNullable(edges); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional totalCount() { - return this.totalCount; - } - - /** - * The edges for each of the character's friends. - */ - public Optional> edges() { - return this.edges; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - writer.writeList($responseFields[2], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount + ", " - + "edges=" + edges - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection) { - FriendsConnection that = (FriendsConnection) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount) - && this.edges.equals(that.edges); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge.Mapper edgeFieldMapper = new Edge.Mapper(); - - @Override - public FriendsConnection map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - final List edges = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Edge read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge read(ResponseReader reader) { - return edgeFieldMapper.map(reader); - } - }); - } - }); - return new FriendsConnection(__typename, totalCount, edges); - } - } - } - - /** - * An edge object for a character's friends - */ - public static class Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge(@NotNull String __typename, @Nullable Node node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.fromNullable(node); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The character represented by this friendship edge - */ - public Optional node() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge) { - Edge that = (Edge) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Node.Mapper nodeFieldMapper = new Node.Mapper(); - - @Override - public Edge map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node read(ResponseReader reader) { - return nodeFieldMapper.map(reader); - } - }); - return new Edge(__typename, node); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node) { - Node that = (Node) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Node map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Node(__typename, name); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Luke { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String id; - - final @NotNull String name; - - final @NotNull FriendsConnection1 friendsConnection; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Luke(@NotNull String __typename, @NotNull String id, @NotNull String name, - @NotNull FriendsConnection1 friendsConnection) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.id = Utils.checkNotNull(id, "id == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The ID of the character - */ - public @NotNull String id() { - return this.id; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The friends of the character exposed as a connection with edges - */ - public @NotNull FriendsConnection1 friendsConnection() { - return this.friendsConnection; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[1], id); - writer.writeString($responseFields[2], name); - writer.writeObject($responseFields[3], friendsConnection.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Luke{" - + "__typename=" + __typename + ", " - + "id=" + id + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Luke) { - Luke that = (Luke) o; - return this.__typename.equals(that.__typename) - && this.id.equals(that.id) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= id.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection1.Mapper friendsConnection1FieldMapper = new FriendsConnection1.Mapper(); - - @Override - public Luke map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]); - final String name = reader.readString($responseFields[2]); - final FriendsConnection1 friendsConnection = reader.readObject($responseFields[3], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection1 read(ResponseReader reader) { - return friendsConnection1FieldMapper.map(reader); - } - }); - return new Luke(__typename, id, name, friendsConnection); - } - } - } - - /** - * A connection object for a character's friends - */ - public static class FriendsConnection1 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - final Optional> edges; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection1(@NotNull String __typename, @Nullable Integer totalCount, - @Nullable List edges) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.fromNullable(totalCount); - this.edges = Optional.fromNullable(edges); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional totalCount() { - return this.totalCount; - } - - /** - * The edges for each of the character's friends. - */ - public Optional> edges() { - return this.edges; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - writer.writeList($responseFields[2], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge1) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection1{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount + ", " - + "edges=" + edges - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection1) { - FriendsConnection1 that = (FriendsConnection1) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount) - && this.edges.equals(that.edges); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge1.Mapper edge1FieldMapper = new Edge1.Mapper(); - - @Override - public FriendsConnection1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - final List edges = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Edge1 read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge1 read(ResponseReader reader) { - return edge1FieldMapper.map(reader); - } - }); - } - }); - return new FriendsConnection1(__typename, totalCount, edges); - } - } - } - - /** - * An edge object for a character's friends - */ - public static class Edge1 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge1(@NotNull String __typename, @Nullable Node1 node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.fromNullable(node); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The character represented by this friendship edge - */ - public Optional node() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge1{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge1) { - Edge1 that = (Edge1) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Node1.Mapper node1FieldMapper = new Node1.Mapper(); - - @Override - public Edge1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node1 node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node1 read(ResponseReader reader) { - return node1FieldMapper.map(reader); - } - }); - return new Edge1(__typename, node); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Node1 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node1(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node1{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node1) { - Node1 that = (Node1) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Node1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Node1(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/two_heroes_with_friends/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/two_heroes_with_friends/TestQuery.kt deleted file mode 100644 index 571f2fc9d77..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/two_heroes_with_friends/TestQuery.kt +++ /dev/null @@ -1,515 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.two_heroes_with_friends - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.two_heroes_with_friends.type.CustomType -import kotlin.Array -import kotlin.Boolean -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - /** - * A character from the Star Wars universe - */ - data class Node( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Node.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Node( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An edge object for a character's friends - */ - data class Edge( - val __typename: String = "FriendsEdge", - /** - * The character represented by this friendship edge - */ - val node: Node? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node(reader) - } - Edge( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int?, - /** - * The edges for each of the character's friends. - */ - val edges: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection.totalCount) - writer.writeList(RESPONSE_FIELDS[2], this@FriendsConnection.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null), - ResponseField.forList("edges", "edges", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - val edges = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Edge(reader) - } - } - FriendsConnection( - __typename = __typename, - totalCount = totalCount, - edges = edges - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class R2( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The friends of the character exposed as a connection with edges - */ - val friendsConnection: FriendsConnection - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@R2.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@R2.name) - writer.writeObject(RESPONSE_FIELDS[2], this@R2.friendsConnection.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): R2 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friendsConnection = readObject(RESPONSE_FIELDS[2]) { reader -> - FriendsConnection(reader) - }!! - R2( - __typename = __typename, - name = name, - friendsConnection = friendsConnection - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Node1( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node1.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Node1.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Node1( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An edge object for a character's friends - */ - data class Edge1( - val __typename: String = "FriendsEdge", - /** - * The character represented by this friendship edge - */ - val node: Node1? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge1.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge1.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node1(reader) - } - Edge1( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection1( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int?, - /** - * The edges for each of the character's friends. - */ - val edges: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection1.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection1.totalCount) - writer.writeList(RESPONSE_FIELDS[2], this@FriendsConnection1.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null), - ResponseField.forList("edges", "edges", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - val edges = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Edge1(reader) - } - } - FriendsConnection1( - __typename = __typename, - totalCount = totalCount, - edges = edges - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Luke( - val __typename: String = "Character", - /** - * The ID of the character - */ - val id: String, - /** - * The name of the character - */ - val name: String, - /** - * The friends of the character exposed as a connection with edges - */ - val friendsConnection: FriendsConnection1 - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Luke.__typename) - writer.writeCustom(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField, this@Luke.id) - writer.writeString(RESPONSE_FIELDS[2], this@Luke.name) - writer.writeObject(RESPONSE_FIELDS[3], this@Luke.friendsConnection.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Luke = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val id = readCustomType(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField)!! - val name = readString(RESPONSE_FIELDS[2])!! - val friendsConnection = readObject(RESPONSE_FIELDS[3]) { reader -> - FriendsConnection1(reader) - }!! - Luke( - __typename = __typename, - id = id, - name = name, - friendsConnection = friendsConnection - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val r2: R2?, - val luke: Luke? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.r2?.marshaller()) - writer.writeObject(RESPONSE_FIELDS[1], this@Data.luke?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("r2", "hero", null, true, null), - ResponseField.forObject("luke", "hero", mapOf( - "episode" to "EMPIRE"), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val r2 = readObject(RESPONSE_FIELDS[0]) { reader -> - R2(reader) - } - val luke = readObject(RESPONSE_FIELDS[1]) { reader -> - Luke(reader) - } - Data( - r2 = r2, - luke = luke - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "21133941aec3d5db7db82cc2688faa410a90b34e7cb283efa038fe67526b6b4b" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | r2: hero { - | __typename - | name - | friendsConnection { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | } - | } - | luke: hero(episode: EMPIRE) { - | __typename - | id - | name - | friendsConnection { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/two_heroes_with_friends/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/two_heroes_with_friends/type/CustomType.java deleted file mode 100644 index 1736aa40320..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/two_heroes_with_friends/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.two_heroes_with_friends.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/two_heroes_with_friends/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/two_heroes_with_friends/type/CustomType.kt deleted file mode 100644 index 4e47faa0655..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/two_heroes_with_friends/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.two_heroes_with_friends.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_fragment/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/union_fragment/TestOperation.graphql deleted file mode 100644 index f77c81a5dbf..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_fragment/TestOperation.graphql +++ /dev/null @@ -1,15 +0,0 @@ -query TestQuery { - search(text: "test") { - ...Character - ...Starship - } -} - -fragment Character on Character { - id - name -} - -fragment Starship on Starship { - name -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_fragment/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/union_fragment/TestQuery.java deleted file mode 100644 index 07e1ea58eff..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_fragment/TestQuery.java +++ /dev/null @@ -1,460 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.union_fragment; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.union_fragment.fragment.Character; -import com.example.union_fragment.fragment.Starship; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query { - public static final String OPERATION_ID = "de57eb41c200d48c0f6c508ebf5b4d23b8edd06c6cea371db90ac8160f911b1f"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " search(text: \"test\") {\n" - + " __typename\n" - + " ...Character\n" - + " ...Starship\n" - + " }\n" - + "}\n" - + "fragment Character on Character {\n" - + " __typename\n" - + " id\n" - + " name\n" - + "}\n" - + "fragment Starship on Starship {\n" - + " __typename\n" - + " name\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public TestQuery.Data wrapData(TestQuery.Data data) { - return data; - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response parse(@NotNull final BufferedSource source) throws IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response parse(@NotNull final ByteString byteString) throws IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forList("search", "search", new UnmodifiableMapBuilder(1) - .put("text", "test") - .build(), true, Collections.emptyList()) - }; - - final @Nullable List search; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable List search) { - this.search = search; - } - - public @Nullable List search() { - return this.search; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeList($responseFields[0], search, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Search) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "search=" + search - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return ((this.search == null) ? (that.search == null) : this.search.equals(that.search)); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= (search == null) ? 0 : search.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Search.Mapper searchFieldMapper = new Search.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final List search = reader.readList($responseFields[0], new ResponseReader.ListReader() { - @Override - public Search read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Search read(ResponseReader reader) { - return searchFieldMapper.map(reader); - } - }); - } - }); - return new Data(search); - } - } - } - - public static class Search { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Search(@NotNull String __typename, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Search{" - + "__typename=" + __typename + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Search) { - Search that = (Search) o; - return this.__typename.equals(that.__typename) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @Nullable Character character; - - final @Nullable Starship starship; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@Nullable Character character, @Nullable Starship starship) { - this.character = character; - this.starship = starship; - } - - public @Nullable Character character() { - return this.character; - } - - public @Nullable Starship starship() { - return this.starship; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - final Character $character = character; - if ($character != null) { - writer.writeFragment($character.marshaller()); - } - final Starship $starship = starship; - if ($starship != null) { - writer.writeFragment($starship.marshaller()); - } - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "character=" + character + ", " - + "starship=" + starship - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return ((this.character == null) ? (that.character == null) : this.character.equals(that.character)) - && ((this.starship == null) ? (that.starship == null) : this.starship.equals(that.starship)); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= (character == null) ? 0 : character.hashCode(); - h *= 1000003; - h ^= (starship == null) ? 0 : starship.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid", "Human"}) - )), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Starship"}) - )) - }; - - final Character.Mapper characterFieldMapper = new Character.Mapper(); - - final Starship.Mapper starshipFieldMapper = new Starship.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final Character character = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Character read(ResponseReader reader) { - return characterFieldMapper.map(reader); - } - }); - final Starship starship = reader.readFragment($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Starship read(ResponseReader reader) { - return starshipFieldMapper.map(reader); - } - }); - return new Fragments(character, starship); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Search map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Search(__typename, fragments); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_fragment/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/union_fragment/TestQuery.kt deleted file mode 100644 index d3549b3dd70..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_fragment/TestQuery.kt +++ /dev/null @@ -1,218 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.union_fragment - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.union_fragment.fragment.Character -import com.example.union_fragment.fragment.Starship -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - data class Search( - val __typename: String = "SearchResult", - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Search.__typename) - this@Search.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Search = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val fragments = Fragments(reader) - Search( - __typename = __typename, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val character: Character?, - val starship: Starship? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.character?.marshaller()) - writer.writeFragment(this@Fragments.starship?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid", "Human")) - )), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Starship")) - )) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val character = readFragment(RESPONSE_FIELDS[0]) { reader -> - Character(reader) - } - val starship = readFragment(RESPONSE_FIELDS[1]) { reader -> - Starship(reader) - } - Fragments( - character = character, - starship = starship - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val search: List? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeList(RESPONSE_FIELDS[0], this@Data.search) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun searchFilterNotNull(): List? = search?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forList("search", "search", mapOf( - "text" to "test"), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val search = readList(RESPONSE_FIELDS[0]) { reader -> - reader.readObject { reader -> - Search(reader) - } - } - Data( - search = search - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "de57eb41c200d48c0f6c508ebf5b4d23b8edd06c6cea371db90ac8160f911b1f" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | search(text: "test") { - | __typename - | ...Character - | ...Starship - | } - |} - |fragment Character on Character { - | __typename - | id - | name - |} - |fragment Starship on Starship { - | __typename - | name - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_fragment/fragment/Character.java b/apollo-compiler/src/test/graphql/com/example/union_fragment/fragment/Character.java deleted file mode 100644 index d517a2d6372..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_fragment/fragment/Character.java +++ /dev/null @@ -1,135 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.union_fragment.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import com.example.union_fragment.type.CustomType; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; - -public class Character implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment Character on Character {\n" - + " __typename\n" - + " id\n" - + " name\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String id; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Character(@NotNull String __typename, @NotNull String id, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.id = Utils.checkNotNull(id, "id == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The ID of the character - */ - public @NotNull String id() { - return this.id; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[1], id); - writer.writeString($responseFields[2], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Character{" - + "__typename=" + __typename + ", " - + "id=" + id + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Character) { - Character that = (Character) o; - return this.__typename.equals(that.__typename) - && this.id.equals(that.id) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= id.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Character map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]); - final String name = reader.readString($responseFields[2]); - return new Character(__typename, id, name); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_fragment/fragment/Character.kt b/apollo-compiler/src/test/graphql/com/example/union_fragment/fragment/Character.kt deleted file mode 100644 index 77fc7e8a60e..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_fragment/fragment/Character.kt +++ /dev/null @@ -1,66 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.union_fragment.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.example.union_fragment.type.CustomType -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class Character( - val __typename: String = "Character", - /** - * The ID of the character - */ - val id: String, - /** - * The name of the character - */ - val name: String -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Character.__typename) - writer.writeCustom(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField, this@Character.id) - writer.writeString(RESPONSE_FIELDS[2], this@Character.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, null), - ResponseField.forString("name", "name", null, false, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment Character on Character { - | __typename - | id - | name - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): Character = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val id = readCustomType(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField)!! - val name = readString(RESPONSE_FIELDS[2])!! - Character( - __typename = __typename, - id = id, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_fragment/fragment/Starship.java b/apollo-compiler/src/test/graphql/com/example/union_fragment/fragment/Starship.java deleted file mode 100644 index 7d564983733..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_fragment/fragment/Starship.java +++ /dev/null @@ -1,116 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.union_fragment.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import org.jetbrains.annotations.NotNull; - -public class Starship implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment Starship on Starship {\n" - + " __typename\n" - + " name\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Starship(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the starship - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Starship{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Starship) { - Starship that = (Starship) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Starship map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Starship(__typename, name); - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_fragment/fragment/Starship.kt b/apollo-compiler/src/test/graphql/com/example/union_fragment/fragment/Starship.kt deleted file mode 100644 index 703e279bf48..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_fragment/fragment/Starship.kt +++ /dev/null @@ -1,56 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.union_fragment.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.String -import kotlin.Suppress - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class Starship( - val __typename: String = "Starship", - /** - * The name of the starship - */ - val name: String -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Starship.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Starship.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment Starship on Starship { - | __typename - | name - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): Starship = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Starship( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_fragment/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/union_fragment/type/CustomType.java deleted file mode 100644 index 0ae8a0af35a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_fragment/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.union_fragment.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_fragment/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/union_fragment/type/CustomType.kt deleted file mode 100644 index 53968de5c61..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_fragment/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.union_fragment.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/TestOperation.graphql deleted file mode 100644 index c56ab26151a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/TestOperation.graphql +++ /dev/null @@ -1,30 +0,0 @@ -query TestQuery { - search(text: "test") { - ... on Character { - id - name - friends { - ... on Character { - name - } - ... on Human { - homePlanet - friends { - ... on Character { - firstAppearsIn - } - } - } - ... on Droid { - primaryFunction - friends { - id - } - } - } - } - ... on Starship { - name - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/TestQuery.java b/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/TestQuery.java deleted file mode 100644 index 5225834d32a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/TestQuery.java +++ /dev/null @@ -1,1319 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.union_inline_fragments; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.union_inline_fragments.type.CustomType; -import com.example.union_inline_fragments.type.Episode; -import java.io.IOException; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class TestQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "5450032fd838d0216d8b419846d25e09f98228b403e520aacd7eb68cd838f4da"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query TestQuery {\n" - + " search(text: \"test\") {\n" - + " __typename\n" - + " ... on Character {\n" - + " id\n" - + " name\n" - + " friends {\n" - + " __typename\n" - + " ... on Character {\n" - + " name\n" - + " }\n" - + " ... on Human {\n" - + " homePlanet\n" - + " friends {\n" - + " __typename\n" - + " ... on Character {\n" - + " firstAppearsIn\n" - + " }\n" - + " }\n" - + " }\n" - + " ... on Droid {\n" - + " primaryFunction\n" - + " friends {\n" - + " __typename\n" - + " id\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + " ... on Starship {\n" - + " name\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "TestQuery"; - } - }; - - private final Operation.Variables variables; - - public TestQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(TestQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public TestQuery build() { - return new TestQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forList("search", "search", new UnmodifiableMapBuilder(1) - .put("text", "test") - .build(), true, Collections.emptyList()) - }; - - final Optional> search; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable List search) { - this.search = Optional.fromNullable(search); - } - - public Optional> search() { - return this.search; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeList($responseFields[0], search.isPresent() ? search.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Search) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "search=" + search - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.search.equals(that.search); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= search.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Search.Mapper searchFieldMapper = new Search.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final List search = reader.readList($responseFields[0], new ResponseReader.ListReader() { - @Override - public Search read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Search read(ResponseReader reader) { - return searchFieldMapper.map(reader); - } - }); - } - }); - return new Data(search); - } - } - } - - public interface Search { - @NotNull String __typename(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsCharacter) { - return visitor.visit((AsCharacter) this); - } else if (this instanceof AsStarship) { - return visitor.visit((AsStarship) this); - } else if (this instanceof AsSearchResult) { - return visitor.visit((AsSearchResult) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid", "Human"}) - )), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Starship"}) - )) - }; - - final AsCharacter.Mapper asCharacterFieldMapper = new AsCharacter.Mapper(); - - final AsStarship.Mapper asStarshipFieldMapper = new AsStarship.Mapper(); - - final AsSearchResult.Mapper asSearchResultFieldMapper = new AsSearchResult.Mapper(); - - @Override - public Search map(ResponseReader reader) { - final AsCharacter asCharacter = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsCharacter read(ResponseReader reader) { - return asCharacterFieldMapper.map(reader); - } - }); - if (asCharacter != null) { - return asCharacter; - } - final AsStarship asStarship = reader.readFragment($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public AsStarship read(ResponseReader reader) { - return asStarshipFieldMapper.map(reader); - } - }); - if (asStarship != null) { - return asStarship; - } - return asSearchResultFieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull Search search); - - T visit(@NotNull AsCharacter asCharacter); - - T visit(@NotNull AsStarship asStarship); - - T visit(@NotNull AsSearchResult asSearchResult); - } - } - - /** - * A character from the Star Wars universe - */ - public static class AsCharacter implements Search { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forList("friends", "friends", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String id; - - final @NotNull String name; - - final Optional> friends; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter(@NotNull String __typename, @NotNull String id, @NotNull String name, - @Nullable List friends) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.id = Utils.checkNotNull(id, "id == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friends = Optional.fromNullable(friends); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The ID of the character - */ - public @NotNull String id() { - return this.id; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The friends of the character, or an empty list if they have none - */ - public Optional> friends() { - return this.friends; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[1], id); - writer.writeString($responseFields[2], name); - writer.writeList($responseFields[3], friends.isPresent() ? friends.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Friend) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter{" - + "__typename=" + __typename + ", " - + "id=" + id + ", " - + "name=" + name + ", " - + "friends=" + friends - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter) { - AsCharacter that = (AsCharacter) o; - return this.__typename.equals(that.__typename) - && this.id.equals(that.id) - && this.name.equals(that.name) - && this.friends.equals(that.friends); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= id.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friends.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Friend.Mapper friendFieldMapper = new Friend.Mapper(); - - @Override - public AsCharacter map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]); - final String name = reader.readString($responseFields[2]); - final List friends = reader.readList($responseFields[3], new ResponseReader.ListReader() { - @Override - public Friend read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Friend read(ResponseReader reader) { - return friendFieldMapper.map(reader); - } - }); - } - }); - return new AsCharacter(__typename, id, name, friends); - } - } - } - - /** - * A character from the Star Wars universe - */ - public interface Friend { - @NotNull String __typename(); - - /** - * The name of the character - */ - @NotNull String name(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsHuman) { - return visitor.visit((AsHuman) this); - } else if (this instanceof AsDroid) { - return visitor.visit((AsDroid) this); - } else if (this instanceof AsCharacter1) { - return visitor.visit((AsCharacter1) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )), - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Droid"}) - )) - }; - - final AsHuman.Mapper asHumanFieldMapper = new AsHuman.Mapper(); - - final AsDroid.Mapper asDroidFieldMapper = new AsDroid.Mapper(); - - final AsCharacter1.Mapper asCharacter1FieldMapper = new AsCharacter1.Mapper(); - - @Override - public Friend map(ResponseReader reader) { - final AsHuman asHuman = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsHuman read(ResponseReader reader) { - return asHumanFieldMapper.map(reader); - } - }); - if (asHuman != null) { - return asHuman; - } - final AsDroid asDroid = reader.readFragment($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public AsDroid read(ResponseReader reader) { - return asDroidFieldMapper.map(reader); - } - }); - if (asDroid != null) { - return asDroid; - } - return asCharacter1FieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull Friend friend); - - T visit(@NotNull AsHuman asHuman); - - T visit(@NotNull AsDroid asDroid); - - T visit(@NotNull AsCharacter1 asCharacter1); - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - public static class AsHuman implements Friend { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("homePlanet", "homePlanet", null, true, Collections.emptyList()), - ResponseField.forList("friends", "friends", null, true, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional homePlanet; - - final Optional> friends; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsHuman(@NotNull String __typename, @Nullable String homePlanet, - @Nullable List friends, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.homePlanet = Optional.fromNullable(homePlanet); - this.friends = Optional.fromNullable(friends); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The home planet of the human, or null if unknown - */ - public Optional homePlanet() { - return this.homePlanet; - } - - /** - * This human's friends, or an empty list if they have none - */ - public Optional> friends() { - return this.friends; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], homePlanet.isPresent() ? homePlanet.get() : null); - writer.writeList($responseFields[2], friends.isPresent() ? friends.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Friend1) item).marshaller()); - } - } - }); - writer.writeString($responseFields[3], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsHuman{" - + "__typename=" + __typename + ", " - + "homePlanet=" + homePlanet + ", " - + "friends=" + friends + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsHuman) { - AsHuman that = (AsHuman) o; - return this.__typename.equals(that.__typename) - && this.homePlanet.equals(that.homePlanet) - && this.friends.equals(that.friends) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= homePlanet.hashCode(); - h *= 1000003; - h ^= friends.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Friend1.Mapper friend1FieldMapper = new Friend1.Mapper(); - - @Override - public AsHuman map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String homePlanet = reader.readString($responseFields[1]); - final List friends = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Friend1 read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Friend1 read(ResponseReader reader) { - return friend1FieldMapper.map(reader); - } - }); - } - }); - final String name = reader.readString($responseFields[3]); - return new AsHuman(__typename, homePlanet, friends, name); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Friend1 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("firstAppearsIn", "firstAppearsIn", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull Episode firstAppearsIn; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Friend1(@NotNull String __typename, @NotNull Episode firstAppearsIn) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.firstAppearsIn = Utils.checkNotNull(firstAppearsIn, "firstAppearsIn == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The movie this character first appears in - */ - public @NotNull Episode firstAppearsIn() { - return this.firstAppearsIn; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], firstAppearsIn.rawValue()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Friend1{" - + "__typename=" + __typename + ", " - + "firstAppearsIn=" + firstAppearsIn - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Friend1) { - Friend1 that = (Friend1) o; - return this.__typename.equals(that.__typename) - && this.firstAppearsIn.equals(that.firstAppearsIn); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= firstAppearsIn.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Friend1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String firstAppearsInStr = reader.readString($responseFields[1]); - final Episode firstAppearsIn; - if (firstAppearsInStr != null) { - firstAppearsIn = Episode.safeValueOf(firstAppearsInStr); - } else { - firstAppearsIn = null; - } - return new Friend1(__typename, firstAppearsIn); - } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - public static class AsDroid implements Friend { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, Collections.emptyList()), - ResponseField.forList("friends", "friends", null, true, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional primaryFunction; - - final Optional> friends; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsDroid(@NotNull String __typename, @Nullable String primaryFunction, - @Nullable List friends, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.primaryFunction = Optional.fromNullable(primaryFunction); - this.friends = Optional.fromNullable(friends); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * This droid's primary function - */ - public Optional primaryFunction() { - return this.primaryFunction; - } - - /** - * This droid's friends, or an empty list if they have none - */ - public Optional> friends() { - return this.friends; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], primaryFunction.isPresent() ? primaryFunction.get() : null); - writer.writeList($responseFields[2], friends.isPresent() ? friends.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Friend2) item).marshaller()); - } - } - }); - writer.writeString($responseFields[3], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsDroid{" - + "__typename=" + __typename + ", " - + "primaryFunction=" + primaryFunction + ", " - + "friends=" + friends + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsDroid) { - AsDroid that = (AsDroid) o; - return this.__typename.equals(that.__typename) - && this.primaryFunction.equals(that.primaryFunction) - && this.friends.equals(that.friends) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= primaryFunction.hashCode(); - h *= 1000003; - h ^= friends.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Friend2.Mapper friend2FieldMapper = new Friend2.Mapper(); - - @Override - public AsDroid map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String primaryFunction = reader.readString($responseFields[1]); - final List friends = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Friend2 read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Friend2 read(ResponseReader reader) { - return friend2FieldMapper.map(reader); - } - }); - } - }); - final String name = reader.readString($responseFields[3]); - return new AsDroid(__typename, primaryFunction, friends, name); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Friend2 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String id; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Friend2(@NotNull String __typename, @NotNull String id) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.id = Utils.checkNotNull(id, "id == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The ID of the character - */ - public @NotNull String id() { - return this.id; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeCustom((ResponseField.CustomTypeField) $responseFields[1], id); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Friend2{" - + "__typename=" + __typename + ", " - + "id=" + id - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Friend2) { - Friend2 that = (Friend2) o; - return this.__typename.equals(that.__typename) - && this.id.equals(that.id); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= id.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Friend2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String id = reader.readCustomType((ResponseField.CustomTypeField) $responseFields[1]); - return new Friend2(__typename, id); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class AsCharacter1 implements Friend { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter1(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter1{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter1) { - AsCharacter1 that = (AsCharacter1) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsCharacter1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new AsCharacter1(__typename, name); - } - } - } - - public static class AsStarship implements Search { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsStarship(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the starship - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsStarship{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsStarship) { - AsStarship that = (AsStarship) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsStarship map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new AsStarship(__typename, name); - } - } - } - - public static class AsSearchResult implements Search { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsSearchResult(@NotNull String __typename) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsSearchResult{" - + "__typename=" + __typename - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsSearchResult) { - AsSearchResult that = (AsSearchResult) o; - return this.__typename.equals(that.__typename); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public AsSearchResult map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - return new AsSearchResult(__typename); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/TestQuery.kt b/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/TestQuery.kt deleted file mode 100644 index 56b7c26c582..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/TestQuery.kt +++ /dev/null @@ -1,555 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.union_inline_fragments - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.union_inline_fragments.type.CustomType -import com.example.union_inline_fragments.type.Episode -import kotlin.Array -import kotlin.Boolean -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class TestQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - interface SearchSearchResult { - fun marshaller(): ResponseFieldMarshaller - } - - interface FriendCharacter { - fun marshaller(): ResponseFieldMarshaller - } - - /** - * A character from the Star Wars universe - */ - data class Friend( - val __typename: String = "Character", - /** - * The movie this character first appears in - */ - val firstAppearsIn: Episode - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Friend.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Friend.firstAppearsIn.rawValue) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forEnum("firstAppearsIn", "firstAppearsIn", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Friend = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val firstAppearsIn = Episode.safeValueOf(readString(RESPONSE_FIELDS[1])!!) - Friend( - __typename = __typename, - firstAppearsIn = firstAppearsIn - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - data class AsHuman( - val __typename: String = "Human", - /** - * The home planet of the human, or null if unknown - */ - val homePlanet: String?, - /** - * This human's friends, or an empty list if they have none - */ - val friends: List?, - /** - * The name of the character - */ - val name: String - ) : FriendCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsHuman.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsHuman.homePlanet) - writer.writeList(RESPONSE_FIELDS[2], this@AsHuman.friends) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - writer.writeString(RESPONSE_FIELDS[3], this@AsHuman.name) - } - - fun friendsFilterNotNull(): List? = friends?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("homePlanet", "homePlanet", null, true, null), - ResponseField.forList("friends", "friends", null, true, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): AsHuman = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val homePlanet = readString(RESPONSE_FIELDS[1]) - val friends = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Friend(reader) - } - } - val name = readString(RESPONSE_FIELDS[3])!! - AsHuman( - __typename = __typename, - homePlanet = homePlanet, - friends = friends, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Friend1( - val __typename: String = "Character", - /** - * The ID of the character - */ - val id: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Friend1.__typename) - writer.writeCustom(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField, this@Friend1.id) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, null) - ) - - operator fun invoke(reader: ResponseReader): Friend1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val id = readCustomType(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField)!! - Friend1( - __typename = __typename, - id = id - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An autonomous mechanical character in the Star Wars universe - */ - data class AsDroid( - val __typename: String = "Droid", - /** - * This droid's primary function - */ - val primaryFunction: String?, - /** - * This droid's friends, or an empty list if they have none - */ - val friends: List?, - /** - * The name of the character - */ - val name: String - ) : FriendCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsDroid.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsDroid.primaryFunction) - writer.writeList(RESPONSE_FIELDS[2], this@AsDroid.friends) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - writer.writeString(RESPONSE_FIELDS[3], this@AsDroid.name) - } - - fun friendsFilterNotNull(): List? = friends?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("primaryFunction", "primaryFunction", null, true, null), - ResponseField.forList("friends", "friends", null, true, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): AsDroid = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val primaryFunction = readString(RESPONSE_FIELDS[1]) - val friends = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Friend1(reader) - } - } - val name = readString(RESPONSE_FIELDS[3])!! - AsDroid( - __typename = __typename, - primaryFunction = primaryFunction, - friends = friends, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Friend2( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - val asHuman: AsHuman?, - val asDroid: AsDroid? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Friend2.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Friend2.name) - writer.writeFragment(this@Friend2.asHuman?.marshaller()) - writer.writeFragment(this@Friend2.asDroid?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid")) - )) - ) - - operator fun invoke(reader: ResponseReader): Friend2 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val asHuman = readFragment(RESPONSE_FIELDS[2]) { reader -> - AsHuman(reader) - } - val asDroid = readFragment(RESPONSE_FIELDS[3]) { reader -> - AsDroid(reader) - } - Friend2( - __typename = __typename, - name = name, - asHuman = asHuman, - asDroid = asDroid - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class AsCharacter( - val __typename: String = "Character", - /** - * The ID of the character - */ - val id: String, - /** - * The name of the character - */ - val name: String, - /** - * The friends of the character, or an empty list if they have none - */ - val friends: List? - ) : SearchSearchResult { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsCharacter.__typename) - writer.writeCustom(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField, this@AsCharacter.id) - writer.writeString(RESPONSE_FIELDS[2], this@AsCharacter.name) - writer.writeList(RESPONSE_FIELDS[3], this@AsCharacter.friends) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun friendsFilterNotNull(): List? = friends?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forCustomType("id", "id", null, false, CustomType.ID, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forList("friends", "friends", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): AsCharacter = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val id = readCustomType(RESPONSE_FIELDS[1] as ResponseField.CustomTypeField)!! - val name = readString(RESPONSE_FIELDS[2])!! - val friends = readList(RESPONSE_FIELDS[3]) { reader -> - reader.readObject { reader -> - Friend2(reader) - } - } - AsCharacter( - __typename = __typename, - id = id, - name = name, - friends = friends - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - data class AsStarship( - val __typename: String = "Starship", - /** - * The name of the starship - */ - val name: String - ) : SearchSearchResult { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsStarship.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsStarship.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): AsStarship = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - AsStarship( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - data class Search( - val __typename: String = "SearchResult", - val asCharacter: AsCharacter?, - val asStarship: AsStarship? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Search.__typename) - writer.writeFragment(this@Search.asCharacter?.marshaller()) - writer.writeFragment(this@Search.asStarship?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Droid", "Human")) - )), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Starship")) - )) - ) - - operator fun invoke(reader: ResponseReader): Search = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val asCharacter = readFragment(RESPONSE_FIELDS[1]) { reader -> - AsCharacter(reader) - } - val asStarship = readFragment(RESPONSE_FIELDS[2]) { reader -> - AsStarship(reader) - } - Search( - __typename = __typename, - asCharacter = asCharacter, - asStarship = asStarship - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val search: List? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeList(RESPONSE_FIELDS[0], this@Data.search) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun searchFilterNotNull(): List? = search?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forList("search", "search", mapOf( - "text" to "test"), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val search = readList(RESPONSE_FIELDS[0]) { reader -> - reader.readObject { reader -> - Search(reader) - } - } - Data( - search = search - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "5450032fd838d0216d8b419846d25e09f98228b403e520aacd7eb68cd838f4da" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query TestQuery { - | search(text: "test") { - | __typename - | ... on Character { - | id - | name - | friends { - | __typename - | ... on Character { - | name - | } - | ... on Human { - | homePlanet - | friends { - | __typename - | ... on Character { - | firstAppearsIn - | } - | } - | } - | ... on Droid { - | primaryFunction - | friends { - | __typename - | id - | } - | } - | } - | } - | ... on Starship { - | name - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "TestQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/type/CustomType.java deleted file mode 100644 index 38aab2f6e9f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.union_inline_fragments.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/type/CustomType.kt deleted file mode 100644 index cbf53ab0246..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.union_inline_fragments.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/type/Episode.java b/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/type/Episode.java deleted file mode 100644 index c8aeb1dd407..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/type/Episode.java +++ /dev/null @@ -1,67 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.union_inline_fragments.type; - -import java.lang.Deprecated; -import java.lang.String; - -/** - * The episodes in the Star Wars trilogy - */ -public enum Episode { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - * @deprecated For test purpose only - */ - @Deprecated - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - * @deprecated For test purpose only - */ - @Deprecated - NEW_("new"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Episode(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Episode safeValueOf(String rawValue) { - for (Episode enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Episode.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/type/Episode.kt b/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/type/Episode.kt deleted file mode 100644 index dba6e69a187..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/union_inline_fragments/type/Episode.kt +++ /dev/null @@ -1,54 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.union_inline_fragments.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.Deprecated -import kotlin.String - -/** - * The episodes in the Star Wars trilogy - */ -enum class Episode( - override val rawValue: String -) : EnumValue { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - */ - @Deprecated(message = "For test purpose only") - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - */ - @Deprecated(message = "For test purpose only") - NEW("new"), - - /** - * Auto generated constant for unknown enum values - */ - UNKNOWN__("UNKNOWN__"); - - companion object { - fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: - UNKNOWN__ - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/unique_type_name/HeroDetailQuery.java b/apollo-compiler/src/test/graphql/com/example/unique_type_name/HeroDetailQuery.java deleted file mode 100644 index c5c64753760..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/unique_type_name/HeroDetailQuery.java +++ /dev/null @@ -1,1050 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.unique_type_name; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.Utils; -import com.example.unique_type_name.fragment.HeroDetails; -import com.example.unique_type_name.type.Episode; -import java.io.IOException; -import java.lang.Double; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class HeroDetailQuery implements Query, Operation.Variables> { - public static final String OPERATION_ID = "11473383397766137d7923128dd8cd6f27fcab32df9d9c091f08cf12a893a556"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query HeroDetailQuery {\n" - + " heroDetailQuery {\n" - + " __typename\n" - + " name\n" - + " friends {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " ... on Human {\n" - + " height\n" - + " friends {\n" - + " __typename\n" - + " appearsIn\n" - + " friends {\n" - + " __typename\n" - + " ...HeroDetails\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + "}\n" - + "fragment HeroDetails on Character {\n" - + " __typename\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "HeroDetailQuery"; - } - }; - - private final Operation.Variables variables; - - public HeroDetailQuery() { - this.variables = Operation.EMPTY_VARIABLES; - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(HeroDetailQuery.Data data) { - return Optional.fromNullable(data); - } - - @Override - public Operation.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - Builder() { - } - - public HeroDetailQuery build() { - return new HeroDetailQuery(); - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("heroDetailQuery", "heroDetailQuery", null, true, Collections.emptyList()) - }; - - final Optional heroDetailQuery; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable HeroDetailQuery1 heroDetailQuery) { - this.heroDetailQuery = Optional.fromNullable(heroDetailQuery); - } - - public Optional heroDetailQuery() { - return this.heroDetailQuery; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], heroDetailQuery.isPresent() ? heroDetailQuery.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "heroDetailQuery=" + heroDetailQuery - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.heroDetailQuery.equals(that.heroDetailQuery); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= heroDetailQuery.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final HeroDetailQuery1.Mapper heroDetailQuery1FieldMapper = new HeroDetailQuery1.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final HeroDetailQuery1 heroDetailQuery = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HeroDetailQuery1 read(ResponseReader reader) { - return heroDetailQuery1FieldMapper.map(reader); - } - }); - return new Data(heroDetailQuery); - } - } - } - - /** - * A character from the Star Wars universe - */ - public interface HeroDetailQuery1 { - @NotNull String __typename(); - - /** - * The name of the character - */ - @NotNull String name(); - - /** - * The friends of the character, or an empty list if they have none - */ - Optional> friends(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsHuman) { - return visitor.visit((AsHuman) this); - } else if (this instanceof AsCharacter) { - return visitor.visit((AsCharacter) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )) - }; - - final AsHuman.Mapper asHumanFieldMapper = new AsHuman.Mapper(); - - final AsCharacter.Mapper asCharacterFieldMapper = new AsCharacter.Mapper(); - - @Override - public HeroDetailQuery1 map(ResponseReader reader) { - final AsHuman asHuman = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsHuman read(ResponseReader reader) { - return asHumanFieldMapper.map(reader); - } - }); - if (asHuman != null) { - return asHuman; - } - return asCharacterFieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull HeroDetailQuery1 heroDetailQuery1); - - T visit(@NotNull AsHuman asHuman); - - T visit(@NotNull AsCharacter asCharacter); - } - } - - /** - * A character from the Star Wars universe - */ - public interface Friend { - @NotNull String __typename(); - - /** - * The name of the character - */ - @NotNull String name(); - - ResponseFieldMarshaller marshaller(); - } - - /** - * A humanoid creature from the Star Wars universe - */ - public static class AsHuman implements HeroDetailQuery1 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forList("friends", "friends", null, true, Collections.emptyList()), - ResponseField.forDouble("height", "height", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional> friends; - - final Optional height; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsHuman(@NotNull String __typename, @NotNull String name, - @Nullable List friends, @Nullable Double height) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friends = Optional.fromNullable(friends); - this.height = Optional.fromNullable(height); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - /** - * This human's friends, or an empty list if they have none - */ - public Optional> friends() { - return this.friends; - } - - /** - * Height in the preferred unit, default is meters - */ - public Optional height() { - return this.height; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeList($responseFields[2], friends.isPresent() ? friends.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Friend1) item).marshaller()); - } - } - }); - writer.writeDouble($responseFields[3], height.isPresent() ? height.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsHuman{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friends=" + friends + ", " - + "height=" + height - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsHuman) { - AsHuman that = (AsHuman) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friends.equals(that.friends) - && this.height.equals(that.height); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friends.hashCode(); - h *= 1000003; - h ^= height.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Friend1.Mapper friend1FieldMapper = new Friend1.Mapper(); - - @Override - public AsHuman map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final List friends = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Friend1 read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Friend1 read(ResponseReader reader) { - return friend1FieldMapper.map(reader); - } - }); - } - }); - final Double height = reader.readDouble($responseFields[3]); - return new AsHuman(__typename, name, friends, height); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Friend1 implements Friend { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forList("appearsIn", "appearsIn", null, false, Collections.emptyList()), - ResponseField.forList("friends", "friends", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull List appearsIn; - - final Optional> friends; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Friend1(@NotNull String __typename, @NotNull String name, - @NotNull List appearsIn, @Nullable List friends) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.appearsIn = Utils.checkNotNull(appearsIn, "appearsIn == null"); - this.friends = Optional.fromNullable(friends); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The movies this character appears in - */ - public @NotNull List appearsIn() { - return this.appearsIn; - } - - /** - * The friends of the character, or an empty list if they have none - */ - public Optional> friends() { - return this.friends; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeList($responseFields[2], appearsIn, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeString(((Episode) item).rawValue()); - } - } - }); - writer.writeList($responseFields[3], friends.isPresent() ? friends.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Friend2) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Friend1{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "appearsIn=" + appearsIn + ", " - + "friends=" + friends - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Friend1) { - Friend1 that = (Friend1) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.appearsIn.equals(that.appearsIn) - && this.friends.equals(that.friends); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= appearsIn.hashCode(); - h *= 1000003; - h ^= friends.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Friend2.Mapper friend2FieldMapper = new Friend2.Mapper(); - - @Override - public Friend1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final List appearsIn = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Episode read(ResponseReader.ListItemReader listItemReader) { - return Episode.safeValueOf(listItemReader.readString()); - } - }); - final List friends = reader.readList($responseFields[3], new ResponseReader.ListReader() { - @Override - public Friend2 read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Friend2 read(ResponseReader reader) { - return friend2FieldMapper.map(reader); - } - }); - } - }); - return new Friend1(__typename, name, appearsIn, friends); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Friend2 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - private final @NotNull Fragments fragments; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Friend2(@NotNull String __typename, @NotNull Fragments fragments) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.fragments = Utils.checkNotNull(fragments, "fragments == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - public @NotNull Fragments fragments() { - return this.fragments; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - fragments.marshaller().marshal(writer); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Friend2{" - + "__typename=" + __typename + ", " - + "fragments=" + fragments - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Friend2) { - Friend2 that = (Friend2) o; - return this.__typename.equals(that.__typename) - && this.fragments.equals(that.fragments); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= fragments.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static class Fragments { - final @NotNull HeroDetails heroDetails; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Fragments(@NotNull HeroDetails heroDetails) { - this.heroDetails = Utils.checkNotNull(heroDetails, "heroDetails == null"); - } - - public @NotNull HeroDetails heroDetails() { - return this.heroDetails; - } - - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeFragment(heroDetails.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Fragments{" - + "heroDetails=" + heroDetails - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Fragments) { - Fragments that = (Fragments) o; - return this.heroDetails.equals(that.heroDetails); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= heroDetails.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Collections.emptyList()) - }; - - final HeroDetails.Mapper heroDetailsFieldMapper = new HeroDetails.Mapper(); - - @Override - public @NotNull Fragments map(ResponseReader reader) { - final HeroDetails heroDetails = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public HeroDetails read(ResponseReader reader) { - return heroDetailsFieldMapper.map(reader); - } - }); - return new Fragments(heroDetails); - } - } - } - - public static final class Mapper implements ResponseFieldMapper { - final Fragments.Mapper fragmentsFieldMapper = new Fragments.Mapper(); - - @Override - public Friend2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Fragments fragments = fragmentsFieldMapper.map(reader); - return new Friend2(__typename, fragments); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class AsCharacter implements HeroDetailQuery1 { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forList("friends", "friends", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - final Optional> friends; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter(@NotNull String __typename, @NotNull String name, - @Nullable List friends) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friends = Optional.fromNullable(friends); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The friends of the character, or an empty list if they have none - */ - public Optional> friends() { - return this.friends; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeList($responseFields[2], friends.isPresent() ? friends.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Friend3) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friends=" + friends - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter) { - AsCharacter that = (AsCharacter) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friends.equals(that.friends); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friends.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Friend3.Mapper friend3FieldMapper = new Friend3.Mapper(); - - @Override - public AsCharacter map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final List friends = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Friend3 read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Friend3 read(ResponseReader reader) { - return friend3FieldMapper.map(reader); - } - }); - } - }); - return new AsCharacter(__typename, name, friends); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Friend3 implements Friend { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Friend3(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Friend3{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Friend3) { - Friend3 that = (Friend3) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Friend3 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Friend3(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/unique_type_name/HeroDetailQuery.kt b/apollo-compiler/src/test/graphql/com/example/unique_type_name/HeroDetailQuery.kt deleted file mode 100644 index 961eb910661..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/unique_type_name/HeroDetailQuery.kt +++ /dev/null @@ -1,450 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.unique_type_name - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.unique_type_name.fragment.HeroDetails -import com.example.unique_type_name.type.Episode -import kotlin.Array -import kotlin.Boolean -import kotlin.Double -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -class HeroDetailQuery : Query { - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - interface HeroDetailQueryCharacter { - fun marshaller(): ResponseFieldMarshaller - } - - /** - * A character from the Star Wars universe - */ - data class Friend1( - val __typename: String = "Character", - val fragments: Fragments - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Friend1.__typename) - this@Friend1.fragments.marshaller().marshal(writer) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("__typename", "__typename", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Friend1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val fragments = Fragments(reader) - Friend1( - __typename = __typename, - fragments = fragments - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - data class Fragments( - val heroDetails: HeroDetails - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeFragment(this@Fragments.heroDetails.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forFragment("__typename", "__typename", null) - ) - - operator fun invoke(reader: ResponseReader): Fragments = reader.run { - val heroDetails = readFragment(RESPONSE_FIELDS[0]) { reader -> - HeroDetails(reader) - }!! - Fragments( - heroDetails = heroDetails - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - } - - /** - * A character from the Star Wars universe - */ - data class Friend( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The movies this character appears in - */ - val appearsIn: List, - /** - * The friends of the character, or an empty list if they have none - */ - val friends: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Friend.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Friend.name) - writer.writeList(RESPONSE_FIELDS[2], this@Friend.appearsIn) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeString(value?.rawValue)} - } - writer.writeList(RESPONSE_FIELDS[3], this@Friend.friends) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun appearsInFilterNotNull(): List = appearsIn.filterNotNull() - - fun friendsFilterNotNull(): List? = friends?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forList("appearsIn", "appearsIn", null, false, null), - ResponseField.forList("friends", "friends", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Friend = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val appearsIn = readList(RESPONSE_FIELDS[2]) { reader -> - Episode.safeValueOf(reader.readString()) - }!! - val friends = readList(RESPONSE_FIELDS[3]) { reader -> - reader.readObject { reader -> - Friend1(reader) - } - } - Friend( - __typename = __typename, - name = name, - appearsIn = appearsIn, - friends = friends - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - data class AsHuman( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String, - /** - * This human's friends, or an empty list if they have none - */ - val friends: List?, - /** - * Height in the preferred unit, default is meters - */ - val height: Double? - ) : HeroDetailQueryCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsHuman.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsHuman.name) - writer.writeList(RESPONSE_FIELDS[2], this@AsHuman.friends) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - writer.writeDouble(RESPONSE_FIELDS[3], this@AsHuman.height) - } - - fun friendsFilterNotNull(): List? = friends?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forList("friends", "friends", null, true, null), - ResponseField.forDouble("height", "height", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): AsHuman = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friends = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Friend(reader) - } - } - val height = readDouble(RESPONSE_FIELDS[3]) - AsHuman( - __typename = __typename, - name = name, - friends = friends, - height = height - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Friend2( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Friend2.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Friend2.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Friend2 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Friend2( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class HeroDetailQuery( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The friends of the character, or an empty list if they have none - */ - val friends: List?, - val asHuman: AsHuman? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HeroDetailQuery.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HeroDetailQuery.name) - writer.writeList(RESPONSE_FIELDS[2], this@HeroDetailQuery.friends) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - writer.writeFragment(this@HeroDetailQuery.asHuman?.marshaller()) - } - - fun friendsFilterNotNull(): List? = friends?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forList("friends", "friends", null, true, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )) - ) - - operator fun invoke(reader: ResponseReader): HeroDetailQuery = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friends = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Friend2(reader) - } - } - val asHuman = readFragment(RESPONSE_FIELDS[3]) { reader -> - AsHuman(reader) - } - HeroDetailQuery( - __typename = __typename, - name = name, - friends = friends, - asHuman = asHuman - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val heroDetailQuery: HeroDetailQuery? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.heroDetailQuery?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("heroDetailQuery", "heroDetailQuery", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val heroDetailQuery = readObject(RESPONSE_FIELDS[0]) { reader -> - HeroDetailQuery(reader) - } - Data( - heroDetailQuery = heroDetailQuery - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "11473383397766137d7923128dd8cd6f27fcab32df9d9c091f08cf12a893a556" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query HeroDetailQuery { - | heroDetailQuery { - | __typename - | name - | friends { - | __typename - | name - | } - | ... on Human { - | height - | friends { - | __typename - | appearsIn - | friends { - | __typename - | ...HeroDetails - | } - | } - | } - | } - |} - |fragment HeroDetails on Character { - | __typename - | name - | friendsConnection { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "HeroDetailQuery" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/unique_type_name/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/unique_type_name/TestOperation.graphql deleted file mode 100644 index a49b2b96c51..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/unique_type_name/TestOperation.graphql +++ /dev/null @@ -1,29 +0,0 @@ -query HeroDetailQuery { - heroDetailQuery { - name - friends { - name - } - ... on Human { - height - friends { - appearsIn - friends { - ...HeroDetails - } - } - } - } -} - -fragment HeroDetails on Character { - name - friendsConnection { - totalCount - edges { - node { - name - } - } - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/graphql/com/example/unique_type_name/fragment/HeroDetails.java b/apollo-compiler/src/test/graphql/com/example/unique_type_name/fragment/HeroDetails.java deleted file mode 100644 index 0bc7b11b647..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/unique_type_name/fragment/HeroDetails.java +++ /dev/null @@ -1,482 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.unique_type_name.fragment; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.Utils; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Collections; -import java.util.List; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class HeroDetails implements GraphqlFragment { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, Collections.emptyList()) - }; - - public static final String FRAGMENT_DEFINITION = "fragment HeroDetails on Character {\n" - + " __typename\n" - + " name\n" - + " friendsConnection {\n" - + " __typename\n" - + " totalCount\n" - + " edges {\n" - + " __typename\n" - + " node {\n" - + " __typename\n" - + " name\n" - + " }\n" - + " }\n" - + " }\n" - + "}"; - - final @NotNull String __typename; - - final @NotNull String name; - - final @NotNull FriendsConnection friendsConnection; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HeroDetails(@NotNull String __typename, @NotNull String name, - @NotNull FriendsConnection friendsConnection) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - /** - * The friends of the character exposed as a connection with edges - */ - public @NotNull FriendsConnection friendsConnection() { - return this.friendsConnection; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - writer.writeObject($responseFields[2], friendsConnection.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HeroDetails{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HeroDetails) { - HeroDetails that = (HeroDetails) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection.Mapper friendsConnectionFieldMapper = new FriendsConnection.Mapper(); - - @Override - public HeroDetails map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final FriendsConnection friendsConnection = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection read(ResponseReader reader) { - return friendsConnectionFieldMapper.map(reader); - } - }); - return new HeroDetails(__typename, name, friendsConnection); - } - } - - /** - * A connection object for a character's friends - */ - public static class FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()), - ResponseField.forList("edges", "edges", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - final Optional> edges; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection(@NotNull String __typename, @Nullable Integer totalCount, - @Nullable List edges) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.fromNullable(totalCount); - this.edges = Optional.fromNullable(edges); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional totalCount() { - return this.totalCount; - } - - /** - * The edges for each of the character's friends. - */ - public Optional> edges() { - return this.edges; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - writer.writeList($responseFields[2], edges.isPresent() ? edges.get() : null, new ResponseWriter.ListWriter() { - @Override - public void write(List items, ResponseWriter.ListItemWriter listItemWriter) { - for (Object item : items) { - listItemWriter.writeObject(((Edge) item).marshaller()); - } - } - }); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount + ", " - + "edges=" + edges - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection) { - FriendsConnection that = (FriendsConnection) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount) - && this.edges.equals(that.edges); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - h *= 1000003; - h ^= edges.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Edge.Mapper edgeFieldMapper = new Edge.Mapper(); - - @Override - public FriendsConnection map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - final List edges = reader.readList($responseFields[2], new ResponseReader.ListReader() { - @Override - public Edge read(ResponseReader.ListItemReader listItemReader) { - return listItemReader.readObject(new ResponseReader.ObjectReader() { - @Override - public Edge read(ResponseReader reader) { - return edgeFieldMapper.map(reader); - } - }); - } - }); - return new FriendsConnection(__typename, totalCount, edges); - } - } - } - - /** - * An edge object for a character's friends - */ - public static class Edge { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forObject("node", "node", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional node; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Edge(@NotNull String __typename, @Nullable Node node) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.node = Optional.fromNullable(node); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The character represented by this friendship edge - */ - public Optional node() { - return this.node; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeObject($responseFields[1], node.isPresent() ? node.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Edge{" - + "__typename=" + __typename + ", " - + "node=" + node - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Edge) { - Edge that = (Edge) o; - return this.__typename.equals(that.__typename) - && this.node.equals(that.node); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= node.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Node.Mapper nodeFieldMapper = new Node.Mapper(); - - @Override - public Edge map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Node node = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public Node read(ResponseReader reader) { - return nodeFieldMapper.map(reader); - } - }); - return new Edge(__typename, node); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class Node { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Node(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Node{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Node) { - Node that = (Node) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public Node map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new Node(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/unique_type_name/fragment/HeroDetails.kt b/apollo-compiler/src/test/graphql/com/example/unique_type_name/fragment/HeroDetails.kt deleted file mode 100644 index 22f49f73644..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/unique_type_name/fragment/HeroDetails.kt +++ /dev/null @@ -1,203 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.unique_type_name.fragment - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import kotlin.Array -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class HeroDetails( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String, - /** - * The friends of the character exposed as a connection with edges - */ - val friendsConnection: FriendsConnection -) : GraphqlFragment { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HeroDetails.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HeroDetails.name) - writer.writeObject(RESPONSE_FIELDS[2], this@HeroDetails.friendsConnection.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null), - ResponseField.forObject("friendsConnection", "friendsConnection", null, false, null) - ) - - val FRAGMENT_DEFINITION: String = """ - |fragment HeroDetails on Character { - | __typename - | name - | friendsConnection { - | __typename - | totalCount - | edges { - | __typename - | node { - | __typename - | name - | } - | } - | } - |} - """.trimMargin() - - operator fun invoke(reader: ResponseReader): HeroDetails = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - val friendsConnection = readObject(RESPONSE_FIELDS[2]) { reader -> - FriendsConnection(reader) - }!! - HeroDetails( - __typename = __typename, - name = name, - friendsConnection = friendsConnection - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - - /** - * A character from the Star Wars universe - */ - data class Node( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Node.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Node.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): Node = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - Node( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * An edge object for a character's friends - */ - data class Edge( - val __typename: String = "FriendsEdge", - /** - * The character represented by this friendship edge - */ - val node: Node? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Edge.__typename) - writer.writeObject(RESPONSE_FIELDS[1], this@Edge.node?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forObject("node", "node", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): Edge = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val node = readObject(RESPONSE_FIELDS[1]) { reader -> - Node(reader) - } - Edge( - __typename = __typename, - node = node - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int?, - /** - * The edges for each of the character's friends. - */ - val edges: List? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection.totalCount) - writer.writeList(RESPONSE_FIELDS[2], this@FriendsConnection.edges) { value, listItemWriter -> - value?.forEach { value -> - listItemWriter.writeObject(value?.marshaller())} - } - } - - fun edgesFilterNotNull(): List? = edges?.filterNotNull() - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null), - ResponseField.forList("edges", "edges", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - val edges = readList(RESPONSE_FIELDS[2]) { reader -> - reader.readObject { reader -> - Edge(reader) - } - } - FriendsConnection( - __typename = __typename, - totalCount = totalCount, - edges = edges - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/unique_type_name/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/unique_type_name/type/CustomType.java deleted file mode 100644 index 423934ae0ff..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/unique_type_name/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.unique_type_name.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/unique_type_name/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/unique_type_name/type/CustomType.kt deleted file mode 100644 index 9073ad15acf..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/unique_type_name/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.unique_type_name.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/unique_type_name/type/Episode.java b/apollo-compiler/src/test/graphql/com/example/unique_type_name/type/Episode.java deleted file mode 100644 index 1e6a54ff6cd..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/unique_type_name/type/Episode.java +++ /dev/null @@ -1,67 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.unique_type_name.type; - -import java.lang.Deprecated; -import java.lang.String; - -/** - * The episodes in the Star Wars trilogy - */ -public enum Episode { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - * @deprecated For test purpose only - */ - @Deprecated - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - * @deprecated For test purpose only - */ - @Deprecated - NEW_("new"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - Episode(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static Episode safeValueOf(String rawValue) { - for (Episode enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return Episode.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/unique_type_name/type/Episode.kt b/apollo-compiler/src/test/graphql/com/example/unique_type_name/type/Episode.kt deleted file mode 100644 index fb9e818bae7..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/unique_type_name/type/Episode.kt +++ /dev/null @@ -1,54 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.unique_type_name.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.Deprecated -import kotlin.String - -/** - * The episodes in the Star Wars trilogy - */ -enum class Episode( - override val rawValue: String -) : EnumValue { - /** - * Star Wars Episode IV: A New Hope, released in 1977. - */ - NEWHOPE("NEWHOPE"), - - /** - * Star Wars Episode V: The Empire Strikes Back, released in 1980. - */ - EMPIRE("EMPIRE"), - - /** - * Star Wars Episode VI: Return of the Jedi, released in 1983. - */ - JEDI("JEDI"), - - /** - * Test deprecated enum value - */ - @Deprecated(message = "For test purpose only") - DEPRECATED("DEPRECATED"), - - /** - * Test java reserved word - */ - @Deprecated(message = "For test purpose only") - NEW("new"), - - /** - * Auto generated constant for unknown enum values - */ - UNKNOWN__("UNKNOWN__"); - - companion object { - fun safeValueOf(rawValue: String): Episode = values().find { it.rawValue == rawValue } ?: - UNKNOWN__ - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/variable_default_value/GetHero.java b/apollo-compiler/src/test/graphql/com/example/variable_default_value/GetHero.java deleted file mode 100644 index e9a722bd477..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/variable_default_value/GetHero.java +++ /dev/null @@ -1,1091 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.variable_default_value; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.InputFieldMarshaller; -import com.apollographql.apollo.api.internal.InputFieldWriter; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.QueryDocumentMinifier; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.ResponseWriter; -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.api.internal.Utils; -import com.example.variable_default_value.type.LengthUnit; -import java.io.IOException; -import java.lang.Boolean; -import java.lang.Double; -import java.lang.Integer; -import java.lang.Object; -import java.lang.Override; -import java.lang.String; -import java.lang.SuppressWarnings; -import java.util.Arrays; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import okio.Buffer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public final class GetHero implements Query, GetHero.Variables> { - public static final String OPERATION_ID = "8072e53b9ff2579729b1fd0f06fe483b630c8c1e8a81c06f347a2f25bac675df"; - - public static final String QUERY_DOCUMENT = QueryDocumentMinifier.minify( - "query GetHero($myBool: Boolean = true, $unit: LengthUnit! = FOOT, $listOfInts: [Int] = [1, 2, 3], $first: Int = null, $optionalUnit: LengthUnit = METER) {\n" - + " hero {\n" - + " __typename\n" - + " name @include(if: $myBool)\n" - + " ... on Human {\n" - + " height(unit: $unit)\n" - + " heightInMeters: height(unit: $optionalUnit)\n" - + " }\n" - + " friendsConnection(first: $first) {\n" - + " __typename\n" - + " totalCount\n" - + " }\n" - + " }\n" - + " heroWithReview(listOfInts: $listOfInts) {\n" - + " __typename\n" - + " name\n" - + " }\n" - + "}" - ); - - public static final OperationName OPERATION_NAME = new OperationName() { - @Override - public String name() { - return "GetHero"; - } - }; - - private final GetHero.Variables variables; - - public GetHero(@NotNull Input myBool, @NotNull LengthUnit unit, - @NotNull Input> listOfInts, @NotNull Input first, - @NotNull Input optionalUnit) { - Utils.checkNotNull(myBool, "myBool == null"); - Utils.checkNotNull(unit, "unit == null"); - Utils.checkNotNull(listOfInts, "listOfInts == null"); - Utils.checkNotNull(first, "first == null"); - Utils.checkNotNull(optionalUnit, "optionalUnit == null"); - variables = new GetHero.Variables(myBool, unit, listOfInts, first, optionalUnit); - } - - @Override - public String operationId() { - return OPERATION_ID; - } - - @Override - public String queryDocument() { - return QUERY_DOCUMENT; - } - - @Override - public Optional wrapData(GetHero.Data data) { - return Optional.fromNullable(data); - } - - @Override - public GetHero.Variables variables() { - return variables; - } - - @Override - public ResponseFieldMapper responseFieldMapper() { - return new Data.Mapper(); - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public OperationName name() { - return OPERATION_NAME; - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString, - @NotNull final ScalarTypeAdapters scalarTypeAdapters) throws IOException { - return parse(new Buffer().write(byteString), scalarTypeAdapters); - } - - @Override - @NotNull - public Response> parse(@NotNull final BufferedSource source) throws - IOException { - return parse(source, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public Response> parse(@NotNull final ByteString byteString) throws - IOException { - return parse(byteString, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(@NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull - @Override - public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @Override - @NotNull - public ByteString composeRequestBody(final boolean autoPersistQueries, - final boolean withQueryDocument, @NotNull final ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - public static final class Builder { - private Input myBool = Input.absent(); - - private @NotNull LengthUnit unit; - - private Input> listOfInts = Input.absent(); - - private Input first = Input.absent(); - - private Input optionalUnit = Input.absent(); - - Builder() { - } - - public Builder myBool(@Nullable Boolean myBool) { - this.myBool = Input.fromNullable(myBool); - return this; - } - - public Builder unit(@NotNull LengthUnit unit) { - this.unit = unit; - return this; - } - - public Builder listOfInts(@Nullable List listOfInts) { - this.listOfInts = Input.fromNullable(listOfInts); - return this; - } - - public Builder first(@Nullable Integer first) { - this.first = Input.fromNullable(first); - return this; - } - - public Builder optionalUnit(@Nullable LengthUnit optionalUnit) { - this.optionalUnit = Input.fromNullable(optionalUnit); - return this; - } - - public Builder myBoolInput(@NotNull Input myBool) { - this.myBool = Utils.checkNotNull(myBool, "myBool == null"); - return this; - } - - public Builder listOfIntsInput(@NotNull Input> listOfInts) { - this.listOfInts = Utils.checkNotNull(listOfInts, "listOfInts == null"); - return this; - } - - public Builder firstInput(@NotNull Input first) { - this.first = Utils.checkNotNull(first, "first == null"); - return this; - } - - public Builder optionalUnitInput(@NotNull Input optionalUnit) { - this.optionalUnit = Utils.checkNotNull(optionalUnit, "optionalUnit == null"); - return this; - } - - public GetHero build() { - Utils.checkNotNull(unit, "unit == null"); - return new GetHero(myBool, unit, listOfInts, first, optionalUnit); - } - } - - public static final class Variables extends Operation.Variables { - private final Input myBool; - - private final @NotNull LengthUnit unit; - - private final Input> listOfInts; - - private final Input first; - - private final Input optionalUnit; - - private final transient Map valueMap = new LinkedHashMap<>(); - - Variables(Input myBool, @NotNull LengthUnit unit, Input> listOfInts, - Input first, Input optionalUnit) { - this.myBool = myBool; - this.unit = unit; - this.listOfInts = listOfInts; - this.first = first; - this.optionalUnit = optionalUnit; - if (myBool.defined) { - this.valueMap.put("myBool", myBool.value); - } - this.valueMap.put("unit", unit); - if (listOfInts.defined) { - this.valueMap.put("listOfInts", listOfInts.value); - } - if (first.defined) { - this.valueMap.put("first", first.value); - } - if (optionalUnit.defined) { - this.valueMap.put("optionalUnit", optionalUnit.value); - } - } - - public Input myBool() { - return myBool; - } - - public @NotNull LengthUnit unit() { - return unit; - } - - public Input> listOfInts() { - return listOfInts; - } - - public Input first() { - return first; - } - - public Input optionalUnit() { - return optionalUnit; - } - - @Override - public Map valueMap() { - return Collections.unmodifiableMap(valueMap); - } - - @Override - public InputFieldMarshaller marshaller() { - return new InputFieldMarshaller() { - @Override - public void marshal(InputFieldWriter writer) throws IOException { - if (myBool.defined) { - writer.writeBoolean("myBool", myBool.value); - } - writer.writeString("unit", unit.rawValue()); - if (listOfInts.defined) { - writer.writeList("listOfInts", listOfInts.value != null ? new InputFieldWriter.ListWriter() { - @Override - public void write(InputFieldWriter.ListItemWriter listItemWriter) throws IOException { - for (final Integer $item : listOfInts.value) { - listItemWriter.writeInt($item); - } - } - } : null); - } - if (first.defined) { - writer.writeInt("first", first.value); - } - if (optionalUnit.defined) { - writer.writeString("optionalUnit", optionalUnit.value != null ? optionalUnit.value.rawValue() : null); - } - } - }; - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - public static class Data implements Operation.Data { - static final ResponseField[] $responseFields = { - ResponseField.forObject("hero", "hero", null, true, Collections.emptyList()), - ResponseField.forObject("heroWithReview", "heroWithReview", new UnmodifiableMapBuilder(1) - .put("listOfInts", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "listOfInts") - .build()) - .build(), true, Collections.emptyList()) - }; - - final Optional hero; - - final Optional heroWithReview; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public Data(@Nullable Hero hero, @Nullable HeroWithReview heroWithReview) { - this.hero = Optional.fromNullable(hero); - this.heroWithReview = Optional.fromNullable(heroWithReview); - } - - public Optional hero() { - return this.hero; - } - - public Optional heroWithReview() { - return this.heroWithReview; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeObject($responseFields[0], hero.isPresent() ? hero.get().marshaller() : null); - writer.writeObject($responseFields[1], heroWithReview.isPresent() ? heroWithReview.get().marshaller() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "Data{" - + "hero=" + hero + ", " - + "heroWithReview=" + heroWithReview - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof Data) { - Data that = (Data) o; - return this.hero.equals(that.hero) - && this.heroWithReview.equals(that.heroWithReview); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= hero.hashCode(); - h *= 1000003; - h ^= heroWithReview.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final Hero.Mapper heroFieldMapper = new Hero.Mapper(); - - final HeroWithReview.Mapper heroWithReviewFieldMapper = new HeroWithReview.Mapper(); - - @Override - public Data map(ResponseReader reader) { - final Hero hero = reader.readObject($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public Hero read(ResponseReader reader) { - return heroFieldMapper.map(reader); - } - }); - final HeroWithReview heroWithReview = reader.readObject($responseFields[1], new ResponseReader.ObjectReader() { - @Override - public HeroWithReview read(ResponseReader reader) { - return heroWithReviewFieldMapper.map(reader); - } - }); - return new Data(hero, heroWithReview); - } - } - } - - /** - * A character from the Star Wars universe - */ - public interface Hero { - @NotNull String __typename(); - - /** - * The name of the character - */ - Optional name(); - - /** - * The friends of the character exposed as a connection with edges - */ - @NotNull FriendsConnection friendsConnection(); - - ResponseFieldMarshaller marshaller(); - - default T visit(Visitor visitor) { - if (this instanceof AsHuman) { - return visitor.visit((AsHuman) this); - } else if (this instanceof AsCharacter) { - return visitor.visit((AsCharacter) this); - } - return visitor.visitDefault(this); - } - - final class Mapper implements ResponseFieldMapper { - static final ResponseField[] $responseFields = { - ResponseField.forFragment("__typename", "__typename", Arrays.asList( - ResponseField.Condition.typeCondition(new String[] {"Human"}) - )) - }; - - final AsHuman.Mapper asHumanFieldMapper = new AsHuman.Mapper(); - - final AsCharacter.Mapper asCharacterFieldMapper = new AsCharacter.Mapper(); - - @Override - public Hero map(ResponseReader reader) { - final AsHuman asHuman = reader.readFragment($responseFields[0], new ResponseReader.ObjectReader() { - @Override - public AsHuman read(ResponseReader reader) { - return asHumanFieldMapper.map(reader); - } - }); - if (asHuman != null) { - return asHuman; - } - return asCharacterFieldMapper.map(reader); - } - } - - interface Visitor { - T visitDefault(@NotNull Hero hero); - - T visit(@NotNull AsHuman asHuman); - - T visit(@NotNull AsCharacter asCharacter); - } - } - - /** - * A connection object for a character's friends - */ - public interface FriendsConnection { - @NotNull String __typename(); - - /** - * The total number of friends - */ - Optional totalCount(); - - ResponseFieldMarshaller marshaller(); - } - - /** - * A humanoid creature from the Star Wars universe - */ - public static class AsHuman implements Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, true, Arrays.asList( - ResponseField.Condition.booleanCondition("myBool", false) - )), - ResponseField.forObject("friendsConnection", "friendsConnection", new UnmodifiableMapBuilder(1) - .put("first", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "first") - .build()) - .build(), false, Collections.emptyList()), - ResponseField.forDouble("height", "height", new UnmodifiableMapBuilder(1) - .put("unit", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "unit") - .build()) - .build(), true, Collections.emptyList()), - ResponseField.forDouble("heightInMeters", "height", new UnmodifiableMapBuilder(1) - .put("unit", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "optionalUnit") - .build()) - .build(), true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional name; - - final @NotNull FriendsConnection1 friendsConnection; - - final Optional height; - - final Optional heightInMeters; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsHuman(@NotNull String __typename, @Nullable String name, - @NotNull FriendsConnection1 friendsConnection, @Nullable Double height, - @Nullable Double heightInMeters) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Optional.fromNullable(name); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - this.height = Optional.fromNullable(height); - this.heightInMeters = Optional.fromNullable(heightInMeters); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public Optional name() { - return this.name; - } - - /** - * The friends of the human exposed as a connection with edges - */ - public @NotNull FriendsConnection1 friendsConnection() { - return this.friendsConnection; - } - - /** - * Height in the preferred unit, default is meters - */ - public Optional height() { - return this.height; - } - - /** - * Height in the preferred unit, default is meters - */ - public Optional heightInMeters() { - return this.heightInMeters; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name.isPresent() ? name.get() : null); - writer.writeObject($responseFields[2], friendsConnection.marshaller()); - writer.writeDouble($responseFields[3], height.isPresent() ? height.get() : null); - writer.writeDouble($responseFields[4], heightInMeters.isPresent() ? heightInMeters.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsHuman{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection + ", " - + "height=" + height + ", " - + "heightInMeters=" + heightInMeters - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsHuman) { - AsHuman that = (AsHuman) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection) - && this.height.equals(that.height) - && this.heightInMeters.equals(that.heightInMeters); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - h *= 1000003; - h ^= height.hashCode(); - h *= 1000003; - h ^= heightInMeters.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection1.Mapper friendsConnection1FieldMapper = new FriendsConnection1.Mapper(); - - @Override - public AsHuman map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final FriendsConnection1 friendsConnection = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection1 read(ResponseReader reader) { - return friendsConnection1FieldMapper.map(reader); - } - }); - final Double height = reader.readDouble($responseFields[3]); - final Double heightInMeters = reader.readDouble($responseFields[4]); - return new AsHuman(__typename, name, friendsConnection, height, heightInMeters); - } - } - } - - /** - * A connection object for a character's friends - */ - public static class FriendsConnection1 implements FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection1(@NotNull String __typename, @Nullable Integer totalCount) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.fromNullable(totalCount); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional totalCount() { - return this.totalCount; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection1{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection1) { - FriendsConnection1 that = (FriendsConnection1) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public FriendsConnection1 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - return new FriendsConnection1(__typename, totalCount); - } - } - } - - /** - * A character from the Star Wars universe - */ - public static class AsCharacter implements Hero { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, true, Arrays.asList( - ResponseField.Condition.booleanCondition("myBool", false) - )), - ResponseField.forObject("friendsConnection", "friendsConnection", new UnmodifiableMapBuilder(1) - .put("first", new UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "first") - .build()) - .build(), false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional name; - - final @NotNull FriendsConnection2 friendsConnection; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public AsCharacter(@NotNull String __typename, @Nullable String name, - @NotNull FriendsConnection2 friendsConnection) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Optional.fromNullable(name); - this.friendsConnection = Utils.checkNotNull(friendsConnection, "friendsConnection == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The name of the character - */ - public Optional name() { - return this.name; - } - - /** - * The friends of the character exposed as a connection with edges - */ - public @NotNull FriendsConnection2 friendsConnection() { - return this.friendsConnection; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name.isPresent() ? name.get() : null); - writer.writeObject($responseFields[2], friendsConnection.marshaller()); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "AsCharacter{" - + "__typename=" + __typename + ", " - + "name=" + name + ", " - + "friendsConnection=" + friendsConnection - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof AsCharacter) { - AsCharacter that = (AsCharacter) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name) - && this.friendsConnection.equals(that.friendsConnection); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - h *= 1000003; - h ^= friendsConnection.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - final FriendsConnection2.Mapper friendsConnection2FieldMapper = new FriendsConnection2.Mapper(); - - @Override - public AsCharacter map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - final FriendsConnection2 friendsConnection = reader.readObject($responseFields[2], new ResponseReader.ObjectReader() { - @Override - public FriendsConnection2 read(ResponseReader reader) { - return friendsConnection2FieldMapper.map(reader); - } - }); - return new AsCharacter(__typename, name, friendsConnection); - } - } - } - - /** - * A connection object for a character's friends - */ - public static class FriendsConnection2 implements FriendsConnection { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forInt("totalCount", "totalCount", null, true, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final Optional totalCount; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public FriendsConnection2(@NotNull String __typename, @Nullable Integer totalCount) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.totalCount = Optional.fromNullable(totalCount); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * The total number of friends - */ - public Optional totalCount() { - return this.totalCount; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeInt($responseFields[1], totalCount.isPresent() ? totalCount.get() : null); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "FriendsConnection2{" - + "__typename=" + __typename + ", " - + "totalCount=" + totalCount - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof FriendsConnection2) { - FriendsConnection2 that = (FriendsConnection2) o; - return this.__typename.equals(that.__typename) - && this.totalCount.equals(that.totalCount); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= totalCount.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public FriendsConnection2 map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final Integer totalCount = reader.readInt($responseFields[1]); - return new FriendsConnection2(__typename, totalCount); - } - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - public static class HeroWithReview { - static final ResponseField[] $responseFields = { - ResponseField.forString("__typename", "__typename", null, false, Collections.emptyList()), - ResponseField.forString("name", "name", null, false, Collections.emptyList()) - }; - - final @NotNull String __typename; - - final @NotNull String name; - - private transient volatile String $toString; - - private transient volatile int $hashCode; - - private transient volatile boolean $hashCodeMemoized; - - public HeroWithReview(@NotNull String __typename, @NotNull String name) { - this.__typename = Utils.checkNotNull(__typename, "__typename == null"); - this.name = Utils.checkNotNull(name, "name == null"); - } - - public @NotNull String __typename() { - return this.__typename; - } - - /** - * What this human calls themselves - */ - public @NotNull String name() { - return this.name; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - public ResponseFieldMarshaller marshaller() { - return new ResponseFieldMarshaller() { - @Override - public void marshal(ResponseWriter writer) { - writer.writeString($responseFields[0], __typename); - writer.writeString($responseFields[1], name); - } - }; - } - - @Override - public String toString() { - if ($toString == null) { - $toString = "HeroWithReview{" - + "__typename=" + __typename + ", " - + "name=" + name - + "}"; - } - return $toString; - } - - @Override - public boolean equals(Object o) { - if (o == this) { - return true; - } - if (o instanceof HeroWithReview) { - HeroWithReview that = (HeroWithReview) o; - return this.__typename.equals(that.__typename) - && this.name.equals(that.name); - } - return false; - } - - @Override - public int hashCode() { - if (!$hashCodeMemoized) { - int h = 1; - h *= 1000003; - h ^= __typename.hashCode(); - h *= 1000003; - h ^= name.hashCode(); - $hashCode = h; - $hashCodeMemoized = true; - } - return $hashCode; - } - - public static final class Mapper implements ResponseFieldMapper { - @Override - public HeroWithReview map(ResponseReader reader) { - final String __typename = reader.readString($responseFields[0]); - final String name = reader.readString($responseFields[1]); - return new HeroWithReview(__typename, name); - } - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/variable_default_value/GetHero.kt b/apollo-compiler/src/test/graphql/com/example/variable_default_value/GetHero.kt deleted file mode 100644 index 212609d831f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/variable_default_value/GetHero.kt +++ /dev/null @@ -1,450 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.variable_default_value - -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.ScalarTypeAdapters.Companion.DEFAULT -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.InputFieldWriter -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseReader -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.Throws -import com.example.variable_default_value.type.LengthUnit -import kotlin.Any -import kotlin.Array -import kotlin.Boolean -import kotlin.Double -import kotlin.Int -import kotlin.String -import kotlin.Suppress -import kotlin.collections.List -import kotlin.collections.Map -import kotlin.jvm.Transient -import okio.Buffer -import okio.BufferedSource -import okio.ByteString -import okio.IOException - -@Suppress("NAME_SHADOWING", "UNUSED_ANONYMOUS_PARAMETER", "LocalVariableName", - "RemoveExplicitTypeArguments", "NestedLambdaShadowedImplicitParameter") -data class GetHero( - val myBool: Input = Input.absent(), - val unit: LengthUnit, - val listOfInts: Input> = Input.absent(), - val first: Input = Input.absent(), - val optionalUnit: Input = Input.absent() -) : Query { - @Transient - private val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = mutableMapOf().apply { - if (this@GetHero.myBool.defined) { - this["myBool"] = this@GetHero.myBool.value - } - this["unit"] = this@GetHero.unit - if (this@GetHero.listOfInts.defined) { - this["listOfInts"] = this@GetHero.listOfInts.value - } - if (this@GetHero.first.defined) { - this["first"] = this@GetHero.first.value - } - if (this@GetHero.optionalUnit.defined) { - this["optionalUnit"] = this@GetHero.optionalUnit.value - } - } - - override fun marshaller(): InputFieldMarshaller = InputFieldMarshaller.invoke { writer -> - if (this@GetHero.myBool.defined) { - writer.writeBoolean("myBool", this@GetHero.myBool.value) - } - writer.writeString("unit", this@GetHero.unit.rawValue) - if (this@GetHero.listOfInts.defined) { - writer.writeList("listOfInts", this@GetHero.listOfInts.value?.let { value -> - InputFieldWriter.ListWriter { listItemWriter -> - value.forEach { value -> - listItemWriter.writeInt(value) - } - } - }) - } - if (this@GetHero.first.defined) { - writer.writeInt("first", this@GetHero.first.value) - } - if (this@GetHero.optionalUnit.defined) { - writer.writeString("optionalUnit", this@GetHero.optionalUnit.value?.rawValue) - } - } - } - - override fun operationId(): String = OPERATION_ID - override fun queryDocument(): String = QUERY_DOCUMENT - override fun wrapData(data: Data?): Data? = data - override fun variables(): Operation.Variables = variables - override fun name(): OperationName = OPERATION_NAME - override fun responseFieldMapper(): ResponseFieldMapper = ResponseFieldMapper.invoke { - Data(it) - } - - @Throws(IOException::class) - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response - = SimpleOperationResponseParser.parse(source, this, scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response - = parse(Buffer().write(byteString), scalarTypeAdapters) - - @Throws(IOException::class) - override fun parse(source: BufferedSource): Response = parse(source, DEFAULT) - - @Throws(IOException::class) - override fun parse(byteString: ByteString): Response = parse(byteString, DEFAULT) - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = - OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = scalarTypeAdapters - ) - - override fun composeRequestBody(): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = false, - withQueryDocument = true, - scalarTypeAdapters = DEFAULT - ) - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString = OperationRequestBodyComposer.compose( - operation = this, - autoPersistQueries = autoPersistQueries, - withQueryDocument = withQueryDocument, - scalarTypeAdapters = scalarTypeAdapters - ) - - interface HeroCharacter { - fun marshaller(): ResponseFieldMarshaller - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection.totalCount) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - FriendsConnection( - __typename = __typename, - totalCount = totalCount - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - data class AsHuman( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String?, - /** - * The friends of the human exposed as a connection with edges - */ - val friendsConnection: FriendsConnection, - /** - * Height in the preferred unit, default is meters - */ - val height: Double?, - /** - * Height in the preferred unit, default is meters - */ - val heightInMeters: Double? - ) : HeroCharacter { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@AsHuman.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@AsHuman.name) - writer.writeObject(RESPONSE_FIELDS[2], this@AsHuman.friendsConnection.marshaller()) - writer.writeDouble(RESPONSE_FIELDS[3], this@AsHuman.height) - writer.writeDouble(RESPONSE_FIELDS[4], this@AsHuman.heightInMeters) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, true, listOf( - ResponseField.Condition.booleanCondition("myBool", false) - )), - ResponseField.forObject("friendsConnection", "friendsConnection", mapOf( - "first" to mapOf( - "kind" to "Variable", - "variableName" to "first")), false, null), - ResponseField.forDouble("height", "height", mapOf( - "unit" to mapOf( - "kind" to "Variable", - "variableName" to "unit")), true, null), - ResponseField.forDouble("heightInMeters", "height", mapOf( - "unit" to mapOf( - "kind" to "Variable", - "variableName" to "optionalUnit")), true, null) - ) - - operator fun invoke(reader: ResponseReader): AsHuman = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1]) - val friendsConnection = readObject(RESPONSE_FIELDS[2]) { reader -> - FriendsConnection(reader) - }!! - val height = readDouble(RESPONSE_FIELDS[3]) - val heightInMeters = readDouble(RESPONSE_FIELDS[4]) - AsHuman( - __typename = __typename, - name = name, - friendsConnection = friendsConnection, - height = height, - heightInMeters = heightInMeters - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A connection object for a character's friends - */ - data class FriendsConnection1( - val __typename: String = "FriendsConnection", - /** - * The total number of friends - */ - val totalCount: Int? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@FriendsConnection1.__typename) - writer.writeInt(RESPONSE_FIELDS[1], this@FriendsConnection1.totalCount) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forInt("totalCount", "totalCount", null, true, null) - ) - - operator fun invoke(reader: ResponseReader): FriendsConnection1 = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val totalCount = readInt(RESPONSE_FIELDS[1]) - FriendsConnection1( - __typename = __typename, - totalCount = totalCount - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A character from the Star Wars universe - */ - data class Hero( - val __typename: String = "Character", - /** - * The name of the character - */ - val name: String?, - /** - * The friends of the character exposed as a connection with edges - */ - val friendsConnection: FriendsConnection1, - val asHuman: AsHuman? - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@Hero.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@Hero.name) - writer.writeObject(RESPONSE_FIELDS[2], this@Hero.friendsConnection.marshaller()) - writer.writeFragment(this@Hero.asHuman?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, true, listOf( - ResponseField.Condition.booleanCondition("myBool", false) - )), - ResponseField.forObject("friendsConnection", "friendsConnection", mapOf( - "first" to mapOf( - "kind" to "Variable", - "variableName" to "first")), false, null), - ResponseField.forFragment("__typename", "__typename", listOf( - ResponseField.Condition.typeCondition(arrayOf("Human")) - )) - ) - - operator fun invoke(reader: ResponseReader): Hero = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1]) - val friendsConnection = readObject(RESPONSE_FIELDS[2]) { reader -> - FriendsConnection1(reader) - }!! - val asHuman = readFragment(RESPONSE_FIELDS[3]) { reader -> - AsHuman(reader) - } - Hero( - __typename = __typename, - name = name, - friendsConnection = friendsConnection, - asHuman = asHuman - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * A humanoid creature from the Star Wars universe - */ - data class HeroWithReview( - val __typename: String = "Human", - /** - * What this human calls themselves - */ - val name: String - ) { - fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeString(RESPONSE_FIELDS[0], this@HeroWithReview.__typename) - writer.writeString(RESPONSE_FIELDS[1], this@HeroWithReview.name) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forString("__typename", "__typename", null, false, null), - ResponseField.forString("name", "name", null, false, null) - ) - - operator fun invoke(reader: ResponseReader): HeroWithReview = reader.run { - val __typename = readString(RESPONSE_FIELDS[0])!! - val name = readString(RESPONSE_FIELDS[1])!! - HeroWithReview( - __typename = __typename, - name = name - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - /** - * Data from the response after executing this GraphQL operation - */ - data class Data( - val hero: Hero?, - val heroWithReview: HeroWithReview? - ) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller = ResponseFieldMarshaller.invoke { writer -> - writer.writeObject(RESPONSE_FIELDS[0], this@Data.hero?.marshaller()) - writer.writeObject(RESPONSE_FIELDS[1], this@Data.heroWithReview?.marshaller()) - } - - companion object { - private val RESPONSE_FIELDS: Array = arrayOf( - ResponseField.forObject("hero", "hero", null, true, null), - ResponseField.forObject("heroWithReview", "heroWithReview", mapOf( - "listOfInts" to mapOf( - "kind" to "Variable", - "variableName" to "listOfInts")), true, null) - ) - - operator fun invoke(reader: ResponseReader): Data = reader.run { - val hero = readObject(RESPONSE_FIELDS[0]) { reader -> - Hero(reader) - } - val heroWithReview = readObject(RESPONSE_FIELDS[1]) { reader -> - HeroWithReview(reader) - } - Data( - hero = hero, - heroWithReview = heroWithReview - ) - } - - @Suppress("FunctionName") - fun Mapper(): ResponseFieldMapper = ResponseFieldMapper { invoke(it) } - } - } - - companion object { - const val OPERATION_ID: String = - "8072e53b9ff2579729b1fd0f06fe483b630c8c1e8a81c06f347a2f25bac675df" - - val QUERY_DOCUMENT: String = QueryDocumentMinifier.minify( - """ - |query GetHero(${'$'}myBool: Boolean = true, ${'$'}unit: LengthUnit! = FOOT, ${'$'}listOfInts: [Int] = [1, 2, 3], ${'$'}first: Int = null, ${'$'}optionalUnit: LengthUnit = METER) { - | hero { - | __typename - | name @include(if: ${'$'}myBool) - | ... on Human { - | height(unit: ${'$'}unit) - | heightInMeters: height(unit: ${'$'}optionalUnit) - | } - | friendsConnection(first: ${'$'}first) { - | __typename - | totalCount - | } - | } - | heroWithReview(listOfInts: ${'$'}listOfInts) { - | __typename - | name - | } - |} - """.trimMargin() - ) - - val OPERATION_NAME: OperationName = object : OperationName { - override fun name(): String = "GetHero" - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/variable_default_value/TestOperation.graphql b/apollo-compiler/src/test/graphql/com/example/variable_default_value/TestOperation.graphql deleted file mode 100644 index 114c06ee927..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/variable_default_value/TestOperation.graphql +++ /dev/null @@ -1,33 +0,0 @@ -query GetHero( - $myBool: Boolean = true, - $unit: LengthUnit! = FOOT, - $listOfInts: [Int] = [1, 2, 3] - $first: Int = null, - $optionalUnit: LengthUnit = METER, - # FIXME - #$review: ReviewInput! = { - # stars: 0, - # favoriteColor: { - # red: 1, - # blue: 1 - # }, - # listOfStringNonOptional: ["foo"], - #} -) { - hero { - name @include(if: $myBool) - ... on Human { - height(unit: $unit) - heightInMeters: height(unit: $optionalUnit) - } - friendsConnection(first: $first) { - totalCount - } - } - heroWithReview(listOfInts: $listOfInts) { - name - } - #heroWithReview(review: $review) { - # name - #} -} diff --git a/apollo-compiler/src/test/graphql/com/example/variable_default_value/type/CustomType.java b/apollo-compiler/src/test/graphql/com/example/variable_default_value/type/CustomType.java deleted file mode 100644 index ed782d46309..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/variable_default_value/type/CustomType.java +++ /dev/null @@ -1,24 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.variable_default_value.type; - -import com.apollographql.apollo.api.ScalarType; -import java.lang.Override; -import java.lang.String; - -public enum CustomType implements ScalarType { - ID { - @Override - public String typeName() { - return "ID"; - } - - @Override - public String className() { - return "java.lang.String"; - } - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/variable_default_value/type/CustomType.kt b/apollo-compiler/src/test/graphql/com/example/variable_default_value/type/CustomType.kt deleted file mode 100644 index ff18842a97f..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/variable_default_value/type/CustomType.kt +++ /dev/null @@ -1,17 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.variable_default_value.type - -import com.apollographql.apollo.api.ScalarType -import kotlin.String - -enum class CustomType : ScalarType { - ID { - override fun typeName(): String = "ID" - - override fun className(): String = "kotlin.String" - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/variable_default_value/type/LengthUnit.java b/apollo-compiler/src/test/graphql/com/example/variable_default_value/type/LengthUnit.java deleted file mode 100644 index 13e958fd94a..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/variable_default_value/type/LengthUnit.java +++ /dev/null @@ -1,47 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.variable_default_value.type; - -import java.lang.String; - -/** - * Units of height - */ -public enum LengthUnit { - /** - * The standard unit around the world - */ - METER("METER"), - - /** - * Primarily used in the United States - */ - FOOT("FOOT"), - - /** - * Auto generated constant for unknown enum values - */ - $UNKNOWN("$UNKNOWN"); - - private final String rawValue; - - LengthUnit(String rawValue) { - this.rawValue = rawValue; - } - - public String rawValue() { - return rawValue; - } - - public static LengthUnit safeValueOf(String rawValue) { - for (LengthUnit enumValue : values()) { - if (enumValue.rawValue.equals(rawValue)) { - return enumValue; - } - } - return LengthUnit.$UNKNOWN; - } -} diff --git a/apollo-compiler/src/test/graphql/com/example/variable_default_value/type/LengthUnit.kt b/apollo-compiler/src/test/graphql/com/example/variable_default_value/type/LengthUnit.kt deleted file mode 100644 index 60bc38c2823..00000000000 --- a/apollo-compiler/src/test/graphql/com/example/variable_default_value/type/LengthUnit.kt +++ /dev/null @@ -1,36 +0,0 @@ -// AUTO-GENERATED FILE. DO NOT MODIFY. -// -// This class was automatically generated by Apollo GraphQL plugin from the GraphQL queries it found. -// It should not be modified by hand. -// -package com.example.variable_default_value.type - -import com.apollographql.apollo.api.EnumValue -import kotlin.String - -/** - * Units of height - */ -enum class LengthUnit( - override val rawValue: String -) : EnumValue { - /** - * The standard unit around the world - */ - METER("METER"), - - /** - * Primarily used in the United States - */ - FOOT("FOOT"), - - /** - * Auto generated constant for unknown enum values - */ - UNKNOWN__("UNKNOWN__"); - - companion object { - fun safeValueOf(rawValue: String): LengthUnit = values().find { it.rawValue == rawValue } ?: - UNKNOWN__ - } -} diff --git a/apollo-compiler/src/test/graphql/schema.sdl b/apollo-compiler/src/test/graphql/schema.sdl deleted file mode 100644 index b40edb1f5bc..00000000000 --- a/apollo-compiler/src/test/graphql/schema.sdl +++ /dev/null @@ -1,449 +0,0 @@ -"""Dummy directive with multiple arguments that can be placed on operations.""" -directive @operationDirective( - """blah""" - dummy0: String! - dummy1: Int! -) on QUERY | MUTATION | SUBSCRIPTION - -"""For testing fragment type coercion""" -interface Bar { - bar: String! -} - -type BarObject implements Bar { - bar: String! -} - -"""A character from the Star Wars universe""" -interface Character { - """The dates of appearances""" - appearanceDates: [Date!]! - - """The movies this character appears in""" - appearsIn: [Episode]! - - """The date character was born.""" - birthDate: Date! - - """Test deprecated field""" - deprecated: String! @deprecated(reason: "For test purpose only") - - """Test deprecated field with no reason""" - deprecatedWithNoReason: String! @deprecated - - """Test deprecated field with blank reason""" - deprecatedWithBlankReason: String! @deprecated(reason: "") - - """Test deprecated field""" - deprecatedBool: Boolean! @deprecated(reason: "For test purpose only") - - """The date character was born.""" - fieldWithUnsupportedType: UnsupportedType! - - """The movie this character first appears in""" - firstAppearsIn: Episode! - - """The friends of the character, or an empty list if they have none""" - friends: [Character] - - """The friends of the character exposed as a connection with edges""" - friendsConnection(first: Int, after: ID): FriendsConnection! - - """The ID of the character""" - id: ID! - - """Links""" - links: [URL!]! - - """The name of the character""" - name: String! - - """Profile link""" - profileLink: URL! - - """Hero type""" - type: hero_type! -} - -"""The input object sent when passing in a color""" -input colorInput { - """Red color""" - red: Int! = 1 - - """Green color""" - green: Float = 0 - - """Blue color""" - blue: Float! = 1.5 - - """for test purpose only""" - enumWithDefaultValue: Episode = new - - """Circle ref to review input""" - reviewRefInput: ReviewRefInput -} - -"""The `Date` scalar type represents date format.""" -scalar Date - -"""An autonomous mechanical character in the Star Wars universe""" -type Droid implements Character { - """The dates of appearances""" - appearanceDates: [Date!]! - - """The movies this droid appears in""" - appearsIn: [Episode]! - - """The date droid was created.""" - birthDate: Date! - - """Test deprecated field""" - deprecated: String! @deprecated(reason: "For test purpose only") - - """Test deprecated field""" - deprecatedBool: Boolean! @deprecated(reason: "For test purpose only") - - """The date character was born.""" - fieldWithUnsupportedType: UnsupportedType! - - """The movie this character first appears in""" - firstAppearsIn: Episode! - - """This droid's friends, or an empty list if they have none""" - friends: [Character] - - """The friends of the droid exposed as a connection with edges""" - friendsConnection(first: Int, after: ID): FriendsConnection! - - """The ID of the droid""" - id: ID! - - """Links""" - links: [URL!]! - - """What others call this droid""" - name: String! - - """This droid's primary function""" - primaryFunction: String - - """Profile link""" - profileLink: URL! - - """Hero type""" - type: hero_type! -} - -"""The episodes in the Star Wars trilogy""" -enum Episode { - """Star Wars Episode IV: A New Hope, released in 1977.""" - NEWHOPE - - """Star Wars Episode V: The Empire Strikes Back, released in 1980.""" - EMPIRE - - """Star Wars Episode VI: Return of the Jedi, released in 1983.""" - JEDI - - """Test deprecated enum value""" - DEPRECATED @deprecated(reason: "For test purpose only") - - """Test java reserved word""" - new @deprecated(reason: "For test purpose only") -} - -"""For testing fragment type coercion""" -interface Foo { - foo: String! -} - -"""For testing fragment type coercion""" -type FooBar implements Foo & Bar { - bar: String! - foo: String! -} - -"""For testing fragment type coercion""" -type FooObject implements Foo { - foo: String! -} - -"""A connection object for a character's friends""" -type FriendsConnection { - """The edges for each of the character's friends.""" - edges: [FriendsEdge] - - """A list of the friends, as a convenience when edges are not needed.""" - friends: [Character] - - """For test java beans semantic naming only""" - isEmpty: Boolean! - - """Information for paginating this connection""" - pageInfo: PageInfo! - - """The total number of friends""" - totalCount: Int -} - -"""An edge object for a character's friends""" -type FriendsEdge { - """A cursor used for pagination""" - cursor: ID! - - """The character represented by this friendship edge""" - node: Character -} - -"""Lower case enum type name""" -enum hero_type { - human - droid -} - -"""A humanoid creature from the Star Wars universe""" -type Human implements Character { - """The dates of appearances""" - appearanceDates: [Date!]! - - """The movies this human appears in""" - appearsIn: [Episode]! - - """The date character was born.""" - birthDate: Date! - - """Test deprecated field""" - deprecated: String! @deprecated(reason: "For test purpose only") - - """Test deprecated field""" - deprecatedBool: Boolean! @deprecated(reason: "For test purpose only") - - """The date character was born.""" - fieldWithUnsupportedType: UnsupportedType! - - """The movie this character first appears in""" - firstAppearsIn: Episode! - - """This human's friends, or an empty list if they have none""" - friends: [Character] - - """The friends of the human exposed as a connection with edges""" - friendsConnection(first: Int, after: ID): FriendsConnection! - - """Height in the preferred unit, default is meters""" - height(unit: LengthUnit = METER): Float - - """The home planet of the human, or null if unknown""" - homePlanet: String - - """The ID of the human""" - id: ID! - - """Links""" - links: [URL!]! - - """Mass in kilograms, or null if unknown""" - mass: Float - - """What this human calls themselves""" - name: String! - - """Profile link""" - profileLink: URL! - - """A list of starships this person has piloted, or an empty list if none""" - starships: [Starship] - - """Hero type""" - type: hero_type! -} - -"""Units of height""" -enum LengthUnit { - """The standard unit around the world""" - METER - - """Primarily used in the United States""" - FOOT -} - -"""The mutation type, represents all updates we can make to our data""" -type Mutation { - createReview(episode: Episode, review: ReviewInput!): Review - """For testing https://github.com/apollographql/apollo-android/issues/2660""" - stat_collect: [Boolean!]! @deprecated(reason: "Deprecated") -} - -"""Information for paginating this connection""" -type PageInfo { - endCursor: ID - hasNextPage: Boolean! - startCursor: ID -} - -""" -The query type, represents all of the entry points into our object graph -""" -type Query { - character(id: ID!): Character - droid(id: ID!): Droid - - testNullableArguments( - int: Int, - float: Float, - string: String, - episode: Episode, - review: ReviewInput, - boolean: Boolean, - list: [Episode]): Int! - - """For testing fragment type coercion""" - foo: Foo - hero( - episode: Episode - - """for test purpose only""" - listOfListOfStringArgs: [[String]] - ): Character - heroDetailQuery: Character - heroWithReview( - episode: Episode - review: ReviewInput - - """for test purpose only""" - listOfInts: [Int] - ): Human - human(id: ID!): Human - nonOptionalHero(episode: Episode): Character! - reviews(episode: Episode!, starsInt: Int, starsFloat: Float): [Review] - search(text: String): [SearchResult] - starship(id: ID!): Starship - tree: Tree -} - -"""Represents a review for a movie""" -type Review { - """Comment about the movie""" - commentary: String - - """for test purpose only""" - listOfListOfCustom: [[Date!]!] - - """for test purpose only""" - listOfListOfEnum: [[Episode!]!] - - """for test purpose only""" - listOfListOfObject: [[Character!]!] - - """for test purpose only""" - listOfListOfString: [[String!]!] - - """The number of stars this review gave, 1-5""" - stars: Int! -} - -"""The input object sent when someone is creating a new review""" -input ReviewInput { - """0-5 stars""" - stars: Int! - - """for test purpose only""" - nullableIntFieldWithDefaultValue: Int = 10 - - """Comment about the movie, optional""" - commentary: String - - """Favorite color, optional""" - favoriteColor: colorInput! - - """for test purpose only""" - enumWithDefaultValue: Episode = JEDI - - """for test purpose only""" - nonNullableEnumWithDefaultValue: Episode! = JEDI - - """for test purpose only""" - nullableEnum: Episode - - """for test purpose only""" - listOfCustomScalar: [Date] = ["1984-06-21", "1984-11-21"] - - """for test purpose only""" - customScalar: Date = "1984-06-21" - - """for test purpose only""" - listOfEnums: [Episode] = [NEWHOPE, EMPIRE] - - """for test purpose only""" - listOfInt: [Int] = [1, 2, 3] - - """for test purpose only""" - listOfString: [String] = ["test1", "test2", "test3"] - - """for test purpose only""" - listOfStringNonOptional: [String]! - - """for test purpose only""" - listOfInputTypes: [colorInput] = [] - - """for test purpose only""" - booleanWithDefaultValue: Boolean = true - - """for test purpose only""" - booleanNonOptional: Boolean - - """for test purpose only""" - listOfListOfString: [[String!]!] - - """for test purpose only""" - listOfListOfEnum: [[Episode!]!] - - """for test purpose only""" - listOfListOfCustom: [[Date!]!] - - """for test purpose only""" - listOfListOfObject: [[colorInput!]!] - - """for test purpose only""" - CapitalizedField: String - - """for test purpose only""" - CapitalizedInt: Int -} - -"""Circle ref to review input""" -input ReviewRefInput { - reviewInput: ReviewInput -} - -union SearchResult = Human | Droid | Starship - -type Starship { - coordinates: [[Float!]!] - - """The ID of the starship""" - id: ID! - - """Length of the starship, along the longest axis""" - length(unit: LengthUnit = METER): Float - - """The name of the starship""" - name: String! -} - -"""To test recursive structures""" -type Tree { - children: [Tree!]! - name: String! - parent: Tree -} - -"""UnsupportedType for testing""" -scalar UnsupportedType - -"""URL for testing""" -scalar URL - -extend type Starship { - shieldLevel: Float! -} \ No newline at end of file diff --git a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/CodegenTest.kt b/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/CodegenTest.kt deleted file mode 100644 index 19e20a3bd13..00000000000 --- a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/CodegenTest.kt +++ /dev/null @@ -1,207 +0,0 @@ -package com.apollographql.apollo.compiler - -import com.apollographql.apollo.api.internal.QueryDocumentMinifier -import com.apollographql.apollo.compiler.TestUtils.checkTestFixture -import com.apollographql.apollo.compiler.TestUtils.shouldUpdateTestFixtures -import com.apollographql.apollo.compiler.parser.sdl.GraphSdlSchema -import com.apollographql.apollo.compiler.parser.sdl.toIntrospectionSchema -import com.google.common.truth.Truth.assertAbout -import com.google.testing.compile.JavaFileObjects -import com.google.testing.compile.JavaSourcesSubjectFactory.javaSources -import com.tschuchort.compiletesting.KotlinCompilation -import com.tschuchort.compiletesting.SourceFile -import org.junit.Assert.fail -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.Parameterized -import java.io.File - -@RunWith(Parameterized::class) -class CodegenTest(private val folder: File, private val testLanguage: TestLanguage) { - enum class TestLanguage { - Java, - Kotlin - } - - @Test - fun generateExpectedClasses() { - val args = arguments(folder = folder, generateKotlinModels = testLanguage == TestLanguage.Kotlin) - generateExpectedClasses(args) - } - - private fun generateExpectedClasses(args: GraphQLCompiler.Arguments) { - args.outputDir.deleteRecursively() - GraphQLCompiler().write(args) - - val extension = if (args.generateKotlinModels) { - "kt" - } else { - "java" - } - - val expectedRoot = folder.parentFile.parentFile.parentFile - val expectedFiles = folder.walk().filter { - it.isFile && it.extension == extension - } - - val actualRoot = args.outputDir - val actualFiles = actualRoot.walk().filter { - // extension should always be the correct one, it's a bug else - it.isFile - } - - expectedFiles.forEach { expected -> - val relativePath = expected.relativeTo(expectedRoot).path - val actual = File(actualRoot, relativePath) - if (!actual.exists()) { - if (shouldUpdateTestFixtures()) { - println("removing stale expected file: ${expected.absolutePath}") - expected.delete() - return@forEach - } else { - throw Exception("No actual file for ${actual.absolutePath}") - } - } - checkTestFixture(actual = actual, expected = expected) - } - actualFiles.forEach { actual -> - val relativePath = actual.relativeTo(actualRoot).path - val expected = File(expectedRoot, relativePath) - if (!expected.exists()) { - if (shouldUpdateTestFixtures()) { - println("adding expected file: ${actual.absolutePath} - ${actual.path}") - actual.copyTo(expected) - return@forEach - } else { - throw Exception("No expected file for ${expected.absolutePath}") - } - } - // no need to call checkTestFixture again, this has been taken care of - } - - // And that they compile - if (!args.generateKotlinModels) { - JavaCompiler.assertCompiles(actualFiles.toSet()) - } else { - val expectedWarnings = folder.name in listOf("deprecation", "custom_scalar_type_warnings", "arguments_complex", "arguments_simple") - KotlinCompiler.assertCompiles(actualFiles.toSet(), !expectedWarnings) - } - } - - companion object { - fun arguments(folder: File, generateKotlinModels: Boolean): GraphQLCompiler.Arguments { - val customTypeMap = if (folder.name in listOf("custom_scalar_type", "input_object_type", "mutation_create_review")) { - if (generateKotlinModels) { - mapOf("Date" to "java.util.Date", "URL" to "kotlin.String", "ID" to "kotlin.Int") - } else { - mapOf("Date" to "java.util.Date", "URL" to "java.lang.String", "ID" to "java.lang.Integer") - } - } else { - emptyMap() - } - val nullableValueType = when (folder.name) { - "hero_details_guava" -> NullableValueType.GUAVA_OPTIONAL - "hero_details_java_optional" -> NullableValueType.JAVA_OPTIONAL - "fragments_with_type_condition_nullable" -> NullableValueType.ANNOTATED - "hero_details_nullable" -> NullableValueType.ANNOTATED - "union_fragment" -> NullableValueType.ANNOTATED - else -> NullableValueType.APOLLO_OPTIONAL - } - val useSemanticNaming = when (folder.name) { - "hero_details_semantic_naming" -> true - "mutation_create_review_semantic_naming" -> true - else -> false - } - val generateModelBuilder = when (folder.name) { - "fragment_with_inline_fragment" -> true - else -> false - } - val useJavaBeansSemanticNaming = when (folder.name) { - "java_beans_semantic_naming" -> true - else -> false - } - val suppressRawTypesWarning = when (folder.name) { - "custom_scalar_type_warnings" -> true - else -> false - } - val generateVisitorForPolymorphicDatatypes = when (folder.name) { - "java_beans_semantic_naming" -> false - else -> true - } - val generateAsInternal = when (folder.name) { - "mutation_create_review", "simple_fragment" -> true - else -> false - } - - val operationIdGenerator = when (folder.name) { - "operation_id_generator" -> object : OperationIdGenerator { - override fun apply(operationDocument: String, operationFilepath: String): String { - return "hash" - } - - override val version: String = "1" - } - else -> OperationIdGenerator.Sha256() - } - - val enumAsSealedClassPatternFilters = when(folder.name) { - "arguments_complex" -> setOf(".*") // test all pattern matching - "arguments_simple" -> setOf("Bla-bla", "Yada-yada", "Ep.*de") // test multiple pattern matching - "enum_type" -> setOf("Bla") // test not matching - else -> emptySet() - } - - val packageName = when(folder.name) { - // TODO reorganize tests so that we don't have to make this a child of "com.example.fragment_package_name" - "fragment_package_name" -> "com.example.fragment_package_name.another" - else -> null - } - - val schemaFile = folder.listFiles()!!.find { it.isFile && it.name == "schema.sdl" } - ?: File("src/test/graphql/schema.sdl") - - val graphqlFiles = setOf(File(folder, "TestOperation.graphql")) - val operationOutputGenerator = OperationOutputGenerator.DefaultOperationOuputGenerator(operationIdGenerator) - - val language = if (generateKotlinModels) "kotlin" else "java" - return GraphQLCompiler.Arguments( - rootPackageName = "com.example.${folder.name}", - rootFolders = listOf(folder), - graphqlFiles = graphqlFiles, - schemaFile = schemaFile, - outputDir = File("build/generated/test/${folder.name}/$language"), - operationOutputGenerator = operationOutputGenerator, - customTypeMap = customTypeMap, - generateKotlinModels = generateKotlinModels, - nullableValueType = nullableValueType, - useSemanticNaming = useSemanticNaming, - generateModelBuilder = generateModelBuilder, - useJavaBeansSemanticNaming = useJavaBeansSemanticNaming, - suppressRawTypesWarning = suppressRawTypesWarning, - generateVisitorForPolymorphicDatatypes = generateVisitorForPolymorphicDatatypes, - generateAsInternal = generateAsInternal, - kotlinMultiPlatformProject = true, - enumAsSealedClassPatternFilters = enumAsSealedClassPatternFilters, - metadataOutputFile = File("build/generated/test/${folder.name}/metadata/$language"), - packageName = packageName - ) - } - - @JvmStatic - @Parameterized.Parameters(name = "{0}-{1}") - fun data() = File("src/test/graphql/com/example/") - .listFiles()!! - .filter { it.isDirectory } - .let { - it.map { - arrayOf(it, TestLanguage.Kotlin) - } + it.filter { - // TODO: This specific test currently doesn't generate valid Java code - // see https://github.com/apollographql/apollo-android/issues/2676 - !it.name.contains("test_inline") - }.map { - arrayOf(it, TestLanguage.Java) - } - } - } -} diff --git a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/GraphSdlParseTest.kt b/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/GraphSdlParseTest.kt deleted file mode 100644 index 5c62f7c64de..00000000000 --- a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/GraphSdlParseTest.kt +++ /dev/null @@ -1,94 +0,0 @@ -package com.apollographql.apollo.compiler - -import com.apollographql.apollo.compiler.parser.error.ParseException -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema.Companion.wrap -import com.apollographql.apollo.compiler.parser.introspection.toSDL -import com.apollographql.apollo.compiler.parser.sdl.GraphSdlSchema -import com.apollographql.apollo.compiler.parser.sdl.toIntrospectionSchema -import com.google.common.truth.Truth -import com.google.common.truth.Truth.assertThat -import org.junit.Assert.assertEquals -import org.junit.Assert.fail -import org.junit.Test -import java.io.File - -class GraphSdlParseTest() { - - /** - * GraphQL has Int and Float, json has only Number, map everything to Double - */ - private fun Any?.normalizeNumbers(): Any? { - return when (this) { - is List<*> -> this.map { it?.normalizeNumbers() } - is Number -> this.toDouble() - else -> this - } - } - - private fun IntrospectionSchema.Type.normalize(): IntrospectionSchema.Type { - return when (this) { - is IntrospectionSchema.Type.Scalar -> this - is IntrospectionSchema.Type.Object -> copy(fields = fields?.sortedBy { field -> field.name }) - is IntrospectionSchema.Type.Interface -> copy(fields = fields?.sortedBy { field -> field.name }) - is IntrospectionSchema.Type.Union -> copy(fields = fields?.sortedBy { field -> field.name }) - is IntrospectionSchema.Type.Enum -> this - is IntrospectionSchema.Type.InputObject -> copy(inputFields = inputFields.map { - it.copy(defaultValue = it.defaultValue.normalizeNumbers()) - }.sortedBy { field -> field.name }) - } - } - - @Test - fun `SDL schema parsed successfully and produced the same introspection schema`() { - /** - * Things to watch out: - * - leading/trailing spaces in descriptions - * - defaultValue coercion - */ - val actualSchema = GraphSdlSchema(File("src/test/sdl/schema.sdl")).toIntrospectionSchema().normalize() - val expectedSchema = IntrospectionSchema(File("src/test/sdl/schema.json")).normalize() - - assertEquals(actualSchema.toString(), expectedSchema.toString()) - } - - private fun IntrospectionSchema.normalize(): IntrospectionSchema { - return copy(types = toSortedMap().mapValues { (_, type) -> type.normalize() }) - } - - @Test - fun `implementing an object fails`() { - try { - GraphSdlSchema(File("src/test/sdl/implements-object.sdl")) - fail("parse expected to fail but was successful") - } catch (e: ParseException) { - assertThat(e.message).contains("Object `Cat` cannot implement non-interface `Animal`") - } - } - - @Test - fun `repeatable directive does not throw`() { - GraphSdlSchema(File("src/test/sdl/repeated-directive.sdl")) - } - - @Test - fun `writing SDL and parsing again yields identical schemas`() { - val initialSchema = IntrospectionSchema(File("src/test/sdl/schema.json")).normalize() - val sdlFile = File("build/sdl-test/schema.sdl") - sdlFile.parentFile.deleteRecursively() - sdlFile.parentFile.mkdirs() - initialSchema.toSDL(sdlFile) - val finalSchema = GraphSdlSchema(sdlFile).toIntrospectionSchema().normalize() - - dumpSchemas(initialSchema, finalSchema) - assertEquals(initialSchema, finalSchema) - } - - /** - * use to make easier diffs - */ - private fun dumpSchemas(expected: IntrospectionSchema, actual: IntrospectionSchema) { - actual.wrap().toJson(File("build/sdl-test/actual.json"), " ") - expected.wrap().toJson(File("build/sdl-test/expected.json"), " ") - } -} diff --git a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/JavaCompiler.kt b/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/JavaCompiler.kt deleted file mode 100644 index 282c71c4c95..00000000000 --- a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/JavaCompiler.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.apollographql.apollo.compiler - -import com.google.common.truth.Truth -import com.google.testing.compile.JavaFileObjects -import com.google.testing.compile.JavaSourcesSubjectFactory -import java.io.File - -object JavaCompiler { - fun assertCompiles(files: Set) { - val javaFileObjects = files.map { - val qualifiedName = it.path - .substringBeforeLast(".") - .split(File.separator) - .joinToString(".") - - JavaFileObjects.forSourceLines(qualifiedName, - it.readLines()) - }.toList() - - Truth.assertAbout(JavaSourcesSubjectFactory.javaSources()).that(javaFileObjects).compilesWithoutError() - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/JavaTypeResolverTest.kt b/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/JavaTypeResolverTest.kt deleted file mode 100644 index 395f78b1735..00000000000 --- a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/JavaTypeResolverTest.kt +++ /dev/null @@ -1,113 +0,0 @@ -package com.apollographql.apollo.compiler - -import com.apollographql.apollo.compiler.ir.CodeGenerationContext -import com.apollographql.apollo.compiler.ir.CodeGenerationIR -import com.squareup.javapoet.ClassName -import com.squareup.javapoet.TypeName -import org.junit.Assert -import org.junit.Test -import java.util.Date - -class JavaTypeResolverTest { - private val defaultContext = CodeGenerationContext( - reservedTypeNames = emptyList(), - typeDeclarations = emptyList(), - customTypeMap = emptyMap(), - operationOutput = emptyMap(), - nullableValueType = NullableValueType.APOLLO_OPTIONAL, - ir = CodeGenerationIR( - emptyList(), - emptyList(), - emptyList(), - emptySet(), - emptySet(), - emptySet(), - emptySet(), - ""), - useSemanticNaming = false, - generateModelBuilder = false, - useJavaBeansSemanticNaming = false, - suppressRawTypesWarning = false, - generateVisitorForPolymorphicDatatypes = false - ) - private val defaultResolver = JavaTypeResolver(defaultContext, packageName) - - @Test - fun resolveScalarType() { - Assert.assertEquals(ClassNames.STRING.annotated(Annotations.NONNULL), defaultResolver.resolve("String!")) - Assert.assertEquals(ClassNames.parameterizedOptional(ClassNames.STRING), defaultResolver.resolve("String", true)) - - Assert.assertEquals(TypeName.INT, defaultResolver.resolve("Int!")) - Assert.assertEquals(ClassNames.parameterizedOptional(TypeName.INT.box()), defaultResolver.resolve("Int", true)) - - Assert.assertEquals(TypeName.BOOLEAN, defaultResolver.resolve("Boolean!")) - Assert.assertEquals(ClassNames.parameterizedOptional(TypeName.BOOLEAN.box()), - defaultResolver.resolve("Boolean", true)) - - Assert.assertEquals(TypeName.DOUBLE, defaultResolver.resolve("Float!")) - Assert.assertEquals(ClassNames.parameterizedOptional(TypeName.DOUBLE.box()), defaultResolver.resolve("Float", true)) - } - - @Test - fun resolveListType() { - Assert.assertEquals(ClassNames.parameterizedListOf(ClassNames.STRING).annotated(Annotations.NONNULL), - defaultResolver.resolve("[String!]!")) - Assert.assertEquals(ClassNames.parameterizedOptional(ClassNames.parameterizedListOf(ClassNames.STRING)), - defaultResolver.resolve("[String!]", true)) - - Assert.assertEquals(ClassNames.parameterizedListOf(TypeName.INT.box()).annotated(Annotations.NONNULL), - defaultResolver.resolve("[Int]!")) - Assert.assertEquals(ClassNames.parameterizedOptional(ClassNames.parameterizedListOf(TypeName.INT.box())), - defaultResolver.resolve("[Int]", true)) - - Assert.assertEquals(ClassNames.parameterizedListOf(TypeName.BOOLEAN.box()).annotated(Annotations.NONNULL), - defaultResolver.resolve("[Boolean]!")) - Assert.assertEquals(ClassNames.parameterizedOptional(ClassNames.parameterizedListOf(TypeName.BOOLEAN.box())), - defaultResolver.resolve("[Boolean]", true)) - - Assert.assertEquals(ClassNames.parameterizedListOf(TypeName.DOUBLE.box()).annotated(Annotations.NONNULL), - defaultResolver.resolve("[Float]!")) - Assert.assertEquals(ClassNames.parameterizedOptional(ClassNames.parameterizedListOf(TypeName.DOUBLE.box())), - defaultResolver.resolve("[Float]", true)) - - Assert.assertEquals(ClassNames.parameterizedListOf(ClassNames.parameterizedListOf(ClassNames.STRING)).annotated( - Annotations.NONNULL), - defaultResolver.resolve("[[String!]!]!")) - Assert.assertEquals(ClassNames.parameterizedOptional( - ClassNames.parameterizedListOf(ClassNames.parameterizedListOf(ClassNames.STRING))), - defaultResolver.resolve("[[String]]", true)) - } - - @Test - fun resolveCustomType() { - Assert.assertEquals(ClassName.get("", "CustomClass").annotated(Annotations.NONNULL), - JavaTypeResolver(defaultContext, "").resolve("CustomClass!")) - Assert.assertEquals(ClassNames.parameterizedOptional(ClassName.get("", "CustomClass")), - JavaTypeResolver(defaultContext, "").resolve("CustomClass", true)) - - Assert.assertEquals(ClassName.get(packageName, "CustomClass").annotated(Annotations.NONNULL), - defaultResolver.resolve("CustomClass!")) - Assert.assertEquals(ClassNames.parameterizedOptional(ClassName.get(packageName, "CustomClass")), - defaultResolver.resolve("CustomClass", true)) - } - - @Test - fun resolveCustomScalarType() { - val context = defaultContext.copy(customTypeMap = mapOf("Date" to "java.util.Date", "UnsupportedType" to "Object", - "ID" to "java.lang.Integer")) - Assert.assertEquals(ClassName.get(Date::class.java).annotated(Annotations.NONNULL), - JavaTypeResolver(context, packageName).resolve("Date", false)) - Assert.assertEquals(ClassNames.parameterizedOptional(Date::class.java), - JavaTypeResolver(context, packageName).resolve("Date", true)) - Assert.assertEquals(ClassNames.parameterizedOptional(ClassName.get("", "Object")), - JavaTypeResolver(context, packageName).resolve("UnsupportedType", true)) - Assert.assertEquals(ClassName.get(Integer::class.java).annotated(Annotations.NONNULL), - JavaTypeResolver(context, packageName).resolve("ID", false)) - Assert.assertEquals(ClassNames.parameterizedOptional(Integer::class.java), - JavaTypeResolver(context, packageName).resolve("ID", true)) - } - - companion object { - private const val packageName = "com.example" - } -} diff --git a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/KotlinCompiler.kt b/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/KotlinCompiler.kt deleted file mode 100644 index f1d72b1c2bf..00000000000 --- a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/KotlinCompiler.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.apollographql.apollo.compiler - -import com.tschuchort.compiletesting.KotlinCompilation -import com.tschuchort.compiletesting.SourceFile -import org.junit.Assert -import java.io.File - -object KotlinCompiler { - fun assertCompiles(files: Set, allWarningAsErrors: Boolean) { - val kotlinFiles = files.map { - SourceFile.kotlin(it.name, it.readText()) - }.toList() - - val result = KotlinCompilation().apply { - jvmTarget = "1.8" - sources = kotlinFiles - - allWarningsAsErrors = false // TODO: enable again when kotlin-test-compile targets Kotlin 1.4 allWarningAsErrors - inheritClassPath = true - messageOutputStream = System.out // see diagnostics in real time - }.compile() - - if (result.exitCode != KotlinCompilation.ExitCode.OK) { - val compilationErrorMessages = "\\ne: .*\\n+".toRegex().find(result.messages)?.groupValues ?: emptyList() - val errorMessages = compilationErrorMessages.joinToString(prefix = "\n", separator = "\n", postfix = "\n") { - "`${it.replace("\n", "")}`" - } - Assert.fail("Failed to compile generated Kotlin files due to compiler errors: $errorMessages") - } - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/MetadataTest.kt b/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/MetadataTest.kt deleted file mode 100644 index 86a3adcb635..00000000000 --- a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/MetadataTest.kt +++ /dev/null @@ -1,253 +0,0 @@ -package com.apollographql.apollo.compiler - -import com.apollographql.apollo.compiler.parser.error.DocumentParseException -import com.apollographql.apollo.compiler.parser.error.ParseException -import com.google.common.truth.Truth -import org.junit.Assert.fail -import org.junit.Before -import org.junit.Test -import java.io.File - -class MetadataTest { - private val buildDir = File("build/metadata-test/") - private val rootGraphqlDir = File(buildDir, "root/graphql") - private val rootSchemaFile = File(buildDir, "root/graphql/schema.sdl") - private val rootSourcesDir = File(buildDir, "root/sources") - private val rootMetadataFile = File(buildDir, "root/metadata/metadata.json") - private val leafGraphqlDir = File(buildDir, "leaf/graphql") - private val leafSourcesDir = File(buildDir, "leaf/sources") - private val leafMetadataFile = File(buildDir, "leaf/metadata/metadata.json") - - @Before - fun before() { - buildDir.deleteRecursively() - buildDir.mkdirs() - } - - private fun alwaysGenerateTypesMatchingTest(alwaysGenerateTypesMatching: Set?) { - val schema = SchemaGenerator.generateSDLSchemaWithInputTypes(6) - - rootSchemaFile.parentFile.mkdirs() - rootSchemaFile.writeText(schema) - - val rootArgs = GraphQLCompiler.Arguments( - rootFolders = emptyList(), - graphqlFiles = emptySet(), - schemaFile = rootSchemaFile, - alwaysGenerateTypesMatching = alwaysGenerateTypesMatching, - outputDir = rootSourcesDir, - generateKotlinModels = true, - metadataOutputFile = rootMetadataFile, - generateMetadata = true - ) - GraphQLCompiler().write(rootArgs) - - - val leafFolders = listOf(leafGraphqlDir) - leafGraphqlDir.mkdirs() - File(leafGraphqlDir, "queries.graphql").writeText(SchemaGenerator.generateMutation()) - val leafArgs = GraphQLCompiler.Arguments( - rootFolders = leafFolders, - graphqlFiles = leafFolders.graphqlFiles(), - schemaFile = null, - metadata = listOf(rootMetadataFile), - outputDir = leafSourcesDir, - generateKotlinModels = true, - metadataOutputFile = leafMetadataFile, - generateMetadata = false - ) - GraphQLCompiler().write(leafArgs) - - KotlinCompiler.assertCompiles(listOf(rootSourcesDir, leafSourcesDir).kotlinFiles(), true) - } - - @Test - fun `default alwaysGenerateTypesMatching generate all types in root`() { - alwaysGenerateTypesMatchingTest(null) - - // All types are generated - rootSourcesDir.assertContents( - "MessageInput0.kt", - "Body0.kt", - "User0.kt", - "MessageInput1.kt", - "Body1.kt", - "User1.kt", - "CustomType.kt", - "Encoding.kt", - "__TypeKind.kt", - "__DirectiveLocation.kt", - ) - - // Only the mutation is generated in the leaf - leafSourcesDir.assertContents("SendMessageMutation.kt") - } - - @Test - fun `empty alwaysGenerateTypesMatching does not generate types in root`() { - alwaysGenerateTypesMatchingTest(emptySet()) - - // Only scalar types are generated in the root - rootSourcesDir.assertContents("CustomType.kt") - - // Leaf contains its referenced types but not the unused ones - leafSourcesDir.assertContents( - "MessageInput0.kt", - "SendMessageMutation.kt", - "Body0.kt", - "User0.kt", - "Encoding.kt" - ) - } - - @Test - fun `alwaysGenerateTypesMatching can force generating a type not used downstream`() { - alwaysGenerateTypesMatchingTest(setOf(".*1")) - - // types ending with "1" end up in root - rootSourcesDir.assertContents( - "MessageInput1.kt", - "Body1.kt", - "User1.kt", - "CustomType.kt", - "Encoding.kt" - ) - - // Leaf contains its referenced types but not the unused ones - leafSourcesDir.assertContents( - "MessageInput0.kt", - "SendMessageMutation.kt", - "Body0.kt", - "User0.kt" - ) - } - - private fun fragmentTest(dirName: String) { - val folder = File("src/test/metadata/$dirName/") - val rootArgs = GraphQLCompiler.Arguments( - rootFolders = listOf(folder), - graphqlFiles = setOf(File(folder, "root.graphql")), - schemaFile = File("src/test/metadata/schema.sdl"), - alwaysGenerateTypesMatching = null, - outputDir = rootSourcesDir, - generateKotlinModels = true, - metadataOutputFile = rootMetadataFile, - generateMetadata = true, - rootProjectDir = folder - ) - GraphQLCompiler().write(rootArgs) - - val leafArgs = GraphQLCompiler.Arguments( - rootFolders = listOf(folder), - graphqlFiles = setOf(File(folder, "leaf.graphql")), - schemaFile = null, - metadata = listOf(rootMetadataFile), - outputDir = leafSourcesDir, - generateKotlinModels = true, - metadataOutputFile = leafMetadataFile, - rootProjectDir = folder - ) - GraphQLCompiler().write(leafArgs) - - KotlinCompiler.assertCompiles(listOf(rootSourcesDir, leafSourcesDir).kotlinFiles(), true) - } - - @Test - fun `fragments can be reused`() { - fragmentTest("simple") - - // Root generates the fragment - rootSourcesDir.assertContents( - "Hero_type.kt", - "Episode.kt", - "CustomType.kt", - "LengthUnit.kt", - "CharacterFragment.kt", - "__TypeKind.kt", - "__DirectiveLocation.kt", - ) - - // Leaf contains the query but not the fragment - leafSourcesDir.assertContents( - "GetHeroQuery.kt" - ) - } - - @Test - fun `fragments validation error`() { - try { - fragmentTest("fragment-variable-error") - fail("Parsing the fragment should have failed") - } catch (e: DocumentParseException) { - val actualMessage = e.message?.replace(File("src/test/metadata/fragment-variable-error/").absolutePath, "") ?: "" - val expectedMessage = File("src/test/metadata/fragment-variable-error/error").readText() - - Truth.assertThat(actualMessage).isEqualTo(expectedMessage) - } - - val apolloMetadata = ApolloMetadata.readFrom(rootMetadataFile)!! - // Make sure the metadata does not contain absolute paths - apolloMetadata.fragments.forEach { - Truth.assertThat(it.filePath).isEqualTo("root.graphql") - } - - // Nothing is generated - leafSourcesDir.assertContents() - } - - @Test - fun `fragments nameclash error`() { - try { - fragmentTest("fragment-nameclash-error") - fail("Parsing the fragment should have failed") - } catch (e: ParseException) { - val actualMessage = e.message?.replace(File("src/test/metadata/fragment-nameclash-error/").absolutePath, "") ?: "" - val expectedMessage = File("src/test/metadata/fragment-nameclash-error/error").readText() - - Truth.assertThat(actualMessage).isEqualTo(expectedMessage) - } - - // Nothing is generated - leafSourcesDir.assertContents() - } - - @Test - fun `fragments in both parent and child`() { - fragmentTest("fragment-multiple") - - rootSourcesDir.assertContents( - "Hero_type.kt", - "Episode.kt", - "CustomType.kt", - "LengthUnit.kt", - "CharacterFragment.kt", - "__TypeKind.kt", - "__DirectiveLocation.kt", - ) - - leafSourcesDir.assertContents( - "GetHeroQuery.kt", - "HumanFragment.kt" - ) - } - - companion object { - private fun List.graphqlFiles(): Set { - return flatMap { - it.walk().filter { it.extension == "graphql" }.toList() - }.toSet() - } - - private fun List.kotlinFiles(): Set { - return flatMap { - it.walk().filter { it.extension == "kt" }.toList() - }.toSet() - } - - private fun File.assertContents(vararg files: String) { - Truth.assertThat(walk().filter { it.isFile }.map { it.name }.toSet()).isEqualTo( - files.toSet() - ) - } - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/SchemaGenerator.kt b/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/SchemaGenerator.kt deleted file mode 100644 index 15fe294328b..00000000000 --- a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/SchemaGenerator.kt +++ /dev/null @@ -1,64 +0,0 @@ -package com.apollographql.apollo.compiler - -object SchemaGenerator { - fun generateSDLSchemaWithInputTypes(inputTypeCount: Int): String { - val inputTypes42 = """ -input User42 { - id: ID! - name: String! -} - -input Body42 { - subject: String! - content: String! -} - -scalar CustomScalar42 - -input MessageInput42 { - from: User42! - to: User42! - body: Body42! - customScalar: CustomScalar42! - id: ID! - encoding: Encoding! -} -""" - - val roots = """ - type Query { - random: String! - } - - enum Encoding { - UTF8, - CP1952 - } - - type Mutation { -""".trimIndent() - - // There are 3 input types for each loop - val repeat = inputTypeCount / 3 - - val stringBuilder = StringBuilder() - repeat(repeat) { - stringBuilder.append(inputTypes42.replace("42", it.toString())) - } - stringBuilder.append(roots) - repeat(repeat) { - stringBuilder.append("sendMessage$it(\$input: MessageInput$it): String!") - } - stringBuilder.append("}\n") - - return stringBuilder.toString() - } - - fun generateMutation(): String { - return """ - mutation sendMessage( ${'$'}input : MessageInput0) { - sendMessage0(input: ${'$'}input ) - } - """.trimIndent() - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/TestUtils.kt b/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/TestUtils.kt deleted file mode 100644 index 48a70bad7e2..00000000000 --- a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/TestUtils.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.apollographql.apollo.compiler - -import java.io.File -import java.lang.Exception - -internal object TestUtils { - internal fun shouldUpdateTestFixtures(): Boolean { - return when (System.getProperty("updateTestFixtures")?.trim()) { - "on", "true", "1" -> true - else -> false - } - } - - internal fun checkTestFixture(actual: File, expected: File) { - val actualText = actual.readText() - val expectedText = expected.readText() - - if (actualText != expectedText) { - if (shouldUpdateTestFixtures()) { - expected.writeText(actualText) - } else { - throw Exception("""generatedFile content doesn't match the expectedFile content. - |If you changed the compiler recently, you need to update the testFixtures. - |Run the tests with `-DupdateTestFixtures=true` to do so. - |generatedFile: ${actual.path} - |expectedFile: ${expected.path}""".trimMargin()) - } - } - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/ValidationTest.kt b/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/ValidationTest.kt deleted file mode 100644 index 1abfe03f6e9..00000000000 --- a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/ValidationTest.kt +++ /dev/null @@ -1,55 +0,0 @@ -package com.apollographql.apollo.compiler - -import com.apollographql.apollo.compiler.ir.IRBuilder -import com.apollographql.apollo.compiler.parser.error.DocumentParseException -import com.apollographql.apollo.compiler.parser.error.ParseException -import com.apollographql.apollo.compiler.parser.graphql.GraphQLDocumentParser -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema -import com.google.common.truth.Truth.assertThat -import org.junit.Assert.fail -import org.junit.Test -import org.junit.runner.RunWith -import org.junit.runners.Parameterized -import java.io.File - -@Suppress("UNUSED_PARAMETER") -@RunWith(Parameterized::class) -class ValidationTest(name: String, private val graphQLFile: File) { - - @Test - fun testValidation() { - val schemaFile = File("src/test/validation/schema.json") - val schema = IntrospectionSchema(schemaFile) - val packageNameProvider = DefaultPackageNameProvider( - roots = Roots(listOf(graphQLFile.parentFile)), - rootPackageName = "", - schemaPackageName = "", - packageName = null - ) - - try { - val documentParseResult = GraphQLDocumentParser(schema, packageNameProvider).parse(setOf(graphQLFile)) - IRBuilder(schema, "", null, null, false).build(documentParseResult) - fail("parse expected to fail but was successful") - } catch (e: Exception) { - if (e is DocumentParseException || e is ParseException) { - val expected = File(graphQLFile.parent, graphQLFile.nameWithoutExtension + ".error").readText().removeSuffix("\n") - val actual = e.message!!.removePrefix("\n").removeSuffix("\n").replace(graphQLFile.absolutePath, "/${graphQLFile.name}") - assertThat(actual).isEqualTo(expected) - } else { - throw e - } - } - } - - companion object { - @JvmStatic - @Parameterized.Parameters(name = "{0}") - fun data(): Collection> { - return File("src/test/validation/graphql") - .listFiles()!! - .filter { it.extension == "graphql" } - .map { arrayOf(it.nameWithoutExtension, it) } - } - } -} diff --git a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/VisitorSpecTest.kt b/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/VisitorSpecTest.kt deleted file mode 100644 index 723cf868c98..00000000000 --- a/apollo-compiler/src/test/kotlin/com/apollographql/apollo/compiler/VisitorSpecTest.kt +++ /dev/null @@ -1,55 +0,0 @@ -package com.apollographql.apollo.compiler - -import com.squareup.javapoet.ClassName -import org.junit.Assert -import org.junit.Test - -class VisitorSpecTest { - - private val schemaType = ClassName.get("", "Hero") - private val implementations = listOf( - ClassName.get("", "AsHuman"), - ClassName.get("", "AsDroid"), - ClassName.get("", "AsCharacter") - ) - - @Test - fun createVisitorInterface() { - val expected = """ - public interface Visitor { - T visitDefault(@org.jetbrains.annotations.NotNull Hero hero); - - T visit(@org.jetbrains.annotations.NotNull AsHuman asHuman); - - T visit(@org.jetbrains.annotations.NotNull AsDroid asDroid); - - T visit(@org.jetbrains.annotations.NotNull AsCharacter asCharacter); - } - - """.trimIndent() - val actual = VisitorInterfaceSpec(schemaType, implementations).createVisitorInterface().toString() - - Assert.assertEquals(expected, actual) - } - - @Test - fun createVisitorMethod() { - val expected = """ - public default T visit(Visitor visitor) { - if (this instanceof AsHuman) { - return visitor.visit((AsHuman) this); - } else if (this instanceof AsDroid) { - return visitor.visit((AsDroid) this); - } else if (this instanceof AsCharacter) { - return visitor.visit((AsCharacter) this); - } - return visitor.visitDefault(this); - } - - """.trimIndent() - val actual = VisitorMethodSpec(implementations).createVisitorMethod().toString() - - Assert.assertEquals(expected, actual) - } - -} \ No newline at end of file diff --git a/apollo-compiler/src/test/metadata/fragment-multiple/leaf.graphql b/apollo-compiler/src/test/metadata/fragment-multiple/leaf.graphql deleted file mode 100644 index 1d6b1d2c034..00000000000 --- a/apollo-compiler/src/test/metadata/fragment-multiple/leaf.graphql +++ /dev/null @@ -1,13 +0,0 @@ -query GetHero { - heroDetailQuery { - ...CharacterFragment - ...HumanFragment - } -} - -fragment HumanFragment on Human { - name - appearsIn - id - homePlanet -} \ No newline at end of file diff --git a/apollo-compiler/src/test/metadata/fragment-multiple/root.graphql b/apollo-compiler/src/test/metadata/fragment-multiple/root.graphql deleted file mode 100644 index 4639e170424..00000000000 --- a/apollo-compiler/src/test/metadata/fragment-multiple/root.graphql +++ /dev/null @@ -1,4 +0,0 @@ -fragment CharacterFragment on Character { - name - id -} \ No newline at end of file diff --git a/apollo-compiler/src/test/metadata/fragment-nameclash-error/error b/apollo-compiler/src/test/metadata/fragment-nameclash-error/error deleted file mode 100644 index 0102ebc97d7..00000000000 --- a/apollo-compiler/src/test/metadata/fragment-nameclash-error/error +++ /dev/null @@ -1 +0,0 @@ -/leaf.graphql: There can be only one fragment named `CharacterFragment` \ No newline at end of file diff --git a/apollo-compiler/src/test/metadata/fragment-nameclash-error/leaf.graphql b/apollo-compiler/src/test/metadata/fragment-nameclash-error/leaf.graphql deleted file mode 100644 index c9b247ba9fe..00000000000 --- a/apollo-compiler/src/test/metadata/fragment-nameclash-error/leaf.graphql +++ /dev/null @@ -1,11 +0,0 @@ -query GetHero { - heroDetailQuery { - ...CharacterFragment - } -} - -fragment CharacterFragment on Human { - name - id - appearsIn -} \ No newline at end of file diff --git a/apollo-compiler/src/test/metadata/fragment-nameclash-error/root.graphql b/apollo-compiler/src/test/metadata/fragment-nameclash-error/root.graphql deleted file mode 100644 index 4639e170424..00000000000 --- a/apollo-compiler/src/test/metadata/fragment-nameclash-error/root.graphql +++ /dev/null @@ -1,4 +0,0 @@ -fragment CharacterFragment on Character { - name - id -} \ No newline at end of file diff --git a/apollo-compiler/src/test/metadata/fragment-variable-error/error b/apollo-compiler/src/test/metadata/fragment-variable-error/error deleted file mode 100644 index 74df5f91dc5..00000000000 --- a/apollo-compiler/src/test/metadata/fragment-variable-error/error +++ /dev/null @@ -1,9 +0,0 @@ - -Failed to parse GraphQL file /root.graphql (5:27) -Variable `first` is not defined by operation `GetHero` -Operation `GetHero` declaration [/leaf.graphql] ----------------------------------------------------- -[4]: appearsIn -[5]: friendsConnection(first: $first) { -[6]: isEmpty ----------------------------------------------------- \ No newline at end of file diff --git a/apollo-compiler/src/test/metadata/fragment-variable-error/leaf.graphql b/apollo-compiler/src/test/metadata/fragment-variable-error/leaf.graphql deleted file mode 100644 index 7809e0e2719..00000000000 --- a/apollo-compiler/src/test/metadata/fragment-variable-error/leaf.graphql +++ /dev/null @@ -1,5 +0,0 @@ -query GetHero { - heroDetailQuery { - ...CharacterFragment - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/metadata/fragment-variable-error/root.graphql b/apollo-compiler/src/test/metadata/fragment-variable-error/root.graphql deleted file mode 100644 index 17d4d1dbc2b..00000000000 --- a/apollo-compiler/src/test/metadata/fragment-variable-error/root.graphql +++ /dev/null @@ -1,8 +0,0 @@ -fragment CharacterFragment on Character { - name - id - appearsIn - friendsConnection(first: $first) { - isEmpty - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/metadata/schema.sdl b/apollo-compiler/src/test/metadata/schema.sdl deleted file mode 100644 index 8989eb8b19a..00000000000 --- a/apollo-compiler/src/test/metadata/schema.sdl +++ /dev/null @@ -1,256 +0,0 @@ -"""A character from the Star Wars universe""" -interface Character { - """The dates of appearances""" - appearanceDates: [Date!]! - - """The movies this character appears in""" - appearsIn: [Episode]! - - """The date character was born.""" - birthDate: Date! - - """Test deprecated field""" - deprecated: String! @deprecated(reason: "For test purpose only") - - """Test deprecated field""" - deprecatedBool: Boolean! @deprecated(reason: "For test purpose only") - - """The movie this character first appears in""" - firstAppearsIn: Episode! - - """The friends of the character, or an empty list if they have none""" - friends: [Character] - - """The friends of the character exposed as a connection with edges""" - friendsConnection(first: Int, after: ID): FriendsConnection! - - """The ID of the character""" - id: ID! - - """Links""" - links: [URL!]! - - """The name of the character""" - name: String! - - """Profile link""" - profileLink: URL! - - """Hero type""" - type: hero_type! -} - - -"""The `Date` scalar type represents date format.""" -scalar Date - -"""An autonomous mechanical character in the Star Wars universe""" -type Droid implements Character { - """The dates of appearances""" - appearanceDates: [Date!]! - - """The movies this droid appears in""" - appearsIn: [Episode]! - - """The date droid was created.""" - birthDate: Date! - - """Test deprecated field""" - deprecated: String! @deprecated(reason: "For test purpose only") - - """Test deprecated field""" - deprecatedBool: Boolean! @deprecated(reason: "For test purpose only") - - """The movie this character first appears in""" - firstAppearsIn: Episode! - - """This droid's friends, or an empty list if they have none""" - friends: [Character] - - """The friends of the droid exposed as a connection with edges""" - friendsConnection(first: Int, after: ID): FriendsConnection! - - """The ID of the droid""" - id: ID! - - """Links""" - links: [URL!]! - - """What others call this droid""" - name: String! - - """This droid's primary function""" - primaryFunction: String - - """Profile link""" - profileLink: URL! - - """Hero type""" - type: hero_type! -} - -"""The episodes in the Star Wars trilogy""" -enum Episode { - """Star Wars Episode IV: A New Hope, released in 1977.""" - NEWHOPE - - """Star Wars Episode V: The Empire Strikes Back, released in 1980.""" - EMPIRE - - """Star Wars Episode VI: Return of the Jedi, released in 1983.""" - JEDI - - """Test deprecated enum value""" - DEPRECATED @deprecated(reason: "For test purpose only") - - """Test java reserved word""" - new -} - - -"""A connection object for a character's friends""" -type FriendsConnection { - """The edges for each of the character's friends.""" - edges: [FriendsEdge] - - """A list of the friends, as a convenience when edges are not needed.""" - friends: [Character] - - """For test java beans semantic naming only""" - isEmpty: Boolean! - - """Information for paginating this connection""" - pageInfo: PageInfo! - - """The total number of friends""" - totalCount: Int -} - -"""An edge object for a character's friends""" -type FriendsEdge { - """A cursor used for pagination""" - cursor: ID! - - """The character represented by this friendship edge""" - node: Character -} - -"""Lower case enum type name""" -enum hero_type { - human - droid -} - -"""A humanoid creature from the Star Wars universe""" -type Human implements Character { - """The dates of appearances""" - appearanceDates: [Date!]! - - """The movies this human appears in""" - appearsIn: [Episode]! - - """The date character was born.""" - birthDate: Date! - - """Test deprecated field""" - deprecated: String! @deprecated(reason: "For test purpose only") - - """Test deprecated field""" - deprecatedBool: Boolean! @deprecated(reason: "For test purpose only") - - """The movie this character first appears in""" - firstAppearsIn: Episode! - - """This human's friends, or an empty list if they have none""" - friends: [Character] - - """The friends of the human exposed as a connection with edges""" - friendsConnection(first: Int, after: ID): FriendsConnection! - - """Height in the preferred unit, default is meters""" - height(unit: LengthUnit = METER): Float - - """The home planet of the human, or null if unknown""" - homePlanet: String - - """The ID of the human""" - id: ID! - - """Links""" - links: [URL!]! - - """Mass in kilograms, or null if unknown""" - mass: Float - - """What this human calls themselves""" - name: String! - - """Profile link""" - profileLink: URL! - - """A list of starships this person has piloted, or an empty list if none""" - starships: [Starship] - - """Hero type""" - type: hero_type! -} - -"""Units of height""" -enum LengthUnit { - """The standard unit around the world""" - METER - - """Primarily used in the United States""" - FOOT -} - - -"""Information for paginating this connection""" -type PageInfo { - endCursor: ID - hasNextPage: Boolean! - startCursor: ID -} - -""" -The query type, represents all of the entry points into our object graph -""" -type Query { - character(id: ID!): Character - droid(id: ID!): Droid - - hero( - episode: Episode - - """for test purpose only""" - listOfListOfStringArgs: [[String]] - ): Character - - heroDetailQuery: Character - human(id: ID!): Human - nonOptionalHero(episode: Episode): Character! - search(text: String): [SearchResult] - starship(id: ID!): Starship -} - -union SearchResult = Human | Droid | Starship - -type Starship { - coordinates: [[Float!]!] - - """The ID of the starship""" - id: ID! - - """Length of the starship, along the longest axis""" - length(unit: LengthUnit = METER): Float - - """The name of the starship""" - name: String! -} - -"""URL for testing""" -scalar URL - -schema { - query: Query -} diff --git a/apollo-compiler/src/test/metadata/simple/leaf.graphql b/apollo-compiler/src/test/metadata/simple/leaf.graphql deleted file mode 100644 index 7809e0e2719..00000000000 --- a/apollo-compiler/src/test/metadata/simple/leaf.graphql +++ /dev/null @@ -1,5 +0,0 @@ -query GetHero { - heroDetailQuery { - ...CharacterFragment - } -} \ No newline at end of file diff --git a/apollo-compiler/src/test/metadata/simple/root.graphql b/apollo-compiler/src/test/metadata/simple/root.graphql deleted file mode 100644 index 5d6f4f6eeca..00000000000 --- a/apollo-compiler/src/test/metadata/simple/root.graphql +++ /dev/null @@ -1,5 +0,0 @@ -fragment CharacterFragment on Character { - name - id - appearsIn -} \ No newline at end of file diff --git a/apollo-compiler/src/test/sdl/implements-object.sdl b/apollo-compiler/src/test/sdl/implements-object.sdl deleted file mode 100644 index 419dcefc420..00000000000 --- a/apollo-compiler/src/test/sdl/implements-object.sdl +++ /dev/null @@ -1,11 +0,0 @@ -type Animal { - species: String -} - -type Cat implements Animal { - mustaches: Int -} - -type Query { - randomAnimal: Animal -} \ No newline at end of file diff --git a/apollo-compiler/src/test/sdl/repeated-directive.sdl b/apollo-compiler/src/test/sdl/repeated-directive.sdl deleted file mode 100644 index 7d3cbfc4eb9..00000000000 --- a/apollo-compiler/src/test/sdl/repeated-directive.sdl +++ /dev/null @@ -1,6 +0,0 @@ - -type Query { - random: Int! -} - -directive @testDirective repeatable on OBJECT \ No newline at end of file diff --git a/apollo-compiler/src/test/sdl/schema.json b/apollo-compiler/src/test/sdl/schema.json deleted file mode 100644 index 4bcdec22bad..00000000000 --- a/apollo-compiler/src/test/sdl/schema.json +++ /dev/null @@ -1,3430 +0,0 @@ -{ - "data": { - "__schema": { - "queryType": { - "name": "Query" - }, - "mutationType": { - "name": "Mutation" - }, - "subscriptionType": null, - "types": [ - { - "kind": "OBJECT", - "name": "Query", - "description": "The query type, represents all of the entry points into our object graph", - "fields": [ - { - "name": "hero", - "description": "", - "args": [ - { - "name": "episode", - "description": "Test description with \"quotes\" inside", - "type": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "listOfListOfStringArgs", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "INTERFACE", - "name": "Character", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "heroDetailQuery", - "description": "", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Character", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "heroWithReview", - "description": "", - "args": [ - { - "name": "episode", - "description": "", - "type": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "review", - "description": "", - "type": { - "kind": "INPUT_OBJECT", - "name": "ReviewInput", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "listOfInts", - "description": "for test purpose only", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - } - } - ], - "type": { - "kind": "OBJECT", - "name": "Human", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "reviews", - "description": "", - "args": [ - { - "name": "episode", - "description": "", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "starsInt", - "description": "", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "starsFloat", - "description": "", - "type": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Review", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "search", - "description": "", - "args": [ - { - "name": "text", - "description": "", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "UNION", - "name": "SearchResult", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "character", - "description": "", - "args": [ - { - "name": "id", - "description": "", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "INTERFACE", - "name": "Character", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "droid", - "description": "", - "args": [ - { - "name": "id", - "description": "", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Droid", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "human", - "description": "", - "args": [ - { - "name": "id", - "description": "", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Human", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "starship", - "description": "", - "args": [ - { - "name": "id", - "description": "", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Starship", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "nonOptionalHero", - "description": "", - "args": [ - { - "name": "episode", - "description": "", - "type": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Character", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "foo", - "description": "For testing fragment type coercion", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Foo", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "tree", - "description": "", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Tree", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "hero_type", - "description": "Lower case enum type name", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "human", - "description": "", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "droid", - "description": "", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "Episode", - "description": "The episodes in the Star Wars trilogy", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "NEWHOPE", - "description": "Star Wars Episode IV: A New Hope, released in 1977.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "EMPIRE", - "description": "Star Wars Episode V: The Empire Strikes Back, released in 1980.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "JEDI", - "description": "Star Wars Episode VI: Return of the Jedi, released in 1983.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "DEPRECATED", - "description": "Test deprecated enum value", - "isDeprecated": true, - "deprecationReason": "For test purpose only" - }, - { - "name": "new", - "description": "Test java reserved word", - "isDeprecated": false - } - ], - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Character", - "description": "A character from the Star Wars universe", - "fields": [ - { - "name": "id", - "description": "The ID of the character", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The name of the character", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deprecated", - "description": "Test deprecated field", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "For test purpose only" - }, - { - "name": "deprecatedBool", - "description": "Test deprecated field", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "For test purpose only" - }, - { - "name": "friends", - "description": "The friends of the character, or an empty list if they have none", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Character", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "friendsConnection", - "description": "The friends of the character exposed as a connection with edges", - "args": [ - { - "name": "first", - "description": "", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "", - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "FriendsConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "appearsIn", - "description": "The movies this character appears in", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "firstAppearsIn", - "description": "The movie this character first appears in", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "birthDate", - "description": "The date character was born.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "fieldWithUnsupportedType", - "description": "The date character was born.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "UnsupportedType", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "profileLink", - "description": "Profile link", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URL", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "links", - "description": "Links", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URL", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "appearanceDates", - "description": "The dates of appearances", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": "Hero type", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "hero_type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Droid", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Human", - "ofType": null - } - ] - }, - { - "kind": "SCALAR", - "name": "Date", - "description": "The `Date` scalar type represents date format.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "UnsupportedType", - "description": "UnsupportedType for testing", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "URL", - "description": "", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FriendsConnection", - "description": "A connection object for a character's friends", - "fields": [ - { - "name": "totalCount", - "description": "The total number of friends", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "The edges for each of the character's friends.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "FriendsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "friends", - "description": "A list of the friends, as a convenience when edges are not needed.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Character", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pageInfo", - "description": "Information for paginating this connection", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isEmpty", - "description": "For test java beans semantic naming only", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FriendsEdge", - "description": "An edge object for a character's friends", - "fields": [ - { - "name": "cursor", - "description": "A cursor used for pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "The character represented by this friendship edge", - "args": [], - "type": { - "kind": "INTERFACE", - "name": "Character", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PageInfo", - "description": "Information for paginating this connection", - "fields": [ - { - "name": "startCursor", - "description": "", - "args": [], - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "endCursor", - "description": "", - "args": [], - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hasNextPage", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Review", - "description": "Represents a review for a movie", - "fields": [ - { - "name": "stars", - "description": "The number of stars this review gave, 1-5", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commentary", - "description": "Comment about the movie", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "listOfListOfString", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - } - } - } - }, - { - "name": "listOfListOfEnum", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - } - } - } - } - } - }, - { - "name": "listOfListOfCustom", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - } - } - } - } - } - }, - { - "name": "listOfListOfObject", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Character", - "ofType": null - } - } - } - } - } - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "UNION", - "name": "SearchResult", - "description": "", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Human", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Droid", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Starship", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "Human", - "description": "A humanoid creature from the Star Wars universe", - "fields": [ - { - "name": "id", - "description": "The ID of the human", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "What this human calls themselves", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deprecated", - "description": "Test deprecated field", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "For test purpose only" - }, - { - "name": "deprecatedBool", - "description": "Test deprecated field", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "For test purpose only" - }, - { - "name": "homePlanet", - "description": "The home planet of the human, or null if unknown", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "height", - "description": "Height in the preferred unit, default is meters", - "args": [ - { - "name": "unit", - "description": "", - "type": { - "kind": "ENUM", - "name": "LengthUnit", - "ofType": null - }, - "defaultValue": "METER" - } - ], - "type": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mass", - "description": "Mass in kilograms, or null if unknown", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "friends", - "description": "This human's friends, or an empty list if they have none", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Character", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "friendsConnection", - "description": "The friends of the human exposed as a connection with edges", - "args": [ - { - "name": "first", - "description": "", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "", - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "FriendsConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "appearsIn", - "description": "The movies this human appears in", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "firstAppearsIn", - "description": "The movie this character first appears in", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "birthDate", - "description": "The date character was born.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "fieldWithUnsupportedType", - "description": "The date character was born.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "UnsupportedType", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "profileLink", - "description": "Profile link", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URL", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "links", - "description": "Links", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URL", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "appearanceDates", - "description": "The dates of appearances", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "starships", - "description": "A list of starships this person has piloted, or an empty list if none", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Starship", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": "Hero type", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "hero_type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Character", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "LengthUnit", - "description": "Units of height", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "METER", - "description": "The standard unit around the world", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FOOT", - "description": "Primarily used in the United States", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Starship", - "description": "", - "fields": [ - { - "name": "id", - "description": "The ID of the starship", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The name of the starship", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "length", - "description": "Length of the starship, along the longest axis", - "args": [ - { - "name": "unit", - "description": "", - "type": { - "kind": "ENUM", - "name": "LengthUnit", - "ofType": null - }, - "defaultValue": "METER" - } - ], - "type": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "coordinates", - "description": "", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - } - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Droid", - "description": "An autonomous mechanical character in the Star Wars universe", - "fields": [ - { - "name": "id", - "description": "The ID of the droid", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "What others call this droid", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deprecated", - "description": "Test deprecated field", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "For test purpose only" - }, - { - "name": "deprecatedBool", - "description": "Test deprecated field", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "For test purpose only" - }, - { - "name": "friends", - "description": "This droid's friends, or an empty list if they have none", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "INTERFACE", - "name": "Character", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "friendsConnection", - "description": "The friends of the droid exposed as a connection with edges", - "args": [ - { - "name": "first", - "description": "", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "after", - "description": "", - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "FriendsConnection", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "appearsIn", - "description": "The movies this droid appears in", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "firstAppearsIn", - "description": "The movie this character first appears in", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "birthDate", - "description": "The date droid was created.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "fieldWithUnsupportedType", - "description": "The date character was born.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "UnsupportedType", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "profileLink", - "description": "Profile link", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URL", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "links", - "description": "Links", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "URL", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "appearanceDates", - "description": "The dates of appearances", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "primaryFunction", - "description": "This droid's primary function", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": "Hero type", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "hero_type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Character", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Mutation", - "description": "The mutation type, represents all updates we can make to our data", - "fields": [ - { - "name": "createReview", - "description": "", - "args": [ - { - "name": "episode", - "description": "", - "type": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "review", - "description": "", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "ReviewInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Review", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ReviewInput", - "description": "The input object sent when someone is creating a new review", - "fields": null, - "inputFields": [ - { - "name": "stars", - "description": "0-5 stars", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "nullableIntFieldWithDefaultValue", - "description": "for test purpose only", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": 10 - }, - { - "name": "commentary", - "description": "Comment about the movie, optional", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "favoriteColor", - "description": "Favorite color, optional", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "colorInput", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "enumWithDefaultValue", - "description": "for test purpose only", - "type": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - }, - "defaultValue": "JEDI" - }, - { - "name": "nonNullableEnumWithDefaultValue", - "description": "for test purpose only", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - } - }, - "defaultValue": "JEDI" - }, - { - "name": "nullableEnum", - "description": "for test purpose only", - "type": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "listOfCustomScalar", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - } - }, - "defaultValue": ["1984-06-21", "1984-11-21"] - }, - { - "name": "customScalar", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - }, - "defaultValue": "1984-06-21" - }, - { - "name": "listOfEnums", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - } - }, - "defaultValue": ["NEWHOPE", "EMPIRE"] - }, - { - "name": "listOfInt", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": [1, 2, 3] - }, - { - "name": "listOfString", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": ["test1", "test2", "test3"] - }, - { - "name": "listOfStringNonOptional", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - } - }, - { - "name": "listOfInputTypes", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "colorInput", - "ofType": null - } - }, - "defaultValue": [] - }, - { - "name": "booleanWithDefaultValue", - "description": "for test purpose only", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": true - }, - { - "name": "listOfListOfString", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - } - } - } - }, - { - "name": "listOfListOfEnum", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - } - } - } - } - } - }, - { - "name": "listOfListOfCustom", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - } - } - } - } - } - }, - { - "name": "listOfListOfObject", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "colorInput", - "ofType": null - } - } - } - } - } - }, - { - "name": "CapitalizedField", - "description": "for test purpose only", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "colorInput", - "description": "The input object sent when passing in a color", - "fields": null, - "inputFields": [ - { - "name": "red", - "description": "Red color", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": 1 - }, - { - "name": "green", - "description": "Green color", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": 0 - }, - { - "name": "blue", - "description": "Blue color", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - } - }, - "defaultValue": 1.5 - }, - { - "name": "enumWithDefaultValue", - "description": "for test purpose only", - "type": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - }, - "defaultValue": "new" - }, - { - "name": "reviewRefInput", - "description": "Circle ref to review input", - "type": { - "kind": "INPUT_OBJECT", - "name": "ReviewRefInput", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ReviewRefInput", - "description": "Circle ref to review input", - "fields": null, - "inputFields": [ - { - "name": "reviewInput", - "description": "", - "type": { - "kind": "INPUT_OBJECT", - "name": "ReviewInput", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Foo", - "description": "For testing fragment type coercion", - "fields": [ - { - "name": "foo", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "FooBar", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "FooObject", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "FooObject", - "description": "For testing fragment type coercion", - "fields": [ - { - "name": "foo", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Foo", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": [] - }, - { - "kind": "INTERFACE", - "name": "Bar", - "description": "For testing fragment type coercion", - "fields": [ - { - "name": "bar", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "BarObject", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "FooBar", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "BarObject", - "description": "", - "fields": [ - { - "name": "bar", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Bar", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": [] - }, - { - "kind": "OBJECT", - "name": "FooBar", - "description": "For testing fragment type coercion", - "fields": [ - { - "name": "foo", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "bar", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Foo", - "ofType": null - }, - { - "kind": "INTERFACE", - "name": "Bar", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": [] - }, - { - "kind": "OBJECT", - "name": "Tree", - "description": "To test recursive structures", - "fields": [ - { - "name": "name", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "children", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Tree", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "parent", - "description": "", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Tree", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "ID", - "description": "The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "String", - "description": "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Int", - "description": "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Boolean", - "description": "The `Boolean` scalar type represents `true` or `false`.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Float", - "description": "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Schema", - "description": "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.", - "fields": [ - { - "name": "types", - "description": "A list of all types supported by this server.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "queryType", - "description": "The type that query operations will be rooted at.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mutationType", - "description": "If this server supports mutation, the type that mutation operations will be rooted at.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subscriptionType", - "description": "If this server supports subscription, the type that subscription operations will be rooted at.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "directives", - "description": "A list of all directives supported by this server.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Directive", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Type", - "description": "The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.", - "fields": [ - { - "name": "kind", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "__TypeKind", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "fields", - "description": "", - "args": [ - { - "name": "includeDeprecated", - "description": "", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": false - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Field", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "interfaces", - "description": "", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "possibleTypes", - "description": "", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "enumValues", - "description": "", - "args": [ - { - "name": "includeDeprecated", - "description": "", - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": false - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__EnumValue", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "inputFields", - "description": "", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ofType", - "description": "", - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "__TypeKind", - "description": "An enum describing what kind of type a given `__Type` is.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "SCALAR", - "description": "Indicates this type is a scalar.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OBJECT", - "description": "Indicates this type is an object. `fields` and `interfaces` are valid fields.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INTERFACE", - "description": "Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNION", - "description": "Indicates this type is a union. `possibleTypes` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM", - "description": "Indicates this type is an enum. `enumValues` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_OBJECT", - "description": "Indicates this type is an input object. `inputFields` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "LIST", - "description": "Indicates this type is a list. `ofType` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NON_NULL", - "description": "Indicates this type is a non-null. `ofType` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Field", - "description": "Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.", - "fields": [ - { - "name": "name", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "args", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDeprecated", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deprecationReason", - "description": "", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__InputValue", - "description": "Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.", - "fields": [ - { - "name": "name", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "defaultValue", - "description": "A GraphQL-formatted string representing the default value for this input value.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__EnumValue", - "description": "One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.", - "fields": [ - { - "name": "name", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDeprecated", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deprecationReason", - "description": "", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Directive", - "description": "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", - "fields": [ - { - "name": "name", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "locations", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "__DirectiveLocation", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "args", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "__DirectiveLocation", - "description": "A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "QUERY", - "description": "Location adjacent to a query operation.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MUTATION", - "description": "Location adjacent to a mutation operation.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SUBSCRIPTION", - "description": "Location adjacent to a subscription operation.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FIELD", - "description": "Location adjacent to a field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FRAGMENT_DEFINITION", - "description": "Location adjacent to a fragment definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FRAGMENT_SPREAD", - "description": "Location adjacent to a fragment spread.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INLINE_FRAGMENT", - "description": "Location adjacent to an inline fragment.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SCHEMA", - "description": "Location adjacent to a schema definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SCALAR", - "description": "Location adjacent to a scalar definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OBJECT", - "description": "Location adjacent to an object type definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FIELD_DEFINITION", - "description": "Location adjacent to a field definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ARGUMENT_DEFINITION", - "description": "Location adjacent to an argument definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INTERFACE", - "description": "Location adjacent to an interface definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNION", - "description": "Location adjacent to a union definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM", - "description": "Location adjacent to an enum definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM_VALUE", - "description": "Location adjacent to an enum value definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_OBJECT", - "description": "Location adjacent to an input object type definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_FIELD_DEFINITION", - "description": "Location adjacent to an input object field definition.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - } - ], - "directives": [ - { - "name": "operationDirective", - "description": "Dummy directive that can be placed on operations.", - "locations": [ - "QUERY", - "MUTATION", - "SUBSCRIPTION" - ], - "args": [ - { - "name": "dummy", - "description": "blah", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ] - } - ] - } - } -} diff --git a/apollo-compiler/src/test/sdl/schema.sdl b/apollo-compiler/src/test/sdl/schema.sdl deleted file mode 100644 index 640ef4e2212..00000000000 --- a/apollo-compiler/src/test/sdl/schema.sdl +++ /dev/null @@ -1,427 +0,0 @@ -"""Dummy directive that can be placed on operations.""" -directive @operationDirective( - """blah""" - dummy: String! -) on QUERY | MUTATION | SUBSCRIPTION - -"""For testing fragment type coercion""" -interface Bar { - bar: String! -} - -type BarObject implements Bar { - bar: String! -} - -"""A character from the Star Wars universe""" -interface Character { - """The dates of appearances""" - appearanceDates: [Date!]! - - """The movies this character appears in""" - appearsIn: [Episode]! - - """The date character was born.""" - birthDate: Date! - - """Test deprecated field""" - deprecated: String! @deprecated(reason: "For test purpose only") - - """Test deprecated field""" - deprecatedBool: Boolean! @deprecated(reason: "For test purpose only") - - """The date character was born.""" - fieldWithUnsupportedType: UnsupportedType! - - """The movie this character first appears in""" - firstAppearsIn: Episode! - - """The friends of the character, or an empty list if they have none""" - friends: [Character] - - """The friends of the character exposed as a connection with edges""" - friendsConnection(first: Int, after: ID): FriendsConnection! - - """The ID of the character""" - id: ID! - - """Links""" - links: [URL!]! - - """The name of the character""" - name: String! - - """Profile link""" - profileLink: URL! - - """Hero type""" - type: hero_type! -} - -"""The input object sent when passing in a color""" -input colorInput { - """Red color""" - red: Int! = 1 - - """Green color""" - green: Int = 0 - - """Blue color""" - blue: Float! = 1.5 - - """for test purpose only""" - enumWithDefaultValue: Episode = new - - """Circle ref to review input""" - reviewRefInput: ReviewRefInput -} - -"""The `Date` scalar type represents date format.""" -scalar Date - -"""An autonomous mechanical character in the Star Wars universe""" -type Droid implements Character { - """The dates of appearances""" - appearanceDates: [Date!]! - - """The movies this droid appears in""" - appearsIn: [Episode]! - - """The date droid was created.""" - birthDate: Date! - - """Test deprecated field""" - deprecated: String! @deprecated(reason: "For test purpose only") - - """Test deprecated field""" - deprecatedBool: Boolean! @deprecated(reason: "For test purpose only") - - """The date character was born.""" - fieldWithUnsupportedType: UnsupportedType! - - """The movie this character first appears in""" - firstAppearsIn: Episode! - - """This droid's friends, or an empty list if they have none""" - friends: [Character] - - """The friends of the droid exposed as a connection with edges""" - friendsConnection(first: Int, after: ID): FriendsConnection! - - """The ID of the droid""" - id: ID! - - """Links""" - links: [URL!]! - - """What others call this droid""" - name: String! - - """This droid's primary function""" - primaryFunction: String - - """Profile link""" - profileLink: URL! - - """Hero type""" - type: hero_type! -} - -"""The episodes in the Star Wars trilogy""" -enum Episode { - """Star Wars Episode IV: A New Hope, released in 1977.""" - NEWHOPE - - """Star Wars Episode V: The Empire Strikes Back, released in 1980.""" - EMPIRE - - """Star Wars Episode VI: Return of the Jedi, released in 1983.""" - JEDI - - """Test deprecated enum value""" - DEPRECATED @deprecated(reason: "For test purpose only") - - """Test java reserved word""" - new -} - -"""For testing fragment type coercion""" -interface Foo { - foo: String! -} - -"""For testing fragment type coercion""" -type FooBar implements Foo & Bar { - bar: String! - foo: String! -} - -"""For testing fragment type coercion""" -type FooObject implements Foo { - foo: String! -} - -"""A connection object for a character's friends""" -type FriendsConnection { - """The edges for each of the character's friends.""" - edges: [FriendsEdge] - - """A list of the friends, as a convenience when edges are not needed.""" - friends: [Character] - - """For test java beans semantic naming only""" - isEmpty: Boolean! - - """Information for paginating this connection""" - pageInfo: PageInfo! - - """The total number of friends""" - totalCount: Int -} - -"""An edge object for a character's friends""" -type FriendsEdge { - """A cursor used for pagination""" - cursor: ID! - - """The character represented by this friendship edge""" - node: Character -} - -"""Lower case enum type name""" -enum hero_type { - human - droid -} - -"""A humanoid creature from the Star Wars universe""" -type Human implements Character { - """The dates of appearances""" - appearanceDates: [Date!]! - - """The movies this human appears in""" - appearsIn: [Episode]! - - """The date character was born.""" - birthDate: Date! - - """Test deprecated field""" - deprecated: String! @deprecated(reason: "For test purpose only") - - """Test deprecated field""" - deprecatedBool: Boolean! @deprecated(reason: "For test purpose only") - - """The date character was born.""" - fieldWithUnsupportedType: UnsupportedType! - - """The movie this character first appears in""" - firstAppearsIn: Episode! - - """This human's friends, or an empty list if they have none""" - friends: [Character] - - """The friends of the human exposed as a connection with edges""" - friendsConnection(first: Int, after: ID): FriendsConnection! - - """Height in the preferred unit, default is meters""" - height(unit: LengthUnit = METER): Float - - """The home planet of the human, or null if unknown""" - homePlanet: String - - """The ID of the human""" - id: ID! - - """Links""" - links: [URL!]! - - """Mass in kilograms, or null if unknown""" - mass: Float - - """What this human calls themselves""" - name: String! - - """Profile link""" - profileLink: URL! - - """A list of starships this person has piloted, or an empty list if none""" - starships: [Starship] - - """Hero type""" - type: hero_type! -} - -"""Units of height""" -enum LengthUnit { - """The standard unit around the world""" - METER - - """Primarily used in the United States""" - FOOT -} - -"""The mutation type, represents all updates we can make to our data""" -type Mutation { - createReview(episode: Episode, review: ReviewInput!): Review -} - -"""Information for paginating this connection""" -type PageInfo { - endCursor: ID - hasNextPage: Boolean! - startCursor: ID -} - -""" -The query type, represents all of the entry points into our object graph -""" -type Query { - character(id: ID!): Character - droid(id: ID!): Droid - - """For testing fragment type coercion""" - foo: Foo - hero( - """Test description with "quotes" inside""" - episode: Episode - - """for test purpose only""" - listOfListOfStringArgs: [[String]] - ): Character - heroDetailQuery: Character - heroWithReview( - episode: Episode - review: ReviewInput - - """for test purpose only""" - listOfInts: [Int] - ): Human - human(id: ID!): Human - nonOptionalHero(episode: Episode): Character! - reviews(episode: Episode!, starsInt: Int, starsFloat: Float): [Review] - search(text: String): [SearchResult] - starship(id: ID!): Starship - tree: Tree -} - -"""Represents a review for a movie""" -type Review { - """Comment about the movie""" - commentary: String - - """for test purpose only""" - listOfListOfCustom: [[Date!]!] - - """for test purpose only""" - listOfListOfEnum: [[Episode!]!] - - """for test purpose only""" - listOfListOfObject: [[Character!]!] - - """for test purpose only""" - listOfListOfString: [[String!]!] - - """The number of stars this review gave, 1-5""" - stars: Int! -} - -"""The input object sent when someone is creating a new review""" -input ReviewInput { - """0-5 stars""" - stars: Int! - - """for test purpose only""" - nullableIntFieldWithDefaultValue: Int = 10 - - """Comment about the movie, optional""" - commentary: String - - """Favorite color, optional""" - favoriteColor: colorInput! - - """for test purpose only""" - enumWithDefaultValue: Episode = JEDI - - """for test purpose only""" - nonNullableEnumWithDefaultValue: Episode! = JEDI - - """for test purpose only""" - nullableEnum: Episode - - """for test purpose only""" - listOfCustomScalar: [Date] = ["1984-06-21", "1984-11-21"] - - """for test purpose only""" - customScalar: Date = "1984-06-21" - - """for test purpose only""" - listOfEnums: [Episode] = ["NEWHOPE", "EMPIRE"] - - """for test purpose only""" - listOfInt: [Int] = [1, 2, 3] - - """for test purpose only""" - listOfString: [String] = ["test1", "test2", "test3"] - - """for test purpose only""" - listOfStringNonOptional: [String]! - - """for test purpose only""" - listOfInputTypes: [colorInput] = [] - - """for test purpose only""" - booleanWithDefaultValue: Boolean = true - - """for test purpose only""" - listOfListOfString: [[String!]!] - - """for test purpose only""" - listOfListOfEnum: [[Episode!]!] - - """for test purpose only""" - listOfListOfCustom: [[Date!]!] - - """for test purpose only""" - listOfListOfObject: [[colorInput!]!] - - """for test purpose only""" - CapitalizedField: String -} - -"""Circle ref to review input""" -input ReviewRefInput { - reviewInput: ReviewInput -} - -union SearchResult = Human | Droid | Starship - -#URL for testing -scalar URL - -type Starship { - coordinates: [[Float!]!] - - """The ID of the starship""" - id: ID! - - """Length of the starship, along the longest axis""" - length(unit: LengthUnit = METER): Float - - """The name of the starship""" - name: String! -} - -"""To test recursive structures""" -type Tree { - children: [Tree!]! - name: String! - parent: Tree -} - -"""UnsupportedType for testing""" -scalar UnsupportedType - -schema { - query: Query - mutation: Mutation -} diff --git a/apollo-compiler/src/test/validation/graphql/ArgumentNonOptional.error b/apollo-compiler/src/test/validation/graphql/ArgumentNonOptional.error deleted file mode 100644 index 8d5edd0ad7d..00000000000 --- a/apollo-compiler/src/test/validation/graphql/ArgumentNonOptional.error +++ /dev/null @@ -1,7 +0,0 @@ -Failed to parse GraphQL file /ArgumentNonOptional.graphql (2:23) -Input field `review` is non optional ----------------------------------------------------- -[1]:mutation TestQuery { -[2]: createReview(review: null) { -[3]: commentary ----------------------------------------------------- diff --git a/apollo-compiler/src/test/validation/graphql/ArgumentNonOptional.graphql b/apollo-compiler/src/test/validation/graphql/ArgumentNonOptional.graphql deleted file mode 100644 index 2b3017339f2..00000000000 --- a/apollo-compiler/src/test/validation/graphql/ArgumentNonOptional.graphql +++ /dev/null @@ -1,5 +0,0 @@ -mutation TestQuery { - createReview(review: null) { - commentary - } -} diff --git a/apollo-compiler/src/test/validation/graphql/FragmentDuplication.error b/apollo-compiler/src/test/validation/graphql/FragmentDuplication.error deleted file mode 100644 index 5649c5c5b79..00000000000 --- a/apollo-compiler/src/test/validation/graphql/FragmentDuplication.error +++ /dev/null @@ -1 +0,0 @@ -/FragmentDuplication.graphql: There can be only one fragment named `HeroFragment` diff --git a/apollo-compiler/src/test/validation/graphql/FragmentDuplication.graphql b/apollo-compiler/src/test/validation/graphql/FragmentDuplication.graphql deleted file mode 100644 index c29edfc642e..00000000000 --- a/apollo-compiler/src/test/validation/graphql/FragmentDuplication.graphql +++ /dev/null @@ -1,13 +0,0 @@ -query TestQuery { - hero { - name - } -} - -fragment HeroFragment on Character { - name -} - -fragment HeroFragment on Character { - name -} diff --git a/apollo-compiler/src/test/validation/graphql/FragmentUnknownType.error b/apollo-compiler/src/test/validation/graphql/FragmentUnknownType.error deleted file mode 100644 index 996cce2e504..00000000000 --- a/apollo-compiler/src/test/validation/graphql/FragmentUnknownType.error +++ /dev/null @@ -1,7 +0,0 @@ -Failed to parse GraphQL file /FragmentUnknownType.graphql (7:25) -Unknown type `Banana` ----------------------------------------------------- -[6]: -[7]:fragment HeroFragment on Banana { -[8]: name ----------------------------------------------------- diff --git a/apollo-compiler/src/test/validation/graphql/FragmentUnknownType.graphql b/apollo-compiler/src/test/validation/graphql/FragmentUnknownType.graphql deleted file mode 100644 index bb54cf4b1a1..00000000000 --- a/apollo-compiler/src/test/validation/graphql/FragmentUnknownType.graphql +++ /dev/null @@ -1,9 +0,0 @@ -query TestQuery { - hero { - name - } -} - -fragment HeroFragment on Banana { - name -} diff --git a/apollo-compiler/src/test/validation/graphql/InlineFragmentCanNotBeSpread.error b/apollo-compiler/src/test/validation/graphql/InlineFragmentCanNotBeSpread.error deleted file mode 100644 index 4a91b13eee1..00000000000 --- a/apollo-compiler/src/test/validation/graphql/InlineFragmentCanNotBeSpread.error +++ /dev/null @@ -1,7 +0,0 @@ -Failed to parse GraphQL file /InlineFragmentCanNotBeSpread.graphql (3:11) -Fragment cannot be spread here as result can never be of type `Mutation` ----------------------------------------------------- -[2]: hero { -[3]: ... on Mutation { -[4]: ----------------------------------------------------- diff --git a/apollo-compiler/src/test/validation/graphql/InlineFragmentCanNotBeSpread.graphql b/apollo-compiler/src/test/validation/graphql/InlineFragmentCanNotBeSpread.graphql deleted file mode 100644 index 208bf595a07..00000000000 --- a/apollo-compiler/src/test/validation/graphql/InlineFragmentCanNotBeSpread.graphql +++ /dev/null @@ -1,7 +0,0 @@ -query TestQuery { - hero { - ... on Mutation { - - } - } -} diff --git a/apollo-compiler/src/test/validation/graphql/InlineFragmentUnknonwType.error b/apollo-compiler/src/test/validation/graphql/InlineFragmentUnknonwType.error deleted file mode 100644 index 6da5e2e1cd6..00000000000 --- a/apollo-compiler/src/test/validation/graphql/InlineFragmentUnknonwType.error +++ /dev/null @@ -1,7 +0,0 @@ -Failed to parse GraphQL file /InlineFragmentUnknonwType.graphql (3:11) -Unknown type`Banana}` ----------------------------------------------------- -[2]: hero { -[3]: ... on Banana { -[4]: } ----------------------------------------------------- diff --git a/apollo-compiler/src/test/validation/graphql/InlineFragmentUnknonwType.graphql b/apollo-compiler/src/test/validation/graphql/InlineFragmentUnknonwType.graphql deleted file mode 100644 index 6baec49309d..00000000000 --- a/apollo-compiler/src/test/validation/graphql/InlineFragmentUnknonwType.graphql +++ /dev/null @@ -1,6 +0,0 @@ -query TestQuery { - hero { - ... on Banana { - } - } -} diff --git a/apollo-compiler/src/test/validation/graphql/InputObjectFieldNonOptional.error b/apollo-compiler/src/test/validation/graphql/InputObjectFieldNonOptional.error deleted file mode 100644 index ae33c386459..00000000000 --- a/apollo-compiler/src/test/validation/graphql/InputObjectFieldNonOptional.error +++ /dev/null @@ -1,7 +0,0 @@ -Failed to parse GraphQL file /InputObjectFieldNonOptional.graphql (2:23) -Variable `stars` of type `Int` used in position expecting type `Int!` ----------------------------------------------------- -[1]:mutation TestQuery($stars: Int) { -[2]: createReview(review: { -[3]: stars: $stars ----------------------------------------------------- diff --git a/apollo-compiler/src/test/validation/graphql/InputObjectFieldNonOptional.graphql b/apollo-compiler/src/test/validation/graphql/InputObjectFieldNonOptional.graphql deleted file mode 100644 index c5bf59d546f..00000000000 --- a/apollo-compiler/src/test/validation/graphql/InputObjectFieldNonOptional.graphql +++ /dev/null @@ -1,8 +0,0 @@ -mutation TestQuery($stars: Int) { - createReview(review: { - stars: $stars - }) { - commentary - } -} - diff --git a/apollo-compiler/src/test/validation/graphql/InputObjectFieldTypeMismatch.error b/apollo-compiler/src/test/validation/graphql/InputObjectFieldTypeMismatch.error deleted file mode 100644 index 306028b5c5f..00000000000 --- a/apollo-compiler/src/test/validation/graphql/InputObjectFieldTypeMismatch.error +++ /dev/null @@ -1,7 +0,0 @@ -Failed to parse GraphQL file /InputObjectFieldTypeMismatch.graphql (2:23) -Variable `red` of type `String!` used in position expecting type `Int!` ----------------------------------------------------- -[1]:mutation TestQuery($red: String!) { -[2]: createReview(review: { -[3]: favoriteColor: { ----------------------------------------------------- diff --git a/apollo-compiler/src/test/validation/graphql/InputObjectFieldTypeMismatch.graphql b/apollo-compiler/src/test/validation/graphql/InputObjectFieldTypeMismatch.graphql deleted file mode 100644 index b51088b76b0..00000000000 --- a/apollo-compiler/src/test/validation/graphql/InputObjectFieldTypeMismatch.graphql +++ /dev/null @@ -1,9 +0,0 @@ -mutation TestQuery($red: String!) { - createReview(review: { - favoriteColor: { - red: $red - } - }) { - commentary - } -} diff --git a/apollo-compiler/src/test/validation/graphql/InputObjectListFieldTypeMismatch.error b/apollo-compiler/src/test/validation/graphql/InputObjectListFieldTypeMismatch.error deleted file mode 100644 index 43fe6250f44..00000000000 --- a/apollo-compiler/src/test/validation/graphql/InputObjectListFieldTypeMismatch.error +++ /dev/null @@ -1,7 +0,0 @@ -Failed to parse GraphQL file /InputObjectListFieldTypeMismatch.graphql (2:23) -Variable `item` of type `Int` used in position expecting type `String` ----------------------------------------------------- -[1]:mutation TestQuery($item: Int) { -[2]: createReview(review: { -[3]: listOfStringNonOptional: [$item] ----------------------------------------------------- diff --git a/apollo-compiler/src/test/validation/graphql/InputObjectListFieldTypeMismatch.graphql b/apollo-compiler/src/test/validation/graphql/InputObjectListFieldTypeMismatch.graphql deleted file mode 100644 index c54842550a5..00000000000 --- a/apollo-compiler/src/test/validation/graphql/InputObjectListFieldTypeMismatch.graphql +++ /dev/null @@ -1,8 +0,0 @@ -mutation TestQuery($item: Int) { - createReview(review: { - listOfStringNonOptional: [$item] - }) { - commentary - } -} - diff --git a/apollo-compiler/src/test/validation/graphql/MissingSelectionSet.error b/apollo-compiler/src/test/validation/graphql/MissingSelectionSet.error deleted file mode 100644 index 8ff57520f3a..00000000000 --- a/apollo-compiler/src/test/validation/graphql/MissingSelectionSet.error +++ /dev/null @@ -1,7 +0,0 @@ -Failed to parse GraphQL file /MissingSelectionSet.graphql (2:2) -Field `hero` of type `Query` must have a selection of sub-fields ----------------------------------------------------- -[1]:query TestQuery { -[2]: hero -[3]:} ----------------------------------------------------- diff --git a/apollo-compiler/src/test/validation/graphql/MissingSelectionSet.graphql b/apollo-compiler/src/test/validation/graphql/MissingSelectionSet.graphql deleted file mode 100644 index 79986179964..00000000000 --- a/apollo-compiler/src/test/validation/graphql/MissingSelectionSet.graphql +++ /dev/null @@ -1,3 +0,0 @@ -query TestQuery { - hero -} diff --git a/apollo-compiler/src/test/validation/graphql/QueryUnknowField.error b/apollo-compiler/src/test/validation/graphql/QueryUnknowField.error deleted file mode 100644 index a748c39d8ca..00000000000 --- a/apollo-compiler/src/test/validation/graphql/QueryUnknowField.error +++ /dev/null @@ -1,7 +0,0 @@ -Failed to parse GraphQL file /QueryUnknowField.graphql (2:2) -Can't query `hero12` on type `Query` ----------------------------------------------------- -[1]:query TestQuery { -[2]: hero12 { -[3]: name ----------------------------------------------------- diff --git a/apollo-compiler/src/test/validation/graphql/QueryUnknowField.graphql b/apollo-compiler/src/test/validation/graphql/QueryUnknowField.graphql deleted file mode 100644 index ce7b9a31dfd..00000000000 --- a/apollo-compiler/src/test/validation/graphql/QueryUnknowField.graphql +++ /dev/null @@ -1,5 +0,0 @@ -query TestQuery { - hero12 { - name - } -} diff --git a/apollo-compiler/src/test/validation/graphql/VariableIsOptional.error b/apollo-compiler/src/test/validation/graphql/VariableIsOptional.error deleted file mode 100644 index 95b6cacd9e4..00000000000 --- a/apollo-compiler/src/test/validation/graphql/VariableIsOptional.error +++ /dev/null @@ -1,7 +0,0 @@ -Failed to parse GraphQL file /VariableIsOptional.graphql (2:16) -Variable `episode` of type `Episode` used in position expecting type `Episode!` ----------------------------------------------------- -[1]:query TestQuery($episode: Episode) { -[2]: hero(episode: $episode) { -[3]: name ----------------------------------------------------- diff --git a/apollo-compiler/src/test/validation/graphql/VariableIsOptional.graphql b/apollo-compiler/src/test/validation/graphql/VariableIsOptional.graphql deleted file mode 100644 index 58a5c18b596..00000000000 --- a/apollo-compiler/src/test/validation/graphql/VariableIsOptional.graphql +++ /dev/null @@ -1,5 +0,0 @@ -query TestQuery($episode: Episode) { - hero(episode: $episode) { - name - } -} diff --git a/apollo-compiler/src/test/validation/graphql/VariableMissing.error b/apollo-compiler/src/test/validation/graphql/VariableMissing.error deleted file mode 100644 index 91bebc075cf..00000000000 --- a/apollo-compiler/src/test/validation/graphql/VariableMissing.error +++ /dev/null @@ -1,7 +0,0 @@ -Failed to parse GraphQL file /VariableMissing.graphql (2:16) -Variable `episode` is not defined by operation `TestQuery` ----------------------------------------------------- -[1]:query TestQuery { -[2]: hero(episode: $episode) { -[3]: name ----------------------------------------------------- diff --git a/apollo-compiler/src/test/validation/graphql/VariableMissing.graphql b/apollo-compiler/src/test/validation/graphql/VariableMissing.graphql deleted file mode 100644 index 5100d8293b6..00000000000 --- a/apollo-compiler/src/test/validation/graphql/VariableMissing.graphql +++ /dev/null @@ -1,5 +0,0 @@ -query TestQuery { - hero(episode: $episode) { - name - } -} diff --git a/apollo-compiler/src/test/validation/graphql/VariableTypeMismatch.error b/apollo-compiler/src/test/validation/graphql/VariableTypeMismatch.error deleted file mode 100644 index 2d284f650e6..00000000000 --- a/apollo-compiler/src/test/validation/graphql/VariableTypeMismatch.error +++ /dev/null @@ -1,7 +0,0 @@ -Failed to parse GraphQL file /VariableTypeMismatch.graphql (2:16) -Variable `episode` of type `Int` used in position expecting type `Episode!` ----------------------------------------------------- -[1]:query TestQuery($episode: Int) { -[2]: hero(episode: $episode) { -[3]: name ----------------------------------------------------- diff --git a/apollo-compiler/src/test/validation/graphql/VariableTypeMismatch.graphql b/apollo-compiler/src/test/validation/graphql/VariableTypeMismatch.graphql deleted file mode 100644 index 6251ae07306..00000000000 --- a/apollo-compiler/src/test/validation/graphql/VariableTypeMismatch.graphql +++ /dev/null @@ -1,5 +0,0 @@ -query TestQuery($episode: Int) { - hero(episode: $episode) { - name - } -} diff --git a/apollo-compiler/src/test/validation/schema.json b/apollo-compiler/src/test/validation/schema.json deleted file mode 100644 index f918723987d..00000000000 --- a/apollo-compiler/src/test/validation/schema.json +++ /dev/null @@ -1,1580 +0,0 @@ -{ - "errors": [], - "data": { - "bla-bla": "-bla", - "__schema": { - "queryType": { - "name": "Query" - }, - "mutationType": { - "name": "Mutation" - }, - "subscriptionType": null, - "types": [ - { - "kind": "OBJECT", - "name": "Query", - "description": "The query type, represents all of the entry points into our object graph", - "fields": [ - { - "name": "hero", - "description": "", - "args": [ - { - "name": "episode", - "description": "", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "listOfListOfStringArgs", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "INTERFACE", - "name": "Character", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "Episode", - "description": "The episodes in the Star Wars trilogy", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "NEWHOPE", - "description": "Star Wars Episode IV: A New Hope, released in 1977.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "EMPIRE", - "description": "Star Wars Episode V: The Empire Strikes Back, released in 1980.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "JEDI", - "description": "Star Wars Episode VI: Return of the Jedi, released in 1983.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "DEPRECATED", - "description": "Test deprecated enum value", - "isDeprecated": true, - "deprecationReason": "For test purpose only" - }, - { - "name": "new", - "description": "Test java reserved word", - "isDeprecated": false, - "deprecationReason": "For test purpose only" - } - ], - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Character", - "description": "A character from the Star Wars universe", - "fields": [ - { - "name": "id", - "description": "The ID of the character", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "The name of the character", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Human", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Droid", - "ofType": null - } - ] - }, - { - "kind": "SCALAR", - "name": "ID", - "description": "The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Date", - "description": "The `Date` scalar type represents date format.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "String", - "description": "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Int", - "description": "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. ", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Boolean", - "description": "The `Boolean` scalar type represents `true` or `false`.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Human", - "description": "A humanoid creature from the Star Wars universe", - "fields": [ - { - "name": "id", - "description": "The ID of the human", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "What this human calls themselves", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "height", - "description": "Height in the preferred unit, default is meters", - "args": [ - { - "name": "unit", - "description": "", - "type": { - "kind": "ENUM", - "name": "LengthUnit", - "ofType": null - }, - "defaultValue": "METER" - } - ], - "type": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "birthDate", - "description": "The date character was born.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Date", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Character", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "LengthUnit", - "description": "Units of height", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "METER", - "description": "The standard unit around the world", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FOOT", - "description": "Primarily used in the United States", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Float", - "description": "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point). ", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Droid", - "description": "An autonomous mechanical character in the Star Wars universe", - "fields": [ - { - "name": "id", - "description": "The ID of the droid", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": "What others call this droid", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "primaryFunction", - "description": "This droid's primary function", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Character", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Mutation", - "description": "The mutation type, represents all updates we can make to our data", - "fields": [ - { - "name": "createReview", - "description": "", - "args": [ - { - "name": "episode", - "description": "", - "type": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "review", - "description": "", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "ReviewInput", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Review", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ReviewInput", - "description": "The input object sent when someone is creating a new review", - "fields": null, - "inputFields": [ - { - "name": "stars", - "description": "0-5 stars", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "commentary", - "description": "Comment about the movie, optional", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "favoriteColor", - "description": "Favorite color, optional", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "INPUT_OBJECT", - "name": "colorInput", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "listOfStringNonOptional", - "description": "for test purpose only", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - } - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "colorInput", - "description": "The input object sent when passing in a color", - "fields": null, - "inputFields": [ - { - "name": "red", - "description": "Red color", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "defaultValue": "1" - }, - { - "name": "green", - "description": "Green color", - "type": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - }, - "defaultValue": "0.0" - }, - { - "name": "blue", - "description": "Blue color", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - } - }, - "defaultValue": "1.5" - }, - { - "name": "enumWithDefaultValue", - "description": "for test purpose only", - "type": { - "kind": "ENUM", - "name": "Episode", - "ofType": null - }, - "defaultValue": "new" - }, - { - "name": "reviewRefInput", - "description": "Circle ref to review input", - "type": { - "kind": "INPUT_OBJECT", - "name": "ReviewRefInput", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INPUT_OBJECT", - "name": "ReviewRefInput", - "description": "Circle ref to review input", - "fields": null, - "inputFields": [ - { - "name": "reviewInput", - "description": null, - "type": { - "kind": "INPUT_OBJECT", - "name": "ReviewInput", - "ofType": null - }, - "defaultValue": null - } - ], - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Review", - "description": "Represents a review for a movie", - "fields": [ - { - "name": "stars", - "description": "The number of stars this review gave, 1-5", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commentary", - "description": "Comment about the movie", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Schema", - "description": "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.", - "fields": [ - { - "name": "types", - "description": "A list of all types supported by this server.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "queryType", - "description": "The type that query operations will be rooted at.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mutationType", - "description": "If this server supports mutation, the type that mutation operations will be rooted at.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subscriptionType", - "description": "If this server support subscription, the type that subscription operations will be rooted at.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "directives", - "description": "A list of all directives supported by this server.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Directive", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Type", - "description": "The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.", - "fields": [ - { - "name": "kind", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "__TypeKind", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "fields", - "description": null, - "args": [ - { - "name": "includeDeprecated", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Field", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "interfaces", - "description": null, - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "possibleTypes", - "description": null, - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "enumValues", - "description": null, - "args": [ - { - "name": "includeDeprecated", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__EnumValue", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "inputFields", - "description": null, - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ofType", - "description": null, - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "__TypeKind", - "description": "An enum describing what kind of type a given `__Type` is.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "SCALAR", - "description": "Indicates this type is a scalar.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OBJECT", - "description": "Indicates this type is an object. `fields` and `interfaces` are valid fields.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INTERFACE", - "description": "Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNION", - "description": "Indicates this type is a union. `possibleTypes` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM", - "description": "Indicates this type is an enum. `enumValues` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_OBJECT", - "description": "Indicates this type is an input object. `inputFields` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "LIST", - "description": "Indicates this type is a list. `ofType` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NON_NULL", - "description": "Indicates this type is a non-null. `ofType` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Field", - "description": "Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "args", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDeprecated", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deprecationReason", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__InputValue", - "description": "Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "defaultValue", - "description": "A GraphQL-formatted string representing the default value for this input value.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__EnumValue", - "description": "One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDeprecated", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deprecationReason", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Directive", - "description": "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "locations", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "__DirectiveLocation", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "args", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "onOperation", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "Use `locations`." - }, - { - "name": "onFragment", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "Use `locations`." - }, - { - "name": "onField", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "Use `locations`." - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "__DirectiveLocation", - "description": "A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "QUERY", - "description": "Location adjacent to a query operation.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MUTATION", - "description": "Location adjacent to a mutation operation.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SUBSCRIPTION", - "description": "Location adjacent to a subscription operation.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FIELD", - "description": "Location adjacent to a field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FRAGMENT_DEFINITION", - "description": "Location adjacent to a fragment definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FRAGMENT_SPREAD", - "description": "Location adjacent to a fragment spread.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INLINE_FRAGMENT", - "description": "Location adjacent to an inline fragment.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SCHEMA", - "description": "Location adjacent to a schema definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SCALAR", - "description": "Location adjacent to a scalar definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OBJECT", - "description": "Location adjacent to an object type definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FIELD_DEFINITION", - "description": "Location adjacent to a field definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ARGUMENT_DEFINITION", - "description": "Location adjacent to an argument definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INTERFACE", - "description": "Location adjacent to an interface definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNION", - "description": "Location adjacent to a union definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM", - "description": "Location adjacent to an enum definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM_VALUE", - "description": "Location adjacent to an enum value definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_OBJECT", - "description": "Location adjacent to an input object type definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_FIELD_DEFINITION", - "description": "Location adjacent to an input object field definition.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - } - ], - "directives": [ - { - "name": "skip", - "description": "Directs the executor to skip this field or fragment when the `if` argument is true.", - "locations": [ - "FIELD", - "FRAGMENT_SPREAD", - "INLINE_FRAGMENT" - ], - "args": [ - { - "name": "if", - "description": "Skipped when true.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "defaultValue": null - } - ] - }, - { - "name": "include", - "description": "Directs the executor to include this field or fragment only when the `if` argument is true.", - "locations": [ - "FIELD", - "FRAGMENT_SPREAD", - "INLINE_FRAGMENT" - ], - "args": [ - { - "name": "if", - "description": "Included when true.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "defaultValue": null - } - ] - }, - { - "name": "operationDirective", - "description": "Dummy directive that can be placed on operations.", - "locations": [ - "QUERY", - "MUTATION", - "SUBSCRIPTION" - ], - "args": [ - { - "name": "dummy", - "description": "blah", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ] - }, - { - "name": "deprecated", - "description": "Marks an element of a GraphQL schema as no longer supported.", - "locations": [ - "FIELD_DEFINITION", - "ENUM_VALUE" - ], - "args": [ - { - "name": "reason", - "description": "Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted in [Markdown](https://daringfireball.net/projects/markdown/).", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": "\"No longer supported\"" - } - ] - } - ] - } - } -} diff --git a/apollo-coroutines-support/README.md b/apollo-coroutines-support/README.md index f7e6bf14f91..b8fc00caeeb 100644 --- a/apollo-coroutines-support/README.md +++ b/apollo-coroutines-support/README.md @@ -3,5 +3,5 @@ To add the `apollo-coroutines-support` module to your project, first add the following dependency to your gradle file ```groovy -implementation "com.apollographql.apollo:apollo-coroutines-support:$apollo_version" +implementation "com.homer.apollographql.apollo:apollo-coroutines-support:$apollo_version" ``` \ No newline at end of file diff --git a/apollo-coroutines-support/api.txt b/apollo-coroutines-support/api.txt index e62836fdc0e..f45fb14b8b7 100644 --- a/apollo-coroutines-support/api.txt +++ b/apollo-coroutines-support/api.txt @@ -1,14 +1,14 @@ // Signature format: 3.0 -package com.apollographql.apollo.coroutines { +package com.homer.apollographql.apollo.coroutines { public final class CoroutinesExtensionsKt { - method public static suspend Object? await(com.apollographql.apollo.ApolloCall, kotlin.coroutines.Continuation> p); - method public static suspend Object? await(com.apollographql.apollo.ApolloPrefetch, kotlin.coroutines.Continuation p); - method @Deprecated public static kotlinx.coroutines.Deferred> toDeferred(com.apollographql.apollo.ApolloCall); - method @kotlinx.coroutines.ExperimentalCoroutinesApi public static kotlinx.coroutines.flow.Flow> toFlow(com.apollographql.apollo.ApolloCall); - method @kotlinx.coroutines.ExperimentalCoroutinesApi public static kotlinx.coroutines.flow.Flow> toFlow(com.apollographql.apollo.ApolloQueryWatcher); - method @kotlinx.coroutines.ExperimentalCoroutinesApi public static kotlinx.coroutines.flow.Flow> toFlow(com.apollographql.apollo.ApolloSubscriptionCall); - method @Deprecated public static kotlinx.coroutines.Job toJob(com.apollographql.apollo.ApolloPrefetch); + method public static suspend Object? await(com.homer.apollographql.apollo.ApolloCall, kotlin.coroutines.Continuation> p); + method public static suspend Object? await(com.homer.apollographql.apollo.ApolloPrefetch, kotlin.coroutines.Continuation p); + method @Deprecated public static kotlinx.coroutines.Deferred> toDeferred(com.homer.apollographql.apollo.ApolloCall); + method @kotlinx.coroutines.ExperimentalCoroutinesApi public static kotlinx.coroutines.flow.Flow> toFlow(com.homer.apollographql.apollo.ApolloCall); + method @kotlinx.coroutines.ExperimentalCoroutinesApi public static kotlinx.coroutines.flow.Flow> toFlow(com.homer.apollographql.apollo.ApolloQueryWatcher); + method @kotlinx.coroutines.ExperimentalCoroutinesApi public static kotlinx.coroutines.flow.Flow> toFlow(com.homer.apollographql.apollo.ApolloSubscriptionCall); + method @Deprecated public static kotlinx.coroutines.Job toJob(com.homer.apollographql.apollo.ApolloPrefetch); } } diff --git a/apollo-coroutines-support/src/main/kotlin/com/apollographql/apollo/coroutines/CoroutinesExtensions.kt b/apollo-coroutines-support/src/main/kotlin/com/homer/apollographql/apollo/coroutines/CoroutinesExtensions.kt similarity index 72% rename from apollo-coroutines-support/src/main/kotlin/com/apollographql/apollo/coroutines/CoroutinesExtensions.kt rename to apollo-coroutines-support/src/main/kotlin/com/homer/apollographql/apollo/coroutines/CoroutinesExtensions.kt index 1740bfd53aa..e172ce02bed 100644 --- a/apollo-coroutines-support/src/main/kotlin/com/apollographql/apollo/coroutines/CoroutinesExtensions.kt +++ b/apollo-coroutines-support/src/main/kotlin/com/homer/apollographql/apollo/coroutines/CoroutinesExtensions.kt @@ -1,11 +1,11 @@ -package com.apollographql.apollo.coroutines - -import com.apollographql.apollo.ApolloCall -import com.apollographql.apollo.ApolloPrefetch -import com.apollographql.apollo.ApolloQueryWatcher -import com.apollographql.apollo.ApolloSubscriptionCall -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.exception.ApolloException +package com.homer.apollographql.apollo.coroutines + +import com.homer.apollographql.apollo.ApolloCall +import com.homer.apollographql.apollo.ApolloPrefetch +import com.homer.apollographql.apollo.ApolloQueryWatcher +import com.homer.apollographql.apollo.ApolloSubscriptionCall +import com.homer.apollographql.apollo.api.Response +import com.homer.apollographql.apollo.exception.ApolloException import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.Deferred import kotlinx.coroutines.ExperimentalCoroutinesApi @@ -26,13 +26,13 @@ import kotlin.coroutines.resume * @return a flow which emits [Responses] */ @ExperimentalCoroutinesApi -fun ApolloCall.toFlow(): Flow> = callbackFlow { +fun com.homer.apollographql.apollo.ApolloCall.toFlow(): Flow> = callbackFlow { val clone = clone() clone.enqueue( - object : ApolloCall.Callback() { + object : com.homer.apollographql.apollo.ApolloCall.Callback() { override fun onResponse(response: Response) { runCatching { - offer(response) + trySend(response) } } @@ -40,8 +40,8 @@ fun ApolloCall.toFlow(): Flow> = callbackFlow { close(e) } - override fun onStatusEvent(event: ApolloCall.StatusEvent) { - if (event == ApolloCall.StatusEvent.COMPLETED) { + override fun onStatusEvent(event: com.homer.apollographql.apollo.ApolloCall.StatusEvent) { + if (event == com.homer.apollographql.apollo.ApolloCall.StatusEvent.COMPLETED) { close() } } @@ -57,13 +57,13 @@ fun ApolloCall.toFlow(): Flow> = callbackFlow { * @return a flow which emits [Responses] */ @ExperimentalCoroutinesApi -fun ApolloQueryWatcher.toFlow(): Flow> = callbackFlow { +fun com.homer.apollographql.apollo.ApolloQueryWatcher.toFlow(): Flow> = callbackFlow { val clone = clone() clone.enqueueAndWatch( - object : ApolloCall.Callback() { + object : com.homer.apollographql.apollo.ApolloCall.Callback() { override fun onResponse(response: Response) { runCatching { - offer(response) + trySend(response) } } @@ -87,13 +87,13 @@ fun ApolloQueryWatcher.toFlow(): Flow> = callbackFlow { * @return the response on success. * @throws ApolloException on failure. */ -suspend fun ApolloCall.await(): Response = suspendCancellableCoroutine { cont -> +suspend fun com.homer.apollographql.apollo.ApolloCall.await(): Response = suspendCancellableCoroutine { cont -> cont.invokeOnCancellation { cancel() } - enqueue(object : ApolloCall.Callback() { + enqueue(object : com.homer.apollographql.apollo.ApolloCall.Callback() { private val wasCalled = AtomicBoolean(false) @@ -119,7 +119,7 @@ suspend fun ApolloCall.await(): Response = suspendCancellableCoroutine * @return the deferred */ @Deprecated("Use await() instead.") -fun ApolloCall.toDeferred(): Deferred> { +fun com.homer.apollographql.apollo.ApolloCall.toDeferred(): Deferred> { val deferred = CompletableDeferred>() deferred.invokeOnCompletion { @@ -127,7 +127,7 @@ fun ApolloCall.toDeferred(): Deferred> { cancel() } } - enqueue(object : ApolloCall.Callback() { + enqueue(object : com.homer.apollographql.apollo.ApolloCall.Callback() { override fun onResponse(response: Response) { if (deferred.isActive) { deferred.complete(response) @@ -151,16 +151,16 @@ fun ApolloCall.toDeferred(): Deferred> { * @return a flow which emits [Responses] */ @ExperimentalCoroutinesApi -fun ApolloSubscriptionCall.toFlow(): Flow> = callbackFlow { +fun com.homer.apollographql.apollo.ApolloSubscriptionCall.toFlow(): Flow> = callbackFlow { val clone = clone() clone.execute( - object : ApolloSubscriptionCall.Callback { + object : com.homer.apollographql.apollo.ApolloSubscriptionCall.Callback { override fun onConnected() { } override fun onResponse(response: Response) { runCatching { - channel.offer(response) + channel.trySend(response) } } @@ -188,13 +188,13 @@ fun ApolloSubscriptionCall.toFlow(): Flow> = callbackFlow { * @return the response on success. * @throws ApolloException on failure. */ -suspend fun ApolloPrefetch.await(): Unit = suspendCancellableCoroutine { cont -> +suspend fun com.homer.apollographql.apollo.ApolloPrefetch.await(): Unit = suspendCancellableCoroutine { cont -> cont.invokeOnCancellation { cancel() } - enqueue(object : ApolloPrefetch.Callback() { + enqueue(object : com.homer.apollographql.apollo.ApolloPrefetch.Callback() { private val wasCalled = AtomicBoolean(false) @@ -219,7 +219,7 @@ suspend fun ApolloPrefetch.await(): Unit = suspendCancellableCoroutine { cont -> * @return the converted job */ @Deprecated("Use await() instead.") -fun ApolloPrefetch.toJob(): Job { +fun com.homer.apollographql.apollo.ApolloPrefetch.toJob(): Job { val deferred = CompletableDeferred() deferred.invokeOnCompletion { @@ -228,7 +228,7 @@ fun ApolloPrefetch.toJob(): Job { } } - enqueue(object : ApolloPrefetch.Callback() { + enqueue(object : com.homer.apollographql.apollo.ApolloPrefetch.Callback() { override fun onSuccess() { if (deferred.isActive) { deferred.complete(Unit) diff --git a/apollo-gradle-plugin/api.txt b/apollo-gradle-plugin/api.txt index 8e0383d25ef..2ec196145f1 100644 --- a/apollo-gradle-plugin/api.txt +++ b/apollo-gradle-plugin/api.txt @@ -1,12 +1,12 @@ // Signature format: 3.0 -package com.apollographql.apollo.gradle.api { +package com.homer.apollographql.apollo.gradle.api { public final class ApolloAttributes { method public error.NonExistentClass! getAPOLLO_SERVICE_ATTRIBUTE(); method public error.NonExistentClass! getAPOLLO_VARIANT_ATTRIBUTE(); property public final error.NonExistentClass! APOLLO_SERVICE_ATTRIBUTE; property public final error.NonExistentClass! APOLLO_VARIANT_ATTRIBUTE; - field public static final com.apollographql.apollo.gradle.api.ApolloAttributes INSTANCE; + field public static final com.homer.apollographql.apollo.gradle.api.ApolloAttributes INSTANCE; } public static interface ApolloAttributes.Service extends org.gradle.api.Named { @@ -15,12 +15,12 @@ package com.apollographql.apollo.gradle.api { public static interface ApolloAttributes.Variant extends org.gradle.api.Named { } - public interface ApolloExtension extends com.apollographql.apollo.gradle.api.CompilerParams { - method public void onCompilationUnit(org.gradle.api.Action action); - method public void service(String name, org.gradle.api.Action action); + public interface ApolloExtension extends com.homer.apollographql.apollo.gradle.api.CompilerParams { + method public void onCompilationUnit(org.gradle.api.Action action); + method public void service(String name, org.gradle.api.Action action); } - public interface CompilationUnit extends com.apollographql.apollo.gradle.api.CompilerParams { + public interface CompilationUnit extends com.homer.apollographql.apollo.gradle.api.CompilerParams { method public Object? getAndroidVariant(); method public String getName(); method public org.gradle.api.provider.Provider getOperationOutputFile(); @@ -91,11 +91,11 @@ package com.apollographql.apollo.gradle.api { property public abstract org.gradle.api.provider.Property sourceSetName; } - public interface Service extends com.apollographql.apollo.gradle.api.CompilerParams { + public interface Service extends com.homer.apollographql.apollo.gradle.api.CompilerParams { method public org.gradle.api.provider.ListProperty getExclude(); method public org.gradle.api.provider.Property getSchemaPath(); method public org.gradle.api.provider.Property getSourceFolder(); - method public void introspection(org.gradle.api.Action configure); + method public void introspection(org.gradle.api.Action configure); property public abstract org.gradle.api.provider.ListProperty exclude; property public abstract org.gradle.api.provider.Property schemaPath; property public abstract org.gradle.api.provider.Property sourceFolder; diff --git a/apollo-gradle-plugin/build.gradle.kts b/apollo-gradle-plugin/build.gradle.kts index 54ba103e736..886112e04a5 100644 --- a/apollo-gradle-plugin/build.gradle.kts +++ b/apollo-gradle-plugin/build.gradle.kts @@ -16,7 +16,7 @@ fun Any.dot(key: String): Any { } metalava { - hiddenPackages += setOf("com.apollographql.apollo.gradle.internal") + hiddenPackages += setOf("com.homer.apollographql.apollo.gradle.internal") } dependencies { @@ -56,10 +56,10 @@ pluginBundle { gradlePlugin { plugins { create("apolloGradlePlugin") { - id = "com.apollographql.apollo" + id = "com.homer.apollographql.apollo" displayName = "Apollo Android GraphQL client plugin." description = "Automatically generates typesafe java and kotlin models from your GraphQL files." - implementationClass = "com.apollographql.apollo.gradle.internal.ApolloPlugin" + implementationClass = "com.homer.apollographql.apollo.gradle.internal.ApolloPlugin" } } } diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/ApolloAttributes.kt b/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/ApolloAttributes.kt deleted file mode 100644 index 3e31b0f645a..00000000000 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/ApolloAttributes.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.apollographql.apollo.gradle.api - -import org.gradle.api.Named -import org.gradle.api.attributes.Attribute - -object ApolloAttributes { - interface Variant : Named { - } - - val APOLLO_VARIANT_ATTRIBUTE = Attribute.of("com.apollographql.variant", Variant::class.java) - - interface Service : Named { - } - - val APOLLO_SERVICE_ATTRIBUTE = Attribute.of("com.apollographql.service", Service::class.java) -} \ No newline at end of file diff --git a/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/ApolloAttributes.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/ApolloAttributes.kt new file mode 100644 index 00000000000..11e15ee1b6b --- /dev/null +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/ApolloAttributes.kt @@ -0,0 +1,16 @@ +package com.homer.apollographql.apollo.gradle.api + +import org.gradle.api.Named +import org.gradle.api.attributes.Attribute + +object ApolloAttributes { + interface Variant : Named { + } + + val APOLLO_VARIANT_ATTRIBUTE = Attribute.of("com.homer.apollographql.variant", Variant::class.java) + + interface Service : Named { + } + + val APOLLO_SERVICE_ATTRIBUTE = Attribute.of("com.homer.apollographql.service", Service::class.java) +} \ No newline at end of file diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/ApolloExtension.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/ApolloExtension.kt similarity index 92% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/ApolloExtension.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/ApolloExtension.kt index 8a244f939e8..d792e9fbb7b 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/ApolloExtension.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/ApolloExtension.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.gradle.api +package com.homer.apollographql.apollo.gradle.api -import com.apollographql.apollo.gradle.internal.DefaultService +import com.homer.apollographql.apollo.gradle.internal.DefaultService import org.gradle.api.Action import org.gradle.api.provider.Property diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/CompilationUnit.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/CompilationUnit.kt similarity index 79% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/CompilationUnit.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/CompilationUnit.kt index 44073040e74..f3394f2457e 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/CompilationUnit.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/CompilationUnit.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.gradle.api +package com.homer.apollographql.apollo.gradle.api import org.gradle.api.Task import org.gradle.api.file.Directory @@ -9,7 +9,7 @@ import org.gradle.api.tasks.TaskProvider /** * A [CompilationUnit] is a single invocation of the compiler. It is used by - * [com.apollographql.apollo.gradle.internal.ApolloGenerateSourcesTask] to generate models. + * [com.homer.apollographql.apollo.gradle.internal.ApolloGenerateSourcesTask] to generate models. * * It inherits [CompilerParams] so individual parameters can be directly set on the [CompilationUnit] */ @@ -32,7 +32,7 @@ interface CompilationUnit: CompilerParams { val androidVariant: Any? /** - * A json file containing a [Map]<[String], [com.apollographql.apollo.compiler.operationoutput.OperationDescriptor]> + * A json file containing a [Map]<[String], [com.homer.apollographql.apollo.compiler.operationoutput.OperationDescriptor]> */ val operationOutputFile: Provider diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/CompilerParams.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/CompilerParams.kt similarity index 95% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/CompilerParams.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/CompilerParams.kt index 3b0058c60f3..96a3f653a6a 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/CompilerParams.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/CompilerParams.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.gradle.api +package com.homer.apollographql.apollo.gradle.api -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.compiler.OperationIdGenerator -import com.apollographql.apollo.compiler.OperationOutputGenerator +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.compiler.OperationIdGenerator +import com.homer.apollographql.apollo.compiler.OperationOutputGenerator import org.gradle.api.file.RegularFileProperty import org.gradle.api.file.SourceDirectorySet import org.gradle.api.provider.ListProperty @@ -63,7 +63,7 @@ interface CompilerParams { * * Example Md5 hash generator: * ```groovy - * import com.apollographql.apollo.compiler.OperationIdGenerator + * import com.homer.apollographql.apollo.compiler.OperationIdGenerator * * apollo { * operationIdGenerator = new OperationIdGenerator() { @@ -91,7 +91,7 @@ interface CompilerParams { * * Example Md5 hash generator: * ```groovy - * import com.apollographql.apollo.compiler.OperationIdGenerator + * import com.homer.apollographql.apollo.compiler.OperationIdGenerator * * apollo { * operationOutputGenerator = new OperationIdGenerator() { diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/Introspection.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/Introspection.kt similarity index 94% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/Introspection.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/Introspection.kt index a23498f4a90..ec0cceabd7b 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/Introspection.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/Introspection.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.gradle.api +package com.homer.apollographql.apollo.gradle.api import org.gradle.api.provider.MapProperty import org.gradle.api.provider.Property diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/Service.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/Service.kt similarity index 96% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/Service.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/Service.kt index 2f487162fb0..d8e01bbc964 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/api/Service.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/api/Service.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.gradle.api +package com.homer.apollographql.apollo.gradle.api import org.gradle.api.Action import org.gradle.api.provider.ListProperty diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/AndroidTaskConfigurator.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/AndroidTaskConfigurator.kt similarity index 98% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/AndroidTaskConfigurator.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/AndroidTaskConfigurator.kt index c149a1e3651..1884bb9503e 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/AndroidTaskConfigurator.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/AndroidTaskConfigurator.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal import com.android.build.gradle.AppExtension import com.android.build.gradle.LibraryExtension diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloCheckDuplicatesTask.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloCheckDuplicatesTask.kt similarity index 93% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloCheckDuplicatesTask.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloCheckDuplicatesTask.kt index 6bd91586c2b..7be1d1609b1 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloCheckDuplicatesTask.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloCheckDuplicatesTask.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal -import com.apollographql.apollo.compiler.ApolloMetadata +import com.homer.apollographql.apollo.compiler.ApolloMetadata import org.gradle.api.DefaultTask import org.gradle.api.artifacts.Configuration import org.gradle.api.file.ConfigurableFileCollection diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloConvertSchemaTask.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloConvertSchemaTask.kt similarity index 77% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloConvertSchemaTask.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloConvertSchemaTask.kt index 712077f155c..f1f00ba20e8 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloConvertSchemaTask.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloConvertSchemaTask.kt @@ -1,11 +1,11 @@ -package com.apollographql.apollo.gradle.internal - -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema.Companion.wrap -import com.apollographql.apollo.compiler.parser.introspection.toSDL -import com.apollographql.apollo.compiler.parser.sdl.GraphSdlSchema -import com.apollographql.apollo.compiler.parser.sdl.toIntrospectionSchema -import com.apollographql.apollo.compiler.toJson +package com.homer.apollographql.apollo.gradle.internal + +import com.homer.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema +import com.homer.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema.Companion.wrap +import com.homer.apollographql.apollo.compiler.parser.introspection.toSDL +import com.homer.apollographql.apollo.compiler.parser.sdl.GraphSdlSchema +import com.homer.apollographql.apollo.compiler.parser.sdl.toIntrospectionSchema +import com.homer.apollographql.apollo.compiler.toJson import org.gradle.api.DefaultTask import org.gradle.api.provider.Property import org.gradle.api.tasks.Input diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloDownloadSchemaCliTask.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloDownloadSchemaCliTask.kt similarity index 82% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloDownloadSchemaCliTask.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloDownloadSchemaCliTask.kt index ed362a6ebb7..9ffafd49744 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloDownloadSchemaCliTask.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloDownloadSchemaCliTask.kt @@ -1,12 +1,12 @@ -package com.apollographql.apollo.gradle.internal - -import com.apollographql.apollo.compiler.parser.antlr.GraphSDLParser -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema -import com.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema.Companion.wrap -import com.apollographql.apollo.compiler.parser.introspection.toSDL -import com.apollographql.apollo.compiler.parser.sdl.GraphSDLSchemaParser.parse -import com.apollographql.apollo.compiler.parser.sdl.toIntrospectionSchema -import com.apollographql.apollo.compiler.toJson +package com.homer.apollographql.apollo.gradle.internal + +import com.homer.apollographql.apollo.compiler.parser.antlr.GraphSDLParser +import com.homer.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema +import com.homer.apollographql.apollo.compiler.parser.introspection.IntrospectionSchema.Companion.wrap +import com.homer.apollographql.apollo.compiler.parser.introspection.toSDL +import com.homer.apollographql.apollo.compiler.parser.sdl.GraphSDLSchemaParser.parse +import com.homer.apollographql.apollo.compiler.parser.sdl.toIntrospectionSchema +import com.homer.apollographql.apollo.compiler.toJson import okhttp3.HttpUrl.Companion.toHttpUrl import okio.Buffer import org.gradle.api.DefaultTask @@ -78,8 +78,8 @@ abstract class ApolloDownloadSchemaCliTask : DefaultTask() { } private fun Property.orProperty(name: String) = orElse(project.provider { - (project.findProperty("com.apollographql.apollo.$name") as? String)?.also { - logger.lifecycle("Using the com.apollographql.apollo.$name property is deprecated. Use --$name instead.") + (project.findProperty("com.homer.apollographql.apollo.$name") as? String)?.also { + logger.lifecycle("Using the com.homer.apollographql.apollo.$name property is deprecated. Use --$name instead.") } }).orNull @@ -114,18 +114,18 @@ abstract class ApolloDownloadSchemaCliTask : DefaultTask() { } ?: compilationUnit()?.resolveParams(project)?.first?.schemaFile?.asFile?.get() ?: throw IllegalArgumentException("ApolloGraphQL: cannot determine where to save the schema. Specify --schema or --service") - val headersProp = project.findProperty("com.apollographql.apollo.headers") as? String + val headersProp = project.findProperty("com.homer.apollographql.apollo.headers") as? String val headers = when { headersProp != null -> { - logger.lifecycle("Using the com.apollographql.apollo.headers property is deprecated. Use --header instead.") + logger.lifecycle("Using the com.homer.apollographql.apollo.headers property is deprecated. Use --header instead.") ApolloPlugin.toMap(headersProp) } else -> header.toMap() } - val queryParamsProp = project.findProperty("com.apollographql.apollo.query_params") as? String + val queryParamsProp = project.findProperty("com.homer.apollographql.apollo.query_params") as? String if (queryParamsProp != null) { - logger.lifecycle("Using the com.apollographql.apollo.query_params property is deprecated. Add parameters to the endpoint instead.") + logger.lifecycle("Using the com.homer.apollographql.apollo.query_params property is deprecated. Add parameters to the endpoint instead.") check (endpointUrl != null) { "ApolloGraphql: adding query_params without endpoint makes not sense. Either remove them or specify --endpoint" } diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloDownloadSchemaTask.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloDownloadSchemaTask.kt similarity index 96% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloDownloadSchemaTask.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloDownloadSchemaTask.kt index f63d5d3eba9..bdfbcaf9005 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloDownloadSchemaTask.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloDownloadSchemaTask.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal import org.gradle.api.DefaultTask import org.gradle.api.provider.Property diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloGenerateSourcesTask.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloGenerateSourcesTask.kt similarity index 96% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloGenerateSourcesTask.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloGenerateSourcesTask.kt index ba896dee2e5..296e5b61dc1 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloGenerateSourcesTask.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloGenerateSourcesTask.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal -import com.apollographql.apollo.compiler.GraphQLCompiler -import com.apollographql.apollo.compiler.NullableValueType -import com.apollographql.apollo.compiler.OperationOutputGenerator +import com.homer.apollographql.apollo.compiler.GraphQLCompiler +import com.homer.apollographql.apollo.compiler.NullableValueType +import com.homer.apollographql.apollo.compiler.OperationOutputGenerator import org.gradle.api.DefaultTask import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.file.DirectoryProperty diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloPlugin.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloPlugin.kt similarity index 97% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloPlugin.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloPlugin.kt index c0ec2463632..102b873be83 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloPlugin.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloPlugin.kt @@ -1,9 +1,9 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal -import com.apollographql.apollo.compiler.OperationIdGenerator -import com.apollographql.apollo.compiler.OperationOutputGenerator -import com.apollographql.apollo.gradle.api.ApolloAttributes -import com.apollographql.apollo.gradle.api.ApolloExtension +import com.homer.apollographql.apollo.compiler.OperationIdGenerator +import com.homer.apollographql.apollo.compiler.OperationOutputGenerator +import com.homer.apollographql.apollo.gradle.api.ApolloAttributes +import com.homer.apollographql.apollo.gradle.api.ApolloExtension import okhttp3.HttpUrl.Companion.toHttpUrl import org.gradle.api.Plugin import org.gradle.api.Project @@ -290,7 +290,7 @@ open class ApolloPlugin : Plugin { return configurations.flatMap { configuration -> configuration.incoming.dependencies .filter { - it.group == "com.apollographql.apollo" + it.group == "com.homer.apollographql.apollo" }.map { dependency -> Dep(dependency.name, dependency.version) } diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloPushSchemaTask.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloPushSchemaTask.kt similarity index 87% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloPushSchemaTask.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloPushSchemaTask.kt index 6dec23640ea..fd968cdfe62 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloPushSchemaTask.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloPushSchemaTask.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal import org.gradle.api.DefaultTask import org.gradle.api.provider.Property @@ -31,8 +31,8 @@ abstract class ApolloPushSchemaTask : DefaultTask() { private fun Property.orProperty(name: String) = orElse(project.provider { - (project.findProperty("com.apollographql.apollo.$name") as? String)?.also { - logger.lifecycle("Using the com.apollographql.apollo.$name property is deprecated. Use --$name instead.") + (project.findProperty("com.homer.apollographql.apollo.$name") as? String)?.also { + logger.lifecycle("Using the com.homer.apollographql.apollo.$name property is deprecated. Use --$name instead.") } }).orNull diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloVariant.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloVariant.kt similarity index 94% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloVariant.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloVariant.kt index 24252e2ac71..67b98984d9a 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ApolloVariant.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ApolloVariant.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal class ApolloVariant( /** diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/BuildDirLayout.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/BuildDirLayout.kt similarity index 96% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/BuildDirLayout.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/BuildDirLayout.kt index 94a74f95d4e..8b4741ab0c3 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/BuildDirLayout.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/BuildDirLayout.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal import org.gradle.api.Project import org.gradle.api.file.Directory diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/CompilerParamsExtensions.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/CompilerParamsExtensions.kt similarity index 95% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/CompilerParamsExtensions.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/CompilerParamsExtensions.kt index 4f78db3c6b0..c93a5f99260 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/CompilerParamsExtensions.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/CompilerParamsExtensions.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal -import com.apollographql.apollo.gradle.api.CompilerParams +import com.homer.apollographql.apollo.gradle.api.CompilerParams import org.gradle.api.model.ObjectFactory fun CompilerParams.withFallback(objects: ObjectFactory, other: CompilerParams): CompilerParams { diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/DefaultApolloExtension.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/DefaultApolloExtension.kt similarity index 79% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/DefaultApolloExtension.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/DefaultApolloExtension.kt index d302d878a41..3e4b371c5c2 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/DefaultApolloExtension.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/DefaultApolloExtension.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal -import com.apollographql.apollo.gradle.api.ApolloExtension -import com.apollographql.apollo.gradle.api.CompilationUnit -import com.apollographql.apollo.gradle.api.CompilerParams +import com.homer.apollographql.apollo.gradle.api.ApolloExtension +import com.homer.apollographql.apollo.gradle.api.CompilationUnit +import com.homer.apollographql.apollo.gradle.api.CompilerParams import org.gradle.api.Action import org.gradle.api.Project diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/DefaultCompilationUnit.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/DefaultCompilationUnit.kt similarity index 95% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/DefaultCompilationUnit.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/DefaultCompilationUnit.kt index 9cecc62f225..4e4ba2b6477 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/DefaultCompilationUnit.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/DefaultCompilationUnit.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal -import com.apollographql.apollo.gradle.api.CompilationUnit -import com.apollographql.apollo.gradle.api.CompilerParams -import com.apollographql.apollo.gradle.internal.ApolloPlugin.Companion.isKotlinMultiplatform +import com.homer.apollographql.apollo.gradle.api.CompilationUnit +import com.homer.apollographql.apollo.gradle.api.CompilerParams +import com.homer.apollographql.apollo.gradle.internal.ApolloPlugin.Companion.isKotlinMultiplatform import org.gradle.api.Project import org.gradle.api.file.DirectoryProperty import org.gradle.api.file.RegularFileProperty diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/DefaultCompilerParams.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/DefaultCompilerParams.kt similarity index 91% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/DefaultCompilerParams.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/DefaultCompilerParams.kt index 6f3fca42a08..6cdeeb27ddb 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/DefaultCompilerParams.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/DefaultCompilerParams.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal -import com.apollographql.apollo.compiler.OperationIdGenerator -import com.apollographql.apollo.gradle.api.CompilerParams +import com.homer.apollographql.apollo.compiler.OperationIdGenerator +import com.homer.apollographql.apollo.gradle.api.CompilerParams import org.gradle.api.file.RegularFileProperty import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.ListProperty diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/DefaultIntrospection.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/DefaultIntrospection.kt similarity index 81% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/DefaultIntrospection.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/DefaultIntrospection.kt index 13c186c5270..ee4aa599046 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/DefaultIntrospection.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/DefaultIntrospection.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal -import com.apollographql.apollo.gradle.api.Introspection +import com.homer.apollographql.apollo.gradle.api.Introspection import org.gradle.api.Project import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.MapProperty diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/DefaultService.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/DefaultService.kt similarity index 81% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/DefaultService.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/DefaultService.kt index 9e420eea9b8..3e6adfbff8b 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/DefaultService.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/DefaultService.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal -import com.apollographql.apollo.gradle.api.CompilerParams -import com.apollographql.apollo.gradle.api.Introspection -import com.apollographql.apollo.gradle.api.Service +import com.homer.apollographql.apollo.gradle.api.CompilerParams +import com.homer.apollographql.apollo.gradle.api.Introspection +import com.homer.apollographql.apollo.gradle.api.Service import org.gradle.api.Action import org.gradle.api.model.ObjectFactory import javax.inject.Inject diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/FileExtensions.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/FileExtensions.kt similarity index 67% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/FileExtensions.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/FileExtensions.kt index 2aa86e1bb58..de6503379b0 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/FileExtensions.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/FileExtensions.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal import java.io.File diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/GUtil.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/GUtil.kt similarity index 96% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/GUtil.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/GUtil.kt index 3054dfb75f3..b92376701aa 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/GUtil.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/GUtil.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal import java.util.regex.Pattern diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/JvmTaskConfigurator.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/JvmTaskConfigurator.kt similarity index 97% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/JvmTaskConfigurator.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/JvmTaskConfigurator.kt index 5699d0cf7fe..d1b091a32aa 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/JvmTaskConfigurator.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/JvmTaskConfigurator.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal import org.gradle.api.NamedDomainObjectContainer import org.gradle.api.Project diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/KotlinMultiplatformTaskConfigurator.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/KotlinMultiplatformTaskConfigurator.kt similarity index 97% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/KotlinMultiplatformTaskConfigurator.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/KotlinMultiplatformTaskConfigurator.kt index d86901e64f8..a108d720aa2 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/KotlinMultiplatformTaskConfigurator.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/KotlinMultiplatformTaskConfigurator.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal import org.gradle.api.NamedDomainObjectContainer import org.gradle.api.Project diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ModelNames.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ModelNames.kt similarity index 96% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ModelNames.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ModelNames.kt index 0e22914ab00..ca7820116aa 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/ModelNames.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/ModelNames.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal object ModelNames { private fun camelCase(vararg elements: String): String { diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/SchemaDownloader.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/SchemaDownloader.kt similarity index 96% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/SchemaDownloader.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/SchemaDownloader.kt index 889ea5fac13..04bff3cbf08 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/SchemaDownloader.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/SchemaDownloader.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal -import com.apollographql.apollo.compiler.fromJson +import com.homer.apollographql.apollo.compiler.fromJson object SchemaDownloader { fun downloadIntrospection( diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/SchemaHelper.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/SchemaHelper.kt similarity index 89% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/SchemaHelper.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/SchemaHelper.kt index bb9a10f7c74..dd6df332ccb 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/SchemaHelper.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/SchemaHelper.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal -import com.apollographql.apollo.compiler.toJson +import com.homer.apollographql.apollo.compiler.toJson import com.squareup.moshi.JsonWriter import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.OkHttpClient @@ -21,7 +21,7 @@ internal object SchemaHelper { .addInterceptor { chain -> chain.request().newBuilder() .header("apollographql-client-name", "apollo-gradle-plugin") - .header("apollographql-client-version", com.apollographql.apollo.compiler.VERSION) + .header("apollographql-client-version", com.homer.apollographql.apollo.compiler.VERSION) .build() .let { chain.proceed(it) diff --git a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/SchemaUploader.kt b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/SchemaUploader.kt similarity index 86% rename from apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/SchemaUploader.kt rename to apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/SchemaUploader.kt index 2576c983c9f..d8bd4996e7b 100644 --- a/apollo-gradle-plugin/src/main/kotlin/com/apollographql/apollo/gradle/internal/SchemaUploader.kt +++ b/apollo-gradle-plugin/src/main/kotlin/com/homer/apollographql/apollo/gradle/internal/SchemaUploader.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.gradle.internal +package com.homer.apollographql.apollo.gradle.internal -import com.apollographql.apollo.compiler.fromJson -import com.apollographql.apollo.gradle.internal.SchemaDownloader.cast +import com.homer.apollographql.apollo.compiler.fromJson +import com.homer.apollographql.apollo.gradle.internal.SchemaDownloader.cast import java.net.InetAddress import java.nio.charset.StandardCharsets import java.security.MessageDigest diff --git a/apollo-gradle-plugin/src/main/resources/META-INF/gradle-plugins/com.apollographql.apollo.properties b/apollo-gradle-plugin/src/main/resources/META-INF/gradle-plugins/com.apollographql.apollo.properties index fe62ce89d57..baf9582ef52 100644 --- a/apollo-gradle-plugin/src/main/resources/META-INF/gradle-plugins/com.apollographql.apollo.properties +++ b/apollo-gradle-plugin/src/main/resources/META-INF/gradle-plugins/com.apollographql.apollo.properties @@ -1 +1 @@ -implementation-class=com.apollographql.apollo.gradle.internal.ApolloPlugin \ No newline at end of file +implementation-class=com.homer.apollographql.apollo.gradle.internal.ApolloPlugin \ No newline at end of file diff --git a/apollo-gradle-plugin/src/test/files/githunt/FeedQuery.graphql b/apollo-gradle-plugin/src/test/files/githunt/FeedQuery.graphql deleted file mode 100644 index 195ccaa88c2..00000000000 --- a/apollo-gradle-plugin/src/test/files/githunt/FeedQuery.graphql +++ /dev/null @@ -1,29 +0,0 @@ -query FeedQuery($type: FeedType!, $limit: Int!) { - feed(type: $type, limit: $limit) { - comments { - ...FeedCommentFragment - } - repository { - ...RepositoryFragment - } - postedBy { - login - } - } -} - -fragment RepositoryFragment on Repository { - name - full_name - owner { - login - } -} - -fragment FeedCommentFragment on Comment { - id - postedBy { - login - } - content -} diff --git a/apollo-gradle-plugin/src/test/files/githunt/schema.json b/apollo-gradle-plugin/src/test/files/githunt/schema.json deleted file mode 100644 index 6325baa24ed..00000000000 --- a/apollo-gradle-plugin/src/test/files/githunt/schema.json +++ /dev/null @@ -1,1747 +0,0 @@ -{ - "data": { - "__schema": { - "queryType": { - "name": "Query" - }, - "mutationType": { - "name": "Mutation" - }, - "subscriptionType": { - "name": "Subscription" - }, - "types": [ - { - "kind": "OBJECT", - "name": "Query", - "description": "", - "fields": [ - { - "name": "feed", - "description": "A feed of repository submissions", - "args": [ - { - "name": "type", - "description": "The sort order for the feed", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "FeedType", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "offset", - "description": "The number of items to skip, for pagination", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "limit", - "description": "The number of items to fetch starting from the offset, for pagination", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Entry", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "entry", - "description": "A single entry", - "args": [ - { - "name": "repoFullName", - "description": "The full repository name from GitHub, e.g. \"apollostack/GitHunt-API\"", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Entry", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "currentUser", - "description": "Return the currently logged in user, or null if nobody is logged in", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "FeedType", - "description": "A list of options for the sort order of the feed", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "HOT", - "description": "Sort by a combination of freshness and score, using Reddit's algorithm", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NEW", - "description": "Newest entries first", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "TOP", - "description": "Highest score entries first", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Int", - "description": "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. ", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Entry", - "description": "Information about a GitHub repository submitted to GitHunt", - "fields": [ - { - "name": "repository", - "description": "Information about the repository from GitHub", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "postedBy", - "description": "The GitHub user who submitted this entry", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "A timestamp of when the entry was submitted", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "score", - "description": "The score of this repository, upvotes - downvotes", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hotScore", - "description": "The hot score of this repository", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "comments", - "description": "Comments posted about this repository", - "args": [ - { - "name": "limit", - "description": "", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "offset", - "description": "", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Comment", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commentCount", - "description": "The number of comments posted about this repository", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": "The SQL ID of this entry", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "vote", - "description": "XXX to be changed", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Vote", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Repository", - "description": "A repository object from the GitHub API. This uses the exact field names returned by the\nGitHub API for simplicity, even though the convention for GraphQL is usually to camel case.", - "fields": [ - { - "name": "name", - "description": "Just the name of the repository, e.g. GitHunt-API", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "full_name", - "description": "The full name of the repository with the username, e.g. apollostack/GitHunt-API", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "The description of the repository", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "html_url", - "description": "The link to the repository on GitHub", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "stargazers_count", - "description": "The number of people who have starred this repository on GitHub", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "open_issues_count", - "description": "The number of open issues on this repository on GitHub", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "owner", - "description": "The owner of this repository on GitHub, e.g. apollostack", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "String", - "description": "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "User", - "description": "A user object from the GitHub API. This uses the exact field names returned from the GitHub API.", - "fields": [ - { - "name": "login", - "description": "The name of the user, e.g. apollostack", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "avatar_url", - "description": "The URL to a directly embeddable image for this user's avatar", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "html_url", - "description": "The URL of this user's GitHub page", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Float", - "description": "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point). ", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Comment", - "description": "A comment about an entry, submitted by a user", - "fields": [ - { - "name": "id", - "description": "The SQL ID of this entry", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "postedBy", - "description": "The GitHub user who posted the comment", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "A timestamp of when the comment was posted", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "content", - "description": "The text of the comment", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repoName", - "description": "The repository which this comment is about", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Vote", - "description": "XXX to be removed", - "fields": [ - { - "name": "vote_value", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Mutation", - "description": "", - "fields": [ - { - "name": "submitRepository", - "description": "Submit a new repository, returns the new submission", - "args": [ - { - "name": "repoFullName", - "description": "The full repository name from GitHub, e.g. \"apollostack/GitHunt-API\"", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Entry", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "vote", - "description": "Vote on a repository submission, returns the submission that was voted on", - "args": [ - { - "name": "repoFullName", - "description": "The full repository name from GitHub, e.g. \"apollostack/GitHunt-API\"", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "type", - "description": "The type of vote - UP, DOWN, or CANCEL", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "VoteType", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Entry", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "submitComment", - "description": "Comment on a repository, returns the new comment", - "args": [ - { - "name": "repoFullName", - "description": "The full repository name from GitHub, e.g. \"apollostack/GitHunt-API\"", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "commentContent", - "description": "The text content for the new comment", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Comment", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "VoteType", - "description": "The type of vote to record, when submitting a vote", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "UP", - "description": "", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "DOWN", - "description": "", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CANCEL", - "description": "", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Subscription", - "description": "", - "fields": [ - { - "name": "commentAdded", - "description": "Subscription fires on every comment added", - "args": [ - { - "name": "repoFullName", - "description": "", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Comment", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Schema", - "description": "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.", - "fields": [ - { - "name": "types", - "description": "A list of all types supported by this server.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type" - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "queryType", - "description": "The type that query operations will be rooted at.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mutationType", - "description": "If this server supports mutation, the type that mutation operations will be rooted at.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subscriptionType", - "description": "If this server support subscription, the type that subscription operations will be rooted at.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "directives", - "description": "A list of all directives supported by this server.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Directive" - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Type", - "description": "The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.", - "fields": [ - { - "name": "kind", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "__TypeKind", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "fields", - "description": null, - "args": [ - { - "name": "includeDeprecated", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Field", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "interfaces", - "description": null, - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "possibleTypes", - "description": null, - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "enumValues", - "description": null, - "args": [ - { - "name": "includeDeprecated", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__EnumValue", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "inputFields", - "description": null, - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ofType", - "description": null, - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "__TypeKind", - "description": "An enum describing what kind of type a given `__Type` is.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "SCALAR", - "description": "Indicates this type is a scalar.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OBJECT", - "description": "Indicates this type is an object. `fields` and `interfaces` are valid fields.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INTERFACE", - "description": "Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNION", - "description": "Indicates this type is a union. `possibleTypes` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM", - "description": "Indicates this type is an enum. `enumValues` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_OBJECT", - "description": "Indicates this type is an input object. `inputFields` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "LIST", - "description": "Indicates this type is a list. `ofType` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NON_NULL", - "description": "Indicates this type is a non-null. `ofType` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Boolean", - "description": "The `Boolean` scalar type represents `true` or `false`.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Field", - "description": "Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "args", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue" - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDeprecated", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deprecationReason", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__InputValue", - "description": "Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "defaultValue", - "description": "A GraphQL-formatted string representing the default value for this input value.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__EnumValue", - "description": "One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDeprecated", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deprecationReason", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Directive", - "description": "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "locations", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "__DirectiveLocation" - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "args", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue" - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "onOperation", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "Use `locations`." - }, - { - "name": "onFragment", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "Use `locations`." - }, - { - "name": "onField", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "Use `locations`." - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "__DirectiveLocation", - "description": "A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "QUERY", - "description": "Location adjacent to a query operation.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MUTATION", - "description": "Location adjacent to a mutation operation.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SUBSCRIPTION", - "description": "Location adjacent to a subscription operation.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FIELD", - "description": "Location adjacent to a field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FRAGMENT_DEFINITION", - "description": "Location adjacent to a fragment definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FRAGMENT_SPREAD", - "description": "Location adjacent to a fragment spread.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INLINE_FRAGMENT", - "description": "Location adjacent to an inline fragment.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SCHEMA", - "description": "Location adjacent to a schema definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SCALAR", - "description": "Location adjacent to a scalar definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OBJECT", - "description": "Location adjacent to an object type definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FIELD_DEFINITION", - "description": "Location adjacent to a field definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ARGUMENT_DEFINITION", - "description": "Location adjacent to an argument definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INTERFACE", - "description": "Location adjacent to an interface definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNION", - "description": "Location adjacent to a union definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM", - "description": "Location adjacent to an enum definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM_VALUE", - "description": "Location adjacent to an enum value definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_OBJECT", - "description": "Location adjacent to an input object type definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_FIELD_DEFINITION", - "description": "Location adjacent to an input object field definition.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - } - ], - "directives": [ - { - "name": "skip", - "description": "Directs the executor to skip this field or fragment when the `if` argument is true.", - "locations": [ - "FIELD", - "FRAGMENT_SPREAD", - "INLINE_FRAGMENT" - ], - "args": [ - { - "name": "if", - "description": "Skipped when true.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "defaultValue": null - } - ] - }, - { - "name": "include", - "description": "Directs the executor to include this field or fragment only when the `if` argument is true.", - "locations": [ - "FIELD", - "FRAGMENT_SPREAD", - "INLINE_FRAGMENT" - ], - "args": [ - { - "name": "if", - "description": "Included when true.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "defaultValue": null - } - ] - }, - { - "name": "deprecated", - "description": "Marks an element of a GraphQL schema as no longer supported.", - "locations": [ - "FIELD_DEFINITION", - "ENUM_VALUE" - ], - "args": [ - { - "name": "reason", - "description": "Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted in [Markdown](https://daringfireball.net/projects/markdown/).", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": "\"No longer supported\"" - } - ] - } - ] - } - } -} diff --git a/apollo-gradle-plugin/src/test/files/gradle/build.gradle.kts b/apollo-gradle-plugin/src/test/files/gradle/build.gradle.kts deleted file mode 100644 index a069d6825d8..00000000000 --- a/apollo-gradle-plugin/src/test/files/gradle/build.gradle.kts +++ /dev/null @@ -1,4 +0,0 @@ -plugins { - id("org.jetbrains.kotlin.jvm") - id("com.apollographql.apollo") -} diff --git a/apollo-gradle-plugin/src/test/files/gradle/build.gradle.kts.template b/apollo-gradle-plugin/src/test/files/gradle/build.gradle.kts.template deleted file mode 100644 index 27cd53de9d5..00000000000 --- a/apollo-gradle-plugin/src/test/files/gradle/build.gradle.kts.template +++ /dev/null @@ -1,74 +0,0 @@ -import com.apollographql.apollo.gradle.api.ApolloExtension - -buildscript { - apply("../../../gradle/dependencies.gradle") - - val classpathDep = {artifact: String -> - val c = artifact.split(".") - - var ret = (extra["dep"] as Map)[c[0]]!! - - if (c.size > 1) { - ret = (ret as Map)[c[1]]!! - } - ret - } - - repositories { - maven { - url = uri("../../../build/localMaven") - } - google() - mavenCentral() - jcenter { - content { - includeGroup("org.jetbrains.trove4j") - } - } - } - dependencies { - // ADD BUILDSCRIPT DEPENDENCIES HERE - } -} - -fun kotlinDep(artifact: String): Any { - val c = artifact.split(".") - - var ret = (extra["dep"] as Map)[c[0]]!! - - if (c.size > 1) { - ret = (ret as Map)[c[1]]!! - } - return ret -} - -// ADD PLUGINS HERE -// apply plugin: 'com.android.library' -// apply plugin: 'com.apollographql.apollo' - -repositories { - maven { - url = uri("../../../build/localMaven") - } - google() // for aapt2 - mavenCentral() - jcenter { - content { - includeGroup("org.jetbrains.trove4j") - } - } -} - -dependencies { - // ADD DEPENDENCIES HERE - add("implementation", kotlinDep("jetbrainsAnnotations")) - add("implementation", kotlinDep("apollo.api")) -} - -// ADD ANDROID CONFIGURATION HERE -// android { -// compileSdkVersion androidConfig.compileSdkVersion -// } - -// ADD APOLLO CONFIGURATION HERE - diff --git a/apollo-gradle-plugin/src/test/files/gradle/build.gradle.template b/apollo-gradle-plugin/src/test/files/gradle/build.gradle.template deleted file mode 100644 index e9675883fe5..00000000000 --- a/apollo-gradle-plugin/src/test/files/gradle/build.gradle.template +++ /dev/null @@ -1,51 +0,0 @@ -buildscript { - apply from: "../../../gradle/dependencies.gradle" - - repositories { - maven { - url = uri("../../../build/localMaven") - } - google() - mavenCentral() - jcenter { - content { - includeGroup("org.jetbrains.trove4j") - } - } - } - dependencies { - // ADD BUILDSCRIPT DEPENDENCIES HERE - // classpath(dep.androidPlugin) - // classpath(dep.apolloPlugin) - } -} - -// ADD PLUGINS HERE -// apply plugin: 'com.android.library' -// apply plugin: 'com.apollographql.apollo' - -repositories { - maven { - url = uri("../../../build/localMaven") - } - google() // for aapt2 - mavenCentral() // for jetbrainsAnnotations, depended on by apolloApi - jcenter { - content { - includeGroup("org.jetbrains.trove4j") - } - } -} - -dependencies { - // ADD DEPENDENCIES HERE - implementation dep.jetbrainsAnnotations - implementation dep.apollo.api -} - -// ADD ANDROID CONFIGURATION HERE -// android { -// compileSdkVersion androidConfig.compileSdkVersion -// } - -// ADD APOLLO CONFIGURATION HERE diff --git a/apollo-gradle-plugin/src/test/files/gradle/settings.gradle b/apollo-gradle-plugin/src/test/files/gradle/settings.gradle deleted file mode 100644 index 96ff658a8f8..00000000000 --- a/apollo-gradle-plugin/src/test/files/gradle/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name="testProject" \ No newline at end of file diff --git a/apollo-gradle-plugin/src/test/files/gradle/settings.gradle.kts b/apollo-gradle-plugin/src/test/files/gradle/settings.gradle.kts deleted file mode 100644 index abacf90cc6d..00000000000 --- a/apollo-gradle-plugin/src/test/files/gradle/settings.gradle.kts +++ /dev/null @@ -1,25 +0,0 @@ -rootProject.name="testProject" - -apply("../../../gradle/dependencies.gradle") - -pluginManagement { - repositories { - maven { - url = uri("../../../build/localMaven") - } - gradlePluginPortal() - } - - - resolutionStrategy { - eachPlugin { - if (requested.id.id == "org.jetbrains.kotlin.jvm") { - useModule(groovy.util.Eval.x(extra, "x.dep.kotlin.plugin")) - } - - if (requested.id.id == "com.apollographql.apollo") { - useModule(groovy.util.Eval.x(extra, "x.dep.apollo.plugin")) - } - } - } -} \ No newline at end of file diff --git a/apollo-gradle-plugin/src/test/files/java/com/example/Main.java b/apollo-gradle-plugin/src/test/files/java/com/example/Main.java deleted file mode 100644 index 3c78759ec40..00000000000 --- a/apollo-gradle-plugin/src/test/files/java/com/example/Main.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.example; - -import com.example.DroidDetailsQuery; - -class Main { - DroidDetailsQuery aMethodThatReferencesAGeneratedQuery() { - return new DroidDetailsQuery(); - } -} \ No newline at end of file diff --git a/apollo-gradle-plugin/src/test/files/kotlin/com/example/Main.kt b/apollo-gradle-plugin/src/test/files/kotlin/com/example/Main.kt deleted file mode 100644 index 7706ba15c25..00000000000 --- a/apollo-gradle-plugin/src/test/files/kotlin/com/example/Main.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.example - -import com.example.DroidDetailsQuery - -class Main { - internal fun aMethodThatReferencesAGeneratedQuery(): DroidDetailsQuery { - return DroidDetailsQuery() - } -} diff --git a/apollo-gradle-plugin/src/test/files/manifest/AndroidManifest.xml b/apollo-gradle-plugin/src/test/files/manifest/AndroidManifest.xml deleted file mode 100644 index c0b911838c8..00000000000 --- a/apollo-gradle-plugin/src/test/files/manifest/AndroidManifest.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/apollo-gradle-plugin/src/test/files/sdl/FeedRepositoryQuery.graphql b/apollo-gradle-plugin/src/test/files/sdl/FeedRepositoryQuery.graphql deleted file mode 100644 index 12880612ae3..00000000000 --- a/apollo-gradle-plugin/src/test/files/sdl/FeedRepositoryQuery.graphql +++ /dev/null @@ -1,7 +0,0 @@ -query FeedRepositoryQuery($type: FeedType!, $limit: Int!) { - feed(type: $type, limit: $limit) { - repository { - name - } - } -} diff --git a/apollo-gradle-plugin/src/test/files/sdl/schema.json b/apollo-gradle-plugin/src/test/files/sdl/schema.json deleted file mode 100644 index 6325baa24ed..00000000000 --- a/apollo-gradle-plugin/src/test/files/sdl/schema.json +++ /dev/null @@ -1,1747 +0,0 @@ -{ - "data": { - "__schema": { - "queryType": { - "name": "Query" - }, - "mutationType": { - "name": "Mutation" - }, - "subscriptionType": { - "name": "Subscription" - }, - "types": [ - { - "kind": "OBJECT", - "name": "Query", - "description": "", - "fields": [ - { - "name": "feed", - "description": "A feed of repository submissions", - "args": [ - { - "name": "type", - "description": "The sort order for the feed", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "FeedType", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "offset", - "description": "The number of items to skip, for pagination", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "limit", - "description": "The number of items to fetch starting from the offset, for pagination", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Entry", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "entry", - "description": "A single entry", - "args": [ - { - "name": "repoFullName", - "description": "The full repository name from GitHub, e.g. \"apollostack/GitHunt-API\"", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Entry", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "currentUser", - "description": "Return the currently logged in user, or null if nobody is logged in", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "FeedType", - "description": "A list of options for the sort order of the feed", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "HOT", - "description": "Sort by a combination of freshness and score, using Reddit's algorithm", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NEW", - "description": "Newest entries first", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "TOP", - "description": "Highest score entries first", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Int", - "description": "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. ", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Entry", - "description": "Information about a GitHub repository submitted to GitHunt", - "fields": [ - { - "name": "repository", - "description": "Information about the repository from GitHub", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Repository", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "postedBy", - "description": "The GitHub user who submitted this entry", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "A timestamp of when the entry was submitted", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "score", - "description": "The score of this repository, upvotes - downvotes", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hotScore", - "description": "The hot score of this repository", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "comments", - "description": "Comments posted about this repository", - "args": [ - { - "name": "limit", - "description": "", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "offset", - "description": "", - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Comment", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "commentCount", - "description": "The number of comments posted about this repository", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": "The SQL ID of this entry", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "vote", - "description": "XXX to be changed", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Vote", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Repository", - "description": "A repository object from the GitHub API. This uses the exact field names returned by the\nGitHub API for simplicity, even though the convention for GraphQL is usually to camel case.", - "fields": [ - { - "name": "name", - "description": "Just the name of the repository, e.g. GitHunt-API", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "full_name", - "description": "The full name of the repository with the username, e.g. apollostack/GitHunt-API", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": "The description of the repository", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "html_url", - "description": "The link to the repository on GitHub", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "stargazers_count", - "description": "The number of people who have starred this repository on GitHub", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "open_issues_count", - "description": "The number of open issues on this repository on GitHub", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "owner", - "description": "The owner of this repository on GitHub, e.g. apollostack", - "args": [], - "type": { - "kind": "OBJECT", - "name": "User", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "String", - "description": "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "User", - "description": "A user object from the GitHub API. This uses the exact field names returned from the GitHub API.", - "fields": [ - { - "name": "login", - "description": "The name of the user, e.g. apollostack", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "avatar_url", - "description": "The URL to a directly embeddable image for this user's avatar", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "html_url", - "description": "The URL of this user's GitHub page", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Float", - "description": "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point). ", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Comment", - "description": "A comment about an entry, submitted by a user", - "fields": [ - { - "name": "id", - "description": "The SQL ID of this entry", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "postedBy", - "description": "The GitHub user who posted the comment", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "User", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "createdAt", - "description": "A timestamp of when the comment was posted", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "content", - "description": "The text of the comment", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "repoName", - "description": "The repository which this comment is about", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Vote", - "description": "XXX to be removed", - "fields": [ - { - "name": "vote_value", - "description": "", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Mutation", - "description": "", - "fields": [ - { - "name": "submitRepository", - "description": "Submit a new repository, returns the new submission", - "args": [ - { - "name": "repoFullName", - "description": "The full repository name from GitHub, e.g. \"apollostack/GitHunt-API\"", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Entry", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "vote", - "description": "Vote on a repository submission, returns the submission that was voted on", - "args": [ - { - "name": "repoFullName", - "description": "The full repository name from GitHub, e.g. \"apollostack/GitHunt-API\"", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "type", - "description": "The type of vote - UP, DOWN, or CANCEL", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "VoteType", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Entry", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "submitComment", - "description": "Comment on a repository, returns the new comment", - "args": [ - { - "name": "repoFullName", - "description": "The full repository name from GitHub, e.g. \"apollostack/GitHunt-API\"", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - }, - { - "name": "commentContent", - "description": "The text content for the new comment", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Comment", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "VoteType", - "description": "The type of vote to record, when submitting a vote", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "UP", - "description": "", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "DOWN", - "description": "", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "CANCEL", - "description": "", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Subscription", - "description": "", - "fields": [ - { - "name": "commentAdded", - "description": "Subscription fires on every comment added", - "args": [ - { - "name": "repoFullName", - "description": "", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Comment", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Schema", - "description": "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.", - "fields": [ - { - "name": "types", - "description": "A list of all types supported by this server.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type" - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "queryType", - "description": "The type that query operations will be rooted at.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mutationType", - "description": "If this server supports mutation, the type that mutation operations will be rooted at.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subscriptionType", - "description": "If this server support subscription, the type that subscription operations will be rooted at.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "directives", - "description": "A list of all directives supported by this server.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Directive" - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Type", - "description": "The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.", - "fields": [ - { - "name": "kind", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "__TypeKind", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "fields", - "description": null, - "args": [ - { - "name": "includeDeprecated", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Field", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "interfaces", - "description": null, - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "possibleTypes", - "description": null, - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "enumValues", - "description": null, - "args": [ - { - "name": "includeDeprecated", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__EnumValue", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "inputFields", - "description": null, - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ofType", - "description": null, - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "__TypeKind", - "description": "An enum describing what kind of type a given `__Type` is.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "SCALAR", - "description": "Indicates this type is a scalar.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OBJECT", - "description": "Indicates this type is an object. `fields` and `interfaces` are valid fields.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INTERFACE", - "description": "Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNION", - "description": "Indicates this type is a union. `possibleTypes` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM", - "description": "Indicates this type is an enum. `enumValues` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_OBJECT", - "description": "Indicates this type is an input object. `inputFields` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "LIST", - "description": "Indicates this type is a list. `ofType` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NON_NULL", - "description": "Indicates this type is a non-null. `ofType` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Boolean", - "description": "The `Boolean` scalar type represents `true` or `false`.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Field", - "description": "Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "args", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue" - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDeprecated", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deprecationReason", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__InputValue", - "description": "Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "defaultValue", - "description": "A GraphQL-formatted string representing the default value for this input value.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__EnumValue", - "description": "One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDeprecated", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deprecationReason", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Directive", - "description": "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "locations", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "__DirectiveLocation" - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "args", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue" - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "onOperation", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "Use `locations`." - }, - { - "name": "onFragment", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "Use `locations`." - }, - { - "name": "onField", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": true, - "deprecationReason": "Use `locations`." - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "__DirectiveLocation", - "description": "A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "QUERY", - "description": "Location adjacent to a query operation.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MUTATION", - "description": "Location adjacent to a mutation operation.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SUBSCRIPTION", - "description": "Location adjacent to a subscription operation.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FIELD", - "description": "Location adjacent to a field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FRAGMENT_DEFINITION", - "description": "Location adjacent to a fragment definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FRAGMENT_SPREAD", - "description": "Location adjacent to a fragment spread.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INLINE_FRAGMENT", - "description": "Location adjacent to an inline fragment.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SCHEMA", - "description": "Location adjacent to a schema definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "SCALAR", - "description": "Location adjacent to a scalar definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OBJECT", - "description": "Location adjacent to an object type definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "FIELD_DEFINITION", - "description": "Location adjacent to a field definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ARGUMENT_DEFINITION", - "description": "Location adjacent to an argument definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INTERFACE", - "description": "Location adjacent to an interface definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNION", - "description": "Location adjacent to a union definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM", - "description": "Location adjacent to an enum definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM_VALUE", - "description": "Location adjacent to an enum value definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_OBJECT", - "description": "Location adjacent to an input object type definition.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_FIELD_DEFINITION", - "description": "Location adjacent to an input object field definition.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - } - ], - "directives": [ - { - "name": "skip", - "description": "Directs the executor to skip this field or fragment when the `if` argument is true.", - "locations": [ - "FIELD", - "FRAGMENT_SPREAD", - "INLINE_FRAGMENT" - ], - "args": [ - { - "name": "if", - "description": "Skipped when true.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "defaultValue": null - } - ] - }, - { - "name": "include", - "description": "Directs the executor to include this field or fragment only when the `if` argument is true.", - "locations": [ - "FIELD", - "FRAGMENT_SPREAD", - "INLINE_FRAGMENT" - ], - "args": [ - { - "name": "if", - "description": "Included when true.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "defaultValue": null - } - ] - }, - { - "name": "deprecated", - "description": "Marks an element of a GraphQL schema as no longer supported.", - "locations": [ - "FIELD_DEFINITION", - "ENUM_VALUE" - ], - "args": [ - { - "name": "reason", - "description": "Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted in [Markdown](https://daringfireball.net/projects/markdown/).", - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": "\"No longer supported\"" - } - ] - } - ] - } - } -} diff --git a/apollo-gradle-plugin/src/test/files/sdl/schema.sdl b/apollo-gradle-plugin/src/test/files/sdl/schema.sdl deleted file mode 100644 index d0b82321076..00000000000 --- a/apollo-gradle-plugin/src/test/files/sdl/schema.sdl +++ /dev/null @@ -1,178 +0,0 @@ -"""A comment about an entry, submitted by a user""" -type Comment { - """The text of the comment""" - content: String! - - """A timestamp of when the comment was posted""" - createdAt: Float! - - """The SQL ID of this entry""" - id: Int! - - """The GitHub user who posted the comment""" - postedBy: User! - - """The repository which this comment is about""" - repoName: String! -} - -"""Information about a GitHub repository submitted to GitHunt""" -type Entry { - """The number of comments posted about this repository""" - commentCount: Int! - - """Comments posted about this repository""" - comments(limit: Int, offset: Int): [Comment]! - - """A timestamp of when the entry was submitted""" - createdAt: Float! - - """The hot score of this repository""" - hotScore: Float! - - """The SQL ID of this entry""" - id: Int! - - """The GitHub user who submitted this entry""" - postedBy: User! - - """Information about the repository from GitHub""" - repository: Repository! - - """The score of this repository, upvotes - downvotes""" - score: Int! - - """XXX to be changed""" - vote: Vote! -} - -"""A list of options for the sort order of the feed""" -enum FeedType { - """Sort by a combination of freshness and score, using Reddit's algorithm""" - HOT - - """Newest entries first""" - NEW - - """Highest score entries first""" - TOP -} - -type Mutation { - """Comment on a repository, returns the new comment""" - submitComment( - """ - The full repository name from GitHub, e.g. "apollostack/GitHunt-API" - """ - repoFullName: String! - - """The text content for the new comment""" - commentContent: String! - ): Comment - - """Submit a new repository, returns the new submission""" - submitRepository( - """ - The full repository name from GitHub, e.g. "apollostack/GitHunt-API" - """ - repoFullName: String! - ): Entry - - """ - Vote on a repository submission, returns the submission that was voted on - """ - vote( - """ - The full repository name from GitHub, e.g. "apollostack/GitHunt-API" - """ - repoFullName: String! - - """The type of vote - UP, DOWN, or CANCEL""" - type: VoteType! - ): Entry -} - -type Query { - """Return the currently logged in user, or null if nobody is logged in""" - currentUser: User - - """A single entry""" - entry( - """ - The full repository name from GitHub, e.g. "apollostack/GitHunt-API" - """ - repoFullName: String! - ): Entry - - """A feed of repository submissions""" - feed( - """The sort order for the feed""" - type: FeedType! - - """The number of items to skip, for pagination""" - offset: Int - - """The number of items to fetch starting from the offset, for pagination""" - limit: Int - ): [Entry] -} - -""" -A repository object from the GitHub API. This uses the exact field names returned by the -GitHub API for simplicity, even though the convention for GraphQL is usually to camel case. -""" -type Repository { - """The description of the repository""" - description: String - - """ - The full name of the repository with the username, e.g. apollostack/GitHunt-API - """ - full_name: String! - - """The link to the repository on GitHub""" - html_url: String! - - """Just the name of the repository, e.g. GitHunt-API""" - name: String! - - """The number of open issues on this repository on GitHub""" - open_issues_count: Int - - """The owner of this repository on GitHub, e.g. apollostack""" - owner: User - - """The number of people who have starred this repository on GitHub""" - stargazers_count: Int! -} - -type Subscription { - """Subscription fires on every comment added""" - commentAdded(repoFullName: String!): Comment -} - -""" -A user object from the GitHub API. This uses the exact field names returned from the GitHub API. -""" -type User { - """The URL to a directly embeddable image for this user's avatar""" - avatar_url: String! - - """The URL of this user's GitHub page""" - html_url: String! - - """The name of the user, e.g. apollostack""" - login: String! -} - -"""XXX to be removed""" -type Vote { - vote_value: Int! -} - -"""The type of vote to record, when submitting a vote""" -enum VoteType { - UP - DOWN - CANCEL -} diff --git a/apollo-gradle-plugin/src/test/files/starwars/AllFilms.graphql b/apollo-gradle-plugin/src/test/files/starwars/AllFilms.graphql deleted file mode 100644 index a0658d29f00..00000000000 --- a/apollo-gradle-plugin/src/test/files/starwars/AllFilms.graphql +++ /dev/null @@ -1,9 +0,0 @@ -query Films { - allFilms { - films { - id - title - releaseDate - } - } -} \ No newline at end of file diff --git a/apollo-gradle-plugin/src/test/files/starwars/DroidDetails.graphql b/apollo-gradle-plugin/src/test/files/starwars/DroidDetails.graphql deleted file mode 100644 index e9145187191..00000000000 --- a/apollo-gradle-plugin/src/test/files/starwars/DroidDetails.graphql +++ /dev/null @@ -1,7 +0,0 @@ -query DroidDetails { - species(id: "c3BlY2llczoy") { - id - name - classification - } -} \ No newline at end of file diff --git a/apollo-gradle-plugin/src/test/files/starwars/DroidDetailsSpeciesInfo.graphql b/apollo-gradle-plugin/src/test/files/starwars/DroidDetailsSpeciesInfo.graphql deleted file mode 100644 index e279910f21b..00000000000 --- a/apollo-gradle-plugin/src/test/files/starwars/DroidDetailsSpeciesInfo.graphql +++ /dev/null @@ -1,12 +0,0 @@ -query DroidDetailsSpeciesInfo { - species(id: "c3BlY2llczoy") { - id - name - ...SpeciesInformation - - } -} - -fragment SpeciesInformation on Species { - classification -} diff --git a/apollo-gradle-plugin/src/test/files/starwars/schema.json b/apollo-gradle-plugin/src/test/files/starwars/schema.json deleted file mode 100644 index c932e017b80..00000000000 --- a/apollo-gradle-plugin/src/test/files/starwars/schema.json +++ /dev/null @@ -1,5843 +0,0 @@ -{ - "data": { - "__schema": { - "queryType": { - "name": "Root" - }, - "mutationType": null, - "subscriptionType": null, - "types": [ - { - "kind": "OBJECT", - "name": "Root", - "description": null, - "fields": [ - { - "name": "allFilms", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "FilmsConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "film", - "description": null, - "args": [ - { - "name": "id", - "description": null, - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "filmID", - "description": null, - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Film", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "allPeople", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "PeopleConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "person", - "description": null, - "args": [ - { - "name": "id", - "description": null, - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "personID", - "description": null, - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Person", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "allPlanets", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "PlanetsConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "planet", - "description": null, - "args": [ - { - "name": "id", - "description": null, - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "planetID", - "description": null, - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Planet", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "allSpecies", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "SpeciesConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "species", - "description": null, - "args": [ - { - "name": "id", - "description": null, - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "speciesID", - "description": null, - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Species", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "allStarships", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "StarshipsConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "starship", - "description": null, - "args": [ - { - "name": "id", - "description": null, - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "starshipID", - "description": null, - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Starship", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "allVehicles", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "VehiclesConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "vehicle", - "description": null, - "args": [ - { - "name": "id", - "description": null, - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "vehicleID", - "description": null, - "type": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "Vehicle", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "node", - "description": "Fetches an object given its ID", - "args": [ - { - "name": "id", - "description": "The ID of an object", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "defaultValue": null - } - ], - "type": { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "String", - "description": "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Int", - "description": "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. ", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "DateTime", - "description": null, - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FilmsConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "FilmsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "films", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Film", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PageInfo", - "description": "Information about pagination in a connection.", - "fields": [ - { - "name": "hasNextPage", - "description": "When paginating forwards, are there more items?", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hasPreviousPage", - "description": "When paginating backwards, are there more items?", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "startCursor", - "description": "When paginating backwards, the cursor to continue.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "endCursor", - "description": "When paginating forwards, the cursor to continue.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Boolean", - "description": "The `Boolean` scalar type represents `true` or `false`.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FilmsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Film", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Film", - "description": "A single film.", - "fields": [ - { - "name": "title", - "description": "The title of this film.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "episodeID", - "description": "The episode number of this film.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "openingCrawl", - "description": "The opening paragraphs at the beginning of this film.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "director", - "description": "The name of the director of this film.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "producers", - "description": "The name(s) of the producer(s) of this film.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "releaseDate", - "description": "The ISO 8601 date format of film release at original creator country.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "DateTime", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "speciesConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "FilmSpeciesConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "starshipConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "FilmStarshipsConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "vehicleConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "FilmVehiclesConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "characterConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "FilmCharactersConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "planetConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "FilmPlanetsConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "created", - "description": "The ISO 8601 date format of the time that this resource was created.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edited", - "description": "The ISO 8601 date format of the time that this resource was edited.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": "The ID of an object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "INTERFACE", - "name": "Node", - "description": "An object with an ID", - "fields": [ - { - "name": "id", - "description": "The id of the object.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": [ - { - "kind": "OBJECT", - "name": "Planet", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Species", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Starship", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Vehicle", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Person", - "ofType": null - }, - { - "kind": "OBJECT", - "name": "Film", - "ofType": null - } - ] - }, - { - "kind": "OBJECT", - "name": "Planet", - "description": "A large mass, planet or planetoid in the Star Wars Universe, at the time of\n0 ABY.", - "fields": [ - { - "name": "name", - "description": "The name of this planet.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "diameter", - "description": "The diameter of this planet in kilometers.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "rotationPeriod", - "description": "The number of standard hours it takes for this planet to complete a single\nrotation on its axis.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "orbitalPeriod", - "description": "The number of standard days it takes for this planet to complete a single orbit\nof its local star.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "gravity", - "description": "A number denoting the gravity of this planet, where \"1\" is normal or 1 standard\nG. \"2\" is twice or 2 standard Gs. \"0.5\" is half or 0.5 standard Gs.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "population", - "description": "The average population of sentient beings inhabiting this planet.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "climates", - "description": "The climates of this planet.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "terrains", - "description": "The terrains of this planet.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "surfaceWater", - "description": "The percentage of the planet surface that is naturally occuring water or bodies\nof water.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "residentConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "PlanetResidentsConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "filmConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "PlanetFilmsConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "created", - "description": "The ISO 8601 date format of the time that this resource was created.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edited", - "description": "The ISO 8601 date format of the time that this resource was edited.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": "The ID of an object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "Float", - "description": "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point). ", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PlanetResidentsConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PlanetResidentsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "residents", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Person", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PlanetResidentsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Person", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Person", - "description": "An individual person or character within the Star Wars universe.", - "fields": [ - { - "name": "name", - "description": "The name of this person.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "birthYear", - "description": "The birth year of the person, using the in-universe standard of BBY or ABY -\nBefore the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin is\na battle that occurs at the end of Star Wars episode IV: A New Hope.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "eyeColor", - "description": "The eye color of this person. Will be \"unknown\" if not known or \"n/a\" if the\nperson does not have an eye.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "gender", - "description": "The gender of this person. Either \"Male\", \"Female\" or \"unknown\",\n\"n/a\" if the person does not have a gender.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hairColor", - "description": "The hair color of this person. Will be \"unknown\" if not known or \"n/a\" if the\nperson does not have hair.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "height", - "description": "The height of the person in centimeters.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mass", - "description": "The mass of the person in kilograms.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "skinColor", - "description": "The skin color of this person.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "homeworld", - "description": "A planet that this person was born on or inhabits.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Planet", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "filmConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "PersonFilmsConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "species", - "description": "The species that this person belongs to, or null if unknown.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Species", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "starshipConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "PersonStarshipsConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "vehicleConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "PersonVehiclesConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "created", - "description": "The ISO 8601 date format of the time that this resource was created.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edited", - "description": "The ISO 8601 date format of the time that this resource was edited.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": "The ID of an object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PersonFilmsConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PersonFilmsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "films", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Film", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PersonFilmsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Film", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Species", - "description": "A type of person or character within the Star Wars Universe.", - "fields": [ - { - "name": "name", - "description": "The name of this species.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "classification", - "description": "The classification of this species, such as \"mammal\" or \"reptile\".", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "designation", - "description": "The designation of this species, such as \"sentient\".", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "averageHeight", - "description": "The average height of this species in centimeters.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "averageLifespan", - "description": "The average lifespan of this species in years.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "eyeColors", - "description": "Common eye colors for this species, null if this species does not typically\nhave eyes.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hairColors", - "description": "Common hair colors for this species, null if this species does not typically\nhave hair.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "skinColors", - "description": "Common skin colors for this species, null if this species does not typically\nhave skin.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "language", - "description": "The language commonly spoken by this species.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "homeworld", - "description": "A planet that this species originates from.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Planet", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "personConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "SpeciesPeopleConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "filmConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "SpeciesFilmsConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "created", - "description": "The ISO 8601 date format of the time that this resource was created.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edited", - "description": "The ISO 8601 date format of the time that this resource was edited.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": "The ID of an object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SpeciesPeopleConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SpeciesPeopleEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "people", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Person", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SpeciesPeopleEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Person", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SpeciesFilmsConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SpeciesFilmsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "films", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Film", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SpeciesFilmsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Film", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "SCALAR", - "name": "ID", - "description": "The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PersonStarshipsConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PersonStarshipsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "starships", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Starship", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PersonStarshipsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Starship", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Starship", - "description": "A single transport craft that has hyperdrive capability.", - "fields": [ - { - "name": "name", - "description": "The name of this starship. The common name, such as \"Death Star\".", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "model", - "description": "The model or official name of this starship. Such as \"T-65 X-wing\" or \"DS-1\nOrbital Battle Station\".", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "starshipClass", - "description": "The class of this starship, such as \"Starfighter\" or \"Deep Space Mobile\nBattlestation\"", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "manufacturers", - "description": "The manufacturers of this starship.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "costInCredits", - "description": "The cost of this starship new, in galactic credits.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "length", - "description": "The length of this starship in meters.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "crew", - "description": "The number of personnel needed to run or pilot this starship.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "passengers", - "description": "The number of non-essential people this starship can transport.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "maxAtmospheringSpeed", - "description": "The maximum speed of this starship in atmosphere. null if this starship is\nincapable of atmosphering flight.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "hyperdriveRating", - "description": "The class of this starships hyperdrive.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "MGLT", - "description": "The Maximum number of Megalights this starship can travel in a standard hour.\nA \"Megalight\" is a standard unit of distance and has never been defined before\nwithin the Star Wars universe. This figure is only really useful for measuring\nthe difference in speed of starships. We can assume it is similar to AU, the\ndistance between our Sun (Sol) and Earth.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cargoCapacity", - "description": "The maximum number of kilograms that this starship can transport.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "consumables", - "description": "The maximum length of time that this starship can provide consumables for its\nentire crew without having to resupply.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pilotConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "StarshipPilotsConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "filmConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "StarshipFilmsConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "created", - "description": "The ISO 8601 date format of the time that this resource was created.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edited", - "description": "The ISO 8601 date format of the time that this resource was edited.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": "The ID of an object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "StarshipPilotsConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "StarshipPilotsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pilots", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Person", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "StarshipPilotsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Person", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "StarshipFilmsConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "StarshipFilmsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "films", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Film", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "StarshipFilmsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Film", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PersonVehiclesConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PersonVehiclesEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "vehicles", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Vehicle", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PersonVehiclesEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Vehicle", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "Vehicle", - "description": "A single transport craft that does not have hyperdrive capability", - "fields": [ - { - "name": "name", - "description": "The name of this vehicle. The common name, such as \"Sand Crawler\" or \"Speeder\nbike\".", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "model", - "description": "The model or official name of this vehicle. Such as \"All-Terrain Attack\nTransport\".", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "vehicleClass", - "description": "The class of this vehicle, such as \"Wheeled\" or \"Repulsorcraft\".", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "manufacturers", - "description": "The manufacturers of this vehicle.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "costInCredits", - "description": "The cost of this vehicle new, in Galactic Credits.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "length", - "description": "The length of this vehicle in meters.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Float", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "crew", - "description": "The number of personnel needed to run or pilot this vehicle.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "passengers", - "description": "The number of non-essential people this vehicle can transport.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "maxAtmospheringSpeed", - "description": "The maximum speed of this vehicle in atmosphere.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cargoCapacity", - "description": "The maximum number of kilograms that this vehicle can transport.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "consumables", - "description": "The maximum length of time that this vehicle can provide consumables for its\nentire crew without having to resupply.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pilotConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "VehiclePilotsConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "filmConnection", - "description": null, - "args": [ - { - "name": "after", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "first", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "before", - "description": null, - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "defaultValue": null - }, - { - "name": "last", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "defaultValue": null - } - ], - "type": { - "kind": "OBJECT", - "name": "VehicleFilmsConnection", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "created", - "description": "The ISO 8601 date format of the time that this resource was created.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edited", - "description": "The ISO 8601 date format of the time that this resource was edited.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "id", - "description": "The ID of an object", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "ID", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [ - { - "kind": "INTERFACE", - "name": "Node", - "ofType": null - } - ], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "VehiclePilotsConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "VehiclePilotsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "pilots", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Person", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "VehiclePilotsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Person", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "VehicleFilmsConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "VehicleFilmsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "films", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Film", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "VehicleFilmsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Film", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PlanetFilmsConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PlanetFilmsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "films", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Film", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PlanetFilmsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Film", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FilmSpeciesConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "FilmSpeciesEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "species", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Species", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FilmSpeciesEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Species", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FilmStarshipsConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "FilmStarshipsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "starships", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Starship", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FilmStarshipsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Starship", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FilmVehiclesConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "FilmVehiclesEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "vehicles", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Vehicle", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FilmVehiclesEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Vehicle", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FilmCharactersConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "FilmCharactersEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "characters", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Person", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FilmCharactersEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Person", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FilmPlanetsConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "FilmPlanetsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "planets", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Planet", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "FilmPlanetsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Planet", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PeopleConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PeopleEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "people", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Person", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PeopleEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Person", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PlanetsConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PlanetsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "planets", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Planet", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "PlanetsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Planet", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SpeciesConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "SpeciesEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "species", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Species", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "SpeciesEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Species", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "StarshipsConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "StarshipsEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "starships", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Starship", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "StarshipsEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Starship", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "VehiclesConnection", - "description": "A connection to a list of items.", - "fields": [ - { - "name": "pageInfo", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "PageInfo", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "edges", - "description": "Information to aid in pagination.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "VehiclesEdge", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "totalCount", - "description": "A count of the total number of objects in this connection, ignoring pagination.\nThis allows a client to fetch the first five objects by passing \"5\" as the\nargument to \"first\", then fetch the total count so it could display \"5 of 83\",\nfor example.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "vehicles", - "description": "A list of all of the objects returned in the connection. This is a convenience\nfield provided for quickly exploring the API; rather than querying for\n\"{ edges { node } }\" when no edge data is needed, this field can be be used\ninstead. Note that when clients like Relay need to fetch the \"cursor\" field on\nthe edge to enable efficient pagination, this shortcut cannot be used, and the\nfull \"{ edges { node } }\" version should be used instead.", - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "Vehicle", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "VehiclesEdge", - "description": "An edge in a connection.", - "fields": [ - { - "name": "node", - "description": "The item at the end of the edge", - "args": [], - "type": { - "kind": "OBJECT", - "name": "Vehicle", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "cursor", - "description": "A cursor for use in pagination", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Schema", - "description": "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.", - "fields": [ - { - "name": "types", - "description": "A list of all types supported by this server.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "queryType", - "description": "The type that query operations will be rooted at.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "mutationType", - "description": "If this server supports mutation, the type that mutation operations will be rooted at.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "subscriptionType", - "description": "If this server support subscription, the type that subscription operations will be rooted at.", - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "directives", - "description": "A list of all directives supported by this server.", - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Directive", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Type", - "description": "The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.", - "fields": [ - { - "name": "kind", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "ENUM", - "name": "__TypeKind", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "fields", - "description": null, - "args": [ - { - "name": "includeDeprecated", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Field", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "interfaces", - "description": null, - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "possibleTypes", - "description": null, - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "enumValues", - "description": null, - "args": [ - { - "name": "includeDeprecated", - "description": null, - "type": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - }, - "defaultValue": "false" - } - ], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__EnumValue", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "inputFields", - "description": null, - "args": [], - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue", - "ofType": null - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ofType", - "description": null, - "args": [], - "type": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "ENUM", - "name": "__TypeKind", - "description": "An enum describing what kind of type a given `__Type` is.", - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "SCALAR", - "description": "Indicates this type is a scalar.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "OBJECT", - "description": "Indicates this type is an object. `fields` and `interfaces` are valid fields.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INTERFACE", - "description": "Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "UNION", - "description": "Indicates this type is a union. `possibleTypes` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ENUM", - "description": "Indicates this type is an enum. `enumValues` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "INPUT_OBJECT", - "description": "Indicates this type is an input object. `inputFields` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "LIST", - "description": "Indicates this type is a list. `ofType` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "NON_NULL", - "description": "Indicates this type is a non-null. `ofType` is a valid field.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Field", - "description": "Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "args", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDeprecated", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deprecationReason", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__InputValue", - "description": "Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "type", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__Type", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "defaultValue", - "description": "A GraphQL-formatted string representing the default value for this input value.", - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__EnumValue", - "description": "One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "isDeprecated", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "deprecationReason", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - }, - { - "kind": "OBJECT", - "name": "__Directive", - "description": "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL’s execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", - "fields": [ - { - "name": "name", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "description", - "description": null, - "args": [], - "type": { - "kind": "SCALAR", - "name": "String", - "ofType": null - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "args", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "OBJECT", - "name": "__InputValue", - "ofType": null - } - } - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "onOperation", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "onFragment", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "onField", - "description": null, - "args": [], - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "isDeprecated": false, - "deprecationReason": null - } - ], - "inputFields": null, - "interfaces": [], - "enumValues": null, - "possibleTypes": null - } - ], - "directives": [ - { - "name": "include", - "description": "Directs the executor to include this field or fragment only when the `if` argument is true.", - "args": [ - { - "name": "if", - "description": "Included when true.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "defaultValue": null - } - ] - }, - { - "name": "skip", - "description": "Directs the executor to skip this field or fragment when the `if` argument is true.", - "args": [ - { - "name": "if", - "description": "Skipped when true.", - "type": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Boolean", - "ofType": null - } - }, - "defaultValue": null - } - ] - } - ] - } - } -} diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/AndroidTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/AndroidTests.kt deleted file mode 100644 index 1743fc1b9ab..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/AndroidTests.kt +++ /dev/null @@ -1,139 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.util.TestUtils -import com.apollographql.apollo.gradle.util.TestUtils.withProject -import com.apollographql.apollo.gradle.util.generatedChild -import com.apollographql.apollo.gradle.util.replaceInText -import org.gradle.testkit.runner.TaskOutcome -import org.gradle.testkit.runner.UnexpectedBuildFailure -import org.hamcrest.CoreMatchers.containsString -import org.junit.Assert.* -import org.junit.Test -import java.io.File - -class AndroidTests { - - @Test - fun `android library is compiling fine`() { - withProject(apolloConfiguration = "", - usesKotlinDsl = false, - plugins = listOf(TestUtils.androidLibraryPlugin, TestUtils.apolloPlugin)) { dir -> - val result = TestUtils.executeTask("build", dir) - - assertEquals(TaskOutcome.SUCCESS, result.task(":build")!!.outcome) - - // Java classes generated successfully - assertTrue(dir.generatedChild("debug/service/com/example/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("debug/service/com/example/FilmsQuery.java").isFile) - assertTrue(dir.generatedChild("debug/service/com/example/fragment/SpeciesInformation.java").isFile) - assertTrue(dir.generatedChild("release/service/com/example/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("release/service/com/example/FilmsQuery.java").isFile) - assertTrue(dir.generatedChild("release/service/com/example/fragment/SpeciesInformation.java").isFile) - } - } - - @Test - fun `android library debug does not compile release`() { - withProject(apolloConfiguration = "", - usesKotlinDsl = false, - plugins = listOf(TestUtils.androidLibraryPlugin, TestUtils.apolloPlugin)) { dir -> - val result = TestUtils.executeTask("generateDebugApolloSources", dir) - - assertEquals(TaskOutcome.SUCCESS, result.task(":generateDebugApolloSources")!!.outcome) - - // Java classes generated successfully - assertTrue(dir.generatedChild("debug/service/com/example/DroidDetailsQuery.java").isFile) - assertFalse(dir.generatedChild("release/service/com/example/DroidDetailsQuery.java").exists()) - } - } - - @Test - fun `android library debug query overrides main`() { - withProject(apolloConfiguration = "", - usesKotlinDsl = false, - plugins = listOf(TestUtils.androidLibraryPlugin, TestUtils.apolloPlugin)) { dir -> - - val debugFile = File(dir, "src/debug/graphql/com/example/DroidDetails.graphql") - File(dir, "src/main/graphql/com/example/DroidDetails.graphql").copyTo(debugFile) - debugFile.replaceInText("c3BlY2llczoy", "speciesIdForDebug") - - var exception: Exception? = null - try { - TestUtils.executeTask("generateDebugApolloSources", dir) - } catch (e: UnexpectedBuildFailure) { - exception = e - assertThat(e.message, containsString("duplicate(s) graphql file(s) found")) - } - - assertNotNull(exception) - } - } - - - @Test - fun `product flavors compile correctly`() { - withProject(apolloConfiguration = "", - usesKotlinDsl = false, - isFlavored = true, - plugins = listOf(TestUtils.androidLibraryPlugin, TestUtils.apolloPlugin)) { dir -> - - TestUtils.executeTask("build", dir) - - assertTrue(dir.generatedChild("freeDebug/service/com/example/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("freeRelease/service/com/example/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("paidDebug/service/com/example/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("paidRelease/service/com/example/DroidDetailsQuery.java").isFile) - } - } - - @Test - fun `flavor with invalid schema fails while others compile correctly`() { - withProject(apolloConfiguration = "", - usesKotlinDsl = false, - isFlavored = true, - plugins = listOf(TestUtils.androidLibraryPlugin, TestUtils.apolloPlugin)) { dir -> - - val freeDebugDir = File(dir, "src/freeDebug/graphql/com/example/") - freeDebugDir.mkdirs() - File(freeDebugDir, "schema.json").writeText("This is an invalid schema") - - val paidDebugDir = File(dir, "src/paidDebug/graphql/com/example/") - paidDebugDir.mkdirs() - File(dir, "src/main/graphql/com/example/schema.json").copyTo(File(paidDebugDir, "schema.json")) - - File(dir, "src/main/graphql/com/example/schema.json").delete() - - var exception: Exception? = null - try { - TestUtils.executeTask("generateFreeDebugApolloSources", dir) - } catch (e: UnexpectedBuildFailure) { - exception = e - assertThat(e.message, containsString("Failed to parse GraphQL schema introspection query")) - } - - assertNotNull(exception) - - val result = TestUtils.executeTask("generatePaidDebugApolloSources", dir) - assertEquals(TaskOutcome.SUCCESS, result.task(":generatePaidDebugApolloSources")!!.outcome) - } - } - - @Test - fun `android application is compiling fine`() { - withProject(apolloConfiguration = "", - usesKotlinDsl = false, - plugins = listOf(TestUtils.androidApplicationPlugin, TestUtils.apolloPlugin)) { dir -> - val result = TestUtils.executeTask("build", dir) - - assertEquals(TaskOutcome.SUCCESS, result.task(":build")!!.outcome) - - // Java classes generated successfully - assertTrue(dir.generatedChild("debug/service/com/example/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("debug/service/com/example/FilmsQuery.java").isFile) - assertTrue(dir.generatedChild("debug/service/com/example/fragment/SpeciesInformation.java").isFile) - assertTrue(dir.generatedChild("release/service/com/example/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("release/service/com/example/FilmsQuery.java").isFile) - assertTrue(dir.generatedChild("release/service/com/example/fragment/SpeciesInformation.java").isFile) - } - } -} diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/ConfigurationTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/ConfigurationTests.kt deleted file mode 100644 index 418851420b5..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/ConfigurationTests.kt +++ /dev/null @@ -1,601 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.internal.child -import com.apollographql.apollo.gradle.util.TestUtils -import com.apollographql.apollo.gradle.util.TestUtils.fixturesDirectory -import com.apollographql.apollo.gradle.util.TestUtils.withSimpleProject -import com.apollographql.apollo.gradle.util.TestUtils.withTestProject -import com.apollographql.apollo.gradle.util.generatedChild -import com.apollographql.apollo.gradle.util.replaceInText -import org.gradle.testkit.runner.TaskOutcome -import org.gradle.testkit.runner.UnexpectedBuildFailure -import org.hamcrest.CoreMatchers.containsString -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNotNull -import org.junit.Assert.assertThat -import org.junit.Assert.assertTrue -import org.junit.Test -import java.io.File -import java.nio.file.Files - -class ConfigurationTests { - @Test - fun `customTypeMapping is working`() { - withSimpleProject(""" - apollo { - customTypeMapping = ["DateTime": "java.util.Date"] - suppressRawTypesWarning = true - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - TestUtils.assertFileContains(dir, "main/service/com/example/type/CustomType.java", "return \"java.util.Date\";") - } - } - - @Test - fun `customTypeMapping can be applied from a service block`() { - withSimpleProject(""" - apollo { - service("other") { - schemaPath = "com/example/schema.json" - } - service("api") { - customTypeMapping = ["DateTime": "java.util.Date"] - schemaPath = "com/example/schema.json" - } - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - TestUtils.assertFileContains(dir, "main/api/com/example/type/CustomType.java", "return \"java.util.Date\";") - } - } - - @Test - fun `nullableValueType is working`() { - for (pair in listOf( - "annotated" to "@Nullable String name()", - "apolloOptional" to "import com.apollographql.apollo.api.internal.Optional;", - "guavaOptional" to "import com.google.common.base.Optional;", - "javaOptional" to "import java.util.Optional;", - "inputType" to "Input name()" - )) { - withSimpleProject(""" - apollo { - nullableValueType = "${pair.first}" - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - TestUtils.assertFileContains(dir, "main/service/com/example/DroidDetailsQuery.java", pair.second) - } - } - } - - @Test - fun `useSemanticNaming defaults to true`() { - withSimpleProject(""" - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - TestUtils.assertFileContains(dir, "main/service/com/example/DroidDetailsQuery.java", "class DroidDetailsQuery ") - } - } - - @Test - fun `useSemanticNaming can be turned off correctly`() { - withSimpleProject(""" - apollo { - useSemanticNaming = false - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - TestUtils.assertFileContains(dir, "main/service/com/example/DroidDetails.java", "class DroidDetails ") - } - } - - @Test - fun `generateModelBuilders defaults to false`() { - withSimpleProject(""" - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - TestUtils.assertFileDoesNotContain(dir, "main/service/com/example/DroidDetailsQuery.java", "Builder toBuilder()") - } - } - - @Test - fun `generateModelBuilders generates builders correctly`() { - withSimpleProject(""" - apollo { - generateModelBuilder = true - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - TestUtils.assertFileContains(dir, "main/service/com/example/DroidDetailsQuery.java", "Builder toBuilder()") - } - } - - @Test - fun `useJavaBeansSemanticNaming defaults to false`() { - withSimpleProject(""" - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - TestUtils.assertFileContains(dir, "main/service/com/example/DroidDetailsQuery.java", "String name()") - } - } - - @Test - fun `useJavaBeansSemanticNaming generates java beans methods correctly`() { - withSimpleProject(""" - apollo { - useJavaBeansSemanticNaming = true - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - TestUtils.assertFileContains(dir, "main/service/com/example/DroidDetailsQuery.java", "String getName()") - } - } - - @Test - fun `rootPackageName works as expected`() { - withSimpleProject(""" - apollo { - rootPackageName = "com.starwars" - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - assertTrue(dir.generatedChild("main/service/com/starwars/com/example/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("main/service/com/starwars/com/example/type/CustomType.java").isFile) - assertTrue(dir.generatedChild("main/service/com/starwars/com/example/fragment/SpeciesInformation.java").isFile) - } - } - - @Test - fun `service compilerParams override extension compilerParams`() { - withSimpleProject(""" - apollo { - useSemanticNaming = false - service("starwars") { - useSemanticNaming = true - schemaPath = "com/example/schema.json" - } - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - TestUtils.assertFileContains(dir, "main/starwars/com/example/DroidDetailsQuery.java", "class DroidDetailsQuery ") - } - } - - @Test - fun `sourceFolder can be changed`() { - withSimpleProject(""" - apollo { - service("starwars") { - sourceFolder = "starwars" - } - } - """.trimIndent()) { dir -> - File(dir, "src/main/graphql/com/example").copyRecursively(File(dir, "src/main/graphql/starwars")) - File(dir, "src/main/graphql/com").deleteRecursively() - - TestUtils.executeTask("generateApolloSources", dir) - assertTrue(dir.generatedChild("main/starwars/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("main/starwars/type/CustomType.java").isFile) - assertTrue(dir.generatedChild("main/starwars/fragment/SpeciesInformation.java").isFile) - } - } - - @Test - fun `schemaPath can be absolute path`() { - val schema = File(System.getProperty("user.dir"), "src/test/files/starwars/schema.json") - withSimpleProject(""" - apollo { - service("starwars") { - schemaPath = "${schema.absolutePath}" - } - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - TestUtils.assertFileContains(dir, "main/starwars/com/example/DroidDetailsQuery.java", "class DroidDetailsQuery ") - } - } - - @Test - fun `sourceFolder can be absolute path`() { - val folder = File(System.getProperty("user.dir"), "src/test/files/starwars") - withSimpleProject(""" - apollo { - service("starwars") { - sourceFolder = "${folder.absolutePath}" - } - } - """.trimIndent()) { dir -> - File(dir, "src/main/graphql/com").deleteRecursively() - - TestUtils.executeTask("generateApolloSources", dir) - println(dir.absolutePath) - dir.list()?.forEach(::println) - assertTrue(dir.generatedChild("main/starwars/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("main/starwars/type/CustomType.java").isFile) - assertTrue(dir.generatedChild("main/starwars/fragment/SpeciesInformation.java").isFile) - } - } - - @Test - fun `rootPackageName can be overridden in service`() { - withSimpleProject(""" - apollo { - rootPackageName = "com.something.else" - service("service") { - rootPackageName = "com.starwars" - } - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - assertTrue(dir.generatedChild("main/service/com/starwars/com/example/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("main/service/com/starwars/com/example/type/CustomType.java").isFile) - assertTrue(dir.generatedChild("main/service/com/starwars/com/example/fragment/SpeciesInformation.java").isFile) - } - } - - @Test - fun `rootPackageName can be overridden in compilationUnit`() { - withSimpleProject(""" - apollo { - rootPackageName = "com.default" - service("starwars") { - rootPackageName = "com.starwars" - } - onCompilationUnit { - rootPackageName = "com.overrides" - } - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - assertTrue(dir.generatedChild("main/starwars/com/overrides/com/example/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("main/starwars/com/overrides/com/example/type/CustomType.java").isFile) - assertTrue(dir.generatedChild("main/starwars/com/overrides/com/example/fragment/SpeciesInformation.java").isFile) - } - } - - @Test - fun `sources with a service can be overridden in compilationUnit`() { - withSimpleProject(""" - apollo { - service("starwars") { - schemaPath = "com/some/other/schema.json" - sourceFolder = "com/some/other" - } - - onCompilationUnit { - schemaFile = file("src/main/graphql/com/example/schema.json") - graphqlSourceDirectorySet.srcDir(file("src/main/graphql/")) - graphqlSourceDirectorySet.include("**/*.graphql") - } - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - assertTrue(dir.generatedChild("main/starwars/com/example/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("main/starwars/com/example/type/CustomType.java").isFile) - assertTrue(dir.generatedChild("main/starwars/com/example/fragment/SpeciesInformation.java").isFile) - } - } - - @Test - fun `sources can be overridden in compilationUnit`() { - withSimpleProject(""" - apollo { - schemaFile = file("com/some/other/schema.json") - - onCompilationUnit { - schemaFile = file("src/main/graphql/com/example/schema.json") - graphqlSourceDirectorySet.srcDir(file("src/main/graphql/")) - graphqlSourceDirectorySet.include("**/*.graphql") - } - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - assertTrue(dir.generatedChild("main/service/com/example/DroidDetailsQuery.java").isFile) - } - } - - @Test - fun `onCompilationUnit can configure sources alone`() { - withSimpleProject(""" - apollo { - onCompilationUnit { - schemaFile = file("src/main/graphql/com/example/schema.json") - graphqlSourceDirectorySet.srcDir(file("src/main/graphql/")) - graphqlSourceDirectorySet.include("**/*.graphql") - } - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - assertTrue(dir.generatedChild("main/service/com/example/DroidDetailsQuery.java").isFile) - } - } - - @Test - fun `onCompilationUnit can point to a schema file outside the module`() { - withSimpleProject(""" - apollo { - onCompilationUnit { - schemaFile = file("../schema.json") - } - } - """.trimIndent()) { dir -> - val dest = File(dir, "../schema.json") - File(dir, "src/main/graphql/com/example/schema.json").copyTo(dest, true) - TestUtils.executeTask("generateApolloSources", dir) - dest.delete() - assertTrue(dir.generatedChild("main/service/testProject/src/main/graphql/com/example/DroidDetailsQuery.java").isFile) - } - } - - @Test - fun `onCompilationUnit can override schemaFile for Android Projects`() { - withTestProject("compilationUnitAndroid") { dir -> - TestUtils.executeTaskAndAssertSuccess(":app:generateApolloSources", dir) - } - } - - @Test - fun `onCompilationUnits for main sourceSet should not generate for test`() { - withSimpleProject(""" - apollo { - onCompilationUnit { - if (variantName == "main") { - schemaFile = file("src/main/graphql/com/example/schema.json") - graphqlSourceDirectorySet.srcDir(file("src/main/graphql/")) - graphqlSourceDirectorySet.include("**/*.graphql") - } - } - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - assertTrue(dir.generatedChild("main/service/com/example/DroidDetailsQuery.java").exists()) - assertTrue(dir.generatedChild("test/service/com/example/DroidDetailsQuery.java").exists().not()) - } - } - - @Test - fun `explicit schemaFile and graphqlSourceDirectorySet should not generate for test`() { - withSimpleProject(""" - apollo { - schemaFile = file("src/main/graphql/com/example/schema.json") - graphqlSourceDirectorySet.srcDir(file("src/main/graphql/")) - graphqlSourceDirectorySet.include("**/*.graphql") - } - """.trimIndent()) { dir -> - TestUtils.executeTask("generateApolloSources", dir) - assertTrue(dir.generatedChild("main/service/com/example/DroidDetailsQuery.java").exists()) - assertTrue(dir.generatedChild("test/service/com/example/DroidDetailsQuery.java").exists().not()) - } - } - - @Test - fun `graphql queries under test sources should still generate for test`() { - withSimpleProject(""" - apollo { - schemaFile = file("src/main/graphql/com/example/schema.json") - } - """.trimIndent()) { dir -> - // Move AllFilms into test sources - dir.child("src/main/graphql/com/example/AllFilms.graphql").delete() - fixturesDirectory().child("starwars/AllFilms.graphql").copyTo(target = dir.child("src/test/graphql/com/example/AllFilms.graphql")) - - TestUtils.executeTask("generateApolloSources", dir) - assertTrue(dir.generatedChild("test/service/com/example/FilmsQuery.java").exists()) - } - } - - @Test - fun `explicit schemaFile outside the module should not generate for test`() { - withSimpleProject(""" - apollo { - schemaFile = file("../schema.json") - } - """.trimIndent()) { dir -> - val dest = File(dir, "../schema.json") - File(dir, "src/main/graphql/com/example/schema.json").copyTo(dest, true) - TestUtils.executeTask("generateApolloSources", dir) - assertTrue(dir.generatedChild("main/service/testProject/src/main/graphql/com/example/DroidDetailsQuery.java").exists()) - assertTrue(dir.generatedChild("test/service/").exists().not()) - } - } - - @Test - fun `exclude is working properly`() { - withSimpleProject(""" - apollo { - service("starwars") { - schemaPath = "com/example/schema.json" - exclude = ["**/*.gql"] - } - } - """.trimIndent()) { dir -> - File(dir, "src/main/graphql/com/example/error.gql").writeText("this is not valid graphql") - File(dir, "src/main/graphql/com/example/error/").mkdir() - File(dir, "src/main/graphql/com/example/error/error.gql").writeText("this is not valid graphql") - val result = TestUtils.executeTask("generateApolloSources", dir) - - assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - } - } - - @Test - fun `versions are enforced`() { - withSimpleProject { dir -> - File(dir, "build.gradle").replaceInText("dep.apollo.api", "\"com.apollographql.apollo:apollo-api:1.2.0\"") - - var exception: Exception? = null - try { - TestUtils.executeTask("generateApolloSources", dir) - } catch (e: UnexpectedBuildFailure) { - exception = e - assertThat(e.message, containsString("All apollo versions should be the same")) - } - assertNotNull(exception) - } - } - - @Test - fun `changing a dependency checks versions again`() { - withSimpleProject { dir -> - - TestUtils.executeTaskAndAssertSuccess(":generateApolloSources", dir) - - val result = TestUtils.executeTask("checkApolloVersions", dir) - assert(result.task(":checkApolloVersions")?.outcome == TaskOutcome.UP_TO_DATE) - - File(dir, "build.gradle").replaceInText("dep.apollo.api", "\"com.apollographql.apollo:apollo-api:1.2.0\"") - - var exception: Exception? = null - try { - TestUtils.executeTask("checkApolloVersions", dir) - } catch (e: UnexpectedBuildFailure) { - exception = e - assertThat(e.message, containsString("All apollo versions should be the same")) - } - assertNotNull(exception) - } - } - - @Test - fun `versions are enforced even in rootProject`() { - withTestProject("mismatchedVersions") { dir -> - var exception: Exception? = null - try { - TestUtils.executeTask("generateApolloSources", dir) - } catch (e: UnexpectedBuildFailure) { - exception = e - assertThat(e.message, containsString("All apollo versions should be the same")) - } - assertNotNull(exception) - } - } - - @Test - fun `generateOperationOutput generates queries with __typename`() { - withSimpleProject(""" - apollo { - generateOperationOutput = true - } - """.trimIndent()) { dir -> - val result = TestUtils.executeTask("generateApolloSources", dir) - - assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - val operationOutput = dir.child("build/generated/operationOutput/apollo/main/service/OperationOutput.json") - - // Check that the filename case did not change. See https://github.com/apollographql/apollo-android/issues/2533 - assertTrue(operationOutput.canonicalFile.path.endsWith("build/generated/operationOutput/apollo/main/service/operationOutput.json")) - - assertThat(operationOutput.readText(), containsString("__typename")) - } - } - - @Test - fun `generateOperationOutput uses same id as the query`() { - withSimpleProject(""" - apollo { - generateOperationOutput = true - } - """.trimIndent()) { dir -> - val result = TestUtils.executeTask("generateApolloSources", dir) - - assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - val expectedOperationId = "260dd8d889c94e78b975e435300929027d0ad10ea55b63695b13894eb8cd8578" - val operationOutput = dir.child("build/generated/operationOutput/apollo/main/service/operationOutput.json") - assertThat(operationOutput.readText(), containsString(expectedOperationId)) - - val queryJavaFile = dir.generatedChild("main/service/com/example/DroidDetailsQuery.java") - assertThat(queryJavaFile.readText(), containsString(expectedOperationId)) - } - } - - @Test - fun `compilation unit directory properties carry task dependencies`() { - withSimpleProject(""" - apollo { - generateOperationOutput = true - - onCompilationUnit { compilationUnit -> - tasks.register("customTask" + compilationUnit.name.capitalize()) { - inputs.file(compilationUnit.operationOutputFile) - } - } - } - """.trimIndent()) { dir -> - val result = TestUtils.executeTask("customTaskMainService", dir) - - assertEquals(TaskOutcome.SUCCESS, result.task(":generateMainServiceApolloSources")!!.outcome) - } - } - - @Test - fun `symlinks are not followed for the schema`() { - withSimpleProject { dir -> - dir.child("src/main/graphql/com/example/schema.json").copyTo(dir.child("schema.json")) - dir.child("src/main/graphql/com/example/schema.json").delete() - - - Files.createSymbolicLink(dir.child( - "src/main/graphql/com/example/schema.json").toPath(), - dir.child("schema.json").toPath() - ) - - TestUtils.executeTask("generateApolloSources", dir) - - assertTrue(dir.generatedChild("main/service/com/example/fragment/SpeciesInformation.java").isFile) - } - } - - @Test - fun `symlinks are not followed for sources`() { - withSimpleProject { dir -> - dir.child("src/main/graphql/com/example").copyRecursively(dir.child("tmp")) - dir.child("src/main/graphql/com/").deleteRecursively() - - - Files.createSymbolicLink( - dir.child("src/main/graphql/example").toPath(), - dir.child("tmp").toPath() - ) - - TestUtils.executeTask("generateApolloSources", dir) - - assertTrue(dir.generatedChild("main/service/example/fragment/SpeciesInformation.java").isFile) - } - } - - @Test - fun `test variants do not create duplicate classes`() { - withSimpleProject(""" - apollo { - schemaFile = file("src/main/graphql/com/example/schema.json") - graphqlSourceDirectorySet.srcDir("src/main/graphql/") - graphqlSourceDirectorySet.include("**/*.graphql") - } - """.trimIndent()) { dir -> - - File(dir, "build.gradle").replaceInText( - "implementation dep.apollo.api", - "implementation dep.apollo.api\nimplementation \"junit:junit:4.12\"" - ) - File(dir, "src/test/java/com/example/").mkdirs() - File(dir, "src/test/java/com/example/MainTest.java").writeText(""" - package com.example; - - import com.example.DroidDetailsQuery; - import org.junit.Test; - - public class MainTest { - @Test - public void aMethodThatReferencesAGeneratedQuery() { - new DroidDetailsQuery(); - } - } -""".trimIndent()) - val result = TestUtils.executeTask("build", dir) - - assertEquals(TaskOutcome.SUCCESS, result.task(":build")!!.outcome) - } - } -} diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/ConvertSchemaTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/ConvertSchemaTests.kt deleted file mode 100644 index f60dafdc978..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/ConvertSchemaTests.kt +++ /dev/null @@ -1,74 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.util.TestUtils -import com.google.common.truth.Truth -import org.gradle.testkit.runner.TaskOutcome -import org.junit.Assert -import org.junit.Test -import java.io.File - -class ConvertSchemaTests { - @Test - fun `convert from SDL to Json works`() { - TestUtils.withTestProject("convertSchema") { dir -> - val from = File(dir, "schemas/schema.sdl") - val to = File(dir, "schema.json") - val result = TestUtils.executeTask("convertApolloSchema", - dir, - "--from", - from.absolutePath, - "--to", - to.absolutePath - ) - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":convertApolloSchema")!!.outcome) - Truth.assertThat(to.readText()).isEqualTo(File(dir, "schemas/schema.json").readText()) - } - } - - @Test - fun `convert is never up-to-date`() { - TestUtils.withTestProject("convertSchema") { dir -> - val from = File(dir, "schemas/schema.sdl") - val to = File(dir, "schema.json") - var result = TestUtils.executeTask("convertApolloSchema", - dir, - "--from", - from.absolutePath, - "--to", - to.absolutePath - ) - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":convertApolloSchema")!!.outcome) - result = TestUtils.executeTask("convertApolloSchema", - dir, - "--from", - from.absolutePath, - "--to", - to.absolutePath - ) - // even if inputs are the same, - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":convertApolloSchema")!!.outcome) - } - } - - @Test - fun `convert from Json to SDL works`() { - TestUtils.withTestProject("convertSchema") { dir -> - val from = File(dir, "schemas/schema.json") - val to = File(dir, "schema.sdl") - val result = TestUtils.executeTask("convertApolloSchema", - dir, - "--from", - from.absolutePath, - "--to", - to.absolutePath - ) - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":convertApolloSchema")!!.outcome) - // SDL to Json and back is not idempotent as SDL will add a `schema {}` block - Truth.assertThat(to.readText()).contains(""" - type Query { - greeting: String - } - """.trimIndent()) - } - } -} \ No newline at end of file diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/DeprecationTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/DeprecationTests.kt deleted file mode 100644 index 792b5715f86..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/DeprecationTests.kt +++ /dev/null @@ -1,53 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.util.TestUtils -import com.google.common.truth.Truth -import junit.framework.Assert.fail -import org.gradle.testkit.runner.TaskOutcome -import org.gradle.testkit.runner.UnexpectedBuildFailure -import org.junit.Assert -import org.junit.Test -import java.io.File - -class DeprecationTests { - @Test - fun `deprecation warnings are shown by default`() { - TestUtils.withTestProject("deprecationWarnings") { dir -> - val result = TestUtils.executeTask("generateMainServiceApolloSources", dir) - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateMainServiceApolloSources")!!.outcome) - Truth.assertThat(result.output).contains("operations.graphql:6:7: ApolloGraphQL: Use of deprecated field 'number'") - Truth.assertThat(result.output).contains("operations.graphql:3:5: ApolloGraphQL: Use of deprecated field 'name'") - } - } - - @Test - fun `deprecation warnings can be silenced`() { - TestUtils.withTestProject("deprecationWarnings") { dir -> - File(dir, "build.gradle.kts").appendText(""" - configure { - warnOnDeprecatedUsages.set(false) - } - """.trimIndent()) - val result = TestUtils.executeTask("generateMainServiceApolloSources", dir) - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateMainServiceApolloSources")!!.outcome) - Truth.assertThat(result.output).doesNotContain("ApolloGraphQL: Use of deprecated field") - } - } - - @Test - fun `failOnWarnings works as expected`() { - TestUtils.withTestProject("deprecationWarnings") { dir -> - File(dir, "build.gradle.kts").appendText(""" - configure { - failOnWarnings.set(true) - } - """.trimIndent()) - try { - TestUtils.executeTask("generateMainServiceApolloSources", dir) - fail("generateMainServiceApolloSources was expected to fail") - } catch (e: UnexpectedBuildFailure) { - Truth.assertThat(e.message).contains("Warnings found and 'failOnWarnings' is true, aborting") - } - } - } -} \ No newline at end of file diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/DownloadSchemaTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/DownloadSchemaTests.kt deleted file mode 100644 index b295ee7899b..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/DownloadSchemaTests.kt +++ /dev/null @@ -1,136 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.internal.child -import com.apollographql.apollo.gradle.util.TestUtils -import com.apollographql.apollo.gradle.util.TestUtils.withSimpleProject -import com.apollographql.apollo.gradle.util.TestUtils.withTestProject -import okhttp3.mockwebserver.MockResponse -import okhttp3.mockwebserver.MockWebServer -import org.gradle.testkit.runner.TaskOutcome -import org.junit.Assert.assertEquals -import org.junit.Test -import java.io.File - -class DownloadSchemaTests { - val mockServer = MockWebServer() - - val apolloConfiguration = """ - apollo { - service("mock") { - schemaPath = "com/example/schema.json" - introspection { - endpointUrl = "${mockServer.url("/").toUrl()}" - } - } - } - """.trimIndent() - - @Test - fun `schema is downloaded correctly`() { - - withSimpleProject(apolloConfiguration = apolloConfiguration) { dir -> - val content = "schema should be here" - val mockResponse = MockResponse().setBody(content) - mockServer.enqueue(mockResponse) - - TestUtils.executeTask("downloadMockApolloSchema", dir) - - assertEquals(content, dir.child("src", "main", "graphql", "com", "example", "schema.json").readText()) - } - } - - @Test - fun `download schema is never up-to-date`() { - - withSimpleProject(apolloConfiguration = apolloConfiguration) { dir -> - val content = "schema should be here" - val mockResponse = MockResponse().setBody(content) - mockServer.enqueue(mockResponse) - - var result = TestUtils.executeTask("downloadMockApolloSchema", dir) - assertEquals(TaskOutcome.SUCCESS, result.task(":downloadMockApolloSchema")?.outcome) - - mockServer.enqueue(mockResponse) - - // Since the task does not declare any output, it should never be up-to-date - result = TestUtils.executeTask("downloadMockApolloSchema", dir) - assertEquals(TaskOutcome.SUCCESS, result.task(":downloadMockApolloSchema")?.outcome) - - assertEquals(content, dir.child("src", "main", "graphql", "com", "example", "schema.json").readText()) - } - } - - @Test - fun `Android, downloadApolloSchema find the schema location`() { - withTestProject("compilationUnitAndroid") { dir -> - val content = "schema should be here" - val mockResponse = MockResponse().setBody(content) - mockServer.enqueue(mockResponse) - - TestUtils.executeTask("downloadApolloSchema", dir, "--endpoint=${mockServer.url("/").toUrl()}") - - assertEquals(content, dir.child( "schema.json").readText()) - } - } - - @Test - fun `Android, downloadApolloSchema endpoint and schema override the default resolution`() { - withTestProject("compilationUnitAndroid") { dir -> - val content = "schema should be here" - val mockResponse = MockResponse().setBody(content) - mockServer.enqueue(mockResponse) - - val schemaFile = File(dir, "schema.json") - TestUtils.executeTask("downloadApolloSchema", dir, "--endpoint=${mockServer.url("/").toUrl()}", "--schema=${schemaFile.absolutePath}") - - assertEquals(content, schemaFile.readText()) - } - } - - @Test - fun `download schema is never cached`() { - - withSimpleProject(apolloConfiguration = apolloConfiguration) { dir -> - val buildCacheDir = dir.child("buildCache") - - File(dir, "settings.gradle").appendText(""" - - buildCache { - local { - directory '${buildCacheDir.absolutePath}' - } - } - """.trimIndent()) - - val schemaFile = dir.child("src", "main", "graphql", "com", "example", "schema.json") - - val content1 = "schema1" - mockServer.enqueue(MockResponse().setBody(content1)) - - TestUtils.executeTask("downloadMockApolloSchema", dir, "--build-cache") - assertEquals(content1, schemaFile.readText()) - - val content2 = "schema2" - mockServer.enqueue(MockResponse().setBody(content2)) - - TestUtils.executeTask("downloadMockApolloSchema", dir, "--build-cache") - assertEquals(content2, schemaFile.readText()) - } - } - - @Test - fun `manually downloading a schema is working`() { - - withSimpleProject(apolloConfiguration = "") { dir -> - val content = "schema should be here" - val mockResponse = MockResponse().setBody(content) - mockServer.enqueue(mockResponse) - - TestUtils.executeGradle(dir, "downloadApolloSchema", - "-Pcom.apollographql.apollo.schema=schema.json", - "-Pcom.apollographql.apollo.endpoint=${mockServer.url("/")}") - - assertEquals(content, dir.child("schema.json").readText()) - } - } -} diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/GradleBuildCacheTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/GradleBuildCacheTests.kt deleted file mode 100644 index 2c4c0410751..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/GradleBuildCacheTests.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.util.TestUtils -import com.apollographql.apollo.gradle.util.replaceInText -import org.gradle.testkit.runner.TaskOutcome -import org.junit.Assert -import org.junit.Test -import java.io.File - -class GradleBuildCacheTests { - - @Test - fun `generate and check apollo classes task are cached`() { - TestUtils.withDirectory { dir -> - val project1 = File(dir, "project1") - val project2 = File(dir, "directory/project2") - project2.mkdirs() - - File(System.getProperty("user.dir"), "testProjects/buildCache").copyRecursively(project1) - File(System.getProperty("user.dir"), "testProjects/buildCache").copyRecursively(project2) - - File(project2, "build.gradle.kts").replaceInText("../../../../", "../../../../../") - File(project2, "settings.gradle.kts").replaceInText("../buildCache", "../../buildCache") - - System.out.println("Generate sources project1") - var result = TestUtils.executeTask("generateMainServiceApolloSources", project1, "--build-cache") - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":module:generateMainServiceApolloSources")!!.outcome) - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":checkMainServiceApolloDuplicates")!!.outcome) - - System.out.println("Generate sources project2") - result = TestUtils.executeTask("generateMainServiceApolloSources", project2, "--build-cache") - Assert.assertEquals(TaskOutcome.FROM_CACHE, result.task(":module:generateMainServiceApolloSources")!!.outcome) - Assert.assertEquals(TaskOutcome.FROM_CACHE, result.task(":checkMainServiceApolloDuplicates")!!.outcome) - } - } -} diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/GradleVersionTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/GradleVersionTests.kt deleted file mode 100644 index d93268210a4..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/GradleVersionTests.kt +++ /dev/null @@ -1,40 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.internal.ApolloPlugin.Companion.MIN_GRADLE_VERSION -import com.apollographql.apollo.gradle.internal.child -import com.apollographql.apollo.gradle.util.TestUtils -import com.apollographql.apollo.gradle.util.generatedChild -import com.google.common.truth.Truth -import junit.framework.Assert.fail -import org.gradle.testkit.runner.TaskOutcome -import org.gradle.testkit.runner.UnexpectedBuildFailure -import org.hamcrest.CoreMatchers -import org.hamcrest.CoreMatchers.containsString -import org.hamcrest.CoreMatchers.not -import org.junit.Assert -import org.junit.Test -import java.nio.file.Files - -class GradleVersionTests { - @Test - fun `minGradleVersion is working and does not show warnings`() { - TestUtils.withSimpleProject { dir -> - val result = TestUtils.executeGradleWithVersion(dir, MIN_GRADLE_VERSION,"generateApolloSources") - - Truth.assertThat(result.task(":generateApolloSources")!!.outcome).isEqualTo(TaskOutcome.SUCCESS) - Truth.assertThat(result.output).doesNotContain("Deprecated Gradle features were used in this build") - } - } - - @Test - fun `gradle below minGradleVersion shows an error`() { - TestUtils.withSimpleProject { dir -> - try { - TestUtils.executeGradleWithVersion(dir, "5.4","generateApolloSources") - fail("Compiling with an old version of Gradle should fail") - } catch (e: UnexpectedBuildFailure) { - Truth.assertThat(e.message).contains("apollo-android requires Gradle version $MIN_GRADLE_VERSION or greater") - } - } - } -} \ No newline at end of file diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/KotlinCodegenTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/KotlinCodegenTests.kt deleted file mode 100644 index c985f44715c..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/KotlinCodegenTests.kt +++ /dev/null @@ -1,97 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.internal.child -import com.apollographql.apollo.gradle.util.TestUtils -import com.apollographql.apollo.gradle.util.TestUtils.withProject -import com.apollographql.apollo.gradle.util.generatedChild -import org.hamcrest.CoreMatchers -import org.junit.Assert.assertThat -import org.junit.Assert.assertTrue -import org.junit.Test -import java.io.File - -class KotlinCodegenTests { - @Test - fun `generates and compiles kotlin`() { - val apolloConfiguration = """ - apollo { - generateKotlinModels = true - } - """.trimIndent() - withProject(usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.javaPlugin, TestUtils.kotlinJvmPlugin, TestUtils.apolloPlugin)) { dir -> - - val source = TestUtils.fixturesDirectory() - source.child("kotlin").copyRecursively(dir.child("src", "main", "kotlin")) - - TestUtils.executeTask("build", dir) - assertTrue(File(dir, "build/classes/kotlin/main/com/example/DroidDetailsQuery.class").isFile) - assertTrue(dir.generatedChild("main/service/com/example/DroidDetailsQuery.kt").isFile) - assertTrue(dir.generatedChild("main/service/com/example/type/CustomType.kt").isFile) - assertTrue(dir.generatedChild("main/service/com/example/fragment/SpeciesInformation.kt").isFile) - } - } - - - @Test - fun `when generateAsInternal set to true - generated models are internal`() { - val apolloConfiguration = """ - apollo { - generateKotlinModels = true - generateAsInternal = true - } - """.trimIndent() - - withProject( - usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.javaPlugin, TestUtils.kotlinJvmPlugin, TestUtils.apolloPlugin) - ) { dir -> - - val source = TestUtils.fixturesDirectory() - source.child("kotlin").copyRecursively(dir.child("src", "main", "kotlin")) - - TestUtils.executeTask("build", dir) - - assertTrue(dir.generatedChild("main/service/com/example/DroidDetailsQuery.kt").isFile) - assertThat(dir.generatedChild("main/service/com/example/DroidDetailsQuery.kt").readText(), CoreMatchers.containsString("internal class")) - - assertTrue(dir.generatedChild("main/service/com/example/type/CustomType.kt").isFile) - assertThat(dir.generatedChild("main/service/com/example/type/CustomType.kt").readText(), CoreMatchers.containsString("internal enum class")) - - assertTrue(dir.generatedChild("main/service/com/example/fragment/SpeciesInformation.kt").isFile) - assertThat(dir.generatedChild("main/service/com/example/fragment/SpeciesInformation.kt").readText(), CoreMatchers.containsString("internal data class")) - } - } - - @Test - fun `when sealedClassesForEnumsMatching to match all - generated enum type as sealed class`() { - val apolloConfiguration = """ - apollo { - service("githunt") { - sourceFolder = "githunt" - } - generateKotlinModels = true - sealedClassesForEnumsMatching = [".*"] - } - """.trimIndent() - withProject( - usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.javaPlugin, TestUtils.kotlinJvmPlugin, TestUtils.apolloPlugin) - ) { dir -> - val source = TestUtils.fixturesDirectory() - - val target = dir.child("src", "main", "graphql", "githunt") - source.child("githunt").copyRecursively(target = target, overwrite = true) - - dir.child("src", "main", "graphql", "com").deleteRecursively() - - TestUtils.executeTask("build", dir) - - assertTrue(dir.generatedChild("main/githunt/type/FeedType.kt").isFile) - assertThat(dir.generatedChild("main/githunt/type/FeedType.kt").readText(), CoreMatchers.containsString("sealed class")) - } - } -} diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/KotlinDSLTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/KotlinDSLTests.kt deleted file mode 100644 index 29ce5b99b69..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/KotlinDSLTests.kt +++ /dev/null @@ -1,80 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.util.TestUtils -import com.apollographql.apollo.gradle.util.generatedChild -import org.gradle.testkit.runner.TaskOutcome -import org.gradle.testkit.runner.UnexpectedBuildFailure -import org.hamcrest.CoreMatchers -import org.junit.Assert -import org.junit.Assert.assertEquals -import org.junit.Test - -class KotlinDSLTests { - @Test - fun `generated accessors work as expected`() { - val apolloConfiguration = """ - apollo { - nullableValueType.set("annotated") - } - """.trimIndent() - - TestUtils.withGeneratedAccessorsProject(apolloConfiguration) {dir -> - TestUtils.executeGradle(dir) - } - } - - @Test - fun `generated accessors do not expose DefaultApolloExtension`() { - val apolloConfiguration = """ - apollo { - println("apollo has ${'$'}{services.size} services") - } - """.trimIndent() - - TestUtils.withGeneratedAccessorsProject(apolloConfiguration) {dir -> - var exception: Exception? = null - try { - TestUtils.executeGradle(dir) - } catch (e: UnexpectedBuildFailure) { - exception = e - Assert.assertThat(e.message, CoreMatchers.containsString("Unresolved reference: services")) - } - Assert.assertNotNull(exception) - } - } - - @Test - fun `parameters do not throw`() { - val apolloConfiguration = """ - configure { - nullableValueType.set("annotated") - useJavaBeansSemanticNaming.set(false) - generateModelBuilder.set(false) - useSemanticNaming.set(false) - useJavaBeansSemanticNaming.set(false) - suppressRawTypesWarning.set(false) - generateVisitorForPolymorphicDatatypes.set(false) - customTypeMapping.set(mapOf("DateTime" to "java.util.Date")) - generateKotlinModels.set(false) - generateOperationOutput.set(false) - - service("starwars") { - sourceFolder.set("com/example") - schemaPath.set("com/example/schema.json") - rootPackageName.set("com.starwars") - exclude.set(listOf("*.gql")) - } - } - """.trimIndent() - - TestUtils.withProject( - usesKotlinDsl = true, - plugins = listOf(TestUtils.javaPlugin, TestUtils.apolloPlugin), - apolloConfiguration = apolloConfiguration - ) { dir -> - val result = TestUtils.executeTask("generateApolloSources", dir) - assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - Assert.assertTrue(dir.generatedChild("main/starwars/com/starwars/DroidDetails.java").isFile) - } - } -} diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/LazyTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/LazyTests.kt deleted file mode 100644 index 4d15e241b75..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/LazyTests.kt +++ /dev/null @@ -1,63 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.util.TestUtils -import org.gradle.testkit.runner.TaskOutcome -import org.junit.Assert -import org.junit.Test - - -class LazyTests { - @Test - fun `properties are not called during configuration`() { - - val apolloConfiguration = """ -configure { - useSemanticNaming.set(project.provider { - throw IllegalArgumentException("this should not be called during configuration") - }) -} - """.trimIndent() - TestUtils.withProject( - usesKotlinDsl = true, - plugins = listOf(TestUtils.javaPlugin, TestUtils.apolloPlugin), - apolloConfiguration = apolloConfiguration - ) { dir -> - TestUtils.executeGradle(dir, "tasks", "--all") - } - } - - - @Test - fun `configuring compilation unit input carries task dependencies`() { - - val apolloConfiguration = """ -abstract class InstallGraphQLFilesTask: DefaultTask() { - @get:OutputDirectory - abstract val outputDir: DirectoryProperty - @TaskAction - fun taskAction() { - println("installing graphql files") - project.file( "src/main/graphql/com/example").copyRecursively(outputDir.asFile.get()) - } -} -val installTask = tasks.register("installTask", InstallGraphQLFilesTask::class.java) { - outputDir.set(project.file("build/toto")) -} -configure { - onCompilationUnit { - graphqlSourceDirectorySet.srcDir(installTask.flatMap { it.outputDir }) - } -} -""".trimIndent() - - TestUtils.withProject( - usesKotlinDsl = true, - plugins = listOf(TestUtils.javaPlugin, TestUtils.apolloPlugin), - apolloConfiguration = apolloConfiguration - ) { dir -> - val result = TestUtils.executeTask("generateApolloSources", dir) - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":installTask")?.outcome) - } - } -} diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/MultiModulesTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/MultiModulesTests.kt deleted file mode 100644 index 22caac45c4e..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/MultiModulesTests.kt +++ /dev/null @@ -1,70 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.util.TestUtils -import com.apollographql.apollo.gradle.util.replaceInText -import com.google.common.truth.Truth -import junit.framework.Assert.fail -import org.gradle.api.tasks.TaskExecutionException -import org.gradle.testkit.runner.TaskOutcome -import org.gradle.testkit.runner.UnexpectedBuildFailure -import org.junit.Assert -import org.junit.Test -import java.io.File - -class MultiModulesTests { - @Test - fun `multi-modules project compiles`() { - TestUtils.withTestProject("multi-modules") { dir -> - val result = TestUtils.executeTask(":leaf:assemble", dir) - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":leaf:assemble")!!.outcome) - } - } - - @Test - fun `multi-modules project can use transitive dependencies`() { - TestUtils.withTestProject("multi-modules-transitive") { dir -> - val result = TestUtils.executeTask(":leaf:assemble", dir) - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":leaf:assemble")!!.outcome) - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":leaf:generateMainServiceApolloSources")!!.outcome) - } - } - - @Test - fun `transitive dependencies are only included once`() { - /** - * A dimaond shaped hierarchy does not include the schema multiple times - */ - TestUtils.withTestProject("multi-modules-diamond") { dir -> - val result = TestUtils.executeTask(":leaf:jar", dir) - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":leaf:generateMainServiceApolloSources")!!.outcome) - } - } - - @Test - fun `duplicate fragments are detected correctly`() { - TestUtils.withTestProject("multi-modules-duplicates") { dir -> - try { - TestUtils.executeTask(":node1:generateApolloSources", dir) - fail("the build did not detect duplicate classes") - } catch(e: UnexpectedBuildFailure) { - Truth.assertThat(e.message).contains("duplicate Fragment 'CatFragment' generated in modules: node1,node2") - } - } - } - - @Test - fun `changing a module does not recompile siblings`() { - TestUtils.withTestProject("multi-modules-duplicates") { dir -> - File(dir, "node1/src/main/graphql/com/library/operations.graphql").replaceInText("CatFragment", "CatFragment1") - TestUtils.executeTaskAndAssertSuccess(":node1:generateApolloSources", dir) - File(dir, "node1/src/main/graphql/com/library/operations.graphql").replaceInText("CatFragment", "CatFragment2") - val result = TestUtils.executeTask(":node1:jar", dir) - - Truth.assertThat(result.task(":node1:generateMainServiceApolloSources")?.outcome).isEqualTo(TaskOutcome.SUCCESS) - Truth.assertThat(result.task(":node1:compileKotlin")?.outcome).isEqualTo(TaskOutcome.SUCCESS) - Truth.assertThat(result.task(":checkMainServiceApolloDuplicates")?.outcome).isEqualTo(TaskOutcome.SUCCESS) - Truth.assertThat(result.task(":node2:compileKotlin")?.outcome).isEqualTo(null) - Truth.assertThat(result.task(":node2:generateMainServiceApolloSources")?.outcome).isEqualTo(TaskOutcome.UP_TO_DATE) - } - } -} \ No newline at end of file diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/MultiplatformTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/MultiplatformTests.kt deleted file mode 100644 index 190774d22c4..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/MultiplatformTests.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.util.TestUtils -import org.junit.Test - -class MultiplatformTests { - @Test - fun `ios framework compiles`() { - TestUtils.withTestProject("multiplatform") { dir -> - TestUtils.executeTaskAndAssertSuccess(":linkDebugFrameworkIosArm64", dir) - } - } -} \ No newline at end of file diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/MultipleServicesTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/MultipleServicesTests.kt deleted file mode 100644 index 2b906b9c659..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/MultipleServicesTests.kt +++ /dev/null @@ -1,69 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.internal.child -import com.apollographql.apollo.gradle.util.TestUtils -import com.apollographql.apollo.gradle.util.TestUtils.withProject -import com.apollographql.apollo.gradle.util.generatedChild -import org.gradle.testkit.runner.UnexpectedBuildFailure -import org.hamcrest.CoreMatchers -import org.hamcrest.CoreMatchers.containsString -import org.hamcrest.MatcherAssert -import org.junit.Assert.* -import org.junit.Test -import java.io.File - -class MultipleServicesTests { - fun withMultipleServicesProject(apolloConfiguration: String, block: (File) -> Unit) { - withProject(usesKotlinDsl = false, - plugins = listOf(TestUtils.javaPlugin, TestUtils.apolloPlugin), - apolloConfiguration = apolloConfiguration) { dir -> - val source = TestUtils.fixturesDirectory() - - val target = dir.child("src", "main", "graphql", "githunt") - source.child("githunt").copyRecursively(target = target, overwrite = true) - - dir.child("src", "main", "graphql", "com").copyRecursively(target = dir.child("src", "main", "graphql", "starwars"), overwrite = true) - dir.child("src", "main", "graphql", "com").deleteRecursively() - - block(dir) - } - } - - @Test - fun `multiple schema files without using service is not supported`() { - withMultipleServicesProject("") { dir -> - try { - TestUtils.executeTask("generateApolloSources", dir) - fail("expected to fail") - } catch (e: UnexpectedBuildFailure) { - MatcherAssert.assertThat( - e.message, - containsString("ApolloGraphQL: By default only one schema.[json | sdl] file is supported.") - ) - } - } - } - - @Test - fun `can specify services explicitly`() { - val apolloConfiguration = """ - apollo { - service("starwars") { - sourceFolder = "starwars" - } - service("githunt") { - sourceFolder = "githunt" - } - } - """.trimIndent() - withMultipleServicesProject(apolloConfiguration) { dir -> - TestUtils.executeTask("build", dir) - - assertTrue(dir.generatedChild("main/starwars/example/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("main/starwars/example/FilmsQuery.java").isFile) - assertTrue(dir.generatedChild("main/starwars/example/fragment/SpeciesInformation.java").isFile) - assertTrue(dir.generatedChild("main/githunt/FeedQuery.java").isFile) - assertTrue(dir.generatedChild("main/githunt/fragment/RepositoryFragment.java").isFile) - } - } -} diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/NonAndroidTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/NonAndroidTests.kt deleted file mode 100644 index 05e58a2c609..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/NonAndroidTests.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.util.TestUtils -import com.apollographql.apollo.gradle.util.TestUtils.withSimpleProject -import com.apollographql.apollo.gradle.util.replaceInText -import org.gradle.testkit.runner.TaskOutcome -import org.junit.Assert -import org.junit.Test -import java.io.File - -class NonAndroidTests { - @Test - fun `applying the apollo plugin does not pull the android plugin in the classpath`() { - withSimpleProject { dir -> - // Remove the google() repo where the android plugin resides - File(dir, "build.gradle").replaceInText("google()", "") - - val result = TestUtils.executeTask("generateApolloSources", dir) - - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - } - } -} \ No newline at end of file diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/OperationIdGeneratorTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/OperationIdGeneratorTests.kt deleted file mode 100644 index 701b31ab0a2..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/OperationIdGeneratorTests.kt +++ /dev/null @@ -1,152 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.util.TestUtils -import com.apollographql.apollo.gradle.util.TestUtils.withSimpleProject -import com.apollographql.apollo.gradle.util.TestUtils.withTestProject -import com.apollographql.apollo.gradle.util.generatedChild -import com.apollographql.apollo.gradle.util.replaceInText -import org.gradle.testkit.runner.TaskOutcome -import org.hamcrest.CoreMatchers -import org.junit.Assert -import org.junit.Test -import java.io.File - -class OperationIdGeneratorTests { - val apolloConfiguration = """ - class MyIdGenerator implements OperationIdGenerator { - String apply(String queryString, String queryFilepath) { - return queryString.length().toString(); - } - String version = "MyIdGenerator-v1" - } - - apollo { - operationIdGenerator = new MyIdGenerator() - } - """.trimIndent() - - @Test - fun `up-to-date checks are working`() { - withSimpleProject(apolloConfiguration = apolloConfiguration) {dir -> - val gradleFile = File(dir, "build.gradle").readText() - - File(dir, "build.gradle").writeText("import com.apollographql.apollo.compiler.OperationIdGenerator\n$gradleFile") - - var result = TestUtils.executeTask("generateApolloSources", dir) - - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - - result = TestUtils.executeTask("generateApolloSources", dir) - - Assert.assertEquals(TaskOutcome.UP_TO_DATE, result.task(":generateApolloSources")!!.outcome) - } - } - - @Test - fun `operationIdGenerator can be set from onCompilationUnit`() { - val apolloConfiguration = """ - class MyIdGenerator implements OperationIdGenerator { - String apply(String queryString, String queryFilepath) { - return queryFilepath; - } - String version = "MyIdGenerator-v1" - } - - apollo { - onCompilationUnit { - operationIdGenerator = new MyIdGenerator() - } - } - """.trimIndent() - - withSimpleProject(apolloConfiguration = apolloConfiguration) {dir -> - val gradleFile = File(dir, "build.gradle").readText() - - File(dir, "build.gradle").writeText("import com.apollographql.apollo.compiler.OperationIdGenerator\n$gradleFile") - - val result = TestUtils.executeTask("generateApolloSources", dir) - - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - - val queryJavaFile = dir.generatedChild("main/service/com/example/DroidDetailsQuery.java") - Assert.assertThat(queryJavaFile.readText(), CoreMatchers.containsString("com/example/DroidDetails.graphql")) - } - } - - @Test - fun `changing the operationIdGenerator recompiles sources`() { - withSimpleProject(apolloConfiguration = apolloConfiguration) { dir -> - val gradleFile = File(dir, "build.gradle").readText() - - File(dir, "build.gradle").writeText("import com.apollographql.apollo.compiler.OperationIdGenerator\n$gradleFile") - - var result = TestUtils.executeTask("generateApolloSources", dir) - - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - - File(dir, "build.gradle").replaceInText("queryString.length().toString()", "queryString.length().toString() + \"(modified)\"") - File(dir, "build.gradle").replaceInText("MyIdGenerator-v1", "MyIdGenerator-v2") - - result = TestUtils.executeTask("generateApolloSources", dir) - - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - } - } - - @Test - fun `build cache is working as expected`() { - withSimpleProject(apolloConfiguration = apolloConfiguration) { dir -> - val buildCachePath = File(dir, "buildCache").absolutePath - File(dir, "settings.gradle").appendText(""" - - buildCache { - local { - directory = new File("$buildCachePath") - } - } - """.trimIndent()) - - val gradleFile = File(dir, "build.gradle").readText() - - File(dir, "build.gradle").writeText("import com.apollographql.apollo.compiler.OperationIdGenerator\n$gradleFile") - - var result = TestUtils.executeTask("generateMainServiceApolloSources", dir, "--build-cache", "-i") - - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateMainServiceApolloSources")!!.outcome) - - File(dir, "build").deleteRecursively() - - result = TestUtils.executeTask("generateMainServiceApolloSources", dir, "--build-cache", "-i") - - Assert.assertEquals(TaskOutcome.FROM_CACHE, result.task(":generateMainServiceApolloSources")!!.outcome) - } - } - - @Test - fun `operationOutputGenerator is working as expected`() { - withTestProject("operationIds") { dir -> - - var result = TestUtils.executeTask("generateApolloSources", dir) - - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateMainServiceApolloSources")!!.outcome) - - Assert.assertThat( - dir.generatedChild("main/service/com/example/GreetingQuery.java").readText(), - CoreMatchers.containsString("OPERATION_ID = \"GreetingCustomId\";") - ) - - // Change the implementation of the operation ID generator and check again - File(dir,"build.gradle.kts").replaceInText("CustomId", "anotherCustomId") - File(dir,"build.gradle.kts").replaceInText("OperationOutputGenerator-v1", "OperationOutputGenerator-v2") - - result = TestUtils.executeTask("generateApolloSources", dir) - - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":generateMainServiceApolloSources")!!.outcome) - - Assert.assertThat( - dir.generatedChild("main/service/com/example/GreetingQuery.java").readText(), - CoreMatchers.containsString("anotherCustomId") - ) - } - } -} diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/SchemaResolutionTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/SchemaResolutionTests.kt deleted file mode 100644 index de2331f440e..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/SchemaResolutionTests.kt +++ /dev/null @@ -1,109 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.internal.child -import com.apollographql.apollo.gradle.util.TestUtils -import com.apollographql.apollo.gradle.util.TestUtils.executeTask -import com.apollographql.apollo.gradle.util.TestUtils.withProject -import com.apollographql.apollo.gradle.util.generatedChild -import org.gradle.testkit.runner.UnexpectedBuildFailure -import org.hamcrest.CoreMatchers -import org.hamcrest.MatcherAssert -import org.junit.Assert.assertTrue -import org.junit.Assert.fail -import org.junit.Test - -class SchemaResolutionTests { - - @Test - fun `when SDL schema assert implicitly resolved and generates classes`() { - val apolloConfiguration = """ - apollo { - service("api") { - generateKotlinModels = true - } - } - """.trimIndent() - - withProject( - usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.javaPlugin, TestUtils.kotlinJvmPlugin, TestUtils.apolloPlugin) - ) { projectDir -> - projectDir.child("src", "main", "graphql", "com").deleteRecursively() - - val fixturesDir = TestUtils.fixturesDirectory() - - val target = projectDir.child("src", "main", "graphql") - fixturesDir.child("sdl").copyRecursively(target = target, overwrite = true) - - projectDir.child("src", "main", "graphql", "schema.json").delete() - - executeTask("generateApolloSources", projectDir) - - assertTrue(projectDir.generatedChild("main/api/FeedRepositoryQuery.kt").isFile) - } - } - - @Test - fun `when SDL schema set explicitly assert generates classes`() { - val apolloConfiguration = """ - apollo { - service("api") { - schemaPath = "schema.sdl" - generateKotlinModels = true - } - } - """.trimIndent() - - withProject( - usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.javaPlugin, TestUtils.kotlinJvmPlugin, TestUtils.apolloPlugin) - ) { projectDir -> - projectDir.child("src", "main", "graphql", "com").deleteRecursively() - - val fixturesDir = TestUtils.fixturesDirectory() - - val target = projectDir.child("src", "main", "graphql") - fixturesDir.child("sdl").copyRecursively(target = target, overwrite = true) - - executeTask("generateApolloSources", projectDir) - - assertTrue(projectDir.generatedChild("main/api/FeedRepositoryQuery.kt").isFile) - } - } - - @Test - fun `when SDL and introspection schema not set explicitly assert build fails`() { - val apolloConfiguration = """ - apollo { - service("api") { - generateKotlinModels = true - } - } - """.trimIndent() - - withProject( - usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.javaPlugin, TestUtils.kotlinJvmPlugin, TestUtils.apolloPlugin) - ) { projectDir -> - projectDir.child("src", "main", "graphql", "com").deleteRecursively() - - val fixturesDir = TestUtils.fixturesDirectory() - - val target = projectDir.child("src", "main", "graphql") - fixturesDir.child("sdl").copyRecursively(target = target, overwrite = true) - - try { - executeTask("generateApolloSources", projectDir) - fail("expected to fail") - } catch (e: UnexpectedBuildFailure) { - MatcherAssert.assertThat( - e.message, - CoreMatchers.containsString("ApolloGraphQL: By default only one schema.[json | sdl] file is supported.") - ) - } - } - } -} diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/SourceDirectorySetTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/SourceDirectorySetTests.kt deleted file mode 100644 index 030447539d4..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/SourceDirectorySetTests.kt +++ /dev/null @@ -1,279 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.internal.child -import com.apollographql.apollo.gradle.util.TestUtils -import com.apollographql.apollo.gradle.util.generatedChild -import org.gradle.testkit.runner.TaskOutcome -import org.junit.Assert -import org.junit.Test -import java.io.File - -class SourceDirectorySetTests { - @Test - fun `android-kotlin builds an apk`() { - val apolloConfiguration = """ - apollo { - generateKotlinModels = true - } - """.trimIndent() - TestUtils.withProject(usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.androidApplicationPlugin, TestUtils.kotlinAndroidPlugin, TestUtils.apolloPlugin)) { dir -> - - val source = TestUtils.fixturesDirectory() - source.child("kotlin").copyRecursively(dir.child("src", "main", "kotlin")) - - TestUtils.executeTask("assembleDebug", dir) - - Assert.assertTrue(File(dir, "build/tmp/kotlin-classes/debug/com/example/DroidDetailsQuery.class").isFile) - Assert.assertTrue(File(dir, "build/tmp/kotlin-classes/debug/com/example/Main.class").isFile) - Assert.assertTrue(File(dir, "build/outputs/apk/debug/testProject-debug.apk").isFile) - Assert.assertTrue(dir.generatedChild("debug/service/com/example/DroidDetailsQuery.kt").isFile) - } - } - - @Test - fun `non-android-kotlin builds a jar`() { - val apolloConfiguration = """ - apollo { - generateKotlinModels = true - } - """.trimIndent() - TestUtils.withProject(usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.javaPlugin, TestUtils.kotlinJvmPlugin, TestUtils.apolloPlugin)) { dir -> - - val source = TestUtils.fixturesDirectory() - source.child("kotlin").copyRecursively(dir.child("src", "main", "kotlin")) - - TestUtils.executeTask("build", dir) - - Assert.assertTrue(File(dir, "build/classes/kotlin/main/com/example/DroidDetailsQuery.class").isFile) - Assert.assertTrue(File(dir, "build/classes/kotlin/main/com/example/Main.class").isFile) - Assert.assertTrue(dir.generatedChild("main/service/com/example/DroidDetailsQuery.kt").isFile) - Assert.assertTrue(File(dir, "build/libs/testProject.jar").isFile) - } - } - - @Test - fun `pure-jvm java models are reachable from kotlin code`() { - val apolloConfiguration = """ - apollo { - generateKotlinModels = false - } - """.trimIndent() - TestUtils.withProject(usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.javaPlugin, TestUtils.kotlinJvmPlugin, TestUtils.apolloPlugin)) { dir -> - - val source = TestUtils.fixturesDirectory() - source.child("kotlin").copyRecursively(dir.child("src", "main", "kotlin")) - - TestUtils.executeTask("build", dir) - - Assert.assertTrue(File(dir, "build/classes/java/main/com/example/DroidDetailsQuery.class").isFile) - Assert.assertTrue(File(dir, "build/classes/kotlin/main/com/example/Main.class").isFile) - Assert.assertTrue(dir.generatedChild("main/service/com/example/DroidDetailsQuery.java").isFile) - Assert.assertTrue(File(dir, "build/libs/testProject.jar").isFile) - } - } - - @Test - fun `android java models are reachable from kotlin code`() { - val apolloConfiguration = """ - apollo { - generateKotlinModels = false - } - """.trimIndent() - TestUtils.withProject(usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.androidApplicationPlugin, TestUtils.kotlinAndroidPlugin, TestUtils.apolloPlugin)) { dir -> - - val source = TestUtils.fixturesDirectory() - source.child("kotlin").copyRecursively(dir.child("src", "main", "kotlin")) - - TestUtils.executeTask("assembleDebug", dir) - - Assert.assertTrue(File(dir, "build/intermediates/javac/debug/classes/com/example/DroidDetailsQuery.class").isFile) - Assert.assertTrue(File(dir, "build/tmp/kotlin-classes/debug/com/example/Main.class").isFile) - Assert.assertTrue(File(dir, "build/outputs/apk/debug/testProject-debug.apk").isFile) - Assert.assertTrue(dir.generatedChild("debug/service/com/example/DroidDetailsQuery.java").isFile) - } - } - - @Test - fun `android-java builds an apk`() { - val apolloConfiguration = """ - apollo { - generateKotlinModels = false - } - """.trimIndent() - TestUtils.withProject(usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.androidApplicationPlugin, TestUtils.apolloPlugin)) { dir -> - - val source = TestUtils.fixturesDirectory() - source.child("java").copyRecursively(dir.child("src", "main", "java")) - - TestUtils.executeTask("assembleDebug", dir) - - Assert.assertTrue(File(dir, "build/intermediates/javac/debug/classes/com/example/DroidDetailsQuery.class").isFile) - Assert.assertTrue(File(dir, "build/intermediates/javac/debug/classes/com/example/Main.class").isFile) - Assert.assertTrue(File(dir, "build/outputs/apk/debug/testProject-debug.apk").isFile) - Assert.assertTrue(dir.generatedChild("debug/service/com/example/DroidDetailsQuery.java").isFile) - } - } - - @Test - fun `non-android-java builds a jar`() { - val apolloConfiguration = """ - apollo { - generateKotlinModels = false - } - """.trimIndent() - TestUtils.withProject(usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.javaPlugin, TestUtils.apolloPlugin)) { dir -> - - val source = TestUtils.fixturesDirectory() - source.child("java").copyRecursively(dir.child("src", "main", "java")) - - TestUtils.executeTask("build", dir) - - Assert.assertTrue(File(dir, "build/classes/java/main/com/example/DroidDetailsQuery.class").isFile) - Assert.assertTrue(File(dir, "build/classes/java/main/com/example/Main.class").isFile) - Assert.assertTrue(dir.generatedChild("main/service/com/example/DroidDetailsQuery.java").isFile) - Assert.assertTrue(File(dir, "build/libs/testProject.jar").isFile) - } - } - - @Test - fun `non-android jvm can add queries to the test variant`() { - val apolloConfiguration = """ - apollo { - generateKotlinModels = false - } - """.trimIndent() - TestUtils.withProject(usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.javaPlugin, TestUtils.apolloPlugin)) { dir -> - - val source = TestUtils.fixturesDirectory() - source.child("java").copyRecursively(dir.child("src", "test", "java")) - - dir.child("src/main/graphql").copyRecursively(dir.child("src/test/graphql")) - dir.child("src/main/graphql").deleteRecursively() - - TestUtils.executeTask("test", dir) - - Assert.assertTrue(File(dir, "build/classes/java/test/com/example/DroidDetailsQuery.class").isFile) - Assert.assertTrue(File(dir, "build/classes/java/test/com/example/Main.class").isFile) - Assert.assertTrue(dir.generatedChild("test/service/com/example/DroidDetailsQuery.java").isFile) - } - } - - @Test - fun `non-android jvm can add additional sourceSets`() { - val apolloConfiguration = """ - sourceSets { - foo { - } - } - dependencies { - fooImplementation dep.jetbrainsAnnotations - fooImplementation dep.apollo.api - } - apollo { - generateKotlinModels = false - } - """.trimIndent() - TestUtils.withProject(usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.javaPlugin, TestUtils.apolloPlugin)) { dir -> - - val source = TestUtils.fixturesDirectory() - source.child("java").copyRecursively(dir.child("src", "foo", "java")) - - dir.child("src/main/graphql").copyRecursively(dir.child("src/foo/graphql")) - dir.child("src/main/graphql").deleteRecursively() - - val result = TestUtils.executeTask("compileFooJava", dir) - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(":compileFooJava")!!.outcome) - - Assert.assertTrue(File(dir, "build/classes/java/foo/com/example/DroidDetailsQuery.class").isFile) - Assert.assertTrue(File(dir, "build/classes/java/foo/com/example/Main.class").isFile) - Assert.assertTrue(dir.generatedChild("foo/service/com/example/DroidDetailsQuery.java").isFile) - - // Also verify that the compile task is compileJava and not compileMainJava - val resultMain = TestUtils.executeTask("compileJava", dir) - Assert.assertEquals(TaskOutcome.NO_SOURCE, resultMain.task(":compileJava")!!.outcome) - } - } - - @Test - fun `custom sourceSets with dash does not make configuration fail`() { - val apolloConfiguration = """ - sourceSets { - 'native-test' { - } - } - """.trimIndent() - TestUtils.withProject(apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.javaPlugin, TestUtils.apolloPlugin), - usesKotlinDsl = false) { dir -> - - val result = TestUtils.executeTask("compileNativeTestJava", dir) - Assert.assertEquals(TaskOutcome.NO_SOURCE, result.task(":compileNativeTestJava")!!.outcome) - } - } - - @Test - fun `android can add queries to the test variant`() { - val apolloConfiguration = """ - apollo { - generateKotlinModels = false - } - """.trimIndent() - TestUtils.withProject(usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.javaPlugin, TestUtils.apolloPlugin)) { dir -> - - val source = TestUtils.fixturesDirectory() - source.child("java").copyRecursively(dir.child("src", "test", "java")) - - dir.child("src/main/graphql").copyRecursively(dir.child("src/test/graphql")) - dir.child("src/main/graphql").deleteRecursively() - - TestUtils.executeTask("test", dir) - - Assert.assertTrue(File(dir, "build/classes/java/test/com/example/DroidDetailsQuery.class").isFile) - Assert.assertTrue(File(dir, "build/classes/java/test/com/example/Main.class").isFile) - Assert.assertTrue(dir.generatedChild("test/service/com/example/DroidDetailsQuery.java").isFile) - } - } - - @Test - fun `android can add queries to the androidTest variant`() { - val apolloConfiguration = """ - apollo { - generateKotlinModels = false - } - """.trimIndent() - TestUtils.withProject(usesKotlinDsl = false, - apolloConfiguration = apolloConfiguration, - plugins = listOf(TestUtils.androidApplicationPlugin, TestUtils.apolloPlugin)) { dir -> - - val source = TestUtils.fixturesDirectory() - source.child("java").copyRecursively(dir.child("src", "androidTest", "java")) - - dir.child("src/main/graphql").copyRecursively(dir.child("src/androidTest/graphql")) - dir.child("src/main/graphql").deleteRecursively() - - TestUtils.executeTask("assembleAndroidTest", dir) - - Assert.assertTrue(dir.generatedChild("debugAndroidTest/service/com/example/DroidDetailsQuery.java").isFile) - Assert.assertTrue(dir.child("build/outputs/apk/androidTest/debug/testProject-debug-androidTest.apk").isFile) - - } - } -} diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/UpToDateTests.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/UpToDateTests.kt deleted file mode 100644 index b98e8013e0b..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/test/UpToDateTests.kt +++ /dev/null @@ -1,107 +0,0 @@ -package com.apollographql.apollo.gradle.test - -import com.apollographql.apollo.gradle.internal.child -import com.apollographql.apollo.gradle.util.TestUtils -import com.apollographql.apollo.gradle.util.TestUtils.withSimpleProject -import com.apollographql.apollo.gradle.util.generatedChild -import com.apollographql.apollo.gradle.util.replaceInText -import org.gradle.testkit.runner.TaskOutcome -import org.hamcrest.CoreMatchers.containsString -import org.hamcrest.CoreMatchers.not -import org.junit.Assert.* -import org.junit.Test -import java.io.File - -class UpToDateTests { - @Test - fun `complete test`() { - withSimpleProject { dir -> - `builds successfully and generates expected outputs`(dir) - `nothing changed, task up to date`(dir) - `adding a custom type to the build script re-generates the CustomType class`(dir) - } - } - - private fun `builds successfully and generates expected outputs`(dir: File) { - val result = TestUtils.executeTask("generateApolloSources", dir) - - assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - - // Java classes generated successfully - assertTrue(dir.generatedChild("main/service/com/example/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("main/service/com/example/FilmsQuery.java").isFile) - assertTrue(dir.generatedChild("main/service/com/example/fragment/SpeciesInformation.java").isFile) - - // verify that the custom type generated was Object.class because no customType mapping was specified - TestUtils.assertFileContains(dir, "main/service/com/example/type/CustomType.java", "return \"java.lang.Object\";") - - // Optional is not added to the generated classes - assert(!TestUtils.fileContains(dir, "main/service/com/example/DroidDetailsQuery.java", "Optional")) - TestUtils.assertFileContains(dir, "main/service/com/example/DroidDetailsQuery.java", "import org.jetbrains.annotations.Nullable;") - } - - fun `nothing changed, task up to date`(dir: File) { - val result = TestUtils.executeTask("generateApolloSources", dir) - - assertEquals(TaskOutcome.UP_TO_DATE, result.task(":generateApolloSources")!!.outcome) - - // Java classes generated successfully - assertTrue(dir.generatedChild("main/service/com/example/DroidDetailsQuery.java").isFile) - assertTrue(dir.generatedChild("main/service/com/example/FilmsQuery.java").isFile) - assertTrue(dir.generatedChild("main/service/com/example/fragment/SpeciesInformation.java").isFile) - } - - fun `adding a custom type to the build script re-generates the CustomType class`(dir: File) { - val apolloBlock = """ - apollo { - customTypeMapping = ["DateTime": "java.util.Date"] - } - """.trimIndent() - - File(dir, "build.gradle").appendText(apolloBlock) - - val result = TestUtils.executeTask("generateApolloSources", dir) - - // modifying the customTypeMapping should cause the task to be out of date - // and the task should run again - assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - - TestUtils.assertFileContains(dir, "main/service/com/example/type/CustomType.java", "return \"java.util.Date\";") - - val text = File(dir, "build.gradle").readText() - File(dir, "build.gradle").writeText(text.replace(apolloBlock, "")) - } - - @Test - fun `change graphql file rebuilds the sources`() { - withSimpleProject { dir -> - var result = TestUtils.executeTask("generateApolloSources", dir, "-i") - - assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - assertThat(dir.generatedChild("main/service/com/example/DroidDetailsQuery.java").readText(), containsString("classification")) - - dir.child("src", "main", "graphql", "com", "example", "DroidDetails.graphql").replaceInText("classification", "") - - result = TestUtils.executeTask("generateApolloSources", dir, "-i") - - assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - assertThat(dir.generatedChild("main/service/com/example/DroidDetailsQuery.java").readText(), not(containsString("classification"))) - } - } - - @Test - fun `change schema file rebuilds the sources`() { - withSimpleProject { dir -> - var result = TestUtils.executeTask("generateApolloSources", dir, "-i") - - assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - - val schemaFile = dir.child("src", "main", "graphql", "com", "example", "schema.json") - schemaFile.replaceInText("The ID of an object", "The ID of an object (modified)") - - result = TestUtils.executeTask("generateApolloSources", dir, "-i") - - assertEquals(TaskOutcome.SUCCESS, result.task(":generateApolloSources")!!.outcome) - } - } -} diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/util/AndroidTestUtils.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/util/AndroidTestUtils.kt deleted file mode 100644 index 0ae5b5d81fe..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/util/AndroidTestUtils.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2016 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.apollographql.apollo.gradle.util - -import java.io.File -import java.util.Properties - -fun String.withInvariantPathSeparators() = replace("\\", "/") - -internal fun androidHome(): String { - val env = System.getenv("ANDROID_HOME") - if (env != null) { - return env.withInvariantPathSeparators() - } - val localProp = File(File(System.getProperty("user.dir")).parentFile, "local.properties") - if (localProp.exists()) { - val prop = Properties() - localProp.inputStream().use { - prop.load(it) - } - val sdkHome = prop.getProperty("sdk.dir") - if (sdkHome != null) { - return sdkHome.withInvariantPathSeparators() - } - } - throw IllegalStateException( - "Missing 'ANDROID_HOME' environment variable or local.properties with 'sdk.dir'") -} diff --git a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/util/TestUtils.kt b/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/util/TestUtils.kt deleted file mode 100644 index 8ad063c4b08..00000000000 --- a/apollo-gradle-plugin/src/test/kotlin/com/apollographql/apollo/gradle/util/TestUtils.kt +++ /dev/null @@ -1,226 +0,0 @@ -package com.apollographql.apollo.gradle.util - -import com.apollographql.apollo.gradle.internal.child -import org.gradle.testkit.runner.BuildResult -import org.gradle.testkit.runner.GradleRunner -import org.gradle.testkit.runner.TaskOutcome -import org.hamcrest.CoreMatchers.containsString -import org.hamcrest.CoreMatchers.not -import org.junit.Assert -import org.junit.Assert.assertThat -import java.io.File - -object TestUtils { - class Plugin(val artifact: String?, val id: String) - - val javaPlugin = Plugin(id = "java", artifact = null) - val androidApplicationPlugin = Plugin(id = "com.android.application", artifact = "android.plugin") - val androidLibraryPlugin = Plugin(id = "com.android.library", artifact = "android.plugin") - val kotlinJvmPlugin = Plugin(id = "org.jetbrains.kotlin.jvm", artifact = "kotlin.plugin") - val kotlinAndroidPlugin = Plugin(id = "org.jetbrains.kotlin.android", artifact = "kotlin.plugin") - val apolloPlugin = Plugin(id = "com.apollographql.apollo", artifact = "apollo.plugin") - val apolloPluginAndroid = Plugin(id = "com.apollographql.android", artifact = "apollo.plugin") - - - fun withDirectory(block: (File) -> Unit) { - val dest = File(System.getProperty("user.dir")).child("build", "testProject") - dest.deleteRecursively() - - // See https://github.com/apollographql/apollo-android/issues/2184 - dest.mkdirs() - File(dest, "gradle.properties").writeText("org.gradle.jvmargs=-XX:MaxMetaspaceSize=1g") - - block(dest) - - // It's ok to not delete the directory as it will be deleted before next test - // During developement, it's easy to keep the testProject around to investigate if something goes wrong - // dest.deleteRecursively() - } - - fun withProject(usesKotlinDsl: Boolean, - plugins: List, - apolloConfiguration: String, - isFlavored: Boolean = false, - block: (File) -> Unit) = withDirectory { - val source = fixturesDirectory() - val dest = it - - source.child("starwars").copyRecursively(target = dest.child("src", "main", "graphql", "com", "example")) - source.child("gradle", "settings.gradle").copyTo(target = dest.child("settings.gradle")) - - val isAndroid = plugins.firstOrNull { it.id.startsWith("com.android") } != null - val hasKotlin = plugins.firstOrNull { it.id.startsWith("org.jetbrains.kotlin") } != null - - if (usesKotlinDsl) { - val applyLines = plugins.map { "apply(plugin = \"${it.id}\")" }.joinToString("\n") - val classPathLines = plugins.filter { it.artifact != null } - .map { "classpath(classpathDep(\"${it.artifact!!}\"))" } - .joinToString("\n") - - var buildscript = File(source, "gradle/build.gradle.kts.template") - .readText() - .replace("// ADD BUILDSCRIPT DEPENDENCIES HERE", classPathLines) - .replace("// ADD PLUGINS HERE", applyLines) - .replace("// ADD APOLLO CONFIGURATION HERE", apolloConfiguration) - - if (isAndroid) { - val androidConfiguration = """ - android { - setCompileSdkVersion((extra["androidConfig"] as Map).get("compileSdkVersion") as Int) - } - """.trimIndent() - if (isFlavored) { - throw IllegalArgumentException("flavored build using build.gradle.kts are not supported") - } - buildscript = buildscript.replace("// ADD ANDROID CONFIGURATION HERE", androidConfiguration) - } - - if (hasKotlin) { - buildscript = buildscript.replace( - "// ADD DEPENDENCIES HERE", - "add(\"implementation\", kotlinDep(\"kotlin.stdlib\"))") - - buildscript += """ - tasks.withType { - kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString() - } - """.trimIndent() - } - - File(dest, "build.gradle.kts").writeText(buildscript) - } else { - val applyLines = plugins.map { "apply plugin: \"${it.id}\"" }.joinToString("\n") - val classPathLines = plugins.filter { it.artifact != null }.map { "classpath(dep.${it.artifact})" }.joinToString("\n") - - var buildscript = File(source, "gradle/build.gradle.template") - .readText() - .replace("// ADD BUILDSCRIPT DEPENDENCIES HERE", classPathLines) - .replace("// ADD PLUGINS HERE", applyLines) - .replace("// ADD APOLLO CONFIGURATION HERE", apolloConfiguration) - - if (isAndroid) { - var androidConfiguration = """ - |android { - | compileSdkVersion androidConfig.compileSdkVersion - | - """.trimMargin() - - if (isFlavored) { - androidConfiguration += """ - | flavorDimensions "price" - | productFlavors { - | free { - | dimension 'price' - | } - | - | paid { - | dimension 'price' - | } - | } - | - """.trimMargin() - } - - androidConfiguration += """ - |} - """.trimMargin() - - buildscript = buildscript.replace("// ADD ANDROID CONFIGURATION HERE", androidConfiguration) - } - - if (hasKotlin) { - buildscript += """ - tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { - kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8 - } - """.trimIndent() - } - - File(dest, "build.gradle").writeText(buildscript) - } - - if (isAndroid) { - source.child("manifest", "AndroidManifest.xml").copyTo(dest.child("src", "main", "AndroidManifest.xml")) - File(dest, "local.properties").writeText("sdk.dir=${androidHome()}\n") - } - - block(dest) - } - - fun withGeneratedAccessorsProject(apolloConfiguration: String, block: (File) -> Unit) = withDirectory { dir -> - fixturesDirectory().child("gradle", "settings.gradle.kts").copyTo(dir.child("settings.gradle.kts")) - fixturesDirectory().child("gradle", "build.gradle.kts").copyTo(dir.child("build.gradle.kts")) - - dir.child("build.gradle.kts").appendText(apolloConfiguration) - - block(dir) - } - - fun withTestProject(name: String, block: (File) -> Unit) = withDirectory { dir -> - File(System.getProperty("user.dir"), "testProjects/$name").copyRecursively(dir, overwrite = true) - block(dir) - } - - /** - * creates a simple java non-android non-kotlin-gradle project - */ - fun withSimpleProject(apolloConfiguration: String = "", block: (File) -> Unit) = withProject( - usesKotlinDsl = false, - plugins = listOf(javaPlugin, apolloPlugin), - apolloConfiguration = apolloConfiguration - ) { dir -> - fixturesDirectory().child("java").copyRecursively(dir.child("src", "main", "java")) - block(dir) - } - - fun executeGradle(projectDir: File, vararg args: String): BuildResult { - return executeGradleWithVersion(projectDir, null, *args) - } - - fun executeGradleWithVersion(projectDir: File, gradleVersion: String?, vararg args: String): BuildResult { - return GradleRunner.create() - .forwardStdOutput(System.out.writer()) - .forwardStdError(System.err.writer()) - .withProjectDir(projectDir) - .withArguments("--stacktrace", *args) - .apply { - if (gradleVersion != null) { - withGradleVersion(gradleVersion) - } - } - .build() - } - - fun executeTask(task: String, projectDir: File, vararg args: String): BuildResult { - return executeGradleWithVersion(projectDir, null, task, *args) - } - - fun assertFileContains(projectDir: File, path: String, content: String) { - val text = projectDir.generatedChild(path).readText() - assertThat(text, containsString(content)) - } - - fun assertFileDoesNotContain(projectDir: File, path: String, content: String) { - val text = projectDir.generatedChild(path).readText() - assertThat(text, not(containsString(content))) - } - - fun fileContains(projectDir: File, path: String, content: String): Boolean { - return projectDir.generatedChild(path).readText() - .contains(content) - } - - fun fixturesDirectory() = File(System.getProperty("user.dir")).child("src", "test", "files") - - fun executeTaskAndAssertSuccess(task: String, dir: File) { - val result = executeTask(task, dir) - Assert.assertEquals(TaskOutcome.SUCCESS, result.task(task)?.outcome) - } -} - -fun File.generatedChild(path: String) = child("build", "generated", "source", "apollo", path) - -fun File.replaceInText(oldValue: String, newValue: String) { - val text = readText() - writeText(text.replace(oldValue, newValue)) -} diff --git a/apollo-gradle-plugin/testProjects/buildCache/module/build.gradle.kts b/apollo-gradle-plugin/testProjects/buildCache/module/build.gradle.kts index 188a0f1407d..01a552edeab 100644 --- a/apollo-gradle-plugin/testProjects/buildCache/module/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/buildCache/module/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("jvm") - id("com.apollographql.apollo") + id("com.homer.apollographql.apollo") } apollo { diff --git a/apollo-gradle-plugin/testProjects/compilationUnitAndroid/app/build.gradle b/apollo-gradle-plugin/testProjects/compilationUnitAndroid/app/build.gradle index 8eb091be12e..7c7aaef3b2e 100644 --- a/apollo-gradle-plugin/testProjects/compilationUnitAndroid/app/build.gradle +++ b/apollo-gradle-plugin/testProjects/compilationUnitAndroid/app/build.gradle @@ -1,5 +1,5 @@ apply plugin: 'com.android.application' -apply plugin: 'com.apollographql.apollo' +apply plugin: 'com.homer.apollographql.apollo' android { compileSdkVersion androidConfig.compileSdkVersion diff --git a/apollo-gradle-plugin/testProjects/convertSchema/build.gradle.kts b/apollo-gradle-plugin/testProjects/convertSchema/build.gradle.kts index 6ca4e5c6868..28db59692c1 100644 --- a/apollo-gradle-plugin/testProjects/convertSchema/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/convertSchema/build.gradle.kts @@ -16,7 +16,7 @@ buildscript { } apply(plugin = "org.jetbrains.kotlin.jvm") -apply(plugin = "com.apollographql.apollo") +apply(plugin = "com.homer.apollographql.apollo") repositories { maven { diff --git a/apollo-gradle-plugin/testProjects/deprecationWarnings/build.gradle.kts b/apollo-gradle-plugin/testProjects/deprecationWarnings/build.gradle.kts index 986a6c2a31c..5b23d36853e 100644 --- a/apollo-gradle-plugin/testProjects/deprecationWarnings/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/deprecationWarnings/build.gradle.kts @@ -1,4 +1,4 @@ -import com.apollographql.apollo.gradle.api.ApolloExtension +import com.homer.apollographql.apollo.gradle.api.ApolloExtension buildscript { apply(from = "../../../gradle/dependencies.gradle") @@ -16,7 +16,7 @@ buildscript { } apply(plugin = "org.jetbrains.kotlin.jvm") -apply(plugin = "com.apollographql.apollo") +apply(plugin = "com.homer.apollographql.apollo") repositories { mavenCentral() diff --git a/apollo-gradle-plugin/testProjects/mismatchedVersions/module/build.gradle.kts b/apollo-gradle-plugin/testProjects/mismatchedVersions/module/build.gradle.kts index c1d1ce7ee8a..efad97aeb70 100644 --- a/apollo-gradle-plugin/testProjects/mismatchedVersions/module/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/mismatchedVersions/module/build.gradle.kts @@ -1,10 +1,10 @@ apply(plugin = "kotlin") -apply(plugin = "com.apollographql.apollo") +apply(plugin = "com.homer.apollographql.apollo") -configure { +configure { generateKotlinModels.set(true) } dependencies { - add("implementation","com.apollographql.apollo:apollo-runtime:1.4.5") + add("implementation","com.homer.apollographql.apollo:apollo-runtime:1.4.5") } \ No newline at end of file diff --git a/apollo-gradle-plugin/testProjects/multi-modules-diamond/leaf/build.gradle.kts b/apollo-gradle-plugin/testProjects/multi-modules-diamond/leaf/build.gradle.kts index 7ed7243e870..8e157c64629 100644 --- a/apollo-gradle-plugin/testProjects/multi-modules-diamond/leaf/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/multi-modules-diamond/leaf/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("jvm") - id("com.apollographql.apollo") + id("com.homer.apollographql.apollo") id("application") } diff --git a/apollo-gradle-plugin/testProjects/multi-modules-diamond/node1/build.gradle.kts b/apollo-gradle-plugin/testProjects/multi-modules-diamond/node1/build.gradle.kts index 9b1e04d311a..e7c47ac0684 100644 --- a/apollo-gradle-plugin/testProjects/multi-modules-diamond/node1/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/multi-modules-diamond/node1/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("jvm") - id("com.apollographql.apollo") + id("com.homer.apollographql.apollo") } dependencies { diff --git a/apollo-gradle-plugin/testProjects/multi-modules-diamond/node2/build.gradle.kts b/apollo-gradle-plugin/testProjects/multi-modules-diamond/node2/build.gradle.kts index 9b1e04d311a..e7c47ac0684 100644 --- a/apollo-gradle-plugin/testProjects/multi-modules-diamond/node2/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/multi-modules-diamond/node2/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("jvm") - id("com.apollographql.apollo") + id("com.homer.apollographql.apollo") } dependencies { diff --git a/apollo-gradle-plugin/testProjects/multi-modules-diamond/root/build.gradle.kts b/apollo-gradle-plugin/testProjects/multi-modules-diamond/root/build.gradle.kts index cb31b71012f..3ee22de962b 100644 --- a/apollo-gradle-plugin/testProjects/multi-modules-diamond/root/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/multi-modules-diamond/root/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("jvm") - id("com.apollographql.apollo") + id("com.homer.apollographql.apollo") id("maven-publish") } diff --git a/apollo-gradle-plugin/testProjects/multi-modules-duplicates/node1/build.gradle.kts b/apollo-gradle-plugin/testProjects/multi-modules-duplicates/node1/build.gradle.kts index 9b1e04d311a..e7c47ac0684 100644 --- a/apollo-gradle-plugin/testProjects/multi-modules-duplicates/node1/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/multi-modules-duplicates/node1/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("jvm") - id("com.apollographql.apollo") + id("com.homer.apollographql.apollo") } dependencies { diff --git a/apollo-gradle-plugin/testProjects/multi-modules-duplicates/node2/build.gradle.kts b/apollo-gradle-plugin/testProjects/multi-modules-duplicates/node2/build.gradle.kts index 9b1e04d311a..e7c47ac0684 100644 --- a/apollo-gradle-plugin/testProjects/multi-modules-duplicates/node2/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/multi-modules-duplicates/node2/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("jvm") - id("com.apollographql.apollo") + id("com.homer.apollographql.apollo") } dependencies { diff --git a/apollo-gradle-plugin/testProjects/multi-modules-duplicates/root/build.gradle.kts b/apollo-gradle-plugin/testProjects/multi-modules-duplicates/root/build.gradle.kts index cb31b71012f..3ee22de962b 100644 --- a/apollo-gradle-plugin/testProjects/multi-modules-duplicates/root/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/multi-modules-duplicates/root/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("jvm") - id("com.apollographql.apollo") + id("com.homer.apollographql.apollo") id("maven-publish") } diff --git a/apollo-gradle-plugin/testProjects/multi-modules-transitive/leaf/build.gradle.kts b/apollo-gradle-plugin/testProjects/multi-modules-transitive/leaf/build.gradle.kts index c71dc05e056..4ab909e4f5a 100644 --- a/apollo-gradle-plugin/testProjects/multi-modules-transitive/leaf/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/multi-modules-transitive/leaf/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("jvm") - id("com.apollographql.apollo") + id("com.homer.apollographql.apollo") id("application") } diff --git a/apollo-gradle-plugin/testProjects/multi-modules-transitive/node/build.gradle.kts b/apollo-gradle-plugin/testProjects/multi-modules-transitive/node/build.gradle.kts index f1ef76fd7ae..33c67e5775e 100644 --- a/apollo-gradle-plugin/testProjects/multi-modules-transitive/node/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/multi-modules-transitive/node/build.gradle.kts @@ -1,6 +1,6 @@ plugins { id("org.jetbrains.kotlin.jvm") - id("com.apollographql.apollo") + id("com.homer.apollographql.apollo") } dependencies { diff --git a/apollo-gradle-plugin/testProjects/multi-modules-transitive/root/build.gradle.kts b/apollo-gradle-plugin/testProjects/multi-modules-transitive/root/build.gradle.kts index cb31b71012f..3ee22de962b 100644 --- a/apollo-gradle-plugin/testProjects/multi-modules-transitive/root/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/multi-modules-transitive/root/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("jvm") - id("com.apollographql.apollo") + id("com.homer.apollographql.apollo") id("maven-publish") } diff --git a/apollo-gradle-plugin/testProjects/multi-modules/leaf/build.gradle.kts b/apollo-gradle-plugin/testProjects/multi-modules/leaf/build.gradle.kts index 45cbfe72dec..4cf55d5b298 100644 --- a/apollo-gradle-plugin/testProjects/multi-modules/leaf/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/multi-modules/leaf/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("jvm") - id("com.apollographql.apollo") + id("com.homer.apollographql.apollo") id("application") } diff --git a/apollo-gradle-plugin/testProjects/multi-modules/root/build.gradle.kts b/apollo-gradle-plugin/testProjects/multi-modules/root/build.gradle.kts index cb31b71012f..3ee22de962b 100644 --- a/apollo-gradle-plugin/testProjects/multi-modules/root/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/multi-modules/root/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("jvm") - id("com.apollographql.apollo") + id("com.homer.apollographql.apollo") id("maven-publish") } diff --git a/apollo-gradle-plugin/testProjects/multiplatform/build.gradle.kts b/apollo-gradle-plugin/testProjects/multiplatform/build.gradle.kts index f13ebec34c9..cbb435c3235 100644 --- a/apollo-gradle-plugin/testProjects/multiplatform/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/multiplatform/build.gradle.kts @@ -17,7 +17,7 @@ buildscript { } apply(plugin = "org.jetbrains.kotlin.multiplatform") -apply(plugin = "com.apollographql.apollo") +apply(plugin = "com.homer.apollographql.apollo") repositories { maven { diff --git a/apollo-gradle-plugin/testProjects/operationIds/build.gradle.kts b/apollo-gradle-plugin/testProjects/operationIds/build.gradle.kts index 8c5ebbee8ef..9a2464e2a76 100644 --- a/apollo-gradle-plugin/testProjects/operationIds/build.gradle.kts +++ b/apollo-gradle-plugin/testProjects/operationIds/build.gradle.kts @@ -1,7 +1,7 @@ -import com.apollographql.apollo.gradle.api.ApolloExtension -import com.apollographql.apollo.compiler.operationoutput.OperationOutput -import com.apollographql.apollo.compiler.operationoutput.OperationDescriptor -import com.apollographql.apollo.compiler.OperationOutputGenerator +import com.homer.apollographql.apollo.gradle.api.ApolloExtension +import com.homer.apollographql.apollo.compiler.operationoutput.OperationOutput +import com.homer.apollographql.apollo.compiler.operationoutput.OperationDescriptor +import com.homer.apollographql.apollo.compiler.OperationOutputGenerator buildscript { apply(from = "../../../gradle/dependencies.gradle") @@ -19,7 +19,7 @@ buildscript { } apply(plugin = "org.jetbrains.kotlin.jvm") -apply(plugin = "com.apollographql.apollo") +apply(plugin = "com.homer.apollographql.apollo") repositories { maven { diff --git a/apollo-http-cache-api/api.txt b/apollo-http-cache-api/api.txt index e706915d08f..a12a4f34efe 100644 --- a/apollo-http-cache-api/api.txt +++ b/apollo-http-cache-api/api.txt @@ -1,5 +1,5 @@ // Signature format: 3.0 -package com.apollographql.apollo.api.cache.http { +package com.homer.apollographql.apollo.api.cache.http { public interface HttpCache { method public void clear(); @@ -15,7 +15,7 @@ package com.apollographql.apollo.api.cache.http { field public static final String CACHE_KEY_HEADER = "X-APOLLO-CACHE-KEY"; field public static final String CACHE_PREFETCH_HEADER = "X-APOLLO-PREFETCH"; field public static final String CACHE_SERVED_DATE_HEADER = "X-APOLLO-SERVED-DATE"; - field public static final com.apollographql.apollo.api.cache.http.HttpCache.Companion Companion; + field public static final com.homer.apollographql.apollo.api.cache.http.HttpCache.Companion Companion; field public static final String FROM_CACHE = "X-APOLLO-FROM-CACHE"; } @@ -31,34 +31,34 @@ package com.apollographql.apollo.api.cache.http { } public final class HttpCachePolicy { - field public static final com.apollographql.apollo.api.cache.http.HttpCachePolicy.ExpirePolicy CACHE_FIRST; - field public static final com.apollographql.apollo.api.cache.http.HttpCachePolicy.ExpirePolicy CACHE_ONLY; - field public static final com.apollographql.apollo.api.cache.http.HttpCachePolicy INSTANCE; - field public static final com.apollographql.apollo.api.cache.http.HttpCachePolicy.ExpirePolicy NETWORK_FIRST; - field public static final com.apollographql.apollo.api.cache.http.HttpCachePolicy.Policy NETWORK_ONLY; + field public static final com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy.ExpirePolicy CACHE_FIRST; + field public static final com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy.ExpirePolicy CACHE_ONLY; + field public static final com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy INSTANCE; + field public static final com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy.ExpirePolicy NETWORK_FIRST; + field public static final com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy.Policy NETWORK_ONLY; } - public static final class HttpCachePolicy.ExpirePolicy extends com.apollographql.apollo.api.cache.http.HttpCachePolicy.Policy { - method public com.apollographql.apollo.api.cache.http.HttpCachePolicy.ExpirePolicy expireAfter(long expireTimeout, error.NonExistentClass expireTimeUnit); - method public com.apollographql.apollo.api.cache.http.HttpCachePolicy.ExpirePolicy expireAfterRead(); + public static final class HttpCachePolicy.ExpirePolicy extends com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy.Policy { + method public com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy.ExpirePolicy expireAfter(long expireTimeout, error.NonExistentClass expireTimeUnit); + method public com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy.ExpirePolicy expireAfterRead(); } public enum HttpCachePolicy.FetchStrategy { - method public static com.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy valueOf(String name); - method public static com.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy[] values(); - enum_constant public static final com.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy CACHE_FIRST; - enum_constant public static final com.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy CACHE_ONLY; - enum_constant public static final com.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy NETWORK_FIRST; - enum_constant public static final com.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy NETWORK_ONLY; + method public static com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy valueOf(String name); + method public static com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy[] values(); + enum_constant public static final com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy CACHE_FIRST; + enum_constant public static final com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy CACHE_ONLY; + enum_constant public static final com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy NETWORK_FIRST; + enum_constant public static final com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy NETWORK_ONLY; } public static class HttpCachePolicy.Policy { - ctor public HttpCachePolicy.Policy(com.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy fetchStrategy, long expireTimeout, error.NonExistentClass? expireTimeUnit, boolean expireAfterRead); + ctor public HttpCachePolicy.Policy(com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy fetchStrategy, long expireTimeout, error.NonExistentClass? expireTimeUnit, boolean expireAfterRead); method public final long expireTimeoutMs(); field public final boolean expireAfterRead; field public final error.NonExistentClass? expireTimeUnit; field public final long expireTimeout; - field public final com.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy fetchStrategy; + field public final com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy.FetchStrategy fetchStrategy; } public interface HttpCacheRecord { @@ -75,8 +75,8 @@ package com.apollographql.apollo.api.cache.http { } public interface HttpCacheStore { - method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public com.apollographql.apollo.api.cache.http.HttpCacheRecord? cacheRecord(String cacheKey); - method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public com.apollographql.apollo.api.cache.http.HttpCacheRecordEditor? cacheRecordEditor(String cacheKey); + method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public com.homer.apollographql.apollo.api.cache.http.HttpCacheRecord? cacheRecord(String cacheKey); + method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public com.homer.apollographql.apollo.api.cache.http.HttpCacheRecordEditor? cacheRecordEditor(String cacheKey); method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public void delete(); method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public void remove(String cacheKey); } diff --git a/apollo-http-cache-api/src/main/kotlin/com/apollographql/apollo/api/cache/http/HttpCache.kt b/apollo-http-cache-api/src/main/kotlin/com/homer/apollographql/apollo/api/cache/http/HttpCache.kt similarity index 97% rename from apollo-http-cache-api/src/main/kotlin/com/apollographql/apollo/api/cache/http/HttpCache.kt rename to apollo-http-cache-api/src/main/kotlin/com/homer/apollographql/apollo/api/cache/http/HttpCache.kt index 439a78cdb97..a957d31db2c 100644 --- a/apollo-http-cache-api/src/main/kotlin/com/apollographql/apollo/api/cache/http/HttpCache.kt +++ b/apollo-http-cache-api/src/main/kotlin/com/homer/apollographql/apollo/api/cache/http/HttpCache.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.cache.http +package com.homer.apollographql.apollo.api.cache.http import okhttp3.Interceptor import okhttp3.Response diff --git a/apollo-http-cache-api/src/main/kotlin/com/apollographql/apollo/api/cache/http/HttpCachePolicy.kt b/apollo-http-cache-api/src/main/kotlin/com/homer/apollographql/apollo/api/cache/http/HttpCachePolicy.kt similarity index 98% rename from apollo-http-cache-api/src/main/kotlin/com/apollographql/apollo/api/cache/http/HttpCachePolicy.kt rename to apollo-http-cache-api/src/main/kotlin/com/homer/apollographql/apollo/api/cache/http/HttpCachePolicy.kt index a3d961aa9a3..be868c85015 100644 --- a/apollo-http-cache-api/src/main/kotlin/com/apollographql/apollo/api/cache/http/HttpCachePolicy.kt +++ b/apollo-http-cache-api/src/main/kotlin/com/homer/apollographql/apollo/api/cache/http/HttpCachePolicy.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.cache.http +package com.homer.apollographql.apollo.api.cache.http import java.util.concurrent.TimeUnit diff --git a/apollo-http-cache-api/src/main/kotlin/com/apollographql/apollo/api/cache/http/HttpCacheRecord.kt b/apollo-http-cache-api/src/main/kotlin/com/homer/apollographql/apollo/api/cache/http/HttpCacheRecord.kt similarity index 69% rename from apollo-http-cache-api/src/main/kotlin/com/apollographql/apollo/api/cache/http/HttpCacheRecord.kt rename to apollo-http-cache-api/src/main/kotlin/com/homer/apollographql/apollo/api/cache/http/HttpCacheRecord.kt index 20c06053385..2fa03bb747f 100644 --- a/apollo-http-cache-api/src/main/kotlin/com/apollographql/apollo/api/cache/http/HttpCacheRecord.kt +++ b/apollo-http-cache-api/src/main/kotlin/com/homer/apollographql/apollo/api/cache/http/HttpCacheRecord.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.cache.http +package com.homer.apollographql.apollo.api.cache.http import okio.Source diff --git a/apollo-http-cache-api/src/main/kotlin/com/apollographql/apollo/api/cache/http/HttpCacheRecordEditor.kt b/apollo-http-cache-api/src/main/kotlin/com/homer/apollographql/apollo/api/cache/http/HttpCacheRecordEditor.kt similarity index 80% rename from apollo-http-cache-api/src/main/kotlin/com/apollographql/apollo/api/cache/http/HttpCacheRecordEditor.kt rename to apollo-http-cache-api/src/main/kotlin/com/homer/apollographql/apollo/api/cache/http/HttpCacheRecordEditor.kt index 7f9bb27e333..46f3ba2cd32 100644 --- a/apollo-http-cache-api/src/main/kotlin/com/apollographql/apollo/api/cache/http/HttpCacheRecordEditor.kt +++ b/apollo-http-cache-api/src/main/kotlin/com/homer/apollographql/apollo/api/cache/http/HttpCacheRecordEditor.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.cache.http +package com.homer.apollographql.apollo.api.cache.http import okio.Sink import java.io.IOException diff --git a/apollo-http-cache-api/src/main/kotlin/com/apollographql/apollo/api/cache/http/HttpCacheStore.kt b/apollo-http-cache-api/src/main/kotlin/com/homer/apollographql/apollo/api/cache/http/HttpCacheStore.kt similarity index 95% rename from apollo-http-cache-api/src/main/kotlin/com/apollographql/apollo/api/cache/http/HttpCacheStore.kt rename to apollo-http-cache-api/src/main/kotlin/com/homer/apollographql/apollo/api/cache/http/HttpCacheStore.kt index 0bf45d74d8c..e5739c9a80e 100644 --- a/apollo-http-cache-api/src/main/kotlin/com/apollographql/apollo/api/cache/http/HttpCacheStore.kt +++ b/apollo-http-cache-api/src/main/kotlin/com/homer/apollographql/apollo/api/cache/http/HttpCacheStore.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.api.cache.http +package com.homer.apollographql.apollo.api.cache.http import java.io.IOException diff --git a/apollo-http-cache/api.txt b/apollo-http-cache/api.txt index 047418fa698..b4a2749c8af 100644 --- a/apollo-http-cache/api.txt +++ b/apollo-http-cache/api.txt @@ -1,9 +1,9 @@ // Signature format: 3.0 -package com.apollographql.apollo.cache.http { +package com.homer.apollographql.apollo.cache.http { public final class ApolloHttpCache { ctor public ApolloHttpCache(HttpCacheStore); - ctor public ApolloHttpCache(HttpCacheStore, com.apollographql.apollo.Logger?); + ctor public ApolloHttpCache(HttpCacheStore, com.homer.apollographql.apollo.Logger?); method public void clear(); method public okhttp3.Interceptor! interceptor(); method public okhttp3.Response! read(String); @@ -14,7 +14,7 @@ package com.apollographql.apollo.cache.http { public final class DiskLruHttpCacheStore { ctor public DiskLruHttpCacheStore(File, long); - ctor public DiskLruHttpCacheStore(com.apollographql.apollo.cache.http.internal.FileSystem, File, long); + ctor public DiskLruHttpCacheStore(com.homer.apollographql.apollo.cache.http.internal.FileSystem, File, long); method public HttpCacheRecord cacheRecord(String); method public HttpCacheRecordEditor cacheRecordEditor(String); method public void delete(); diff --git a/apollo-http-cache/build.gradle.kts b/apollo-http-cache/build.gradle.kts index dd4a4bfce67..448d71870ea 100644 --- a/apollo-http-cache/build.gradle.kts +++ b/apollo-http-cache/build.gradle.kts @@ -3,7 +3,7 @@ plugins { } metalava { - hiddenPackages += setOf("com.apollographql.apollo.cache.http.internal") + hiddenPackages += setOf("com.homer.apollographql.apollo.cache.http.internal") } dependencies { diff --git a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/ApolloHttpCache.java b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/ApolloHttpCache.java similarity index 88% rename from apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/ApolloHttpCache.java rename to apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/ApolloHttpCache.java index 52da3d032df..16b104920df 100644 --- a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/ApolloHttpCache.java +++ b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/ApolloHttpCache.java @@ -1,11 +1,11 @@ -package com.apollographql.apollo.cache.http; - -import com.apollographql.apollo.Logger; -import com.apollographql.apollo.api.cache.http.HttpCache; -import com.apollographql.apollo.api.cache.http.HttpCacheRecord; -import com.apollographql.apollo.api.cache.http.HttpCacheRecordEditor; -import com.apollographql.apollo.api.cache.http.HttpCacheStore; -import com.apollographql.apollo.api.internal.ApolloLogger; +package com.homer.apollographql.apollo.cache.http; + +import com.homer.apollographql.apollo.Logger; +import com.homer.apollographql.apollo.api.cache.http.HttpCache; +import com.homer.apollographql.apollo.api.cache.http.HttpCacheRecord; +import com.homer.apollographql.apollo.api.cache.http.HttpCacheRecordEditor; +import com.homer.apollographql.apollo.api.cache.http.HttpCacheStore; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; import okhttp3.Interceptor; import okhttp3.Response; import okio.ForwardingSource; @@ -16,9 +16,9 @@ import java.io.IOException; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; -import static com.apollographql.apollo.cache.http.Utils.copyResponseBody; -import static com.apollographql.apollo.cache.http.Utils.skipStoreResponse; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.cache.http.Utils.copyResponseBody; +import static com.homer.apollographql.apollo.cache.http.Utils.skipStoreResponse; @SuppressWarnings("WeakerAccess") public final class ApolloHttpCache implements HttpCache { diff --git a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/CacheResponseBody.java b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/CacheResponseBody.java similarity index 94% rename from apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/CacheResponseBody.java rename to apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/CacheResponseBody.java index 2ee696f2fb5..cb50bfc0694 100644 --- a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/CacheResponseBody.java +++ b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/CacheResponseBody.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.cache.http; +package com.homer.apollographql.apollo.cache.http; import okhttp3.MediaType; import okhttp3.ResponseBody; diff --git a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/DiskLruHttpCacheStore.java b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/DiskLruHttpCacheStore.java similarity index 88% rename from apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/DiskLruHttpCacheStore.java rename to apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/DiskLruHttpCacheStore.java index 785d1af4d7d..5ba1d2e409b 100644 --- a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/DiskLruHttpCacheStore.java +++ b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/DiskLruHttpCacheStore.java @@ -1,10 +1,10 @@ -package com.apollographql.apollo.cache.http; +package com.homer.apollographql.apollo.cache.http; -import com.apollographql.apollo.api.cache.http.HttpCacheRecord; -import com.apollographql.apollo.api.cache.http.HttpCacheRecordEditor; -import com.apollographql.apollo.api.cache.http.HttpCacheStore; -import com.apollographql.apollo.cache.http.internal.DiskLruCache; -import com.apollographql.apollo.cache.http.internal.FileSystem; +import com.homer.apollographql.apollo.api.cache.http.HttpCacheRecord; +import com.homer.apollographql.apollo.api.cache.http.HttpCacheRecordEditor; +import com.homer.apollographql.apollo.api.cache.http.HttpCacheStore; +import com.homer.apollographql.apollo.cache.http.internal.DiskLruCache; +import com.homer.apollographql.apollo.cache.http.internal.FileSystem; import java.io.File; import java.io.IOException; import java.util.concurrent.locks.ReadWriteLock; diff --git a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/HttpCacheInterceptor.java b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/HttpCacheInterceptor.java similarity index 68% rename from apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/HttpCacheInterceptor.java rename to apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/HttpCacheInterceptor.java index 8bc71993770..5993e6d73b6 100644 --- a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/HttpCacheInterceptor.java +++ b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/HttpCacheInterceptor.java @@ -1,24 +1,24 @@ -package com.apollographql.apollo.cache.http; +package com.homer.apollographql.apollo.cache.http; -import com.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; import okhttp3.Interceptor; import okhttp3.Request; import okhttp3.Response; import java.io.IOException; -import static com.apollographql.apollo.api.cache.http.HttpCache.CACHE_KEY_HEADER; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; -import static com.apollographql.apollo.cache.http.Utils.isNetworkFirst; -import static com.apollographql.apollo.cache.http.Utils.isNetworkOnly; -import static com.apollographql.apollo.cache.http.Utils.isPrefetchResponse; -import static com.apollographql.apollo.cache.http.Utils.isStale; -import static com.apollographql.apollo.cache.http.Utils.shouldExpireAfterRead; -import static com.apollographql.apollo.cache.http.Utils.shouldSkipCache; -import static com.apollographql.apollo.cache.http.Utils.shouldSkipNetwork; -import static com.apollographql.apollo.cache.http.Utils.strip; -import static com.apollographql.apollo.cache.http.Utils.unsatisfiableCacheRequest; -import static com.apollographql.apollo.cache.http.Utils.withServedDateHeader; +import static com.homer.apollographql.apollo.api.cache.http.HttpCache.CACHE_KEY_HEADER; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.cache.http.Utils.isNetworkFirst; +import static com.homer.apollographql.apollo.cache.http.Utils.isNetworkOnly; +import static com.homer.apollographql.apollo.cache.http.Utils.isPrefetchResponse; +import static com.homer.apollographql.apollo.cache.http.Utils.isStale; +import static com.homer.apollographql.apollo.cache.http.Utils.shouldExpireAfterRead; +import static com.homer.apollographql.apollo.cache.http.Utils.shouldSkipCache; +import static com.homer.apollographql.apollo.cache.http.Utils.shouldSkipNetwork; +import static com.homer.apollographql.apollo.cache.http.Utils.strip; +import static com.homer.apollographql.apollo.cache.http.Utils.unsatisfiableCacheRequest; +import static com.homer.apollographql.apollo.cache.http.Utils.withServedDateHeader; final class HttpCacheInterceptor implements Interceptor { private final ApolloHttpCache cache; @@ -31,22 +31,22 @@ final class HttpCacheInterceptor implements Interceptor { @Override public Response intercept(Chain chain) throws IOException { Request request = chain.request(); - if (shouldSkipCache(request)) { + if (Utils.shouldSkipCache(request)) { logger.d("Skip http cache for request: %s", request); return chain.proceed(request); } - if (shouldSkipNetwork(request)) { + if (Utils.shouldSkipNetwork(request)) { logger.d("Read http cache only for request: %s", request); return cacheOnlyResponse(request); } - if (isNetworkOnly(request)) { + if (Utils.isNetworkOnly(request)) { logger.d("Skip http cache network only request: %s", request); return networkOnly(request, chain); } - if (isNetworkFirst(request)) { + if (Utils.isNetworkFirst(request)) { logger.d("Network first for request: %s", request); return networkFirst(request, chain); } else { @@ -59,19 +59,19 @@ private Response cacheOnlyResponse(Request request) throws IOException { Response cacheResponse = cachedResponse(request); if (cacheResponse == null) { logCacheMiss(request); - return unsatisfiableCacheRequest(request); + return Utils.unsatisfiableCacheRequest(request); } logCacheHit(request); return cacheResponse.newBuilder() - .cacheResponse(strip(cacheResponse)) + .cacheResponse(Utils.strip(cacheResponse)) .build(); } private Response networkOnly(Request request, Chain chain) throws IOException { String cacheKey = request.header(CACHE_KEY_HEADER); - Response networkResponse = withServedDateHeader(chain.proceed(request)); - if (isPrefetchResponse(request)) { + Response networkResponse = Utils.withServedDateHeader(chain.proceed(request)); + if (Utils.isPrefetchResponse(request)) { return prefetch(networkResponse, cacheKey); } else if (networkResponse.isSuccessful()) { logger.d("Network success, skip http cache for request: %s, with cache key: %s", request, cacheKey); @@ -86,7 +86,7 @@ private Response networkFirst(Request request, Chain chain) throws IOException { IOException rethrowException; Response networkResponse = null; try { - networkResponse = withServedDateHeader(chain.proceed(request)); + networkResponse = Utils.withServedDateHeader(chain.proceed(request)); if (networkResponse.isSuccessful()) { logger.d("Network success, skip http cache for request: %s, with cache key: %s", request, cacheKey); return cache.cacheProxy(networkResponse, cacheKey); @@ -107,8 +107,8 @@ private Response networkFirst(Request request, Chain chain) throws IOException { logCacheHit(request); return cachedResponse.newBuilder() - .cacheResponse(strip(cachedResponse)) - .networkResponse(strip(networkResponse)) + .cacheResponse(Utils.strip(cachedResponse)) + .networkResponse(Utils.strip(networkResponse)) .request(request) .build(); } @@ -118,7 +118,7 @@ private Response cacheFirst(Request request, Chain chain) throws IOException { if (cachedResponse != null) { logCacheHit(request); return cachedResponse.newBuilder() - .cacheResponse(strip(cachedResponse)) + .cacheResponse(Utils.strip(cachedResponse)) .request(request) .build(); } @@ -126,8 +126,8 @@ private Response cacheFirst(Request request, Chain chain) throws IOException { logCacheMiss(request); String cacheKey = request.header(CACHE_KEY_HEADER); - Response networkResponse = withServedDateHeader(chain.proceed(request)); - if (isPrefetchResponse(request)) { + Response networkResponse = Utils.withServedDateHeader(chain.proceed(request)); + if (Utils.isPrefetchResponse(request)) { return prefetch(networkResponse, cacheKey); } else if (networkResponse.isSuccessful()) { return cache.cacheProxy(networkResponse, cacheKey); @@ -153,19 +153,19 @@ private Response prefetch(Response networkResponse, String cacheKey) throws IOEx return cachedResponse .newBuilder() - .networkResponse(strip(networkResponse)) + .networkResponse(Utils.strip(networkResponse)) .build(); } private Response cachedResponse(Request request) { String cacheKey = request.header(CACHE_KEY_HEADER); - Response cachedResponse = cache.read(cacheKey, shouldExpireAfterRead(request)); + Response cachedResponse = cache.read(cacheKey, Utils.shouldExpireAfterRead(request)); if (cachedResponse == null) { return null; } - if (isStale(request, cachedResponse)) { + if (Utils.isStale(request, cachedResponse)) { Utils.closeQuietly(cachedResponse); return null; } diff --git a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/ResponseBodyCacheSink.java b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/ResponseBodyCacheSink.java similarity index 96% rename from apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/ResponseBodyCacheSink.java rename to apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/ResponseBodyCacheSink.java index 583e41a44da..39eba374208 100644 --- a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/ResponseBodyCacheSink.java +++ b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/ResponseBodyCacheSink.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.cache.http; +package com.homer.apollographql.apollo.cache.http; import java.io.IOException; diff --git a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/ResponseBodyProxy.java b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/ResponseBodyProxy.java similarity index 84% rename from apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/ResponseBodyProxy.java rename to apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/ResponseBodyProxy.java index 051dd3faa82..16edffb8a6c 100644 --- a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/ResponseBodyProxy.java +++ b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/ResponseBodyProxy.java @@ -1,7 +1,7 @@ -package com.apollographql.apollo.cache.http; +package com.homer.apollographql.apollo.cache.http; -import com.apollographql.apollo.api.cache.http.HttpCacheRecordEditor; -import com.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.api.cache.http.HttpCacheRecordEditor; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; import okhttp3.MediaType; import okhttp3.Response; import okhttp3.ResponseBody; @@ -14,9 +14,9 @@ import java.io.IOException; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; -import static com.apollographql.apollo.cache.http.Utils.closeQuietly; -import static com.apollographql.apollo.cache.http.Utils.discard; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.cache.http.Utils.closeQuietly; +import static com.homer.apollographql.apollo.cache.http.Utils.discard; import static java.util.concurrent.TimeUnit.MILLISECONDS; final class ResponseBodyProxy extends ResponseBody { @@ -103,7 +103,7 @@ private static class ProxySource implements Source { if (closed) return; closed = true; - if (discard(this, 100, MILLISECONDS)) { + if (Utils.discard(this, 100, MILLISECONDS)) { commitCache(); } else { abortCacheQuietly(); @@ -111,20 +111,20 @@ private static class ProxySource implements Source { } private void commitCache() { - closeQuietly(responseBodySource); + Utils.closeQuietly(responseBodySource); try { responseBodyCacheSink.close(); cacheRecordEditor.commit(); } catch (Exception e) { - closeQuietly(responseBodyCacheSink); + Utils.closeQuietly(responseBodyCacheSink); abortCacheQuietly(); logger.e(e, "Failed to commit cache changes"); } } void abortCacheQuietly() { - closeQuietly(responseBodySource); - closeQuietly(responseBodyCacheSink); + Utils.closeQuietly(responseBodySource); + Utils.closeQuietly(responseBodyCacheSink); try { cacheRecordEditor.abort(); } catch (Exception e) { diff --git a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/ResponseHeaderRecord.java b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/ResponseHeaderRecord.java similarity index 98% rename from apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/ResponseHeaderRecord.java rename to apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/ResponseHeaderRecord.java index c9354e31d1c..9a5325843ad 100644 --- a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/ResponseHeaderRecord.java +++ b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/ResponseHeaderRecord.java @@ -13,9 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.apollographql.apollo.cache.http; +package com.homer.apollographql.apollo.cache.http; -import com.apollographql.apollo.cache.http.internal.StatusLine; +import com.homer.apollographql.apollo.cache.http.internal.StatusLine; import java.io.IOException; import java.security.cert.Certificate; import java.security.cert.CertificateEncodingException; @@ -42,7 +42,6 @@ import okio.Sink; import okio.Source; -import static com.apollographql.apollo.cache.http.Utils.varyHeaders; /** * Class was copied and modified from {@link okhttp3.Cache.Entry} @@ -169,7 +168,7 @@ final class ResponseHeaderRecord { ResponseHeaderRecord(Response response) { this.url = response.request().url().toString(); - this.varyHeaders = varyHeaders(response); + this.varyHeaders = Utils.varyHeaders(response); this.requestMethod = response.request().method(); this.protocol = response.protocol(); this.code = response.code(); diff --git a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/Utils.java b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/Utils.java similarity index 90% rename from apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/Utils.java rename to apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/Utils.java index 1492e5becf8..430f622a742 100644 --- a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/Utils.java +++ b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/Utils.java @@ -1,7 +1,7 @@ -package com.apollographql.apollo.cache.http; +package com.homer.apollographql.apollo.cache.http; -import com.apollographql.apollo.api.cache.http.HttpCachePolicy; -import com.apollographql.apollo.cache.http.internal.HttpDate; +import com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy; +import com.homer.apollographql.apollo.cache.http.internal.HttpDate; import java.io.Closeable; import java.io.IOException; import java.io.InterruptedIOException; @@ -22,13 +22,13 @@ import okio.Sink; import okio.Source; -import static com.apollographql.apollo.api.cache.http.HttpCache.CACHE_DO_NOT_STORE; -import static com.apollographql.apollo.api.cache.http.HttpCache.CACHE_EXPIRE_AFTER_READ_HEADER; -import static com.apollographql.apollo.api.cache.http.HttpCache.CACHE_EXPIRE_TIMEOUT_HEADER; -import static com.apollographql.apollo.api.cache.http.HttpCache.CACHE_FETCH_STRATEGY_HEADER; -import static com.apollographql.apollo.api.cache.http.HttpCache.CACHE_KEY_HEADER; -import static com.apollographql.apollo.api.cache.http.HttpCache.CACHE_PREFETCH_HEADER; -import static com.apollographql.apollo.api.cache.http.HttpCache.CACHE_SERVED_DATE_HEADER; +import static com.homer.apollographql.apollo.api.cache.http.HttpCache.CACHE_DO_NOT_STORE; +import static com.homer.apollographql.apollo.api.cache.http.HttpCache.CACHE_EXPIRE_AFTER_READ_HEADER; +import static com.homer.apollographql.apollo.api.cache.http.HttpCache.CACHE_EXPIRE_TIMEOUT_HEADER; +import static com.homer.apollographql.apollo.api.cache.http.HttpCache.CACHE_FETCH_STRATEGY_HEADER; +import static com.homer.apollographql.apollo.api.cache.http.HttpCache.CACHE_KEY_HEADER; +import static com.homer.apollographql.apollo.api.cache.http.HttpCache.CACHE_PREFETCH_HEADER; +import static com.homer.apollographql.apollo.api.cache.http.HttpCache.CACHE_SERVED_DATE_HEADER; final class Utils { private static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; diff --git a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/internal/DiskLruCache.java b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/internal/DiskLruCache.java similarity index 99% rename from apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/internal/DiskLruCache.java rename to apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/internal/DiskLruCache.java index 5c09c8cf448..cefeadccfd6 100644 --- a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/internal/DiskLruCache.java +++ b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/internal/DiskLruCache.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.apollographql.apollo.cache.http.internal; +package com.homer.apollographql.apollo.cache.http.internal; import java.io.Closeable; import java.io.EOFException; diff --git a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/internal/FaultHidingSink.java b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/internal/FaultHidingSink.java similarity index 96% rename from apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/internal/FaultHidingSink.java rename to apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/internal/FaultHidingSink.java index 2a37b72c374..5ef68dee038 100644 --- a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/internal/FaultHidingSink.java +++ b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/internal/FaultHidingSink.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.apollographql.apollo.cache.http.internal; +package com.homer.apollographql.apollo.cache.http.internal; import java.io.IOException; import okio.Buffer; diff --git a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/internal/FileSystem.java b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/internal/FileSystem.java similarity index 98% rename from apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/internal/FileSystem.java rename to apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/internal/FileSystem.java index c528cbd89d1..86ded7683c5 100644 --- a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/internal/FileSystem.java +++ b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/internal/FileSystem.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.apollographql.apollo.cache.http.internal; +package com.homer.apollographql.apollo.cache.http.internal; import java.io.File; import java.io.FileNotFoundException; diff --git a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/internal/HttpDate.java b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/internal/HttpDate.java similarity index 98% rename from apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/internal/HttpDate.java rename to apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/internal/HttpDate.java index a94071b1dff..7a2e3943f9f 100644 --- a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/internal/HttpDate.java +++ b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/internal/HttpDate.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.apollographql.apollo.cache.http.internal; +package com.homer.apollographql.apollo.cache.http.internal; import java.text.DateFormat; import java.text.ParsePosition; diff --git a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/internal/StatusLine.java b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/internal/StatusLine.java similarity index 98% rename from apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/internal/StatusLine.java rename to apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/internal/StatusLine.java index 83a43ad0dde..c974cb7061d 100644 --- a/apollo-http-cache/src/main/java/com/apollographql/apollo/cache/http/internal/StatusLine.java +++ b/apollo-http-cache/src/main/java/com/homer/apollographql/apollo/cache/http/internal/StatusLine.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.apollographql.apollo.cache.http.internal; +package com.homer.apollographql.apollo.cache.http.internal; import java.io.IOException; import java.net.ProtocolException; diff --git a/apollo-http-cache/src/test/java/com/apollographql/apollo/cache/http/internal/DiskLruCacheTest.java b/apollo-http-cache/src/test/java/com/apollographql/apollo/cache/http/internal/DiskLruCacheTest.java deleted file mode 100644 index a2c0708e980..00000000000 --- a/apollo-http-cache/src/test/java/com/apollographql/apollo/cache/http/internal/DiskLruCacheTest.java +++ /dev/null @@ -1,1819 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.apollographql.apollo.cache.http.internal; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Deque; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.concurrent.Executor; -import okio.BufferedSink; -import okio.BufferedSource; -import okio.Okio; -import okio.Source; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.junit.rules.Timeout; - -import static com.google.common.truth.Truth.assertThat; -import static com.apollographql.apollo.cache.http.internal.DiskLruCache.JOURNAL_FILE; -import static com.apollographql.apollo.cache.http.internal.DiskLruCache.JOURNAL_FILE_BACKUP; -import static com.apollographql.apollo.cache.http.internal.DiskLruCache.MAGIC; -import static com.apollographql.apollo.cache.http.internal.DiskLruCache.VERSION_1; -import static org.junit.Assert.fail; - -/** - * Copied from OkHttp 3.14.2: - * https://github.com/square/okhttp/blob/b8b6ee831c65208940c741f8e091ff02425566d5/okhttp-tests - * /src/test/java/okhttp3/internal/cache/DiskLruCacheTest.java - */ -public final class DiskLruCacheTest { - @Rule public final TemporaryFolder tempDir = new TemporaryFolder(); - @Rule public final Timeout timeout = new Timeout(60 * 1000); - - private final FaultyFileSystem fileSystem = new FaultyFileSystem(FileSystem.SYSTEM); - private final int appVersion = 100; - private File cacheDir; - private File journalFile; - private File journalBkpFile; - private final TestExecutor executor = new TestExecutor(); - - private DiskLruCache cache; - private final Deque toClose = new ArrayDeque<>(); - - private void createNewCache() throws IOException { - createNewCacheWithSize(Integer.MAX_VALUE); - } - - private void createNewCacheWithSize(int maxSize) throws IOException { - cache = new DiskLruCache(fileSystem, cacheDir, appVersion, 2, maxSize, executor); - synchronized (cache) { - cache.initialize(); - } - toClose.add(cache); - } - - @Before public void setUp() throws Exception { - cacheDir = tempDir.getRoot(); - journalFile = new File(cacheDir, JOURNAL_FILE); - journalBkpFile = new File(cacheDir, JOURNAL_FILE_BACKUP); - createNewCache(); - } - - @After public void tearDown() throws Exception { - while (!toClose.isEmpty()) { - toClose.pop().close(); - } - } - - @Test public void emptyCache() throws Exception { - cache.close(); - assertJournalEquals(); - } - - @Test public void recoverFromInitializationFailure() throws IOException { - // Add an uncommitted entry. This will get detected on initialization, and the cache will - // attempt to delete the file. Do not explicitly close the cache here so the entry is left as - // incomplete. - DiskLruCache.Editor creator = cache.edit("k1"); - BufferedSink sink = Okio.buffer(creator.newSink(0)); - sink.writeUtf8("Hello"); - sink.close(); - - // Simulate a severe filesystem failure on the first initialization. - fileSystem.setFaultyDelete(new File(cacheDir, "k1.0.tmp"), true); - fileSystem.setFaultyDelete(cacheDir, true); - - cache = new DiskLruCache(fileSystem, cacheDir, appVersion, 2, Integer.MAX_VALUE, executor); - toClose.add(cache); - - try { - cache.get("k1"); - fail(); - } catch (IOException expected) { - } - - // Now let it operate normally. - fileSystem.setFaultyDelete(new File(cacheDir, "k1.0.tmp"), false); - fileSystem.setFaultyDelete(cacheDir, false); - - DiskLruCache.Snapshot snapshot = cache.get("k1"); - assertThat(snapshot).isNull(); - } - - @Test public void validateKey() throws Exception { - String key = null; - try { - key = "has_space "; - cache.edit(key); - fail("Expecting an IllegalArgumentException as the key was invalid."); - } catch (IllegalArgumentException iae) { - assertThat(iae.getMessage()).isEqualTo( - ("keys must match regex [a-z0-9_-]{1,120}: \"" + key + "\"")); - } - try { - key = "has_CR\r"; - cache.edit(key); - fail("Expecting an IllegalArgumentException as the key was invalid."); - } catch (IllegalArgumentException iae) { - assertThat(iae.getMessage()).isEqualTo( - ("keys must match regex [a-z0-9_-]{1,120}: \"" + key + "\"")); - } - try { - key = "has_LF\n"; - cache.edit(key); - fail("Expecting an IllegalArgumentException as the key was invalid."); - } catch (IllegalArgumentException iae) { - assertThat(iae.getMessage()).isEqualTo( - ("keys must match regex [a-z0-9_-]{1,120}: \"" + key + "\"")); - } - try { - key = "has_invalid/"; - cache.edit(key); - fail("Expecting an IllegalArgumentException as the key was invalid."); - } catch (IllegalArgumentException iae) { - assertThat(iae.getMessage()).isEqualTo( - ("keys must match regex [a-z0-9_-]{1,120}: \"" + key + "\"")); - } - try { - key = "has_invalid\u2603"; - cache.edit(key); - fail("Expecting an IllegalArgumentException as the key was invalid."); - } catch (IllegalArgumentException iae) { - assertThat(iae.getMessage()).isEqualTo( - ("keys must match regex [a-z0-9_-]{1,120}: \"" + key + "\"")); - } - try { - key = "this_is_way_too_long_this_is_way_too_long_this_is_way_too_long_" - + "this_is_way_too_long_this_is_way_too_long_this_is_way_too_long"; - cache.edit(key); - fail("Expecting an IllegalArgumentException as the key was too long."); - } catch (IllegalArgumentException iae) { - assertThat(iae.getMessage()).isEqualTo( - ("keys must match regex [a-z0-9_-]{1,120}: \"" + key + "\"")); - } - - // Test valid cases. - - // Exactly 120. - key = "0123456789012345678901234567890123456789012345678901234567890123456789" - + "01234567890123456789012345678901234567890123456789"; - cache.edit(key).abort(); - // Contains all valid characters. - key = "abcdefghijklmnopqrstuvwxyz_0123456789"; - cache.edit(key).abort(); - // Contains dash. - key = "-20384573948576"; - cache.edit(key).abort(); - } - - @Test public void writeAndReadEntry() throws Exception { - DiskLruCache.Editor creator = cache.edit("k1"); - setString(creator, 0, "ABC"); - setString(creator, 1, "DE"); - assertThat(creator.newSource(0)).isNull(); - assertThat(creator.newSource(1)).isNull(); - creator.commit(); - - DiskLruCache.Snapshot snapshot = cache.get("k1"); - assertSnapshotValue(snapshot, 0, "ABC"); - assertSnapshotValue(snapshot, 1, "DE"); - } - - @Test public void readAndWriteEntryAcrossCacheOpenAndClose() throws Exception { - DiskLruCache.Editor creator = cache.edit("k1"); - setString(creator, 0, "A"); - setString(creator, 1, "B"); - creator.commit(); - cache.close(); - - createNewCache(); - DiskLruCache.Snapshot snapshot = cache.get("k1"); - assertSnapshotValue(snapshot, 0, "A"); - assertSnapshotValue(snapshot, 1, "B"); - snapshot.close(); - } - - @Test public void readAndWriteEntryWithoutProperClose() throws Exception { - DiskLruCache.Editor creator = cache.edit("k1"); - setString(creator, 0, "A"); - setString(creator, 1, "B"); - creator.commit(); - - // Simulate a dirty close of 'cache' by opening the cache directory again. - createNewCache(); - DiskLruCache.Snapshot snapshot = cache.get("k1"); - assertSnapshotValue(snapshot, 0, "A"); - assertSnapshotValue(snapshot, 1, "B"); - snapshot.close(); - } - - @Test public void journalWithEditAndPublish() throws Exception { - DiskLruCache.Editor creator = cache.edit("k1"); - assertJournalEquals("DIRTY k1"); // DIRTY must always be flushed. - setString(creator, 0, "AB"); - setString(creator, 1, "C"); - creator.commit(); - cache.close(); - assertJournalEquals("DIRTY k1", "CLEAN k1 2 1"); - } - - @Test public void revertedNewFileIsRemoveInJournal() throws Exception { - DiskLruCache.Editor creator = cache.edit("k1"); - assertJournalEquals("DIRTY k1"); // DIRTY must always be flushed. - setString(creator, 0, "AB"); - setString(creator, 1, "C"); - creator.abort(); - cache.close(); - assertJournalEquals("DIRTY k1", "REMOVE k1"); - } - - @Test public void unterminatedEditIsRevertedOnClose() throws Exception { - cache.edit("k1"); - cache.close(); - assertJournalEquals("DIRTY k1", "REMOVE k1"); - } - - @Test public void journalDoesNotIncludeReadOfYetUnpublishedValue() throws Exception { - DiskLruCache.Editor creator = cache.edit("k1"); - assertThat(cache.get("k1")).isNull(); - setString(creator, 0, "A"); - setString(creator, 1, "BC"); - creator.commit(); - cache.close(); - assertJournalEquals("DIRTY k1", "CLEAN k1 1 2"); - } - - @Test public void journalWithEditAndPublishAndRead() throws Exception { - DiskLruCache.Editor k1Creator = cache.edit("k1"); - setString(k1Creator, 0, "AB"); - setString(k1Creator, 1, "C"); - k1Creator.commit(); - DiskLruCache.Editor k2Creator = cache.edit("k2"); - setString(k2Creator, 0, "DEF"); - setString(k2Creator, 1, "G"); - k2Creator.commit(); - DiskLruCache.Snapshot k1Snapshot = cache.get("k1"); - k1Snapshot.close(); - cache.close(); - assertJournalEquals("DIRTY k1", "CLEAN k1 2 1", "DIRTY k2", "CLEAN k2 3 1", "READ k1"); - } - - @Test public void cannotOperateOnEditAfterPublish() throws Exception { - DiskLruCache.Editor editor = cache.edit("k1"); - setString(editor, 0, "A"); - setString(editor, 1, "B"); - editor.commit(); - assertInoperable(editor); - } - - @Test public void cannotOperateOnEditAfterRevert() throws Exception { - DiskLruCache.Editor editor = cache.edit("k1"); - setString(editor, 0, "A"); - setString(editor, 1, "B"); - editor.abort(); - assertInoperable(editor); - } - - @Test public void explicitRemoveAppliedToDiskImmediately() throws Exception { - DiskLruCache.Editor editor = cache.edit("k1"); - setString(editor, 0, "ABC"); - setString(editor, 1, "B"); - editor.commit(); - File k1 = getCleanFile("k1", 0); - assertThat(readFile(k1)).isEqualTo("ABC"); - cache.remove("k1"); - assertThat(fileSystem.exists(k1)).isFalse(); - } - - @Test public void removePreventsActiveEditFromStoringAValue() throws Exception { - set("a", "a", "a"); - DiskLruCache.Editor a = cache.edit("a"); - setString(a, 0, "a1"); - assertThat(cache.remove("a")).isTrue(); - setString(a, 1, "a2"); - a.commit(); - assertAbsent("a"); - } - - /** - * Each read sees a snapshot of the file at the time read was called. This means that two reads of - * the same key can see different data. - */ - @Test public void readAndWriteOverlapsMaintainConsistency() throws Exception { - DiskLruCache.Editor v1Creator = cache.edit("k1"); - setString(v1Creator, 0, "AAaa"); - setString(v1Creator, 1, "BBbb"); - v1Creator.commit(); - - DiskLruCache.Snapshot snapshot1 = cache.get("k1"); - BufferedSource inV1 = Okio.buffer(snapshot1.getSource(0)); - assertThat(inV1.readByte()).isEqualTo((byte) 'A'); - assertThat(inV1.readByte()).isEqualTo((byte) 'A'); - - DiskLruCache.Editor v1Updater = cache.edit("k1"); - setString(v1Updater, 0, "CCcc"); - setString(v1Updater, 1, "DDdd"); - v1Updater.commit(); - - DiskLruCache.Snapshot snapshot2 = cache.get("k1"); - assertSnapshotValue(snapshot2, 0, "CCcc"); - assertSnapshotValue(snapshot2, 1, "DDdd"); - snapshot2.close(); - - assertThat(inV1.readByte()).isEqualTo((byte) 'a'); - assertThat(inV1.readByte()).isEqualTo((byte) 'a'); - assertSnapshotValue(snapshot1, 1, "BBbb"); - snapshot1.close(); - } - - @Test public void openWithDirtyKeyDeletesAllFilesForThatKey() throws Exception { - cache.close(); - File cleanFile0 = getCleanFile("k1", 0); - File cleanFile1 = getCleanFile("k1", 1); - File dirtyFile0 = getDirtyFile("k1", 0); - File dirtyFile1 = getDirtyFile("k1", 1); - writeFile(cleanFile0, "A"); - writeFile(cleanFile1, "B"); - writeFile(dirtyFile0, "C"); - writeFile(dirtyFile1, "D"); - createJournal("CLEAN k1 1 1", "DIRTY k1"); - createNewCache(); - assertThat(fileSystem.exists(cleanFile0)).isFalse(); - assertThat(fileSystem.exists(cleanFile1)).isFalse(); - assertThat(fileSystem.exists(dirtyFile0)).isFalse(); - assertThat(fileSystem.exists(dirtyFile1)).isFalse(); - assertThat(cache.get("k1")).isNull(); - } - - @Test public void openWithInvalidVersionClearsDirectory() throws Exception { - cache.close(); - generateSomeGarbageFiles(); - createJournalWithHeader(MAGIC, "0", "100", "2", ""); - createNewCache(); - assertGarbageFilesAllDeleted(); - } - - @Test public void openWithInvalidAppVersionClearsDirectory() throws Exception { - cache.close(); - generateSomeGarbageFiles(); - createJournalWithHeader(MAGIC, "1", "101", "2", ""); - createNewCache(); - assertGarbageFilesAllDeleted(); - } - - @Test public void openWithInvalidValueCountClearsDirectory() throws Exception { - cache.close(); - generateSomeGarbageFiles(); - createJournalWithHeader(MAGIC, "1", "100", "1", ""); - createNewCache(); - assertGarbageFilesAllDeleted(); - } - - @Test public void openWithInvalidBlankLineClearsDirectory() throws Exception { - cache.close(); - generateSomeGarbageFiles(); - createJournalWithHeader(MAGIC, "1", "100", "2", "x"); - createNewCache(); - assertGarbageFilesAllDeleted(); - } - - @Test public void openWithInvalidJournalLineClearsDirectory() throws Exception { - cache.close(); - generateSomeGarbageFiles(); - createJournal("CLEAN k1 1 1", "BOGUS"); - createNewCache(); - assertGarbageFilesAllDeleted(); - assertThat(cache.get("k1")).isNull(); - } - - @Test public void openWithInvalidFileSizeClearsDirectory() throws Exception { - cache.close(); - generateSomeGarbageFiles(); - createJournal("CLEAN k1 0000x001 1"); - createNewCache(); - assertGarbageFilesAllDeleted(); - assertThat(cache.get("k1")).isNull(); - } - - @Test public void openWithTruncatedLineDiscardsThatLine() throws Exception { - cache.close(); - writeFile(getCleanFile("k1", 0), "A"); - writeFile(getCleanFile("k1", 1), "B"); - - BufferedSink sink = Okio.buffer(fileSystem.sink(journalFile)); - sink.writeUtf8(MAGIC + "\n" + VERSION_1 + "\n100\n2\n\nCLEAN k1 1 1"); // no trailing newline - sink.close(); - createNewCache(); - assertThat(cache.get("k1")).isNull(); - - // The journal is not corrupt when editing after a truncated line. - set("k1", "C", "D"); - - cache.close(); - createNewCache(); - assertValue("k1", "C", "D"); - } - - @Test public void openWithTooManyFileSizesClearsDirectory() throws Exception { - cache.close(); - generateSomeGarbageFiles(); - createJournal("CLEAN k1 1 1 1"); - createNewCache(); - assertGarbageFilesAllDeleted(); - assertThat(cache.get("k1")).isNull(); - } - - @Test public void keyWithSpaceNotPermitted() throws Exception { - try { - cache.edit("my key"); - fail(); - } catch (IllegalArgumentException expected) { - } - } - - @Test public void keyWithNewlineNotPermitted() throws Exception { - try { - cache.edit("my\nkey"); - fail(); - } catch (IllegalArgumentException expected) { - } - } - - @Test public void keyWithCarriageReturnNotPermitted() throws Exception { - try { - cache.edit("my\rkey"); - fail(); - } catch (IllegalArgumentException expected) { - } - } - - @Test public void nullKeyThrows() throws Exception { - try { - cache.edit(null); - fail(); - } catch (NullPointerException expected) { - } - } - - @Test public void createNewEntryWithTooFewValuesFails() throws Exception { - DiskLruCache.Editor creator = cache.edit("k1"); - setString(creator, 1, "A"); - try { - creator.commit(); - fail(); - } catch (IllegalStateException expected) { - } - - assertThat(fileSystem.exists(getCleanFile("k1", 0))).isFalse(); - assertThat(fileSystem.exists(getCleanFile("k1", 1))).isFalse(); - assertThat(fileSystem.exists(getDirtyFile("k1", 0))).isFalse(); - assertThat(fileSystem.exists(getDirtyFile("k1", 1))).isFalse(); - assertThat(cache.get("k1")).isNull(); - - DiskLruCache.Editor creator2 = cache.edit("k1"); - setString(creator2, 0, "B"); - setString(creator2, 1, "C"); - creator2.commit(); - } - - @Test public void revertWithTooFewValues() throws Exception { - DiskLruCache.Editor creator = cache.edit("k1"); - setString(creator, 1, "A"); - creator.abort(); - assertThat(fileSystem.exists(getCleanFile("k1", 0))).isFalse(); - assertThat(fileSystem.exists(getCleanFile("k1", 1))).isFalse(); - assertThat(fileSystem.exists(getDirtyFile("k1", 0))).isFalse(); - assertThat(fileSystem.exists(getDirtyFile("k1", 1))).isFalse(); - assertThat(cache.get("k1")).isNull(); - } - - @Test public void updateExistingEntryWithTooFewValuesReusesPreviousValues() throws Exception { - DiskLruCache.Editor creator = cache.edit("k1"); - setString(creator, 0, "A"); - setString(creator, 1, "B"); - creator.commit(); - - DiskLruCache.Editor updater = cache.edit("k1"); - setString(updater, 0, "C"); - updater.commit(); - - DiskLruCache.Snapshot snapshot = cache.get("k1"); - assertSnapshotValue(snapshot, 0, "C"); - assertSnapshotValue(snapshot, 1, "B"); - snapshot.close(); - } - - @Test public void growMaxSize() throws Exception { - cache.close(); - createNewCacheWithSize(10); - set("a", "a", "aaa"); // size 4 - set("b", "bb", "bbbb"); // size 6 - cache.setMaxSize(20); - set("c", "c", "c"); // size 12 - assertThat(cache.size()).isEqualTo(12); - } - - @Test public void shrinkMaxSizeEvicts() throws Exception { - cache.close(); - createNewCacheWithSize(20); - set("a", "a", "aaa"); // size 4 - set("b", "bb", "bbbb"); // size 6 - set("c", "c", "c"); // size 12 - cache.setMaxSize(10); - assertThat(executor.jobs.size()).isEqualTo(1); - } - - @Test public void evictOnInsert() throws Exception { - cache.close(); - createNewCacheWithSize(10); - - set("a", "a", "aaa"); // size 4 - set("b", "bb", "bbbb"); // size 6 - assertThat(cache.size()).isEqualTo(10); - - // Cause the size to grow to 12 should evict 'A'. - set("c", "c", "c"); - cache.flush(); - assertThat(cache.size()).isEqualTo(8); - assertAbsent("a"); - assertValue("b", "bb", "bbbb"); - assertValue("c", "c", "c"); - - // Causing the size to grow to 10 should evict nothing. - set("d", "d", "d"); - cache.flush(); - assertThat(cache.size()).isEqualTo(10); - assertAbsent("a"); - assertValue("b", "bb", "bbbb"); - assertValue("c", "c", "c"); - assertValue("d", "d", "d"); - - // Causing the size to grow to 18 should evict 'B' and 'C'. - set("e", "eeee", "eeee"); - cache.flush(); - assertThat(cache.size()).isEqualTo(10); - assertAbsent("a"); - assertAbsent("b"); - assertAbsent("c"); - assertValue("d", "d", "d"); - assertValue("e", "eeee", "eeee"); - } - - @Test public void evictOnUpdate() throws Exception { - cache.close(); - createNewCacheWithSize(10); - - set("a", "a", "aa"); // size 3 - set("b", "b", "bb"); // size 3 - set("c", "c", "cc"); // size 3 - assertThat(cache.size()).isEqualTo(9); - - // Causing the size to grow to 11 should evict 'A'. - set("b", "b", "bbbb"); - cache.flush(); - assertThat(cache.size()).isEqualTo(8); - assertAbsent("a"); - assertValue("b", "b", "bbbb"); - assertValue("c", "c", "cc"); - } - - @Test public void evictionHonorsLruFromCurrentSession() throws Exception { - cache.close(); - createNewCacheWithSize(10); - set("a", "a", "a"); - set("b", "b", "b"); - set("c", "c", "c"); - set("d", "d", "d"); - set("e", "e", "e"); - cache.get("b").close(); // 'B' is now least recently used. - - // Causing the size to grow to 12 should evict 'A'. - set("f", "f", "f"); - // Causing the size to grow to 12 should evict 'C'. - set("g", "g", "g"); - cache.flush(); - assertThat(cache.size()).isEqualTo(10); - assertAbsent("a"); - assertValue("b", "b", "b"); - assertAbsent("c"); - assertValue("d", "d", "d"); - assertValue("e", "e", "e"); - assertValue("f", "f", "f"); - } - - @Test public void evictionHonorsLruFromPreviousSession() throws Exception { - set("a", "a", "a"); - set("b", "b", "b"); - set("c", "c", "c"); - set("d", "d", "d"); - set("e", "e", "e"); - set("f", "f", "f"); - cache.get("b").close(); // 'B' is now least recently used. - assertThat(cache.size()).isEqualTo(12); - cache.close(); - createNewCacheWithSize(10); - - set("g", "g", "g"); - cache.flush(); - assertThat(cache.size()).isEqualTo(10); - assertAbsent("a"); - assertValue("b", "b", "b"); - assertAbsent("c"); - assertValue("d", "d", "d"); - assertValue("e", "e", "e"); - assertValue("f", "f", "f"); - assertValue("g", "g", "g"); - } - - @Test public void cacheSingleEntryOfSizeGreaterThanMaxSize() throws Exception { - cache.close(); - createNewCacheWithSize(10); - set("a", "aaaaa", "aaaaaa"); // size=11 - cache.flush(); - assertAbsent("a"); - } - - @Test public void cacheSingleValueOfSizeGreaterThanMaxSize() throws Exception { - cache.close(); - createNewCacheWithSize(10); - set("a", "aaaaaaaaaaa", "a"); // size=12 - cache.flush(); - assertAbsent("a"); - } - - @Test public void constructorDoesNotAllowZeroCacheSize() throws Exception { - try { - DiskLruCache.create(fileSystem, cacheDir, appVersion, 2, 0); - fail(); - } catch (IllegalArgumentException expected) { - } - } - - @Test public void constructorDoesNotAllowZeroValuesPerEntry() throws Exception { - try { - DiskLruCache.create(fileSystem, cacheDir, appVersion, 0, 10); - fail(); - } catch (IllegalArgumentException expected) { - } - } - - @Test public void removeAbsentElement() throws Exception { - cache.remove("a"); - } - - @Test public void readingTheSameStreamMultipleTimes() throws Exception { - set("a", "a", "b"); - DiskLruCache.Snapshot snapshot = cache.get("a"); - assertThat(snapshot.getSource(0)).isSameAs(snapshot.getSource(0)); - snapshot.close(); - } - - @Test public void rebuildJournalOnRepeatedReads() throws Exception { - set("a", "a", "a"); - set("b", "b", "b"); - while (executor.jobs.isEmpty()) { - assertValue("a", "a", "a"); - assertValue("b", "b", "b"); - } - } - - @Test public void rebuildJournalOnRepeatedEdits() throws Exception { - while (executor.jobs.isEmpty()) { - set("a", "a", "a"); - set("b", "b", "b"); - } - executor.jobs.removeFirst().run(); - - // Sanity check that a rebuilt journal behaves normally. - assertValue("a", "a", "a"); - assertValue("b", "b", "b"); - } - - /** @see Issue #28 */ - @Test public void rebuildJournalOnRepeatedReadsWithOpenAndClose() throws Exception { - set("a", "a", "a"); - set("b", "b", "b"); - while (executor.jobs.isEmpty()) { - assertValue("a", "a", "a"); - assertValue("b", "b", "b"); - cache.close(); - createNewCache(); - } - } - - /** @see Issue #28 */ - @Test public void rebuildJournalOnRepeatedEditsWithOpenAndClose() throws Exception { - while (executor.jobs.isEmpty()) { - set("a", "a", "a"); - set("b", "b", "b"); - cache.close(); - createNewCache(); - } - } - - @Test public void rebuildJournalFailurePreventsEditors() throws Exception { - while (executor.jobs.isEmpty()) { - set("a", "a", "a"); - set("b", "b", "b"); - } - - // Cause the rebuild action to fail. - fileSystem.setFaultyRename(new File(cacheDir, DiskLruCache.JOURNAL_FILE_BACKUP), true); - executor.jobs.removeFirst().run(); - - // Don't allow edits under any circumstances. - assertThat(cache.edit("a")).isNull(); - assertThat(cache.edit("c")).isNull(); - DiskLruCache.Snapshot snapshot = cache.get("a"); - assertThat(snapshot.edit()).isNull(); - snapshot.close(); - } - - @Test public void rebuildJournalFailureIsRetried() throws Exception { - while (executor.jobs.isEmpty()) { - set("a", "a", "a"); - set("b", "b", "b"); - } - - // Cause the rebuild action to fail. - fileSystem.setFaultyRename(new File(cacheDir, DiskLruCache.JOURNAL_FILE_BACKUP), true); - executor.jobs.removeFirst().run(); - - // The rebuild is retried on cache hits and on cache edits. - DiskLruCache.Snapshot snapshot = cache.get("b"); - snapshot.close(); - assertThat(cache.edit("d")).isNull(); - assertThat(executor.jobs.size()).isEqualTo(2); - - // On cache misses, no retry job is queued. - assertThat(cache.get("c")).isNull(); - assertThat(executor.jobs.size()).isEqualTo(2); - - // Let the rebuild complete successfully. - fileSystem.setFaultyRename(new File(cacheDir, DiskLruCache.JOURNAL_FILE_BACKUP), false); - executor.jobs.removeFirst().run(); - assertJournalEquals("CLEAN a 1 1", "CLEAN b 1 1"); - } - - @Test public void rebuildJournalFailureWithInFlightEditors() throws Exception { - while (executor.jobs.isEmpty()) { - set("a", "a", "a"); - set("b", "b", "b"); - } - DiskLruCache.Editor commitEditor = cache.edit("c"); - DiskLruCache.Editor abortEditor = cache.edit("d"); - cache.edit("e"); // Grab an editor, but don't do anything with it. - - // Cause the rebuild action to fail. - fileSystem.setFaultyRename(new File(cacheDir, DiskLruCache.JOURNAL_FILE_BACKUP), true); - executor.jobs.removeFirst().run(); - - // In-flight editors can commit and have their values retained. - setString(commitEditor, 0, "c"); - setString(commitEditor, 1, "c"); - commitEditor.commit(); - assertValue("c", "c", "c"); - - abortEditor.abort(); - - // Let the rebuild complete successfully. - fileSystem.setFaultyRename(new File(cacheDir, DiskLruCache.JOURNAL_FILE_BACKUP), false); - executor.jobs.removeFirst().run(); - assertJournalEquals("CLEAN a 1 1", "CLEAN b 1 1", "DIRTY e", "CLEAN c 1 1"); - } - - @Test public void rebuildJournalFailureWithEditorsInFlightThenClose() throws Exception { - while (executor.jobs.isEmpty()) { - set("a", "a", "a"); - set("b", "b", "b"); - } - DiskLruCache.Editor commitEditor = cache.edit("c"); - DiskLruCache.Editor abortEditor = cache.edit("d"); - cache.edit("e"); // Grab an editor, but don't do anything with it. - - // Cause the rebuild action to fail. - fileSystem.setFaultyRename(new File(cacheDir, DiskLruCache.JOURNAL_FILE_BACKUP), true); - executor.jobs.removeFirst().run(); - - setString(commitEditor, 0, "c"); - setString(commitEditor, 1, "c"); - commitEditor.commit(); - assertValue("c", "c", "c"); - - abortEditor.abort(); - - cache.close(); - createNewCache(); - - // Although 'c' successfully committed above, the journal wasn't available to issue a CLEAN op. - // Because the last state of 'c' was DIRTY before the journal failed, it should be removed - // entirely on a subsequent open. - assertThat(cache.size()).isEqualTo(4); - assertAbsent("c"); - assertAbsent("d"); - assertAbsent("e"); - } - - @Test public void rebuildJournalFailureAllowsRemovals() throws Exception { - while (executor.jobs.isEmpty()) { - set("a", "a", "a"); - set("b", "b", "b"); - } - - // Cause the rebuild action to fail. - fileSystem.setFaultyRename(new File(cacheDir, DiskLruCache.JOURNAL_FILE_BACKUP), true); - executor.jobs.removeFirst().run(); - - assertThat(cache.remove("a")).isTrue(); - assertAbsent("a"); - - // Let the rebuild complete successfully. - fileSystem.setFaultyRename(new File(cacheDir, DiskLruCache.JOURNAL_FILE_BACKUP), false); - executor.jobs.removeFirst().run(); - - assertJournalEquals("CLEAN b 1 1"); - } - - @Test public void rebuildJournalFailureWithRemovalThenClose() throws Exception { - while (executor.jobs.isEmpty()) { - set("a", "a", "a"); - set("b", "b", "b"); - } - - // Cause the rebuild action to fail. - fileSystem.setFaultyRename(new File(cacheDir, DiskLruCache.JOURNAL_FILE_BACKUP), true); - executor.jobs.removeFirst().run(); - - assertThat(cache.remove("a")).isTrue(); - assertAbsent("a"); - - cache.close(); - createNewCache(); - - // The journal will have no record that 'a' was removed. It will have an entry for 'a', but when - // it tries to read the cache files, it will find they were deleted. Once it encounters an entry - // with missing cache files, it should remove it from the cache entirely. - assertThat(cache.size()).isEqualTo(4); - assertThat(cache.get("a")).isNull(); - assertThat(cache.size()).isEqualTo(2); - } - - @Test public void rebuildJournalFailureAllowsEvictAll() throws Exception { - while (executor.jobs.isEmpty()) { - set("a", "a", "a"); - set("b", "b", "b"); - } - - // Cause the rebuild action to fail. - fileSystem.setFaultyRename(new File(cacheDir, DiskLruCache.JOURNAL_FILE_BACKUP), true); - executor.jobs.removeFirst().run(); - - cache.evictAll(); - - assertThat(cache.size()).isEqualTo(0); - assertAbsent("a"); - assertAbsent("b"); - - cache.close(); - createNewCache(); - - // The journal has no record that 'a' and 'b' were removed. It will have an entry for both, but - // when it tries to read the cache files for either entry, it will discover the cache files are - // missing and remove the entries from the cache. - assertThat(cache.size()).isEqualTo(4); - assertThat(cache.get("a")).isNull(); - assertThat(cache.get("b")).isNull(); - assertThat(cache.size()).isEqualTo(0); - } - - @Test public void rebuildJournalFailureWithCacheTrim() throws Exception { - while (executor.jobs.isEmpty()) { - set("a", "aa", "aa"); - set("b", "bb", "bb"); - } - - // Cause the rebuild action to fail. - fileSystem.setFaultyRename(new File(cacheDir, DiskLruCache.JOURNAL_FILE_BACKUP), true); - executor.jobs.removeFirst().run(); - - // Trigger a job to trim the cache. - cache.setMaxSize(4); - executor.jobs.removeFirst().run(); - - assertAbsent("a"); - assertValue("b", "bb", "bb"); - } - - @Test public void restoreBackupFile() throws Exception { - DiskLruCache.Editor creator = cache.edit("k1"); - setString(creator, 0, "ABC"); - setString(creator, 1, "DE"); - creator.commit(); - cache.close(); - - fileSystem.rename(journalFile, journalBkpFile); - assertThat(fileSystem.exists(journalFile)).isFalse(); - - createNewCache(); - - DiskLruCache.Snapshot snapshot = cache.get("k1"); - assertSnapshotValue(snapshot, 0, "ABC"); - assertSnapshotValue(snapshot, 1, "DE"); - - assertThat(fileSystem.exists(journalBkpFile)).isFalse(); - assertThat(fileSystem.exists(journalFile)).isTrue(); - } - - @Test public void journalFileIsPreferredOverBackupFile() throws Exception { - DiskLruCache.Editor creator = cache.edit("k1"); - setString(creator, 0, "ABC"); - setString(creator, 1, "DE"); - creator.commit(); - cache.flush(); - - copyFile(journalFile, journalBkpFile); - - creator = cache.edit("k2"); - setString(creator, 0, "F"); - setString(creator, 1, "GH"); - creator.commit(); - cache.close(); - - assertThat(fileSystem.exists(journalFile)).isTrue(); - assertThat(fileSystem.exists(journalBkpFile)).isTrue(); - - createNewCache(); - - DiskLruCache.Snapshot snapshotA = cache.get("k1"); - assertSnapshotValue(snapshotA, 0, "ABC"); - assertSnapshotValue(snapshotA, 1, "DE"); - - DiskLruCache.Snapshot snapshotB = cache.get("k2"); - assertSnapshotValue(snapshotB, 0, "F"); - assertSnapshotValue(snapshotB, 1, "GH"); - - assertThat(fileSystem.exists(journalBkpFile)).isFalse(); - assertThat(fileSystem.exists(journalFile)).isTrue(); - } - - @Test public void openCreatesDirectoryIfNecessary() throws Exception { - cache.close(); - File dir = tempDir.newFolder("testOpenCreatesDirectoryIfNecessary"); - cache = DiskLruCache.create(fileSystem, dir, appVersion, 2, Integer.MAX_VALUE); - set("a", "a", "a"); - assertThat(fileSystem.exists(new File(dir, "a.0"))).isTrue(); - assertThat(fileSystem.exists(new File(dir, "a.1"))).isTrue(); - assertThat(fileSystem.exists(new File(dir, "journal"))).isTrue(); - } - - @Test public void fileDeletedExternally() throws Exception { - set("a", "a", "a"); - fileSystem.delete(getCleanFile("a", 1)); - assertThat(cache.get("a")).isNull(); - assertThat(cache.size()).isEqualTo(0); - } - - @Test public void editSameVersion() throws Exception { - set("a", "a", "a"); - DiskLruCache.Snapshot snapshot = cache.get("a"); - DiskLruCache.Editor editor = snapshot.edit(); - setString(editor, 1, "a2"); - editor.commit(); - assertValue("a", "a", "a2"); - } - - @Test public void editSnapshotAfterChangeAborted() throws Exception { - set("a", "a", "a"); - DiskLruCache.Snapshot snapshot = cache.get("a"); - DiskLruCache.Editor toAbort = snapshot.edit(); - setString(toAbort, 0, "b"); - toAbort.abort(); - DiskLruCache.Editor editor = snapshot.edit(); - setString(editor, 1, "a2"); - editor.commit(); - assertValue("a", "a", "a2"); - } - - @Test public void editSnapshotAfterChangeCommitted() throws Exception { - set("a", "a", "a"); - DiskLruCache.Snapshot snapshot = cache.get("a"); - DiskLruCache.Editor toAbort = snapshot.edit(); - setString(toAbort, 0, "b"); - toAbort.commit(); - assertThat(snapshot.edit()).isNull(); - } - - @Test public void editSinceEvicted() throws Exception { - cache.close(); - createNewCacheWithSize(10); - set("a", "aa", "aaa"); // size 5 - DiskLruCache.Snapshot snapshot = cache.get("a"); - set("b", "bb", "bbb"); // size 5 - set("c", "cc", "ccc"); // size 5; will evict 'A' - cache.flush(); - assertThat(snapshot.edit()).isNull(); - } - - @Test public void editSinceEvictedAndRecreated() throws Exception { - cache.close(); - createNewCacheWithSize(10); - set("a", "aa", "aaa"); // size 5 - DiskLruCache.Snapshot snapshot = cache.get("a"); - set("b", "bb", "bbb"); // size 5 - set("c", "cc", "ccc"); // size 5; will evict 'A' - set("a", "a", "aaaa"); // size 5; will evict 'B' - cache.flush(); - assertThat(snapshot.edit()).isNull(); - } - - /** @see Issue #2 */ - @Test public void aggressiveClearingHandlesWrite() throws Exception { - fileSystem.deleteContents(tempDir.getRoot()); - set("a", "a", "a"); - assertValue("a", "a", "a"); - } - - /** @see Issue #2 */ - @Test public void aggressiveClearingHandlesEdit() throws Exception { - set("a", "a", "a"); - DiskLruCache.Editor a = cache.get("a").edit(); - fileSystem.deleteContents(tempDir.getRoot()); - setString(a, 1, "a2"); - a.commit(); - } - - @Test public void removeHandlesMissingFile() throws Exception { - set("a", "a", "a"); - getCleanFile("a", 0).delete(); - cache.remove("a"); - } - - /** @see Issue #2 */ - @Test public void aggressiveClearingHandlesPartialEdit() throws Exception { - set("a", "a", "a"); - set("b", "b", "b"); - DiskLruCache.Editor a = cache.get("a").edit(); - setString(a, 0, "a1"); - fileSystem.deleteContents(tempDir.getRoot()); - setString(a, 1, "a2"); - a.commit(); - assertThat(cache.get("a")).isNull(); - } - - /** @see Issue #2 */ - @Test public void aggressiveClearingHandlesRead() throws Exception { - fileSystem.deleteContents(tempDir.getRoot()); - assertThat(cache.get("a")).isNull(); - } - - /** - * We had a long-lived bug where {@link DiskLruCache#trimToSize} could infinite loop if entries - * being edited required deletion for the operation to complete. - */ - @Test public void trimToSizeWithActiveEdit() throws Exception { - set("a", "a1234", "a1234"); - DiskLruCache.Editor a = cache.edit("a"); - setString(a, 0, "a123"); - - cache.setMaxSize(8); // Smaller than the sum of active edits! - cache.flush(); // Force trimToSize(). - assertThat(cache.size()).isEqualTo(0); - assertThat(cache.get("a")).isNull(); - - // After the edit is completed, its entry is still gone. - setString(a, 1, "a1"); - a.commit(); - assertAbsent("a"); - assertThat(cache.size()).isEqualTo(0); - } - - @Test public void evictAll() throws Exception { - set("a", "a", "a"); - set("b", "b", "b"); - cache.evictAll(); - assertThat(cache.size()).isEqualTo(0); - assertAbsent("a"); - assertAbsent("b"); - } - - @Test public void evictAllWithPartialCreate() throws Exception { - DiskLruCache.Editor a = cache.edit("a"); - setString(a, 0, "a1"); - setString(a, 1, "a2"); - cache.evictAll(); - assertThat(cache.size()).isEqualTo(0); - a.commit(); - assertAbsent("a"); - } - - @Test public void evictAllWithPartialEditDoesNotStoreAValue() throws Exception { - set("a", "a", "a"); - DiskLruCache.Editor a = cache.edit("a"); - setString(a, 0, "a1"); - setString(a, 1, "a2"); - cache.evictAll(); - assertThat(cache.size()).isEqualTo(0); - a.commit(); - assertAbsent("a"); - } - - @Test public void evictAllDoesntInterruptPartialRead() throws Exception { - set("a", "a", "a"); - DiskLruCache.Snapshot a = cache.get("a"); - assertSnapshotValue(a, 0, "a"); - cache.evictAll(); - assertThat(cache.size()).isEqualTo(0); - assertAbsent("a"); - assertSnapshotValue(a, 1, "a"); - a.close(); - } - - @Test public void editSnapshotAfterEvictAllReturnsNullDueToStaleValue() throws Exception { - set("a", "a", "a"); - DiskLruCache.Snapshot a = cache.get("a"); - cache.evictAll(); - assertThat(cache.size()).isEqualTo(0); - assertAbsent("a"); - assertThat(a.edit()).isNull(); - a.close(); - } - - @Test public void iterator() throws Exception { - set("a", "a1", "a2"); - set("b", "b1", "b2"); - set("c", "c1", "c2"); - Iterator iterator = cache.snapshots(); - - assertThat(iterator.hasNext()).isTrue(); - DiskLruCache.Snapshot a = iterator.next(); - assertThat(a.key()).isEqualTo("a"); - assertSnapshotValue(a, 0, "a1"); - assertSnapshotValue(a, 1, "a2"); - a.close(); - - assertThat(iterator.hasNext()).isTrue(); - DiskLruCache.Snapshot b = iterator.next(); - assertThat(b.key()).isEqualTo("b"); - assertSnapshotValue(b, 0, "b1"); - assertSnapshotValue(b, 1, "b2"); - b.close(); - - assertThat(iterator.hasNext()).isTrue(); - DiskLruCache.Snapshot c = iterator.next(); - assertThat(c.key()).isEqualTo("c"); - assertSnapshotValue(c, 0, "c1"); - assertSnapshotValue(c, 1, "c2"); - c.close(); - - assertThat(iterator.hasNext()).isFalse(); - try { - iterator.next(); - fail(); - } catch (NoSuchElementException expected) { - } - } - - @Test public void iteratorElementsAddedDuringIterationAreOmitted() throws Exception { - set("a", "a1", "a2"); - set("b", "b1", "b2"); - Iterator iterator = cache.snapshots(); - - DiskLruCache.Snapshot a = iterator.next(); - assertThat(a.key()).isEqualTo("a"); - a.close(); - - set("c", "c1", "c2"); - - DiskLruCache.Snapshot b = iterator.next(); - assertThat(b.key()).isEqualTo("b"); - b.close(); - - assertThat(iterator.hasNext()).isFalse(); - } - - @Test public void iteratorElementsUpdatedDuringIterationAreUpdated() throws Exception { - set("a", "a1", "a2"); - set("b", "b1", "b2"); - Iterator iterator = cache.snapshots(); - - DiskLruCache.Snapshot a = iterator.next(); - assertThat(a.key()).isEqualTo("a"); - a.close(); - - set("b", "b3", "b4"); - - DiskLruCache.Snapshot b = iterator.next(); - assertThat(b.key()).isEqualTo("b"); - assertSnapshotValue(b, 0, "b3"); - assertSnapshotValue(b, 1, "b4"); - b.close(); - } - - @Test public void iteratorElementsRemovedDuringIterationAreOmitted() throws Exception { - set("a", "a1", "a2"); - set("b", "b1", "b2"); - Iterator iterator = cache.snapshots(); - - cache.remove("b"); - - DiskLruCache.Snapshot a = iterator.next(); - assertThat(a.key()).isEqualTo("a"); - a.close(); - - assertThat(iterator.hasNext()).isFalse(); - } - - @Test public void iteratorRemove() throws Exception { - set("a", "a1", "a2"); - Iterator iterator = cache.snapshots(); - - DiskLruCache.Snapshot a = iterator.next(); - a.close(); - iterator.remove(); - - assertThat(cache.get("a")).isNull(); - } - - @Test public void iteratorRemoveBeforeNext() throws Exception { - set("a", "a1", "a2"); - Iterator iterator = cache.snapshots(); - try { - iterator.remove(); - fail(); - } catch (IllegalStateException expected) { - } - } - - @Test public void iteratorRemoveOncePerCallToNext() throws Exception { - set("a", "a1", "a2"); - Iterator iterator = cache.snapshots(); - - DiskLruCache.Snapshot a = iterator.next(); - iterator.remove(); - a.close(); - - try { - iterator.remove(); - fail(); - } catch (IllegalStateException expected) { - } - } - - @Test public void cacheClosedTruncatesIterator() throws Exception { - set("a", "a1", "a2"); - Iterator iterator = cache.snapshots(); - cache.close(); - assertThat(iterator.hasNext()).isFalse(); - } - - @Test public void isClosedUninitializedCache() throws Exception { - // Create an uninitialized cache. - cache = new DiskLruCache(fileSystem, cacheDir, appVersion, 2, Integer.MAX_VALUE, executor); - toClose.add(cache); - - assertThat(cache.isClosed()).isFalse(); - cache.close(); - assertThat(cache.isClosed()).isTrue(); - } - - @Test public void journalWriteFailsDuringEdit() throws Exception { - set("a", "a", "a"); - set("b", "b", "b"); - - // We can't begin the edit if writing 'DIRTY' fails. - fileSystem.setFaultyWrite(journalFile, true); - assertThat(cache.edit("c")).isNull(); - - // Once the journal has a failure, subsequent writes aren't permitted. - fileSystem.setFaultyWrite(journalFile, false); - assertThat(cache.edit("d")).isNull(); - - // Confirm that the fault didn't corrupt entries stored before the fault was introduced. - cache.close(); - cache = new DiskLruCache(fileSystem, cacheDir, appVersion, 2, Integer.MAX_VALUE, executor); - assertValue("a", "a", "a"); - assertValue("b", "b", "b"); - assertAbsent("c"); - assertAbsent("d"); - } - - /** - * We had a bug where the cache was left in an inconsistent state after a journal write failed. - * https://github.com/square/okhttp/issues/1211 - */ - @Test public void journalWriteFailsDuringEditorCommit() throws Exception { - set("a", "a", "a"); - set("b", "b", "b"); - - // Create an entry that fails to write to the journal during commit. - DiskLruCache.Editor editor = cache.edit("c"); - setString(editor, 0, "c"); - setString(editor, 1, "c"); - fileSystem.setFaultyWrite(journalFile, true); - editor.commit(); - - // Once the journal has a failure, subsequent writes aren't permitted. - fileSystem.setFaultyWrite(journalFile, false); - assertThat(cache.edit("d")).isNull(); - - // Confirm that the fault didn't corrupt entries stored before the fault was introduced. - cache.close(); - cache = new DiskLruCache(fileSystem, cacheDir, appVersion, 2, Integer.MAX_VALUE, executor); - assertValue("a", "a", "a"); - assertValue("b", "b", "b"); - assertAbsent("c"); - assertAbsent("d"); - } - - @Test public void journalWriteFailsDuringEditorAbort() throws Exception { - set("a", "a", "a"); - set("b", "b", "b"); - - // Create an entry that fails to write to the journal during abort. - DiskLruCache.Editor editor = cache.edit("c"); - setString(editor, 0, "c"); - setString(editor, 1, "c"); - fileSystem.setFaultyWrite(journalFile, true); - editor.abort(); - - // Once the journal has a failure, subsequent writes aren't permitted. - fileSystem.setFaultyWrite(journalFile, false); - assertThat(cache.edit("d")).isNull(); - - // Confirm that the fault didn't corrupt entries stored before the fault was introduced. - cache.close(); - cache = new DiskLruCache(fileSystem, cacheDir, appVersion, 2, Integer.MAX_VALUE, executor); - assertValue("a", "a", "a"); - assertValue("b", "b", "b"); - assertAbsent("c"); - assertAbsent("d"); - } - - @Test public void journalWriteFailsDuringRemove() throws Exception { - set("a", "a", "a"); - set("b", "b", "b"); - - // Remove, but the journal write will fail. - fileSystem.setFaultyWrite(journalFile, true); - assertThat(cache.remove("a")).isTrue(); - - // Confirm that the entry was still removed. - fileSystem.setFaultyWrite(journalFile, false); - cache.close(); - cache = new DiskLruCache(fileSystem, cacheDir, appVersion, 2, Integer.MAX_VALUE, executor); - assertAbsent("a"); - assertValue("b", "b", "b"); - } - - @Test public void cleanupTrimFailurePreventsNewEditors() throws Exception { - cache.setMaxSize(8); - executor.jobs.pop(); - set("a", "aa", "aa"); - set("b", "bb", "bbb"); - - // Cause the cache trim job to fail. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), true); - executor.jobs.pop().run(); - - // Confirm that edits are prevented after a cache trim failure. - assertThat(cache.edit("a")).isNull(); - assertThat(cache.edit("b")).isNull(); - assertThat(cache.edit("c")).isNull(); - - // Allow the test to clean up. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), false); - } - - @Test public void cleanupTrimFailureRetriedOnEditors() throws Exception { - cache.setMaxSize(8); - executor.jobs.pop(); - set("a", "aa", "aa"); - set("b", "bb", "bbb"); - - // Cause the cache trim job to fail. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), true); - executor.jobs.pop().run(); - - // An edit should now add a job to clean up if the most recent trim failed. - assertThat(cache.edit("b")).isNull(); - executor.jobs.pop().run(); - - // Confirm a successful cache trim now allows edits. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), false); - assertThat(cache.edit("c")).isNull(); - executor.jobs.pop().run(); - set("c", "cc", "cc"); - assertValue("c", "cc", "cc"); - } - - @Test public void cleanupTrimFailureWithInFlightEditor() throws Exception { - cache.setMaxSize(8); - executor.jobs.pop(); - set("a", "aa", "aaa"); - set("b", "bb", "bb"); - DiskLruCache.Editor inFlightEditor = cache.edit("c"); - - // Cause the cache trim job to fail. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), true); - executor.jobs.pop().run(); - - // The in-flight editor can still write after a trim failure. - setString(inFlightEditor, 0, "cc"); - setString(inFlightEditor, 1, "cc"); - inFlightEditor.commit(); - - // Confirm the committed values are present after a successful cache trim. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), false); - executor.jobs.pop().run(); - assertValue("c", "cc", "cc"); - } - - @Test public void cleanupTrimFailureAllowsSnapshotReads() throws Exception { - cache.setMaxSize(8); - executor.jobs.pop(); - set("a", "aa", "aa"); - set("b", "bb", "bbb"); - - // Cause the cache trim job to fail. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), true); - executor.jobs.pop().run(); - - // Confirm we still allow snapshot reads after a trim failure. - assertValue("a", "aa", "aa"); - assertValue("b", "bb", "bbb"); - - // Allow the test to clean up. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), false); - } - - @Test public void cleanupTrimFailurePreventsSnapshotWrites() throws Exception { - cache.setMaxSize(8); - executor.jobs.pop(); - set("a", "aa", "aa"); - set("b", "bb", "bbb"); - - // Cause the cache trim job to fail. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), true); - executor.jobs.pop().run(); - - // Confirm snapshot writes are prevented after a trim failure. - DiskLruCache.Snapshot snapshot1 = cache.get("a"); - assertThat(snapshot1.edit()).isNull(); - snapshot1.close(); - DiskLruCache.Snapshot snapshot2 = cache.get("b"); - assertThat(snapshot2.edit()).isNull(); - snapshot2.close(); - - // Allow the test to clean up. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), false); - } - - @Test public void evictAllAfterCleanupTrimFailure() throws Exception { - cache.setMaxSize(8); - executor.jobs.pop(); - set("a", "aa", "aa"); - set("b", "bb", "bbb"); - - // Cause the cache trim job to fail. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), true); - executor.jobs.pop().run(); - - // Confirm we prevent edits after a trim failure. - assertThat(cache.edit("c")).isNull(); - - // A successful eviction should allow new writes. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), false); - cache.evictAll(); - set("c", "cc", "cc"); - assertValue("c", "cc", "cc"); - } - - @Test public void manualRemovalAfterCleanupTrimFailure() throws Exception { - cache.setMaxSize(8); - executor.jobs.pop(); - set("a", "aa", "aa"); - set("b", "bb", "bbb"); - - // Cause the cache trim job to fail. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), true); - executor.jobs.pop().run(); - - // Confirm we prevent edits after a trim failure. - assertThat(cache.edit("c")).isNull(); - - // A successful removal which trims the cache should allow new writes. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), false); - cache.remove("a"); - set("c", "cc", "cc"); - assertValue("c", "cc", "cc"); - } - - @Test public void flushingAfterCleanupTrimFailure() throws Exception { - cache.setMaxSize(8); - executor.jobs.pop(); - set("a", "aa", "aa"); - set("b", "bb", "bbb"); - - // Cause the cache trim job to fail. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), true); - executor.jobs.pop().run(); - - // Confirm we prevent edits after a trim failure. - assertThat(cache.edit("c")).isNull(); - - // A successful flush trims the cache and should allow new writes. - fileSystem.setFaultyDelete(new File(cacheDir, "a.0"), false); - cache.flush(); - set("c", "cc", "cc"); - assertValue("c", "cc", "cc"); - } - - @Test public void cleanupTrimFailureWithPartialSnapshot() throws Exception { - cache.setMaxSize(8); - executor.jobs.pop(); - set("a", "aa", "aa"); - set("b", "bb", "bbb"); - - // Cause the cache trim to fail on the second value leaving a partial snapshot. - fileSystem.setFaultyDelete(new File(cacheDir, "a.1"), true); - executor.jobs.pop().run(); - - // Confirm the partial snapshot is not returned. - assertThat(cache.get("a")).isNull(); - - // Confirm we prevent edits after a trim failure. - assertThat(cache.edit("a")).isNull(); - - // Confirm the partial snapshot is not returned after a successful trim. - fileSystem.setFaultyDelete(new File(cacheDir, "a.1"), false); - executor.jobs.pop().run(); - assertThat(cache.get("a")).isNull(); - } - - @Test public void noSizeCorruptionAfterCreatorDetached() throws Exception { - // Create an editor for k1. Detach it by clearing the cache. - DiskLruCache.Editor editor = cache.edit("k1"); - setString(editor, 0, "a"); - setString(editor, 1, "a"); - cache.evictAll(); - - // Create a new value in its place. - set("k1", "bb", "bb"); - assertThat(cache.size()).isEqualTo(4); - - // Committing the detached editor should not change the cache's size. - editor.commit(); - assertThat(cache.size()).isEqualTo(4); - assertValue("k1", "bb", "bb"); - } - - @Test public void noSizeCorruptionAfterEditorDetached() throws Exception { - set("k1", "a", "a"); - - // Create an editor for k1. Detach it by clearing the cache. - DiskLruCache.Editor editor = cache.edit("k1"); - setString(editor, 0, "bb"); - setString(editor, 1, "bb"); - cache.evictAll(); - - // Create a new value in its place. - set("k1", "ccc", "ccc"); - assertThat(cache.size()).isEqualTo(6); - - // Committing the detached editor should not change the cache's size. - editor.commit(); - assertThat(cache.size()).isEqualTo(6); - assertValue("k1", "ccc", "ccc"); - } - - @Test public void noNewSourceAfterEditorDetached() throws Exception { - set("k1", "a", "a"); - - DiskLruCache.Editor editor = cache.edit("k1"); - cache.evictAll(); - - assertThat(editor.newSource(0)).isNull(); - } - - @Test public void editsDiscardedAfterEditorDetached() throws Exception { - set("k1", "a", "a"); - - // Create an editor, then detach it. - DiskLruCache.Editor editor = cache.edit("k1"); - BufferedSink sink = Okio.buffer(editor.newSink(0)); - cache.evictAll(); - - // Create another value in its place. - set("k1", "ccc", "ccc"); - - // Complete the original edit. It goes into a black hole. - sink.writeUtf8("bb"); - sink.close(); - - assertValue("k1", "ccc", "ccc"); - } - - @Test public void abortAfterDetach() throws Exception { - set("k1", "a", "a"); - - DiskLruCache.Editor editor = cache.edit("k1"); - cache.evictAll(); - - editor.abort(); - assertThat(cache.size()).isEqualTo(0); - assertAbsent("k1"); - } - - private void assertJournalEquals(String... expectedBodyLines) throws Exception { - List expectedLines = new ArrayList<>(); - expectedLines.add(MAGIC); - expectedLines.add(VERSION_1); - expectedLines.add("100"); - expectedLines.add("2"); - expectedLines.add(""); - expectedLines.addAll(Arrays.asList(expectedBodyLines)); - assertThat(readJournalLines()).isEqualTo(expectedLines); - } - - private void createJournal(String... bodyLines) throws Exception { - createJournalWithHeader(MAGIC, VERSION_1, "100", "2", "", bodyLines); - } - - private void createJournalWithHeader(String magic, String version, String appVersion, - String valueCount, String blank, String... bodyLines) throws Exception { - BufferedSink sink = Okio.buffer(fileSystem.sink(journalFile)); - sink.writeUtf8(magic + "\n"); - sink.writeUtf8(version + "\n"); - sink.writeUtf8(appVersion + "\n"); - sink.writeUtf8(valueCount + "\n"); - sink.writeUtf8(blank + "\n"); - for (String line : bodyLines) { - sink.writeUtf8(line); - sink.writeUtf8("\n"); - } - sink.close(); - } - - private List readJournalLines() throws Exception { - List result = new ArrayList<>(); - BufferedSource source = Okio.buffer(fileSystem.source(journalFile)); - for (String line; (line = source.readUtf8Line()) != null;) { - result.add(line); - } - source.close(); - return result; - } - - private File getCleanFile(String key, int index) { - return new File(cacheDir, key + "." + index); - } - - private File getDirtyFile(String key, int index) { - return new File(cacheDir, key + "." + index + ".tmp"); - } - - private String readFile(File file) throws Exception { - BufferedSource source = Okio.buffer(fileSystem.source(file)); - String result = source.readUtf8(); - source.close(); - return result; - } - - public void writeFile(File file, String content) throws Exception { - BufferedSink sink = Okio.buffer(fileSystem.sink(file)); - sink.writeUtf8(content); - sink.close(); - } - - private static void assertInoperable(DiskLruCache.Editor editor) throws Exception { - try { - setString(editor, 0, "A"); - fail(); - } catch (IllegalStateException expected) { - } - try { - editor.newSource(0); - fail(); - } catch (IllegalStateException expected) { - } - try { - editor.newSink(0); - fail(); - } catch (IllegalStateException expected) { - } - try { - editor.commit(); - fail(); - } catch (IllegalStateException expected) { - } - try { - editor.abort(); - fail(); - } catch (IllegalStateException expected) { - } - } - - private void generateSomeGarbageFiles() throws Exception { - File dir1 = new File(cacheDir, "dir1"); - File dir2 = new File(dir1, "dir2"); - writeFile(getCleanFile("g1", 0), "A"); - writeFile(getCleanFile("g1", 1), "B"); - writeFile(getCleanFile("g2", 0), "C"); - writeFile(getCleanFile("g2", 1), "D"); - writeFile(getCleanFile("g2", 1), "D"); - writeFile(new File(cacheDir, "otherFile0"), "E"); - writeFile(new File(dir2, "otherFile1"), "F"); - } - - private void assertGarbageFilesAllDeleted() { - assertThat(fileSystem.exists(getCleanFile("g1", 0))).isFalse(); - assertThat(fileSystem.exists(getCleanFile("g1", 1))).isFalse(); - assertThat(fileSystem.exists(getCleanFile("g2", 0))).isFalse(); - assertThat(fileSystem.exists(getCleanFile("g2", 1))).isFalse(); - assertThat(fileSystem.exists(new File(cacheDir, "otherFile0"))).isFalse(); - assertThat(fileSystem.exists(new File(cacheDir, "dir1"))).isFalse(); - } - - private void set(String key, String value0, String value1) throws Exception { - DiskLruCache.Editor editor = cache.edit(key); - setString(editor, 0, value0); - setString(editor, 1, value1); - editor.commit(); - } - - public static void setString(DiskLruCache.Editor editor, int index, String value) - throws IOException { - BufferedSink writer = Okio.buffer(editor.newSink(index)); - writer.writeUtf8(value); - writer.close(); - } - - private void assertAbsent(String key) throws Exception { - DiskLruCache.Snapshot snapshot = cache.get(key); - if (snapshot != null) { - snapshot.close(); - fail(); - } - assertThat(fileSystem.exists(getCleanFile(key, 0))).isFalse(); - assertThat(fileSystem.exists(getCleanFile(key, 1))).isFalse(); - assertThat(fileSystem.exists(getDirtyFile(key, 0))).isFalse(); - assertThat(fileSystem.exists(getDirtyFile(key, 1))).isFalse(); - } - - private void assertValue(String key, String value0, String value1) throws Exception { - DiskLruCache.Snapshot snapshot = cache.get(key); - assertSnapshotValue(snapshot, 0, value0); - assertSnapshotValue(snapshot, 1, value1); - assertThat(fileSystem.exists(getCleanFile(key, 0))).isTrue(); - assertThat(fileSystem.exists(getCleanFile(key, 1))).isTrue(); - snapshot.close(); - } - - private void assertSnapshotValue(DiskLruCache.Snapshot snapshot, int index, String value) - throws IOException { - assertThat(sourceAsString(snapshot.getSource(index))).isEqualTo(value); - assertThat(snapshot.getLength(index)).isEqualTo(value.length()); - } - - private String sourceAsString(Source source) throws IOException { - return source != null ? Okio.buffer(source).readUtf8() : null; - } - - private void copyFile(File from, File to) throws IOException { - Source source = fileSystem.source(from); - BufferedSink sink = Okio.buffer(fileSystem.sink(to)); - sink.writeAll(source); - source.close(); - sink.close(); - } - - private static class TestExecutor implements Executor { - final Deque jobs = new ArrayDeque<>(); - - @Override public void execute(Runnable command) { - jobs.addLast(command); - } - } -} diff --git a/apollo-http-cache/src/test/java/com/apollographql/apollo/cache/http/internal/FaultyFileSystem.java b/apollo-http-cache/src/test/java/com/apollographql/apollo/cache/http/internal/FaultyFileSystem.java deleted file mode 100644 index f37c005b63c..00000000000 --- a/apollo-http-cache/src/test/java/com/apollographql/apollo/cache/http/internal/FaultyFileSystem.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.apollographql.apollo.cache.http.internal; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.LinkedHashSet; -import java.util.Set; -import okio.Buffer; -import okio.ForwardingSink; -import okio.Sink; -import okio.Source; - -/** - * Copied from OkHttp 3.14.2: - * ttps://github.com/square/okhttp/blob/b8b6ee831c65208940c741f8e091ff02425566d5/okhttp-tests - * /src/test/java/okhttp3/internal/io/FaultyFileSystem.java - */ -public final class FaultyFileSystem implements FileSystem { - private final FileSystem delegate; - private final Set writeFaults = new LinkedHashSet<>(); - private final Set deleteFaults = new LinkedHashSet<>(); - private final Set renameFaults = new LinkedHashSet<>(); - - public FaultyFileSystem(FileSystem delegate) { - this.delegate = delegate; - } - - public void setFaultyWrite(File file, boolean faulty) { - if (faulty) { - writeFaults.add(file); - } else { - writeFaults.remove(file); - } - } - - public void setFaultyDelete(File file, boolean faulty) { - if (faulty) { - deleteFaults.add(file); - } else { - deleteFaults.remove(file); - } - } - - public void setFaultyRename(File file, boolean faulty) { - if (faulty) { - renameFaults.add(file); - } else { - renameFaults.remove(file); - } - } - - @Override public Source source(File file) throws FileNotFoundException { - return delegate.source(file); - } - - @Override public Sink sink(File file) throws FileNotFoundException { - return new FaultySink(delegate.sink(file), file); - } - - @Override public Sink appendingSink(File file) throws FileNotFoundException { - return new FaultySink(delegate.appendingSink(file), file); - } - - @Override public void delete(File file) throws IOException { - if (deleteFaults.contains(file)) throw new IOException("boom!"); - delegate.delete(file); - } - - @Override public boolean exists(File file) { - return delegate.exists(file); - } - - @Override public long size(File file) { - return delegate.size(file); - } - - @Override public void rename(File from, File to) throws IOException { - if (renameFaults.contains(from) || renameFaults.contains(to)) throw new IOException("boom!"); - delegate.rename(from, to); - } - - @Override public void deleteContents(File directory) throws IOException { - if (deleteFaults.contains(directory)) throw new IOException("boom!"); - delegate.deleteContents(directory); - } - - private class FaultySink extends ForwardingSink { - private final File file; - - FaultySink(Sink delegate, File file) { - super(delegate); - this.file = file; - } - - @Override public void write(Buffer source, long byteCount) throws IOException { - if (writeFaults.contains(file)) throw new IOException("boom!"); - super.write(source, byteCount); - } - } -} diff --git a/apollo-idling-resource/api.txt b/apollo-idling-resource/api.txt index c19faf76a28..49ecf987596 100644 --- a/apollo-idling-resource/api.txt +++ b/apollo-idling-resource/api.txt @@ -1,8 +1,8 @@ // Signature format: 3.0 -package com.apollographql.apollo.test.espresso { +package com.homer.apollographql.apollo.test.espresso { public final class ApolloIdlingResource implements androidx.test.espresso.IdlingResource { - method public static com.apollographql.apollo.test.espresso.ApolloIdlingResource! create(String, com.apollographql.apollo.ApolloClient); + method public static com.homer.apollographql.apollo.test.espresso.ApolloIdlingResource! create(String, com.homer.apollographql.apollo.ApolloClient); method public String! getName(); method public boolean isIdleNow(); method public void registerIdleTransitionCallback(androidx.test.espresso.IdlingResource.ResourceCallback!); diff --git a/apollo-idling-resource/src/main/AndroidManifest.xml b/apollo-idling-resource/src/main/AndroidManifest.xml index ce3691953fe..8bf52ec927d 100644 --- a/apollo-idling-resource/src/main/AndroidManifest.xml +++ b/apollo-idling-resource/src/main/AndroidManifest.xml @@ -1 +1 @@ - + diff --git a/apollo-idling-resource/src/main/java/com/apollographql/apollo/test/espresso/ApolloIdlingResource.java b/apollo-idling-resource/src/main/java/com/homer/apollographql/apollo/test/espresso/ApolloIdlingResource.java similarity index 88% rename from apollo-idling-resource/src/main/java/com/apollographql/apollo/test/espresso/ApolloIdlingResource.java rename to apollo-idling-resource/src/main/java/com/homer/apollographql/apollo/test/espresso/ApolloIdlingResource.java index fd46cb07eb6..a2d9c663df5 100644 --- a/apollo-idling-resource/src/main/java/com/apollographql/apollo/test/espresso/ApolloIdlingResource.java +++ b/apollo-idling-resource/src/main/java/com/homer/apollographql/apollo/test/espresso/ApolloIdlingResource.java @@ -1,11 +1,11 @@ -package com.apollographql.apollo.test.espresso; +package com.homer.apollographql.apollo.test.espresso; import androidx.test.espresso.IdlingResource; -import com.apollographql.apollo.ApolloClient; -import com.apollographql.apollo.IdleResourceCallback; +import com.homer.apollographql.apollo.ApolloClient; +import com.homer.apollographql.apollo.IdleResourceCallback; import org.jetbrains.annotations.NotNull; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; /** * An Espresso {@link IdlingResource} for {@link ApolloClient}. diff --git a/apollo-idling-resource/src/test/java/com/apollographql/apollo/test/espresso/ApolloIdlingResourceTest.java b/apollo-idling-resource/src/test/java/com/apollographql/apollo/test/espresso/ApolloIdlingResourceTest.java deleted file mode 100644 index 08daeaf1e20..00000000000 --- a/apollo-idling-resource/src/test/java/com/apollographql/apollo/test/espresso/ApolloIdlingResourceTest.java +++ /dev/null @@ -1,273 +0,0 @@ -package com.apollographql.apollo.test.espresso; - -import androidx.test.espresso.IdlingResource; -import com.apollographql.apollo.ApolloCall; -import com.apollographql.apollo.ApolloClient; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.rx2.Rx2Apollo; -import okhttp3.OkHttpClient; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.junit.After; -import org.junit.Rule; -import org.junit.Test; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicInteger; - -import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.fail; - -public class ApolloIdlingResourceTest { - @Rule - public final MockWebServer server = new MockWebServer(); - - private final OkHttpClient okHttpClient = new OkHttpClient(); - private ApolloIdlingResource idlingResource; - private ApolloClient apolloClient; - - private static final long TIME_OUT_SECONDS = 3; - private static final String IDLING_RESOURCE_NAME = "apolloIdlingResource"; - - private static final Query EMPTY_QUERY = new Query() { - - OperationName operationName = new OperationName() { - @Override public String name() { - return "EmptyQuery"; - } - }; - - @Override public String queryDocument() { - return ""; - } - - @Override public Variables variables() { - return EMPTY_VARIABLES; - } - - @Override public ResponseFieldMapper responseFieldMapper() { - return new ResponseFieldMapper() { - @Override public Data map(ResponseReader responseReader) { - return null; - } - }; - } - - @Override public Object wrapData(Data data) { - return data; - } - - @NotNull @Override public OperationName name() { - return operationName; - } - - @NotNull @Override public String operationId() { - return ""; - } - - @NotNull @Override public ByteString composeRequestBody(boolean autoPersistQueries, boolean withQueryDocument, @NotNull ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @NotNull @Override public Response parse(@NotNull BufferedSource source, @NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull BufferedSource source) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull ByteString byteString) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull ByteString byteString, @NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public ByteString composeRequestBody(@NotNull ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - - @NotNull @Override public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - }; - - @After - public void tearDown() { - idlingResource = null; - } - - @SuppressWarnings("ConstantConditions") @Test - public void onNullNamePassed_NullPointerExceptionIsThrown() { - apolloClient = ApolloClient.builder() - .okHttpClient(okHttpClient) - .serverUrl(server.url("/")) - .build(); - - try { - idlingResource = ApolloIdlingResource.create(null, apolloClient); - fail(); - } catch (Exception e) { - assertThat(e).isInstanceOf(NullPointerException.class); - assertThat(e.getMessage()).isEqualTo("name == null"); - } - } - - @SuppressWarnings("ConstantConditions") @Test - public void onNullApolloClientPassed_NullPointerExceptionIsThrown() { - try { - idlingResource = ApolloIdlingResource.create(IDLING_RESOURCE_NAME, null); - fail(); - } catch (Exception e) { - assertThat(e).isInstanceOf(NullPointerException.class); - assertThat(e.getMessage()).isEqualTo("apolloClient == null"); - } - } - - @Test - public void checkValidIdlingResourceNameIsRegistered() { - apolloClient = ApolloClient.builder() - .okHttpClient(okHttpClient) - .serverUrl(server.url("/")) - .build(); - - idlingResource = ApolloIdlingResource.create(IDLING_RESOURCE_NAME, apolloClient); - - assertThat(idlingResource.getName()).isEqualTo(IDLING_RESOURCE_NAME); - } - - @Test - public void checkIsIdleNow_whenCallIsQueued() throws InterruptedException { - server.enqueue(mockResponse()); - - final CountDownLatch latch = new CountDownLatch(1); - - ExecutorService executorService = Executors.newFixedThreadPool(1); - - apolloClient = ApolloClient.builder() - .okHttpClient(okHttpClient) - .dispatcher(executorService) - .serverUrl(server.url("/")) - .build(); - - idlingResource = ApolloIdlingResource.create(IDLING_RESOURCE_NAME, apolloClient); - assertThat(idlingResource.isIdleNow()).isTrue(); - - apolloClient.query(EMPTY_QUERY).enqueue(new ApolloCall.Callback() { - @Override public void onResponse(@NotNull Response response) { - latch.countDown(); - } - - @Override public void onFailure(@NotNull ApolloException e) { - throw new AssertionError("This callback can't be called."); - } - }); - assertThat(idlingResource.isIdleNow()).isFalse(); - - latch.await(TIME_OUT_SECONDS, TimeUnit.SECONDS); - - executorService.shutdown(); - executorService.awaitTermination(TIME_OUT_SECONDS, TimeUnit.SECONDS); - Thread.sleep(100); - assertThat(idlingResource.isIdleNow()).isTrue(); - } - - @Test - public void checkIsIdleNow_whenCallIsWatched() throws InterruptedException { - server.enqueue(mockResponse()); - - final CountDownLatch latch = new CountDownLatch(1); - - ExecutorService executorService = Executors.newFixedThreadPool(1); - - apolloClient = ApolloClient.builder() - .okHttpClient(okHttpClient) - .dispatcher(executorService) - .serverUrl(server.url("/")) - .build(); - - idlingResource = ApolloIdlingResource.create(IDLING_RESOURCE_NAME, apolloClient); - assertThat(idlingResource.isIdleNow()).isTrue(); - - apolloClient.query(EMPTY_QUERY).watcher().enqueueAndWatch(new ApolloCall.Callback() { - @Override public void onResponse(@NotNull Response response) { - latch.countDown(); - } - - @Override public void onFailure(@NotNull ApolloException e) { - throw new AssertionError("This callback can't be called."); - } - }); - - assertThat(idlingResource.isIdleNow()).isFalse(); - - latch.await(TIME_OUT_SECONDS, TimeUnit.SECONDS); - - executorService.shutdown(); - executorService.awaitTermination(TIME_OUT_SECONDS, TimeUnit.SECONDS); - Thread.sleep(100); - assertThat(idlingResource.isIdleNow()).isTrue(); - } - - - @Test - public void checkIdlingResourceTransition_whenCallIsQueued() throws ApolloException { - server.enqueue(mockResponse()); - - apolloClient = ApolloClient.builder() - .okHttpClient(okHttpClient) - .dispatcher(new Executor() { - @Override public void execute(@NotNull Runnable command) { - command.run(); - } - }) - .serverUrl(server.url("/")) - .build(); - - final AtomicInteger counter = new AtomicInteger(1); - idlingResource = ApolloIdlingResource.create(IDLING_RESOURCE_NAME, apolloClient); - - idlingResource.registerIdleTransitionCallback(new IdlingResource.ResourceCallback() { - @Override public void onTransitionToIdle() { - counter.decrementAndGet(); - } - }); - - assertThat(counter.get()).isEqualTo(1); - Rx2Apollo.from(apolloClient.query(EMPTY_QUERY)).test().awaitTerminalEvent(); - assertThat(counter.get()).isEqualTo(0); - } - - private MockResponse mockResponse() { - return new MockResponse().setResponseCode(200).setBody("{" + - " \"errors\": [" + - " {" + - " \"message\": \"Cannot query field \\\"names\\\" on type \\\"Species\\\".\"," + - " \"locations\": [" + - " {" + - " \"line\": 3," + - " \"column\": 5" + - " }" + - " ]" + - " }" + - " ]" + - "}"); - } -} diff --git a/apollo-integration/build.gradle.kts b/apollo-integration/build.gradle.kts index 5cb3cf167c7..c09c2cd890f 100644 --- a/apollo-integration/build.gradle.kts +++ b/apollo-integration/build.gradle.kts @@ -1,18 +1,18 @@ -import com.apollographql.apollo.gradle.api.ApolloExtension +import com.homer.apollographql.apollo.gradle.api.ApolloExtension -apply(plugin = "com.apollographql.apollo") +apply(plugin = "com.homer.apollographql.apollo") apply(plugin = "org.jetbrains.kotlin.jvm") dependencies { add("implementation", groovy.util.Eval.x(project, "x.dep.kotlin.coroutines")) - add("implementation", "com.apollographql.apollo:apollo-runtime") - add("implementation", "com.apollographql.apollo:apollo-rx2-support") - add("implementation", "com.apollographql.apollo:apollo-rx3-support") - add("implementation", "com.apollographql.apollo:apollo-coroutines-support") - add("implementation", "com.apollographql.apollo:apollo-http-cache") - add("implementation", "com.apollographql.apollo:apollo-normalized-cache-sqlite") - add("implementation", "com.apollographql.apollo:apollo-compiler") + add("implementation", "com.homer.apollographql.apollo:apollo-runtime") + add("implementation", "com.homer.apollographql.apollo:apollo-rx2-support") + add("implementation", "com.homer.apollographql.apollo:apollo-rx3-support") + add("implementation", "com.homer.apollographql.apollo:apollo-coroutines-support") + add("implementation", "com.homer.apollographql.apollo:apollo-http-cache") + add("implementation", "com.homer.apollographql.apollo:apollo-normalized-cache-sqlite") + add("implementation", "com.homer.apollographql.apollo:apollo-compiler") add("testImplementation", kotlin("test-junit")) add("testImplementation", groovy.util.Eval.x(project, "x.dep.junit")) @@ -25,43 +25,43 @@ dependencies { configure { customTypeMapping.set(mapOf( "Date" to "java.util.Date", - "Upload" to "com.apollographql.apollo.api.FileUpload" + "Upload" to "com.homer.apollographql.apollo.api.FileUpload" )) generateOperationOutput.set(true) service("httpcache") { sourceFolder.set("com/apollographql/apollo/integration/httpcache") - rootPackageName.set("com.apollographql.apollo.integration.httpcache") + rootPackageName.set("com.homer.apollographql.apollo.integration.httpcache") } service("interceptor") { sourceFolder.set("com/apollographql/apollo/integration/interceptor") - rootPackageName.set("com.apollographql.apollo.integration.interceptor") + rootPackageName.set("com.homer.apollographql.apollo.integration.interceptor") } service("normalizer") { sourceFolder.set("com/apollographql/apollo/integration/normalizer") - rootPackageName.set("com.apollographql.apollo.integration.normalizer") + rootPackageName.set("com.homer.apollographql.apollo.integration.normalizer") } service("upload") { sourceFolder.set("com/apollographql/apollo/integration/upload") - rootPackageName.set("com.apollographql.apollo.integration.upload") + rootPackageName.set("com.homer.apollographql.apollo.integration.upload") } service("subscription") { sourceFolder.set("com/apollographql/apollo/integration/subscription") - rootPackageName.set("com.apollographql.apollo.integration.subscription") + rootPackageName.set("com.homer.apollographql.apollo.integration.subscription") } service("performance") { sourceFolder.set("com/apollographql/apollo/integration/performance") - rootPackageName.set("com.apollographql.apollo.integration.performance") + rootPackageName.set("com.homer.apollographql.apollo.integration.performance") } service("directives") { sourceFolder.set("com/apollographql/apollo/integration/directives") - rootPackageName.set("com.apollographql.apollo.integration.directives") + rootPackageName.set("com.homer.apollographql.apollo.integration.directives") generateKotlinModels.set(true) } service("sealedclasses") { sealedClassesForEnumsMatching.set(listOf(".*")) generateKotlinModels.set(true) sourceFolder.set("com/apollographql/apollo/integration/sealedclasses") - rootPackageName.set("com.apollographql.apollo.integration.sealedclasses") + rootPackageName.set("com.homer.apollographql.apollo.integration.sealedclasses") } } diff --git a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedMapPartBodyMultiple.json b/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedMapPartBodyMultiple.json deleted file mode 100644 index de2f4b9ba76..00000000000 --- a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedMapPartBodyMultiple.json +++ /dev/null @@ -1 +0,0 @@ -{"0":["variables.files.0"],"1":["variables.files.1"]} \ No newline at end of file diff --git a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedMapPartBodyNested.json b/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedMapPartBodyNested.json deleted file mode 100644 index f61bd3ee308..00000000000 --- a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedMapPartBodyNested.json +++ /dev/null @@ -1 +0,0 @@ -{"0":["variables.topFile"],"1":["variables.topFileList.0"],"2":["variables.topFileList.1"],"3":["variables.nested.recursiveNested.0.file"],"4":["variables.nested.recursiveNested.0.fileList.0"],"5":["variables.nested.recursiveNested.0.fileList.1"],"6":["variables.nested.recursiveNested.1.file"],"7":["variables.nested.recursiveNested.1.fileList.0"],"8":["variables.nested.recursiveNested.1.fileList.1"],"9":["variables.nested.file"],"10":["variables.nested.fileList.0"],"11":["variables.nested.fileList.1"]} \ No newline at end of file diff --git a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedMapPartBodySingle.json b/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedMapPartBodySingle.json deleted file mode 100644 index f6f58dc2785..00000000000 --- a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedMapPartBodySingle.json +++ /dev/null @@ -1 +0,0 @@ -{"0":["variables.file"]} \ No newline at end of file diff --git a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedMapPartBodyTwice.json b/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedMapPartBodyTwice.json deleted file mode 100644 index 1dd4a46d8bf..00000000000 --- a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedMapPartBodyTwice.json +++ /dev/null @@ -1 +0,0 @@ -{"0":["variables.file1"],"1":["variables.file2"]} \ No newline at end of file diff --git a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedOperationsPartBodyMultiple.json b/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedOperationsPartBodyMultiple.json deleted file mode 100644 index faccafcd7df..00000000000 --- a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedOperationsPartBodyMultiple.json +++ /dev/null @@ -1 +0,0 @@ -{"operationName":"MultipleUpload","variables":{"files":[null,null]},"query":"mutation MultipleUpload($files: [Upload!]!) { multipleUpload(files: $files) { __typename id path filename mimetype } }"} diff --git a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedOperationsPartBodyNested.json b/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedOperationsPartBodyNested.json deleted file mode 100644 index 7040db50a68..00000000000 --- a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedOperationsPartBodyNested.json +++ /dev/null @@ -1 +0,0 @@ -{"operationName":"NestedUpload","variables":{"topFile":null,"topFileList":[null,null],"nested":{"recursiveNested":[{"file":null,"fileList":[null,null]},{"file":null,"fileList":[null,null]}],"file":null,"fileList":[null,null]}},"query":"mutation NestedUpload($topFile: Upload, $topFileList: [Upload], $nested: NestedObject) { nestedUpload(topFile: $topFile, topFileList: $topFileList, nested: $nested) }"} diff --git a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedOperationsPartBodySingle.json b/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedOperationsPartBodySingle.json deleted file mode 100644 index 400620946ca..00000000000 --- a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedOperationsPartBodySingle.json +++ /dev/null @@ -1 +0,0 @@ -{"operationName":"SingleUpload","variables":{"file":null},"query":"mutation SingleUpload($file: Upload!) { singleUpload(file: $file) { __typename id path filename mimetype } }"} diff --git a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedOperationsPartBodyTwice.json b/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedOperationsPartBodyTwice.json deleted file mode 100644 index 22eb1c5c178..00000000000 --- a/apollo-integration/src/test/fixtures/ApolloServerInterceptorFileUploadTest/expectedOperationsPartBodyTwice.json +++ /dev/null @@ -1 +0,0 @@ -{"operationName":"SingleUploadTwice","variables":{"file1":null,"file2":null},"query":"mutation SingleUploadTwice($file1: Upload!, $file2: Upload!) { file1: singleUpload(file: $file1) { __typename id path filename mimetype } file2: singleUpload(file: $file2) { __typename id path filename mimetype } }"} diff --git a/apollo-integration/src/test/fixtures/ApolloServerInterceptorTest/interceptorRequestBody.json b/apollo-integration/src/test/fixtures/ApolloServerInterceptorTest/interceptorRequestBody.json deleted file mode 100644 index 521b2e9eb6f..00000000000 --- a/apollo-integration/src/test/fixtures/ApolloServerInterceptorTest/interceptorRequestBody.json +++ /dev/null @@ -1 +0,0 @@ -{"operationName":"AllFilms","variables":{"after":"some cursor","first":null,"last":100},"query":"query AllFilms($after: String, $first: Int, $before: String, $last: Int) { allFilms(after: $after, first: $first, before: $before, last: $last) { __typename totalCount films { __typename title releaseDate } } }"} \ No newline at end of file diff --git a/apollo-integration/src/test/fixtures/IntegrationTest/allPlanets.json b/apollo-integration/src/test/fixtures/IntegrationTest/allPlanets.json deleted file mode 100644 index 0e848d4925e..00000000000 --- a/apollo-integration/src/test/fixtures/IntegrationTest/allPlanets.json +++ /dev/null @@ -1 +0,0 @@ -{"operationName":"AllPlanets","variables":{},"query":"query AllPlanets { allPlanets(first: 300) { __typename planets { __typename ...PlanetFragment filmConnection { __typename totalCount films { __typename title ...FilmFragment } } } } } fragment PlanetFragment on Planet { __typename name climates surfaceWater } fragment FilmFragment on Film { __typename title producers }"} \ No newline at end of file diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/ApolloCancelCallTest.kt b/apollo-integration/src/test/java/com/apollographql/apollo/ApolloCancelCallTest.kt deleted file mode 100644 index 069a9f41c02..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/ApolloCancelCallTest.kt +++ /dev/null @@ -1,233 +0,0 @@ -package com.apollographql.apollo - -import com.apollographql.apollo.Utils.immediateExecutor -import com.apollographql.apollo.Utils.immediateExecutorService -import com.apollographql.apollo.Utils.readFileToString -import com.apollographql.apollo.api.Input.Companion.fromNullable -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.cache.http.ApolloHttpCache -import com.apollographql.apollo.cache.http.DiskLruHttpCacheStore -import com.apollographql.apollo.exception.ApolloCanceledException -import com.apollographql.apollo.exception.ApolloException -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery -import com.apollographql.apollo.integration.normalizer.type.Episode -import com.google.common.truth.Truth -import okhttp3.Dispatcher -import okhttp3.OkHttpClient -import okhttp3.mockwebserver.MockResponse -import okhttp3.mockwebserver.MockWebServer -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import java.io.File -import java.io.IOException -import java.util.concurrent.TimeUnit -import java.util.concurrent.TimeoutException -import kotlin.test.fail - -class ApolloCancelCallTest { - private lateinit var apolloClient: ApolloClient - private lateinit var cacheStore: MockHttpCacheStore - - @get:Rule - val server = MockWebServer() - - @Before - fun setup() { - cacheStore = MockHttpCacheStore() - cacheStore.delegate = DiskLruHttpCacheStore(InMemoryFileSystem(), File("/cache/"), Int.MAX_VALUE.toLong()) - - val okHttpClient = OkHttpClient.Builder() - .dispatcher(Dispatcher(immediateExecutorService())) - .build() - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(okHttpClient) - .httpCache(ApolloHttpCache(cacheStore, null)) - .build() - } - - class TestableCallback : ApolloCall.Callback() { - val lock = Object() - var completed = false - val responses = mutableListOf>() - val errors = mutableListOf() - - override fun onResponse(response: Response) { - synchronized(lock) { - responses.add(response) - } - } - - override fun onFailure(e: ApolloException) { - synchronized(lock) { - errors.add(e) - - // Runtime doesn't send the COMPLETED status event - completed = true - lock.notifyAll() - } - } - - override fun onStatusEvent(event: ApolloCall.StatusEvent) { - super.onStatusEvent(event) - if (event == ApolloCall.StatusEvent.COMPLETED) { - synchronized(lock) { - completed = true - lock.notifyAll() - } - } - } - - fun waitForCompletion(timeoutDuration: Long, unit: TimeUnit) { - val start = System.currentTimeMillis() - while (true) { - val timeoutMillis = TimeUnit.MILLISECONDS.convert(timeoutDuration, unit) - (System.currentTimeMillis() - start) - if (timeoutMillis < 0) { - throw TimeoutException("Timeout reached") - } - if (completed) { - break - } - synchronized(lock) { - try { - lock.wait(timeoutMillis) - } catch (e: InterruptedException) { - - } - } - } - } - } - - class TestablePrefetchCallback : ApolloPrefetch.Callback() { - val lock = Object() - var completed = false - val errors = mutableListOf() - - - override fun onFailure(e: ApolloException) { - synchronized(lock) { - errors.add(e) - - // Runtime doesn't send the COMPLETED status event - completed = true - lock.notifyAll() - } - } - - override fun onSuccess() { - synchronized(lock) { - completed = true - lock.notifyAll() - } - } - - fun waitForCompletion(timeoutDuration: Long, unit: TimeUnit) { - val start = System.currentTimeMillis() - while (true) { - val timeoutMillis = TimeUnit.MILLISECONDS.convert(timeoutDuration, unit) - (System.currentTimeMillis() - start) - if (timeoutMillis < 0) { - throw TimeoutException("Timeout reached") - } - if (completed) { - break - } - synchronized(lock) { - try { - lock.wait(timeoutMillis) - } catch (e: InterruptedException) { - - } - } - } - } - } - - @Test - @Throws(Exception::class) - fun cancelCallBeforeEnqueueCanceledException() { - server.enqueue(mockResponse("EpisodeHeroNameResponse.json")) - val call: ApolloCall = apolloClient.query(EpisodeHeroNameQuery(fromNullable(Episode.EMPIRE))) - - val callback = TestableCallback() - - call.cancel() - call.enqueue(callback) - - callback.waitForCompletion(1, TimeUnit.SECONDS) - Truth.assertThat(callback.responses.size).isEqualTo(0) - Truth.assertThat(callback.errors.size).isEqualTo(1) - Truth.assertThat(callback.errors[0]).isInstanceOf(ApolloCanceledException::class.java) - } - - @Test - @Throws(Exception::class) - fun cancelCallAfterEnqueueNoCallback() { - val okHttpClient = OkHttpClient.Builder() - .dispatcher(Dispatcher(immediateExecutorService())) - .build() - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(okHttpClient) - .httpCache(ApolloHttpCache(cacheStore, null)) - .build() - server.enqueue(mockResponse("EpisodeHeroNameResponse.json").setHeadersDelay(500, TimeUnit.MILLISECONDS)) - val call: ApolloCall = apolloClient.query(EpisodeHeroNameQuery(fromNullable(Episode.EMPIRE))) - - val callback = TestableCallback() - - call.enqueue(callback) - call.cancel() - - try { - callback.waitForCompletion(1, TimeUnit.SECONDS) - fail("TimeoutException expected") - } catch (e: TimeoutException) { - - } - Truth.assertThat(callback.responses.size).isEqualTo(0) - Truth.assertThat(callback.errors.size).isEqualTo(0) - } - - @Test - @Throws(Exception::class) - fun cancelPrefetchBeforeEnqueueCanceledException() { - server.enqueue(mockResponse("EpisodeHeroNameResponse.json")) - val call = apolloClient.prefetch(EpisodeHeroNameQuery(fromNullable(Episode.EMPIRE))) - - val callback = TestablePrefetchCallback() - - call.cancel() - call.enqueue(callback) - - callback.waitForCompletion(1, TimeUnit.SECONDS) - Truth.assertThat(callback.errors.size).isEqualTo(1) - Truth.assertThat(callback.errors[0]).isInstanceOf(ApolloCanceledException::class.java) - } - - @Test - @Throws(Exception::class) - fun cancelPrefetchAfterEnqueueNoCallback() { - server.enqueue(mockResponse("EpisodeHeroNameResponse.json").setHeadersDelay(500, TimeUnit.MILLISECONDS)) - val call = apolloClient.prefetch(EpisodeHeroNameQuery(fromNullable(Episode.EMPIRE))) - - val callback = TestablePrefetchCallback() - - call.enqueue(callback) - call.cancel() - - try { - callback.waitForCompletion(1, TimeUnit.SECONDS) - fail("TimeoutException expected") - } catch (e: TimeoutException) { - - } - Truth.assertThat(callback.errors.size).isEqualTo(0) - } - - @Throws(IOException::class) - private fun mockResponse(fileName: String): MockResponse { - return MockResponse().setChunkedBody(readFileToString(javaClass, "/$fileName"), 32) - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/ApolloInterceptorChainTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/ApolloInterceptorChainTest.java deleted file mode 100644 index 6693ab946a4..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/ApolloInterceptorChainTest.java +++ /dev/null @@ -1,225 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.cache.normalized.Record; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery; -import com.apollographql.apollo.integration.normalizer.type.Episode; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptorChain; -import com.apollographql.apollo.internal.interceptor.RealApolloInterceptorChain; -import okhttp3.MediaType; -import okhttp3.Protocol; -import okhttp3.Request; -import okhttp3.ResponseBody; -import org.jetbrains.annotations.NotNull; -import org.junit.Assert; -import org.junit.Test; - -import java.util.Collections; -import java.util.List; -import java.util.concurrent.Executor; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicInteger; - -import static com.apollographql.apollo.interceptor.ApolloInterceptor.CallBack; -import static com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorResponse; -import static com.google.common.truth.Truth.assertThat; - -public class ApolloInterceptorChainTest { - - @Test - public void onProceedAsyncCalled_chainPassesControlToInterceptor() throws TimeoutException, InterruptedException { - final AtomicInteger counter = new AtomicInteger(1); - - EpisodeHeroNameQuery query = createQuery(); - - ApolloInterceptor interceptor = new ApolloInterceptor() { - @Override - public void interceptAsync(@NotNull InterceptorRequest request, @NotNull ApolloInterceptorChain chain, - @NotNull Executor dispatcher, @NotNull CallBack callBack) { - counter.decrementAndGet(); - } - - @Override public void dispose() { - - } - }; - - List interceptors = Collections.singletonList(interceptor); - RealApolloInterceptorChain chain = new RealApolloInterceptorChain(interceptors); - chain.proceedAsync( - ApolloInterceptor.InterceptorRequest.builder(query).fetchFromCache(false).build(), Utils.INSTANCE.immediateExecutor(), - new CallBack() { - @Override public void onResponse(@NotNull InterceptorResponse response) { - } - - @Override public void onFailure(@NotNull ApolloException e) { - } - - @Override public void onCompleted() { - } - - @Override public void onFetch(ApolloInterceptor.FetchSourceType sourceType) { - } - }); - - //If counter's count doesn't go down to zero, it means interceptor's interceptAsync wasn't called - //which means the test should fail. - if (counter.get() != 0) { - Assert.fail("Control not passed to the interceptor"); - } - } - - @Test - public void onProceedAsyncCalled_correctInterceptorResponseIsReceived() throws TimeoutException, InterruptedException { - final AtomicInteger counter = new AtomicInteger(1); - - EpisodeHeroNameQuery query = createQuery(); - final InterceptorResponse expectedResponse = prepareInterceptorResponse(query); - - ApolloInterceptor interceptor = new ApolloInterceptor() { - @Override - public void interceptAsync(@NotNull InterceptorRequest request, @NotNull ApolloInterceptorChain chain, - @NotNull Executor dispatcher, @NotNull final CallBack callBack) { - dispatcher.execute(new Runnable() { - @Override public void run() { - callBack.onResponse(expectedResponse); - } - }); - } - - @Override public void dispose() { - - } - }; - - List interceptors = Collections.singletonList(interceptor); - RealApolloInterceptorChain chain = new RealApolloInterceptorChain(interceptors); - chain.proceedAsync(ApolloInterceptor.InterceptorRequest.builder(query).fetchFromCache(false).build(), - Utils.INSTANCE.immediateExecutor(), new CallBack() { - @Override public void onResponse(@NotNull InterceptorResponse response) { - assertThat(response).isEqualTo(expectedResponse); - counter.decrementAndGet(); - } - - @Override public void onFailure(@NotNull ApolloException e) { - - } - - @Override public void onCompleted() { - - } - - @Override public void onFetch(ApolloInterceptor.FetchSourceType sourceType) { - - } - }); - - if (counter.get() != 0) { - Assert.fail("Interceptor's response not received"); - } - } - - @Test - public void onProceedAsyncCalled_correctExceptionIsCaught() throws TimeoutException, InterruptedException { - final AtomicInteger counter = new AtomicInteger(1); - - final String message = "ApolloException"; - EpisodeHeroNameQuery query = createQuery(); - ApolloInterceptor interceptor = new ApolloInterceptor() { - @Override - public void interceptAsync(@NotNull InterceptorRequest request, @NotNull ApolloInterceptorChain chain, - @NotNull Executor dispatcher, @NotNull final CallBack callBack) { - dispatcher.execute(new Runnable() { - @Override public void run() { - ApolloException apolloException = new ApolloException(message); - callBack.onFailure(apolloException); - } - }); - } - - @Override public void dispose() { - - } - }; - - List interceptors = Collections.singletonList(interceptor); - RealApolloInterceptorChain chain = new RealApolloInterceptorChain(interceptors); - chain.proceedAsync(ApolloInterceptor.InterceptorRequest.builder(query).fetchFromCache(false).build(), - Utils.INSTANCE.immediateExecutor(), new CallBack() { - @Override public void onResponse(@NotNull InterceptorResponse response) { - - } - - @Override public void onFailure(@NotNull ApolloException e) { - assertThat(e.getMessage()).isEqualTo(message); - counter.decrementAndGet(); - } - - @Override public void onCompleted() { - - } - - @Override public void onFetch(ApolloInterceptor.FetchSourceType sourceType) { - - } - }); - - if (counter.get() != 0) { - Assert.fail("Exception thrown by Interceptor not caught"); - } - } - - @Test - public void onDisposeCalled_interceptorIsDisposed() { - final AtomicInteger counter = new AtomicInteger(1); - - ApolloInterceptor interceptor = new ApolloInterceptor() { - @Override - public void interceptAsync(@NotNull InterceptorRequest request, @NotNull ApolloInterceptorChain chain, @NotNull - Executor dispatcher, @NotNull CallBack callBack) { - - } - - @Override public void dispose() { - counter.decrementAndGet(); - } - }; - - List interceptors = Collections.singletonList(interceptor); - RealApolloInterceptorChain chain = new RealApolloInterceptorChain(interceptors); - chain.dispose(); - if (counter.get() != 0) { - Assert.fail("Interceptor's dispose method not called"); - } - } - - @NotNull - private EpisodeHeroNameQuery createQuery() { - return EpisodeHeroNameQuery - .builder() - .episode(Episode.EMPIRE) - .build(); - } - - @NotNull - private InterceptorResponse prepareInterceptorResponse(EpisodeHeroNameQuery query) { - Request request = new Request.Builder() - .url("https://localhost:8080/") - .build(); - - okhttp3.Response okHttpResponse = new okhttp3.Response.Builder() - .request(request) - .protocol(Protocol.HTTP_2) - .code(200) - .message("Intercepted") - .body(ResponseBody.create(MediaType.parse("text/plain; charset=utf-8"), "fakeResponse")) - .build(); - - Response apolloResponse = Response.builder(query).build(); - - return new InterceptorResponse(okHttpResponse, - apolloResponse, Collections.emptyList()); - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/ApolloInterceptorTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/ApolloInterceptorTest.java deleted file mode 100644 index f0c33e78f04..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/ApolloInterceptorTest.java +++ /dev/null @@ -1,344 +0,0 @@ -package com.apollographql.apollo; - - -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.cache.normalized.Record; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.exception.ApolloParseException; -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery; -import com.apollographql.apollo.integration.normalizer.type.Episode; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptorChain; -import com.apollographql.apollo.rx2.Rx2Apollo; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.io.IOException; -import java.util.Collections; -import java.util.concurrent.Executor; -import java.util.concurrent.TimeoutException; - -import org.jetbrains.annotations.NotNull; - -import io.reactivex.functions.Predicate; -import okhttp3.Dispatcher; -import okhttp3.MediaType; -import okhttp3.OkHttpClient; -import okhttp3.Protocol; -import okhttp3.Request; -import okhttp3.ResponseBody; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; - -import static com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorResponse; -import static com.google.common.truth.Truth.assertThat; - -public class ApolloInterceptorTest { - private static final String FILE_EPISODE_HERO_NAME_WITH_ID = "EpisodeHeroNameResponseWithId.json"; - private static final String FILE_EPISODE_HERO_NAME_CHANGE = "EpisodeHeroNameResponseNameChange.json"; - - private ApolloClient client; - @Rule public final MockWebServer server = new MockWebServer(); - private OkHttpClient okHttpClient; - - @Before - public void setup() { - okHttpClient = new OkHttpClient.Builder() - .dispatcher(new Dispatcher(Utils.INSTANCE.immediateExecutorService())) - .build(); - } - - @Test - public void asyncApplicationInterceptorCanShortCircuitResponses() throws Exception { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)); - EpisodeHeroNameQuery query = createHeroNameQuery(); - final InterceptorResponse expectedResponse = prepareInterceptorResponse(query); - ApolloInterceptor interceptor = createShortcutInterceptor(expectedResponse); - - client = createApolloClient(interceptor); - Rx2Apollo.from(client.query(query)).test() - .assertValue(expectedResponse.parsedResponse.get()); - } - - @Test - public void asyncApplicationInterceptorRewritesResponsesFromServer() throws Exception { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)); - EpisodeHeroNameQuery query = createHeroNameQuery(); - final InterceptorResponse rewrittenResponse = prepareInterceptorResponse(query); - ApolloInterceptor interceptor = new ApolloInterceptor() { - @Override - public void interceptAsync(@NotNull InterceptorRequest request, @NotNull ApolloInterceptorChain chain, - @NotNull Executor dispatcher, @NotNull final CallBack callBack) { - chain.proceedAsync(request, dispatcher, new CallBack() { - @Override public void onResponse(@NotNull InterceptorResponse response) { - callBack.onResponse(rewrittenResponse); - } - - @Override public void onFailure(@NotNull ApolloException e) { - throw new RuntimeException(e); - } - - @Override public void onCompleted() { - callBack.onCompleted(); - } - - @Override public void onFetch(FetchSourceType sourceType) { - callBack.onFetch(sourceType); - } - }); - } - - @Override public void dispose() { - - } - }; - - client = createApolloClient(interceptor); - Rx2Apollo.from(client.query(query)).test() - .assertValue(rewrittenResponse.parsedResponse.get()); - } - - @Test - public void asyncApplicationInterceptorThrowsApolloException() throws Exception { - final String message = "ApolloException"; - EpisodeHeroNameQuery query = createHeroNameQuery(); - ApolloInterceptor interceptor = new ApolloInterceptor() { - @Override - public void interceptAsync(@NotNull InterceptorRequest request, @NotNull ApolloInterceptorChain chain, - @NotNull Executor dispatcher, @NotNull CallBack callBack) { - ApolloException apolloException = new ApolloParseException(message); - callBack.onFailure(apolloException); - } - - @Override public void dispose() { - - } - }; - - client = createApolloClient(interceptor); - Rx2Apollo.from(client.query(query)) - .test() - .assertError(new Predicate() { - @Override public boolean test(Throwable throwable) throws Exception { - return message.equals(throwable.getMessage()) && throwable instanceof ApolloParseException; - } - }); - } - - @Test - public void asyncApplicationInterceptorThrowsRuntimeException() throws TimeoutException, InterruptedException { - final String message = "RuntimeException"; - EpisodeHeroNameQuery query = createHeroNameQuery(); - ApolloInterceptor interceptor = new ApolloInterceptor() { - @Override - public void interceptAsync(@NotNull InterceptorRequest request, @NotNull ApolloInterceptorChain chain, - @NotNull Executor dispatcher, @NotNull CallBack callBack) { - dispatcher.execute(new Runnable() { - @Override public void run() { - throw new RuntimeException(message); - } - }); - } - - @Override public void dispose() { - - } - }; - - client = createApolloClient(interceptor); - - Rx2Apollo.from(client.query(query)).test() - .assertError(new Predicate() { - @Override public boolean test(Throwable throwable) throws Exception { - return throwable instanceof RuntimeException && message.equals(throwable.getMessage()); - } - }); - } - - @Test - public void asyncApplicationInterceptorReturnsNull() throws TimeoutException, InterruptedException { - EpisodeHeroNameQuery query = createHeroNameQuery(); - ApolloInterceptor interceptor = new ApolloInterceptor() { - @Override - public void interceptAsync(@NotNull InterceptorRequest request, @NotNull ApolloInterceptorChain chain, - @NotNull Executor dispatcher, @NotNull final CallBack callBack) { - dispatcher.execute(new Runnable() { - @Override public void run() { - callBack.onResponse(null); - } - }); - } - - @Override public void dispose() { - - } - }; - - client = createApolloClient(interceptor); - - Rx2Apollo.from(client.query(query)).test() - .assertError(new Predicate() { - @Override public boolean test(Throwable throwable) throws Exception { - return throwable instanceof NullPointerException; - } - }); - } - - @Test - public void applicationInterceptorCanMakeMultipleRequestsToServer() throws Exception { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_CHANGE)); - EpisodeHeroNameQuery query = createHeroNameQuery(); - ApolloInterceptor interceptor = createChainInterceptor(); - - client = createApolloClient(interceptor); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - FILE_EPISODE_HERO_NAME_WITH_ID, - client.query(query), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().name()).isEqualTo("Artoo"); - return true; - } - } - ); - } - - @Test - public void onShortCircuitingResponseSubsequentInterceptorsAreNotCalled() throws IOException, ApolloException { - EpisodeHeroNameQuery query = createHeroNameQuery(); - final InterceptorResponse expectedResponse = prepareInterceptorResponse(query); - - ApolloInterceptor firstInterceptor = createShortcutInterceptor(expectedResponse); - ApolloInterceptor secondInterceptor = createChainInterceptor(); - - client = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(okHttpClient) - .addApplicationInterceptor(firstInterceptor) - .addApplicationInterceptor(secondInterceptor) - .build(); - - Utils.INSTANCE.assertResponse( - client.query(query), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(expectedResponse.parsedResponse.get()).isEqualTo(response); - return true; - } - } - ); - } - - @Test - public void onApolloCallCanceledAsyncApolloInterceptorIsDisposed() throws ApolloException, TimeoutException, - InterruptedException, IOException { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)); - - EpisodeHeroNameQuery query = createHeroNameQuery(); - SpyingApolloInterceptor interceptor = new SpyingApolloInterceptor(); - - Utils.TestExecutor testExecutor = new Utils.TestExecutor(); - client = createApolloClient(interceptor, testExecutor); - - ApolloCall apolloCall = client.query(query); - - apolloCall.enqueue(new ApolloCall.Callback() { - @Override public void onResponse(@NotNull Response response) { - } - - @Override public void onFailure(@NotNull ApolloException e) { - } - }); - apolloCall.cancel(); - testExecutor.triggerActions(); - assertThat(interceptor.isDisposed).isTrue(); - } - - @NotNull private EpisodeHeroNameQuery createHeroNameQuery() { - return EpisodeHeroNameQuery - .builder() - .episode(Episode.EMPIRE) - .build(); - } - - private ApolloClient createApolloClient(ApolloInterceptor interceptor, Executor dispatcher) { - return ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(okHttpClient) - .addApplicationInterceptor(interceptor) - .dispatcher(dispatcher) - .build(); - } - - private ApolloClient createApolloClient(ApolloInterceptor interceptor) { - return createApolloClient(interceptor, Utils.INSTANCE.immediateExecutor()); - } - - @NotNull private InterceptorResponse prepareInterceptorResponse(EpisodeHeroNameQuery query) { - Request request = new Request.Builder() - .url(server.url("/")) - .build(); - - okhttp3.Response okHttpResponse = new okhttp3.Response.Builder() - .request(request) - .protocol(Protocol.HTTP_2) - .code(200) - .message("Intercepted") - .body(ResponseBody.create(MediaType.parse("text/plain; charset=utf-8"), "fakeResponse")) - .build(); - - Response apolloResponse = Response.builder(query).build(); - - return new InterceptorResponse(okHttpResponse, - apolloResponse, Collections.emptyList()); - } - - private MockResponse mockResponse(String fileName) throws IOException { - return new MockResponse().setChunkedBody(Utils.INSTANCE.readFileToString(getClass(), "/" + fileName), 32); - } - - private static class SpyingApolloInterceptor implements ApolloInterceptor { - - volatile boolean isDisposed = false; - - @Override - public void interceptAsync(@NotNull InterceptorRequest request, @NotNull ApolloInterceptorChain chain, @NotNull Executor dispatcher, @NotNull CallBack callBack) { - chain.proceedAsync(request, dispatcher, callBack); - } - - @Override public void dispose() { - isDisposed = true; - } - } - - @NotNull private static ApolloInterceptor createChainInterceptor() { - return new ApolloInterceptor() { - @Override - public void interceptAsync(@NotNull InterceptorRequest request, @NotNull ApolloInterceptorChain chain, - @NotNull Executor dispatcher, @NotNull CallBack callBack) { - chain.proceedAsync(request, dispatcher, callBack); - } - - @Override public void dispose() { - - } - }; - } - - @NotNull private static ApolloInterceptor createShortcutInterceptor(final InterceptorResponse expectedResponse) { - return new ApolloInterceptor() { - @Override - public void interceptAsync(@NotNull InterceptorRequest request, @NotNull ApolloInterceptorChain chain, - @NotNull Executor dispatcher, @NotNull CallBack callBack) { - callBack.onResponse(expectedResponse); - } - - @Override public void dispose() { - } - }; - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/ApolloPrefetchTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/ApolloPrefetchTest.java deleted file mode 100644 index dd6d9f5723e..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/ApolloPrefetchTest.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.cache.http.HttpCache; -import com.apollographql.apollo.api.cache.http.HttpCachePolicy; -import com.apollographql.apollo.cache.http.ApolloHttpCache; -import com.apollographql.apollo.cache.http.DiskLruHttpCacheStore; -import com.apollographql.apollo.cache.http.internal.FileSystem; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.integration.httpcache.AllPlanetsQuery; -import com.apollographql.apollo.rx2.Rx2Apollo; -import io.reactivex.functions.Predicate; -import java.io.File; -import java.io.IOException; -import java.util.concurrent.TimeUnit; -import okhttp3.Dispatcher; -import okhttp3.Interceptor; -import okhttp3.OkHttpClient; -import okhttp3.mockwebserver.MockWebServer; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import static com.google.common.truth.Truth.assertThat; - -public class ApolloPrefetchTest { - private ApolloClient apolloClient; - @Rule public final MockWebServer server = new MockWebServer(); - @Rule public final InMemoryFileSystem inMemoryFileSystem = new InMemoryFileSystem(); - okhttp3.Request lastHttRequest; - okhttp3.Response lastHttResponse; - private MockHttpCacheStore cacheStore; - private OkHttpClient okHttpClient; - - @Before - public void setup() { - cacheStore = new MockHttpCacheStore(); - cacheStore.delegate = new DiskLruHttpCacheStore(inMemoryFileSystem, new File("/cache/"), Integer.MAX_VALUE); - okHttpClient = new OkHttpClient.Builder() - .addInterceptor(new Interceptor() { - @Override public okhttp3.Response intercept(Chain chain) throws IOException { - lastHttRequest = chain.request(); - lastHttResponse = chain.proceed(lastHttRequest); - return lastHttResponse; - } - }) - .dispatcher(new Dispatcher(Utils.INSTANCE.immediateExecutorService())) - .build(); - - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(okHttpClient) - .dispatcher(Utils.INSTANCE.immediateExecutor()) - .httpCache(new ApolloHttpCache(cacheStore, null)) - .build(); - } - - @After public void tearDown() { - apolloClient.clearHttpCache(); - } - - @Test public void prefetchDefault() throws IOException, ApolloException { - server.enqueue(Utils.INSTANCE.mockResponse("HttpCacheTestAllPlanets.json")); - prefetch(apolloClient.prefetch(new AllPlanetsQuery())); - checkCachedResponse("HttpCacheTestAllPlanets.json"); - Utils.INSTANCE.assertResponse( - apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.CACHE_ONLY.expireAfter(2, TimeUnit.SECONDS)), - new Predicate>() { - @Override public boolean test(Response dataResponse) throws Exception { - return !dataResponse.hasErrors(); - } - } - ); - } - - @Test public void prefetchNoCacheStore() throws Exception { - ApolloClient apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(okHttpClient) - .dispatcher(Utils.INSTANCE.immediateExecutor()) - .build(); - - server.enqueue(Utils.INSTANCE.mockResponse("HttpCacheTestAllPlanets.json")); - prefetch(apolloClient.prefetch(new AllPlanetsQuery())); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HttpCacheTestAllPlanets.json", - apolloClient.query(new AllPlanetsQuery()), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - } - - @Test public void prefetchFileSystemWriteFailure() throws IOException { - FaultyHttpCacheStore faultyCacheStore = new FaultyHttpCacheStore(FileSystem.SYSTEM); - cacheStore.delegate = faultyCacheStore; - - faultyCacheStore.failStrategy(FaultyHttpCacheStore.FailStrategy.FAIL_HEADER_WRITE); - server.enqueue(Utils.INSTANCE.mockResponse("HttpCacheTestAllPlanets.json")); - - Rx2Apollo.from(apolloClient.prefetch(new AllPlanetsQuery())) - .test() - .assertError(Exception.class); - checkNoCachedResponse(); - - server.enqueue(Utils.INSTANCE.mockResponse("HttpCacheTestAllPlanets.json")); - faultyCacheStore.failStrategy(FaultyHttpCacheStore.FailStrategy.FAIL_BODY_WRITE); - Rx2Apollo.from(apolloClient.prefetch(new AllPlanetsQuery())) - .test() - .assertError(Exception.class); - checkNoCachedResponse(); - } - - private void checkCachedResponse(String fileName) throws IOException { - String cacheKey = lastHttRequest.headers(HttpCache.CACHE_KEY_HEADER).get(0); - okhttp3.Response response = apolloClient.cachedHttpResponse(cacheKey); - assertThat(response).isNotNull(); - assertThat(response.body().source().readUtf8()).isEqualTo(Utils.INSTANCE.readFileToString(getClass(), "/" + fileName)); - response.body().source().close(); - } - - private void checkNoCachedResponse() throws IOException { - String cacheKey = lastHttRequest.header(HttpCache.CACHE_KEY_HEADER); - okhttp3.Response cachedResponse = apolloClient.cachedHttpResponse(cacheKey); - assertThat(cachedResponse).isNull(); - } - - @SuppressWarnings("CheckReturnValue") - private static void prefetch(ApolloPrefetch prefetch) { - Rx2Apollo.from(prefetch).test(); - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/ApolloWatcherTest.kt b/apollo-integration/src/test/java/com/apollographql/apollo/ApolloWatcherTest.kt deleted file mode 100644 index e2ce67854a9..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/ApolloWatcherTest.kt +++ /dev/null @@ -1,414 +0,0 @@ -package com.apollographql.apollo - -import com.apollographql.apollo.ApolloCall.Callback -import com.apollographql.apollo.ApolloCall.StatusEvent -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.cache.CacheHeaders -import com.apollographql.apollo.cache.normalized.Record -import com.apollographql.apollo.cache.normalized.internal.Transaction -import com.apollographql.apollo.cache.normalized.internal.WriteableStore -import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy -import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory -import com.apollographql.apollo.coroutines.await -import kotlinx.coroutines.flow.collect -import kotlinx.coroutines.channels.Channel -import kotlinx.coroutines.yield -import com.apollographql.apollo.coroutines.toFlow -import com.apollographql.apollo.exception.ApolloException -import com.apollographql.apollo.fetcher.ApolloResponseFetchers -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesWithIDsQuery -import com.apollographql.apollo.integration.normalizer.StarshipByIdQuery -import com.apollographql.apollo.integration.normalizer.type.Episode -import com.google.common.truth.Truth -import com.google.common.truth.Truth.assertThat -import junit.framework.Assert -import kotlinx.coroutines.delay -import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking -import okhttp3.Dispatcher -import okhttp3.OkHttpClient -import okhttp3.mockwebserver.MockWebServer -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import org.mockito.InOrder -import org.mockito.Mockito -import org.mockito.Mockito.inOrder -import java.io.IOException -import java.util.* -import java.util.concurrent.TimeoutException - -class ApolloWatcherTest { - private lateinit var apolloClient: ApolloClient - - @get:Rule - val server = MockWebServer() - - @Before - @Throws(IOException::class) - fun setUp() { - val okHttpClient = OkHttpClient.Builder() - .dispatcher(Dispatcher(Utils.immediateExecutorService())) - .build() - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .dispatcher(Utils.immediateExecutor()) - .okHttpClient(okHttpClient) - .logger(object : Logger { - override fun log(priority: Int, message: String, t: Throwable?, vararg args: Any) { - println(String.format(message, *args)) - t?.printStackTrace() - } - }) - .normalizedCache(LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), IdFieldCacheKeyResolver()) - .build() - } - - @Test - fun testQueryWatcherUpdated_SameQuery_DifferentResults() { - val heroNameList: MutableList = ArrayList() - val query: EpisodeHeroNameQuery = EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build() - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseWithId.json")) - val watcher = apolloClient.query(query).watcher() - watcher.enqueueAndWatch( - object : Callback() { - override fun onResponse(response: Response) { - heroNameList.add(response.data()!!.hero()!!.name()) - } - - override fun onFailure(e: ApolloException) { - Assert.fail(e.message) - } - }) - - - // Another newer call gets updated information - Utils.enqueueAndAssertResponse( - server, - "EpisodeHeroNameResponseNameChange.json", - apolloClient.query(query).responseFetcher(ApolloResponseFetchers.NETWORK_ONLY), - { response -> !response.hasErrors() } - ) - watcher.cancel() - Truth.assertThat(heroNameList[0]).isEqualTo("R2-D2") - Truth.assertThat(heroNameList[1]).isEqualTo("Artoo") - Truth.assertThat(heroNameList.size).isEqualTo(2) - } - - @Test - @Throws(IOException::class, InterruptedException::class, TimeoutException::class, ApolloException::class) - fun testQueryWatcherUpdated_Store_write() { - val heroNameList: MutableList = ArrayList() - val query: EpisodeHeroNameQuery = EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build() - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseWithId.json")) - val watcher: ApolloQueryWatcher = apolloClient.query(query).watcher() - watcher.enqueueAndWatch( - object : Callback() { - override fun onResponse(response: Response) { - heroNameList.add(response.data()!!.hero()!!.name()) - } - - override fun onFailure(e: ApolloException) { - Assert.fail(e.message) - } - }) - Truth.assertThat(heroNameList[0]).isEqualTo("R2-D2") - - // Someone writes to the store directly - val changedKeys: Set = apolloClient.getApolloStore().writeTransaction(object : Transaction> { - override fun execute(cache: WriteableStore): Set? { - val record: Record = Record.builder("2001") - .addField("name", "Artoo") - .build() - return cache.merge(listOf(record), CacheHeaders.NONE) - } - }) - apolloClient.getApolloStore().publish(changedKeys) - Truth.assertThat(heroNameList[1]).isEqualTo("Artoo") - watcher.cancel() - } - - @Test - fun testQueryWatcherNotUpdated_SameQuery_SameResults() { - val heroNameList: MutableList = ArrayList() - val query: EpisodeHeroNameQuery = EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build() - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseWithId.json")) - val watcher: ApolloQueryWatcher = apolloClient.query(query).watcher() - watcher.enqueueAndWatch( - object : Callback() { - override fun onResponse(response: Response) { - heroNameList.add(response.data()!!.hero()!!.name()) - } - - override fun onFailure(e: ApolloException) { - Assert.fail(e.message) - } - }) - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseWithId.json")) - apolloClient.query(query).responseFetcher(ApolloResponseFetchers.NETWORK_ONLY).enqueue(null) - watcher.cancel() - Truth.assertThat(heroNameList[0]).isEqualTo("R2-D2") - Truth.assertThat(heroNameList.size).isEqualTo(1) - } - - @Test - fun testQueryWatcherUpdated_DifferentQuery_DifferentResults() { - val heroNameList: MutableList = ArrayList() - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseWithId.json")) - val query: EpisodeHeroNameQuery = EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build() - val watcher: ApolloQueryWatcher = apolloClient.query(query).watcher() - watcher.enqueueAndWatch( - object : Callback() { - override fun onResponse(response: Response) { - heroNameList.add(response.data()!!.hero()!!.name()) - } - - override fun onFailure(e: ApolloException) { - Assert.fail(e.message) - } - }) - val friendsQuery: HeroAndFriendsNamesWithIDsQuery = HeroAndFriendsNamesWithIDsQuery.builder() - .episode(Episode.NEWHOPE) - .build() - Utils.enqueueAndAssertResponse( - server, - "HeroAndFriendsNameWithIdsNameChange.json", - apolloClient.query(friendsQuery).responseFetcher(ApolloResponseFetchers.NETWORK_ONLY), - { response -> !response.hasErrors() } - ) - watcher.cancel() - Truth.assertThat(heroNameList[0]).isEqualTo("R2-D2") - Truth.assertThat(heroNameList[1]).isEqualTo("Artoo") - } - - @Test - fun testQueryWatcherNotUpdated_DifferentQueries() { - val heroNameList: MutableList = ArrayList() - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseWithId.json")) - val query: EpisodeHeroNameQuery = EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build() - val watcher: ApolloQueryWatcher = apolloClient.query(query).watcher() - watcher.enqueueAndWatch( - object : Callback() { - override fun onResponse(response: Response) { - heroNameList.add(response.data()!!.hero()!!.name()) - } - - override fun onFailure(e: ApolloException) { - Assert.fail(e.message) - } - }) - val friendsQuery: HeroAndFriendsNamesWithIDsQuery = HeroAndFriendsNamesWithIDsQuery.builder().episode(Episode.NEWHOPE).build() - server.enqueue(Utils.mockResponse("HeroAndFriendsNameWithIdsResponse.json")) - apolloClient.query(friendsQuery).responseFetcher(ApolloResponseFetchers.NETWORK_ONLY).enqueue(null) - watcher.cancel() - Truth.assertThat(heroNameList[0]).isEqualTo("R2-D2") - Truth.assertThat(heroNameList.size).isEqualTo(1) - } - - @Test - fun testRefetchCacheControl() { - val heroNameList: MutableList = ArrayList() - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseWithId.json")) - val query: EpisodeHeroNameQuery = EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build() - val watcher: ApolloQueryWatcher = apolloClient.query(query).watcher() - watcher.refetchResponseFetcher(ApolloResponseFetchers.NETWORK_ONLY) //Force network instead of CACHE_FIRST default - .enqueueAndWatch( - object : Callback() { - override fun onResponse(response: Response) { - heroNameList.add(response.data()!!.hero()!!.name()) - } - - override fun onFailure(e: ApolloException) { - Assert.fail(e.message) - } - }) - - //A different call gets updated information. - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseNameChange.json")) - - //To verify that the updated response comes from server use a different name change - // -- this is for the refetch - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseNameChangeTwo.json")) - apolloClient.query(query).responseFetcher(ApolloResponseFetchers.NETWORK_ONLY).enqueue(null) - watcher.cancel() - Truth.assertThat(heroNameList[0]).isEqualTo("R2-D2") - Truth.assertThat(heroNameList[1]).isEqualTo("ArTwo") - Truth.assertThat(heroNameList.size).isEqualTo(2) - } - - @Test - fun testQueryWatcherUpdated_SameQuery_DifferentResults_cacheOnly() { - val heroNameList: MutableList = ArrayList() - val query: EpisodeHeroNameQuery = EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build() - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseWithId.json")) - apolloClient.query(query).enqueue(object : Callback() { - override fun onResponse(response: Response) {} - override fun onFailure(e: ApolloException) { - Assert.fail(e.message) - } - }) - val watcher: ApolloQueryWatcher = apolloClient.query(query) - .responseFetcher(ApolloResponseFetchers.CACHE_ONLY).watcher() - watcher.enqueueAndWatch( - object : Callback() { - override fun onResponse(response: Response) { - heroNameList.add(response.data()!!.hero()!!.name()) - } - - override fun onFailure(e: ApolloException) { - Assert.fail(e.message) - } - }) - - //Another newer call gets updated information - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseNameChange.json")) - apolloClient.query(query).responseFetcher(ApolloResponseFetchers.NETWORK_ONLY).enqueue(null) - watcher.cancel() - Truth.assertThat(heroNameList[0]).isEqualTo("R2-D2") - Truth.assertThat(heroNameList[1]).isEqualTo("Artoo") - Truth.assertThat(heroNameList.size).isEqualTo(2) - } - - @Test - fun testQueryWatcherNotCalled_WhenCanceled() { - val heroNameList: MutableList = ArrayList() - val query: EpisodeHeroNameQuery = EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build() - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseWithId.json")) - val watcher: ApolloQueryWatcher = apolloClient.query(query).watcher() - watcher.enqueueAndWatch( - object : Callback() { - override fun onResponse(response: Response) { - heroNameList.add(response.data()!!.hero()!!.name()) - } - - override fun onFailure(e: ApolloException) { - Assert.fail(e.message) - } - }) - watcher.cancel() - Utils.enqueueAndAssertResponse( - server, - "EpisodeHeroNameResponseNameChange.json", - apolloClient.query(query).responseFetcher(ApolloResponseFetchers.NETWORK_ONLY), - { response -> !response.hasErrors() } - ) - Truth.assertThat(heroNameList[0]).isEqualTo("R2-D2") - Truth.assertThat(heroNameList.size).isEqualTo(1) - } - - @Test - fun emptyCacheQueryWatcherCacheOnly() { - val watchedHeroes = ArrayList() - val query = EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE)) - apolloClient.query(query) - .responseFetcher(ApolloResponseFetchers.CACHE_ONLY) - .watcher() - .enqueueAndWatch(object : Callback() { - override fun onResponse(response: Response) { - if (response.data() != null) { - watchedHeroes.add(response.data()!!.hero()!!) - } - } - - override fun onFailure(e: ApolloException) { - Assert.fail(e.message) - } - }) - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseWithId.json")) - apolloClient.query(query).enqueue(object : Callback() { - override fun onResponse(response: Response) { - assertThat(response.data()).isNotNull() - assertThat(response.data()?.hero()).isNotNull() - } - - override fun onFailure(e: ApolloException) { - Assert.fail(e.message) - } - }) - Truth.assertThat(watchedHeroes).hasSize(1) - assertThat(watchedHeroes[0]?.name()).isEqualTo("R2-D2") - } - - @Test - fun queryWatcher_onStatusEvent_properlyCalled() { - val query = EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build() - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseWithId.json")) - val watcher = apolloClient.query(query).watcher() - val callback = Mockito.mock(ApolloCall.Callback::class.java) as ApolloCall.Callback - watcher.enqueueAndWatch(callback) - val inOrder: InOrder = inOrder(callback) - inOrder.verify(callback).onStatusEvent(StatusEvent.SCHEDULED) - inOrder.verify(callback).onStatusEvent(StatusEvent.FETCH_CACHE) - inOrder.verify(callback).onStatusEvent(StatusEvent.FETCH_NETWORK) - inOrder.verify(callback).onStatusEvent(StatusEvent.COMPLETED) - } - - @Test - fun queryWatcherWithCacheOnlyNeverGoesToTheNetwork() { - runBlocking { - val channel = Channel>(capacity = Channel.UNLIMITED) - val job = launch { - apolloClient.query(EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build()) - .responseFetcher(ApolloResponseFetchers.CACHE_ONLY) - .watcher() - .refetchResponseFetcher(ApolloResponseFetchers.CACHE_ONLY) - .toFlow() - .collect { - channel.send(it) - } - } - - val response1 = channel.receive() - assertThat(response1.data).isNull() - assertThat(response1.isFromCache).isTrue() - - server.enqueue(Utils.mockResponse("StarshipByIdResponse.json")) - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseWithId.json")) - - // execute a query that doesn't share any key with the main query - // that will trigger a refetch that shouldn't throw - apolloClient.query(StarshipByIdQuery("Starship1")).await() - - val response2 = channel.receive() - // There should be no data - assertThat(response2.data).isNull() - assertThat(response2.isFromCache).isTrue() - - job.cancel() - } - } - - @Test - fun queryWatcherWithCacheOnlyCanBeUpdatedFromAnotherQuery() { - runBlocking { - val channel = Channel>(capacity = Channel.UNLIMITED) - val job = launch { - apolloClient.query(EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build()) - .responseFetcher(ApolloResponseFetchers.CACHE_ONLY) - .watcher() - .refetchResponseFetcher(ApolloResponseFetchers.CACHE_ONLY) - .toFlow() - .collect { - channel.send(it) - } - } - - val response1 = channel.receive() - assertThat(response1.data).isNull() - assertThat(response1.isFromCache).isTrue() - - // execute a query that should go to the network and trigger a result from the watcher - server.enqueue(Utils.mockResponse("EpisodeHeroNameResponseWithId.json")) - apolloClient.query(EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build()).await() - - val response2 = channel.receive() - - assertThat(response2.data()?.hero()?.name()).isEqualTo("R2-D2") - assertThat(response2.isFromCache).isTrue() - - job.cancel() - } - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/AsyncNormalizedCacheTestCase.java b/apollo-integration/src/test/java/com/apollographql/apollo/AsyncNormalizedCacheTestCase.java deleted file mode 100644 index 42dd8ab25b1..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/AsyncNormalizedCacheTestCase.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy; -import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.fetcher.ApolloResponseFetchers; -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery; -import com.apollographql.apollo.integration.normalizer.type.Episode; -import com.apollographql.apollo.rx2.Rx2Apollo; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import io.reactivex.Observable; -import io.reactivex.functions.Predicate; -import io.reactivex.observers.TestObserver; -import okhttp3.OkHttpClient; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; - -public class AsyncNormalizedCacheTestCase { - private ApolloClient apolloClient; - @Rule public final MockWebServer server = new MockWebServer(); - - @Before public void setUp() { - OkHttpClient okHttpClient = new OkHttpClient.Builder() - .build(); - - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(okHttpClient) - .normalizedCache(new LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), new IdFieldCacheKeyResolver()) - .build(); - } - - private MockResponse mockResponse(String fileName) throws IOException, ApolloException { - return new MockResponse().setChunkedBody(Utils.INSTANCE.readFileToString(getClass(), "/" + fileName), 32); - } - - @Test public void testAsync() throws IOException, InterruptedException, ApolloException { - EpisodeHeroNameQuery query = EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build(); - - for (int i = 0; i < 500; i++) { - server.enqueue(mockResponse("HeroNameResponse.json")); - } - - List>> calls = new ArrayList<>(); - for (int i = 0; i < 1000; i++) { - ApolloQueryCall queryCall = apolloClient - .query(query) - .responseFetcher(i % 2 == 0 ? ApolloResponseFetchers.NETWORK_FIRST : ApolloResponseFetchers.CACHE_ONLY); - calls.add(Rx2Apollo.from(queryCall)); - } - TestObserver> observer = new TestObserver<>(); - Observable.merge(calls).subscribe(observer); - observer.awaitTerminalEvent(); - observer.assertNoErrors(); - observer.assertValueCount(1000); - observer.assertNever(new Predicate>() { - @Override public boolean test(Response dataResponse) throws Exception { - return dataResponse.hasErrors(); - } - }); - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/CacheHeadersTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/CacheHeadersTest.java deleted file mode 100644 index da578a801a0..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/CacheHeadersTest.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.cache.ApolloCacheHeaders; -import com.apollographql.apollo.cache.CacheHeaders; -import com.apollographql.apollo.cache.normalized.CacheKey; -import com.apollographql.apollo.cache.normalized.NormalizedCache; -import com.apollographql.apollo.cache.normalized.NormalizedCacheFactory; -import com.apollographql.apollo.cache.normalized.Record; -import com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesQuery; -import com.apollographql.apollo.integration.normalizer.type.Episode; -import com.apollographql.apollo.rx2.Rx2Apollo; -import okhttp3.Dispatcher; -import okhttp3.OkHttpClient; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.junit.Rule; -import org.junit.Test; - -import java.io.IOException; -import java.util.Set; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.google.common.truth.Truth.assertThat; -import static java.util.Collections.emptySet; - -public class CacheHeadersTest { - - @Rule public final MockWebServer server = new MockWebServer(); - - @Test @SuppressWarnings("CheckReturnValue") public void testHeadersReceived() throws ApolloException, IOException { - final AtomicBoolean hasHeader = new AtomicBoolean(); - final NormalizedCache normalizedCache = new NormalizedCache() { - @Nullable @Override public Record loadRecord(@NotNull String key, @NotNull CacheHeaders cacheHeaders) { - hasHeader.set(cacheHeaders.hasHeader(ApolloCacheHeaders.DO_NOT_STORE)); - return null; - } - - @NotNull @Override public Set merge(@NotNull Record record, @NotNull CacheHeaders cacheHeaders) { - hasHeader.set(cacheHeaders.hasHeader(ApolloCacheHeaders.DO_NOT_STORE)); - return emptySet(); - } - - @Override public void clearAll() { - } - - @Override public boolean remove(@NotNull CacheKey cacheKey, boolean cascade) { - return false; - } - - @NotNull @Override - protected Set performMerge(@NotNull Record apolloRecord, @Nullable Record oldRecord, @NotNull CacheHeaders cacheHeaders) { - return emptySet(); - } - }; - - final NormalizedCacheFactory cacheFactory = new NormalizedCacheFactory() { - @Override public NormalizedCache create(RecordFieldJsonAdapter recordFieldAdapter) { - return normalizedCache; - } - }; - - ApolloClient apolloClient = ApolloClient.builder() - .normalizedCache(cacheFactory, new IdFieldCacheKeyResolver()) - .serverUrl(server.url("/")) - .okHttpClient(new OkHttpClient.Builder().dispatcher(new Dispatcher(Utils.INSTANCE.immediateExecutorService())).build()) - .dispatcher(Utils.INSTANCE.immediateExecutor()) - .build(); - - server.enqueue(mockResponse("HeroAndFriendsNameResponse.json")); - CacheHeaders cacheHeaders = CacheHeaders.builder().addHeader(ApolloCacheHeaders.DO_NOT_STORE, "true").build(); - Rx2Apollo.from(apolloClient.query(new HeroAndFriendsNamesQuery(Input.fromNullable(Episode.NEWHOPE))) - .cacheHeaders(cacheHeaders)) - .test(); - assertThat(hasHeader.get()).isTrue(); - } - - @Test @SuppressWarnings("CheckReturnValue") public void testDefaultHeadersReceived() throws Exception { - final AtomicBoolean hasHeader = new AtomicBoolean(); - final NormalizedCache normalizedCache = new NormalizedCache() { - @Nullable @Override public Record loadRecord(@NotNull String key, @NotNull CacheHeaders cacheHeaders) { - hasHeader.set(cacheHeaders.hasHeader(ApolloCacheHeaders.DO_NOT_STORE)); - return null; - } - - @NotNull @Override public Set merge(@NotNull Record record, @NotNull CacheHeaders cacheHeaders) { - hasHeader.set(cacheHeaders.hasHeader(ApolloCacheHeaders.DO_NOT_STORE)); - return emptySet(); - } - - @Override public void clearAll() { - } - - @Override public boolean remove(@NotNull CacheKey cacheKey, boolean cascade) { - return false; - } - - @NotNull @Override - protected Set performMerge(@NotNull Record apolloRecord, @Nullable Record oldRecord, @NotNull CacheHeaders cacheHeaders) { - return emptySet(); - } - }; - - final NormalizedCacheFactory cacheFactory = new NormalizedCacheFactory() { - @Override public NormalizedCache create(RecordFieldJsonAdapter recordFieldAdapter) { - return normalizedCache; - } - }; - - CacheHeaders cacheHeaders = CacheHeaders.builder().addHeader(ApolloCacheHeaders.DO_NOT_STORE, "true").build(); - - ApolloClient apolloClient = ApolloClient.builder() - .normalizedCache(cacheFactory, new IdFieldCacheKeyResolver()) - .serverUrl(server.url("/")) - .okHttpClient(new OkHttpClient.Builder().dispatcher(new Dispatcher(Utils.INSTANCE.immediateExecutorService())).build()) - .dispatcher(Utils.INSTANCE.immediateExecutor()) - .defaultCacheHeaders(cacheHeaders) - .build(); - - server.enqueue(mockResponse("HeroAndFriendsNameResponse.json")); - Rx2Apollo.from(apolloClient.query(new HeroAndFriendsNamesQuery(Input.fromNullable(Episode.NEWHOPE))) - .cacheHeaders(cacheHeaders)) - .test(); - assertThat(hasHeader.get()).isTrue(); - } - - private MockResponse mockResponse(String fileName) throws IOException { - return new MockResponse().setChunkedBody(Utils.INSTANCE.readFileToString(getClass(), "/" + fileName), 32); - } - -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/CoroutinesApolloTest.kt b/apollo-integration/src/test/java/com/apollographql/apollo/CoroutinesApolloTest.kt deleted file mode 100644 index 024bdce1d4d..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/CoroutinesApolloTest.kt +++ /dev/null @@ -1,208 +0,0 @@ -package com.apollographql.apollo - -import com.apollographql.apollo.Utils.immediateExecutor -import com.apollographql.apollo.Utils.immediateExecutorService -import com.apollographql.apollo.Utils.mockResponse -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy -import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory -import com.apollographql.apollo.coroutines.await -import com.apollographql.apollo.coroutines.toFlow -import com.apollographql.apollo.coroutines.toJob -import com.apollographql.apollo.coroutines.toDeferred -import com.apollographql.apollo.exception.ApolloException -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery -import com.apollographql.apollo.integration.normalizer.HeroNameQuery -import com.apollographql.apollo.integration.normalizer.HeroNameWithIdQuery -import com.apollographql.apollo.integration.normalizer.type.Episode -import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.async -import kotlinx.coroutines.flow.first -import kotlinx.coroutines.flow.retry -import kotlinx.coroutines.flow.single -import kotlinx.coroutines.flow.toList -import kotlinx.coroutines.runBlocking -import okhttp3.Dispatcher -import okhttp3.OkHttpClient -import okhttp3.mockwebserver.MockResponse -import okhttp3.mockwebserver.MockWebServer -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import java.util.concurrent.TimeUnit - -class CoroutinesApolloTest { - private lateinit var apolloClient: ApolloClient - - @get:Rule - val server = MockWebServer() - - @Before - fun setup() { - val okHttpClient = OkHttpClient.Builder() - .dispatcher(Dispatcher(immediateExecutorService())) - .build() - - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .dispatcher(immediateExecutor()) - .okHttpClient(okHttpClient) - .normalizedCache(LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), IdFieldCacheKeyResolver()) - .build() - } - - @Test - fun callAwaitProducesValue() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - - runBlocking { - val response: Response = - apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))).await() - assertThat(response.data!!.hero()!!.name()).isEqualTo("R2-D2") - } - } - - @Test - fun callDeferredProducesValue() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - - runBlocking { - val response: Response = - apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))).toDeferred().await() - assertThat(response.data!!.hero()!!.name()).isEqualTo("R2-D2") - } - } - - @Test - fun prefetchCompletes() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - - runBlocking { - apolloClient.prefetch(EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))).await() - } - } - - @Test - fun await_prefetchIsCanceledWhenDisposed() { - // Block for 5 seconds. - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID).throttleBody(1, 5000, TimeUnit.MILLISECONDS)) - - runBlocking { - val prefetchCall = apolloClient.prefetch(EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))) - val job = async { - prefetchCall.await() - } - job.cancel() - } - } - - @Test - fun toJob_prefetchIsCanceledWhenDisposed() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - - runBlocking { - val job = apolloClient.prefetch(EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))) - .toJob() - job.cancel() - } - } - - @Test - @ExperimentalCoroutinesApi - fun flowCanBeRead() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - - val flow = apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))).toFlow() - - runBlocking { - val result = mutableListOf>() - flow.toList(result) - assertThat(result.size).isEqualTo(1) - assertThat(result[0].data?.hero()?.name()).isEqualTo("R2-D2") - } - } - - @Test - @ExperimentalCoroutinesApi - fun flowError() { - server.enqueue(MockResponse().setResponseCode(200).setBody("nonsense")) - - val flow = apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))).toFlow() - - runBlocking { - val result = mutableListOf>() - try { - flow.toList(result) - } catch (e: ApolloException) { - return@runBlocking - } - - throw Exception("exception has not been thrown") - } - } - - @Test - @ExperimentalCoroutinesApi - fun callFlowRetry() { - server.enqueue(MockResponse().setResponseCode(200).setBody("nonsense")) - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - - val response: Response = runBlocking { - apolloClient - .query(EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))) - .toFlow() - .retry(retries = 1) - .single() - } - - assertThat(response.data!!.hero()!!.name()).isEqualTo("R2-D2") - } - - @Test - @ExperimentalCoroutinesApi - fun watcherFlowRetry() { - server.enqueue(MockResponse().setResponseCode(200).setBody("nonsense")) - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - - val response: Response = runBlocking { - apolloClient - .query(EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))) - .watcher() - .toFlow() - .retry(retries = 1) - .first() - } - - assertThat(response.data!!.hero()!!.name()).isEqualTo("R2-D2") - } - - @Test - @ExperimentalCoroutinesApi - fun watcherFlowCancellationCancelsWatcher(): Unit = runBlocking { - server.enqueue(mockResponse("HeroNameWithIdResponse.json")) - apolloClient - .query(HeroNameWithIdQuery()) - .watcher() - .toFlow() - .first() // Cancels the flow after first response - - apolloClient.clearNormalizedCache() - apolloClient.clearHttpCache() - - server.enqueue(mockResponse("HeroNameResponse.json")) - apolloClient - .query(HeroNameQuery()) - .watcher() - .toFlow() - .first() - - assertThat(server.requestCount).isEqualTo(2) - }.let { } - - companion object { - - private const val FILE_EPISODE_HERO_NAME_WITH_ID = "EpisodeHeroNameResponseWithId.json" - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/DecoratedCallTest.kt b/apollo-integration/src/test/java/com/apollographql/apollo/DecoratedCallTest.kt deleted file mode 100644 index 8488f4b7bf8..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/DecoratedCallTest.kt +++ /dev/null @@ -1,84 +0,0 @@ -package com.apollographql.apollo - -import com.apollographql.apollo.Utils.immediateExecutor -import com.apollographql.apollo.Utils.immediateExecutorService -import com.apollographql.apollo.Utils.readFileToString -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.exception.ApolloException -import com.apollographql.apollo.integration.httpcache.AllPlanetsQuery -import okhttp3.* -import okhttp3.mockwebserver.MockResponse -import okhttp3.mockwebserver.MockWebServer -import okio.Timeout -import org.junit.Before -import org.junit.Rule -import org.junit.Test -import org.mockito.Matchers.any -import org.mockito.Mockito.spy -import org.mockito.Mockito.verify - -class DecoratedCallTest { - private lateinit var apolloClient: ApolloClient - @get:Rule - val server = MockWebServer() - private lateinit var callback: ApolloCall.Callback - - @Before - fun setup() { - val okHttpClient = OkHttpClient.Builder() - .dispatcher(Dispatcher(immediateExecutorService())) - .build() - - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .callFactory(object : Call.Factory { - override fun newCall(request: Request) = DecoratedCall(okHttpClient.newCall(request)) - }) - .dispatcher(immediateExecutor()) - .build() - - callback = spy(AllPlanetsCallback()) - } - - @Test - fun onResponseCallbackInvokedWithDecoratedCall() { - val response = MockResponse().setChunkedBody(readFileToString(javaClass, - "/" + "HttpCacheTestAllPlanets.json"), 32) - server.enqueue(response) - apolloClient.query(AllPlanetsQuery()) - .enqueue(callback) - verify(callback).onResponse(any()) - } - - @Test - fun onFailureCallbackInvokedWithDecoratedCall() { - server.enqueue(MockResponse().setResponseCode(500)) - apolloClient.query(AllPlanetsQuery()) - .enqueue(callback) - verify(callback).onFailure(any()) - } - - private open class AllPlanetsCallback : ApolloCall.Callback() { - override fun onResponse(response: Response) { } - - override fun onFailure(e: ApolloException) {} - } - - private class DecoratedCall internal constructor(private val call: Call) : Call { - override fun request(): Request = call.request() - - override fun execute(): okhttp3.Response = call.execute() - - override fun enqueue(responseCallback: Callback) = call.enqueue(responseCallback) - - override fun cancel() = call.cancel() - - override fun isExecuted() = call.isExecuted() - - override fun isCanceled() = call.isCanceled() - - override fun timeout(): Timeout = call.timeout() - - override fun clone() = DecoratedCall(call.clone()) - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/FaultyHttpCacheStore.java b/apollo-integration/src/test/java/com/apollographql/apollo/FaultyHttpCacheStore.java deleted file mode 100644 index e3a645aaf63..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/FaultyHttpCacheStore.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.cache.http.HttpCacheRecord; -import com.apollographql.apollo.api.cache.http.HttpCacheRecordEditor; -import com.apollographql.apollo.api.cache.http.HttpCacheStore; -import com.apollographql.apollo.cache.http.internal.DiskLruCache; -import com.apollographql.apollo.cache.http.internal.FileSystem; -import java.io.File; -import java.io.IOException; -import okio.Buffer; -import okio.Sink; -import okio.Source; -import okio.Timeout; -import org.jetbrains.annotations.NotNull; - -class FaultyHttpCacheStore implements HttpCacheStore { - private static final int VERSION = 99991; - private static final int ENTRY_HEADERS = 0; - private static final int ENTRY_BODY = 1; - private static final int ENTRY_COUNT = 2; - - private DiskLruCache cache; - final FaultySource faultySource = new FaultySource(); - final FaultySink faultySink = new FaultySink(); - FailStrategy failStrategy; - - FaultyHttpCacheStore(FileSystem fileSystem) { - this.cache = DiskLruCache.create(fileSystem, new File("/cache/"), VERSION, ENTRY_COUNT, Integer.MAX_VALUE); - } - - @Override public HttpCacheRecord cacheRecord(@NotNull String cacheKey) throws IOException { - final DiskLruCache.Snapshot snapshot = cache.get(cacheKey); - if (snapshot == null) { - return null; - } - - return new HttpCacheRecord() { - @NotNull @Override public Source headerSource() { - if (failStrategy == FailStrategy.FAIL_HEADER_READ) { - return faultySource; - } else { - return snapshot.getSource(ENTRY_HEADERS); - } - } - - @NotNull @Override public Source bodySource() { - if (failStrategy == FailStrategy.FAIL_BODY_READ) { - return faultySource; - } else { - return snapshot.getSource(ENTRY_BODY); - } - } - - @Override public void close() { - snapshot.close(); - } - }; - } - - @Override public HttpCacheRecordEditor cacheRecordEditor(@NotNull String cacheKey) throws IOException { - final DiskLruCache.Editor editor = cache.edit(cacheKey); - if (editor == null) { - return null; - } - - return new HttpCacheRecordEditor() { - @NotNull @Override public Sink headerSink() { - if (failStrategy == FailStrategy.FAIL_HEADER_WRITE) { - return faultySink; - } else { - return editor.newSink(ENTRY_HEADERS); - } - } - - @NotNull @Override public Sink bodySink() { - if (failStrategy == FailStrategy.FAIL_BODY_WRITE) { - return faultySink; - } else { - return editor.newSink(ENTRY_BODY); - } - } - - @Override public void abort() throws IOException { - editor.abort(); - } - - @Override public void commit() throws IOException { - editor.commit(); - } - }; - } - - @Override public void delete() throws IOException { - cache.delete(); - } - - @Override public void remove(@NotNull String cacheKey) throws IOException { - cache.remove(cacheKey); - } - - void failStrategy(FailStrategy failStrategy) { - this.failStrategy = failStrategy; - } - - enum FailStrategy { - FAIL_HEADER_READ, - FAIL_BODY_READ, - FAIL_HEADER_WRITE, - FAIL_BODY_WRITE - } - - private static class FaultySource implements Source { - @Override public long read(Buffer sink, long byteCount) throws IOException { - throw new IOException("failed to read"); - } - - @Override public Timeout timeout() { - return new Timeout(); - } - - @Override public void close() throws IOException { - - } - } - - private static class FaultySink implements Sink { - @Override public void write(Buffer source, long byteCount) throws IOException { - throw new IOException("failed to write"); - } - - @Override public void flush() throws IOException { - } - - @Override public Timeout timeout() { - return new Timeout(); - } - - @Override public void close() throws IOException { - } - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/HttpCacheTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/HttpCacheTest.java deleted file mode 100644 index 07d88fd28ef..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/HttpCacheTest.java +++ /dev/null @@ -1,679 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.CustomTypeAdapter; -import com.apollographql.apollo.api.CustomTypeValue; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.cache.http.HttpCache; -import com.apollographql.apollo.api.cache.http.HttpCachePolicy; -import com.apollographql.apollo.cache.ApolloCacheHeaders; -import com.apollographql.apollo.cache.CacheHeaders; -import com.apollographql.apollo.cache.http.ApolloHttpCache; -import com.apollographql.apollo.cache.http.DiskLruHttpCacheStore; -import com.apollographql.apollo.cache.http.internal.FileSystem; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.exception.ApolloHttpException; -import com.apollographql.apollo.integration.httpcache.AllFilmsQuery; -import com.apollographql.apollo.integration.httpcache.AllPlanetsQuery; -import com.apollographql.apollo.integration.httpcache.DroidDetailsQuery; -import com.apollographql.apollo.integration.httpcache.type.CustomType; -import com.apollographql.apollo.rx2.Rx2Apollo; -import io.reactivex.functions.Predicate; -import okhttp3.Dispatcher; -import okhttp3.Interceptor; -import okhttp3.OkHttpClient; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okio.Buffer; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Locale; -import java.util.concurrent.TimeUnit; - -import static com.google.common.truth.Truth.assertThat; - -@SuppressWarnings("SimpleDateFormatConstant") -public class HttpCacheTest { - private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", Locale.US); - - private ApolloClient apolloClient; - private okhttp3.Request lastHttRequest; - private okhttp3.Response lastHttResponse; - private MockHttpCacheStore cacheStore; - private OkHttpClient okHttpClient; - @Rule public final MockWebServer server = new MockWebServer(); - @Rule public final InMemoryFileSystem inMemoryFileSystem = new InMemoryFileSystem(); - - @Before public void setUp() { - CustomTypeAdapter dateCustomTypeAdapter = new CustomTypeAdapter() { - @Override public Date decode(CustomTypeValue value) { - try { - return DATE_FORMAT.parse(value.value.toString()); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - - @Override public CustomTypeValue encode(Date value) { - return new CustomTypeValue.GraphQLString(DATE_FORMAT.format(value)); - } - }; - - cacheStore = new MockHttpCacheStore(); - cacheStore.delegate = new DiskLruHttpCacheStore(inMemoryFileSystem, new File("/cache/"), Integer.MAX_VALUE); - - HttpCache cache = new ApolloHttpCache(cacheStore, null); - okHttpClient = new OkHttpClient.Builder() - .addInterceptor(new TrackingInterceptor()) - .addInterceptor(cache.interceptor()) - .dispatcher(new Dispatcher(Utils.INSTANCE.immediateExecutorService())) - .readTimeout(2, TimeUnit.SECONDS) - .writeTimeout(2, TimeUnit.SECONDS) - .build(); - - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(okHttpClient) - .dispatcher(Utils.INSTANCE.immediateExecutor()) - .addCustomTypeAdapter(CustomType.DATE, dateCustomTypeAdapter) - .httpCache(cache) - .build(); - } - - @After public void tearDown() { - try { - apolloClient.clearHttpCache(); - server.shutdown(); - } catch (Exception ignore) { - } - } - - @Test public void prematureDisconnect() throws Exception { - MockResponse mockResponse = mockResponse("/HttpCacheTestAllPlanets.json"); - Buffer truncatedBody = new Buffer(); - truncatedBody.write(mockResponse.getBody(), 16); - mockResponse.setBody(truncatedBody); - server.enqueue(mockResponse); - - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.NETWORK_ONLY)) - .test() - .assertError(ApolloException.class); - - checkNoCachedResponse(); - } - - @Test public void cacheDefault() throws Exception { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - } - - @Test public void cacheSeveralResponses() throws Exception { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - - enqueueResponse("/HttpCacheTestDroidDetails.json"); - Rx2Apollo.from(apolloClient - .query(new DroidDetailsQuery())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - checkCachedResponse("/HttpCacheTestDroidDetails.json"); - - enqueueResponse("/HttpCacheTestAllFilms.json"); - Rx2Apollo.from(apolloClient - .query(new AllFilmsQuery())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - checkCachedResponse("/HttpCacheTestAllFilms.json"); - } - - @Test public void noCacheStore() throws Exception { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - - ApolloClient apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(new OkHttpClient.Builder() - .addInterceptor(new TrackingInterceptor()) - .dispatcher(new Dispatcher(Utils.INSTANCE.immediateExecutorService())) - .build()) - .dispatcher(Utils.INSTANCE.immediateExecutor()) - .build(); - - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - checkNoCachedResponse(); - } - - @Test public void networkOnly() throws Exception { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()).httpCachePolicy(HttpCachePolicy.NETWORK_ONLY)) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - assertThat(server.getRequestCount()).isEqualTo(1); - assertThat(lastHttResponse.networkResponse()).isNotNull(); - assertThat(lastHttResponse.cacheResponse()).isNull(); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - } - - @Test public void networkOnly_DoNotStore() throws Exception { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.NETWORK_ONLY) - .cacheHeaders(CacheHeaders.builder().addHeader(ApolloCacheHeaders.DO_NOT_STORE, "true").build())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - assertThat(server.getRequestCount()).isEqualTo(1); - assertThat(lastHttResponse.networkResponse()).isNotNull(); - assertThat(lastHttResponse.cacheResponse()).isNull(); - - checkNoCachedResponse(); - } - - @Test public void networkOnly_responseWithGraphError_noCached() throws Exception { - enqueueResponse("/ResponseError.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()).httpCachePolicy(HttpCachePolicy.NETWORK_ONLY)) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return response.hasErrors(); - } - }); - assertThat(server.getRequestCount()).isEqualTo(1); - assertThat(lastHttResponse.networkResponse()).isNotNull(); - assertThat(lastHttResponse.cacheResponse()).isNull(); - checkNoCachedResponse(); - } - - @Test public void cacheOnlyHit() throws Exception { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - assertThat(server.takeRequest()).isNotNull(); - - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.CACHE_ONLY)) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - assertThat(server.getRequestCount()).isEqualTo(1); - assertThat(lastHttResponse.networkResponse()).isNull(); - assertThat(lastHttResponse.cacheResponse()).isNotNull(); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - } - - @Test public void cacheOnlyMiss() throws Exception { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.CACHE_ONLY)) - .test() - .assertError(ApolloHttpException.class); - } - - @Test @SuppressWarnings("CheckReturnValue") public void cacheNonStale() throws Exception { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test(); - assertThat(server.takeRequest()).isNotNull(); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.CACHE_FIRST)) - .test(); - - assertThat(server.getRequestCount()).isEqualTo(1); - assertThat(lastHttResponse.networkResponse()).isNull(); - assertThat(lastHttResponse.cacheResponse()).isNotNull(); - } - - @Test @SuppressWarnings("CheckReturnValue") public void cacheAfterDelete() throws Exception { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test(); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - - cacheStore.delegate.delete(); - - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.CACHE_FIRST)) - .test(); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - - assertThat(server.getRequestCount()).isEqualTo(2); - } - - @Test @SuppressWarnings("CheckReturnValue") public void cacheStale() throws Exception { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test(); - assertThat(server.getRequestCount()).isEqualTo(1); - - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test(); - assertThat(server.getRequestCount()).isEqualTo(2); - assertThat(lastHttResponse.networkResponse()).isNotNull(); - assertThat(lastHttResponse.cacheResponse()).isNull(); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - } - - @Test @SuppressWarnings("CheckReturnValue") public void cacheStaleBeforeNetwork() throws Exception { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test(); - assertThat(server.getRequestCount()).isEqualTo(1); - - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()).httpCachePolicy(HttpCachePolicy.NETWORK_FIRST)) - .test(); - - assertThat(server.getRequestCount()).isEqualTo(2); - assertThat(lastHttResponse.networkResponse()).isNotNull(); - assertThat(lastHttResponse.cacheResponse()).isNull(); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - } - - @Test @SuppressWarnings("CheckReturnValue") public void cacheStaleBeforeNetworkError() throws Exception { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test(); - assertThat(server.getRequestCount()).isEqualTo(1); - - server.enqueue(new MockResponse().setResponseCode(504).setBody("")); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.NETWORK_FIRST)) - .test(); - assertThat(server.getRequestCount()).isEqualTo(2); - assertThat(lastHttResponse.networkResponse()).isNotNull(); - assertThat(lastHttResponse.cacheResponse()).isNotNull(); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - } - - @Test @SuppressWarnings("CheckReturnValue") public void cacheUpdate() throws Exception { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test(); - assertThat(server.getRequestCount()).isEqualTo(1); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - - enqueueResponse("/HttpCacheTestAllPlanets2.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test(); - assertThat(server.getRequestCount()).isEqualTo(2); - checkCachedResponse("/HttpCacheTestAllPlanets2.json"); - assertThat(lastHttResponse.networkResponse()).isNotNull(); - assertThat(lastHttResponse.cacheResponse()).isNull(); - - enqueueResponse("/HttpCacheTestAllPlanets2.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.CACHE_FIRST)) - .test(); - - assertThat(server.getRequestCount()).isEqualTo(2); - assertThat(lastHttResponse.networkResponse()).isNull(); - assertThat(lastHttResponse.cacheResponse()).isNotNull(); - checkCachedResponse("/HttpCacheTestAllPlanets2.json"); - } - - @Test public void fileSystemUnavailable() throws IOException, ApolloException { - cacheStore.delegate = new DiskLruHttpCacheStore(new NoFileSystem(), new File("/cache/"), Integer.MAX_VALUE); - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - checkNoCachedResponse(); - } - - @Test public void fileSystemWriteFailure() throws IOException, ApolloException { - FaultyHttpCacheStore faultyCacheStore = new FaultyHttpCacheStore(FileSystem.SYSTEM); - cacheStore.delegate = faultyCacheStore; - - enqueueResponse("/HttpCacheTestAllPlanets.json"); - faultyCacheStore.failStrategy(FaultyHttpCacheStore.FailStrategy.FAIL_HEADER_WRITE); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - checkNoCachedResponse(); - - enqueueResponse("/HttpCacheTestAllPlanets.json"); - faultyCacheStore.failStrategy(FaultyHttpCacheStore.FailStrategy.FAIL_BODY_WRITE); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - checkNoCachedResponse(); - } - - @Test public void fileSystemReadFailure() throws IOException, ApolloException { - FaultyHttpCacheStore faultyCacheStore = new FaultyHttpCacheStore(inMemoryFileSystem); - cacheStore.delegate = faultyCacheStore; - - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - - enqueueResponse("/HttpCacheTestAllPlanets.json"); - faultyCacheStore.failStrategy(FaultyHttpCacheStore.FailStrategy.FAIL_HEADER_READ); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.CACHE_FIRST)) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - - assertThat(server.getRequestCount()).isEqualTo(2); - - enqueueResponse("/HttpCacheTestAllPlanets.json"); - faultyCacheStore.failStrategy(FaultyHttpCacheStore.FailStrategy.FAIL_BODY_READ); - - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.CACHE_FIRST)) - .test() - .assertError(Exception.class); - - assertThat(server.getRequestCount()).isEqualTo(2); - } - - @Test public void expireAfterRead() throws IOException, ApolloException { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.CACHE_ONLY.expireAfterRead())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - - checkNoCachedResponse(); - - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.CACHE_ONLY)) - .test() - .assertError(Exception.class); - - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient.query(new AllPlanetsQuery())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - } - - @Test public void cacheNetworkError() throws IOException, ApolloException { - server.enqueue(new MockResponse().setResponseCode(504).setBody("")); - - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test() - .assertError(Exception.class); - - checkNoCachedResponse(); - - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.CACHE_ONLY)) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - } - - @Test public void networkFirst() throws Exception { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery())) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - assertThat(server.getRequestCount()).isEqualTo(1); - assertThat(lastHttResponse.networkResponse()).isNotNull(); - assertThat(lastHttResponse.cacheResponse()).isNull(); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - - enqueueResponse("/HttpCacheTestAllPlanets.json"); - - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.NETWORK_FIRST)) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - }); - - assertThat(server.getRequestCount()).isEqualTo(2); - assertThat(lastHttResponse.networkResponse()).isNotNull(); - assertThat(lastHttResponse.cacheResponse()).isNull(); - checkCachedResponse("/HttpCacheTestAllPlanets.json"); - } - - @Test public void fromCacheFlag() throws Exception { - enqueueResponse("/HttpCacheTestAllPlanets.json"); - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.NETWORK_FIRST)) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors() && !response.fromCache(); - } - }); - - enqueueResponse("/HttpCacheTestAllPlanets.json"); - - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.NETWORK_ONLY)) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors() && !response.fromCache(); - } - }); - - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.CACHE_ONLY)) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors() && response.fromCache(); - } - }); - - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.CACHE_FIRST)) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors() && response.fromCache(); - } - }); - - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.CACHE_FIRST)) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors() && response.fromCache(); - } - }); - - Rx2Apollo.from(apolloClient - .query(new AllPlanetsQuery()) - .httpCachePolicy(HttpCachePolicy.NETWORK_FIRST)) - .test() - .assertValue(new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors() && response.fromCache(); - } - }); - } - - private void enqueueResponse(String fileName) throws IOException { - server.enqueue(mockResponse(fileName)); - } - - private void checkCachedResponse(String fileName) throws IOException { - String cacheKey = lastHttRequest.headers(HttpCache.CACHE_KEY_HEADER).get(0); - okhttp3.Response response = apolloClient.cachedHttpResponse(cacheKey); - assertThat(response).isNotNull(); - assertThat(response.body().source().readUtf8()).isEqualTo(Utils.INSTANCE.readFileToString(getClass(), fileName)); - response.body().source().close(); - } - - private void checkNoCachedResponse() throws IOException { - String cacheKey = lastHttRequest.header(HttpCache.CACHE_KEY_HEADER); - okhttp3.Response cachedResponse = apolloClient.cachedHttpResponse(cacheKey); - assertThat(cachedResponse).isNull(); - } - - private MockResponse mockResponse(String fileName) throws IOException { - return new MockResponse().setChunkedBody(Utils.INSTANCE.readFileToString(getClass(), fileName), 32); - } - - private class TrackingInterceptor implements Interceptor { - @Override public okhttp3.Response intercept(Chain chain) throws IOException { - lastHttRequest = chain.request(); - lastHttResponse = chain.proceed(lastHttRequest); - return lastHttResponse; - } - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/IdFieldCacheKeyResolver.java b/apollo-integration/src/test/java/com/apollographql/apollo/IdFieldCacheKeyResolver.java deleted file mode 100644 index 939a11ae698..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/IdFieldCacheKeyResolver.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.cache.normalized.CacheKey; -import com.apollographql.apollo.cache.normalized.CacheKeyResolver; -import org.jetbrains.annotations.NotNull; - -import java.util.Map; - -public class IdFieldCacheKeyResolver extends CacheKeyResolver { - - @NotNull @Override - public CacheKey fromFieldRecordSet(@NotNull ResponseField field, @NotNull Map recordSet) { - Object id = recordSet.get("id"); - if (id != null) { - return formatCacheKey(id.toString()); - } else { - return formatCacheKey(null); - } - } - - @NotNull @Override - public CacheKey fromFieldArguments(@NotNull ResponseField field, @NotNull Operation.Variables variables) { - Object id = field.resolveArgument("id", variables); - if (id != null) { - return formatCacheKey(id.toString()); - } else { - return formatCacheKey(null); - } - } - - private CacheKey formatCacheKey(String id) { - if (id == null || id.isEmpty()) { - return CacheKey.NO_KEY; - } else { - return new CacheKey(id); - } - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/InMemoryFileSystem.java b/apollo-integration/src/test/java/com/apollographql/apollo/InMemoryFileSystem.java deleted file mode 100644 index 9e21a20ce87..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/InMemoryFileSystem.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (C) 2015 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.apollographql.apollo; - -import com.apollographql.apollo.cache.http.internal.FileSystem; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.IdentityHashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import okio.Buffer; -import okio.ForwardingSink; -import okio.ForwardingSource; -import okio.Sink; -import okio.Source; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -/** - * A simple file system where all files are held in memory. Not safe for concurrent use. - * - *

Copied from OkHttp 3.14.2: https://github.com/square/okhttp/blob/b8b6ee831c65208940c741f8e091ff02425566d5/okhttp-testing-support/src/main/java/okhttp3/internal/io/InMemoryFileSystem.java - */ -public final class InMemoryFileSystem implements FileSystem, TestRule { - private final Map files = new LinkedHashMap<>(); - private final Map openSources = new IdentityHashMap<>(); - private final Map openSinks = new IdentityHashMap<>(); - - @Override public Statement apply(final Statement base, Description description) { - return new Statement() { - @Override public void evaluate() throws Throwable { - base.evaluate(); - ensureResourcesClosed(); - } - }; - } - - public void ensureResourcesClosed() { - List openResources = new ArrayList<>(); - for (File file : openSources.values()) { - openResources.add("Source for " + file); - } - for (File file : openSinks.values()) { - openResources.add("Sink for " + file); - } - if (!openResources.isEmpty()) { - StringBuilder builder = new StringBuilder("Resources acquired but not closed:"); - for (String resource : openResources) { - builder.append("\n * ").append(resource); - } - throw new IllegalStateException(builder.toString()); - } - } - - @Override public Source source(File file) throws FileNotFoundException { - Buffer result = files.get(file); - if (result == null) throw new FileNotFoundException(); - - final Source source = result.clone(); - openSources.put(source, file); - - return new ForwardingSource(source) { - @Override public void close() throws IOException { - openSources.remove(source); - super.close(); - } - }; - } - - @Override public Sink sink(File file) throws FileNotFoundException { - return sink(file, false); - } - - @Override public Sink appendingSink(File file) throws FileNotFoundException { - return sink(file, true); - } - - private Sink sink(File file, boolean appending) { - Buffer result = null; - if (appending) { - result = files.get(file); - } - if (result == null) { - result = new Buffer(); - } - files.put(file, result); - - final Sink sink = result; - openSinks.put(sink, file); - - return new ForwardingSink(sink) { - @Override public void close() throws IOException { - openSinks.remove(sink); - super.close(); - } - }; - } - - @Override public void delete(File file) throws IOException { - files.remove(file); - } - - @Override public boolean exists(File file) { - return files.containsKey(file); - } - - @Override public long size(File file) { - Buffer buffer = files.get(file); - return buffer != null ? buffer.size() : 0L; - } - - @Override public void rename(File from, File to) throws IOException { - Buffer buffer = files.remove(from); - if (buffer == null) throw new FileNotFoundException(); - files.put(to, buffer); - } - - @Override public void deleteContents(File directory) throws IOException { - String prefix = directory.toString() + "/"; - for (Iterator i = files.keySet().iterator(); i.hasNext(); ) { - File file = i.next(); - if (file.toString().startsWith(prefix)) i.remove(); - } - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/IntegrationTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/IntegrationTest.java deleted file mode 100644 index dbf9136adc1..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/IntegrationTest.java +++ /dev/null @@ -1,392 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.CustomTypeAdapter; -import com.apollographql.apollo.api.CustomTypeValue; -import com.apollographql.apollo.api.Error; -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.OperationDataJsonSerializer; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ScalarType; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy; -import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.fetcher.ApolloResponseFetchers; -import com.apollographql.apollo.integration.httpcache.AllFilmsQuery; -import com.apollographql.apollo.integration.httpcache.AllPlanetsQuery; -import com.apollographql.apollo.integration.httpcache.type.CustomType; -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery; -import com.apollographql.apollo.integration.normalizer.HeroNameQuery; -import com.apollographql.apollo.http.OkHttpExecutionContext; -import com.apollographql.apollo.response.OperationResponseParser; -import com.apollographql.apollo.rx2.Rx2Apollo; -import com.google.common.base.Charsets; -import com.google.common.base.Function; -import com.google.common.collect.FluentIterable; -import io.reactivex.functions.Predicate; -import okhttp3.Dispatcher; -import okhttp3.OkHttpClient; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okio.Buffer; -import org.jetbrains.annotations.NotNull; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.io.IOException; -import java.math.BigDecimal; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import java.util.Locale; - -import static com.apollographql.apollo.integration.normalizer.type.Episode.EMPIRE; -import static com.apollographql.apollo.integration.normalizer.type.Episode.JEDI; -import static com.google.common.truth.Truth.assertThat; - -@SuppressWarnings("SimpleDateFormatConstant") -public class IntegrationTest { - private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd", Locale.US); - - private ApolloClient apolloClient; - private CustomTypeAdapter dateCustomTypeAdapter; - - @Rule - public final MockWebServer server = new MockWebServer(); - - @Before public void setUp() { - dateCustomTypeAdapter = new CustomTypeAdapter() { - @Override public Date decode(CustomTypeValue value) { - try { - return DATE_FORMAT.parse(value.value.toString()); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - - @Override public CustomTypeValue encode(Date value) { - return new CustomTypeValue.GraphQLString(DATE_FORMAT.format(value)); - } - }; - - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(new OkHttpClient.Builder().dispatcher(new Dispatcher(Utils.INSTANCE.immediateExecutorService())).build()) - .addCustomTypeAdapter(CustomType.DATE, dateCustomTypeAdapter) - .normalizedCache(new LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), new IdFieldCacheKeyResolver()) - .defaultResponseFetcher(ApolloResponseFetchers.NETWORK_ONLY) - .dispatcher(Utils.INSTANCE.immediateExecutor()) - .build(); - } - - @SuppressWarnings({"ConstantConditions", "CheckReturnValue"}) - @Test public void allPlanetQuery() throws Exception { - server.enqueue(mockResponse("HttpCacheTestAllPlanets.json")); - - assertResponse( - apolloClient.query(new AllPlanetsQuery()), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().allPlanets().planets().size()).isEqualTo(60); - - List planets = FluentIterable.from(response.data().allPlanets().planets()) - .transform(new Function() { - @Override public String apply(AllPlanetsQuery.Planet planet) { - return planet.fragments().planetFragment().name(); - } - }).toList(); - assertThat(planets).isEqualTo(Arrays.asList(("Tatooine, Alderaan, Yavin IV, Hoth, Dagobah, Bespin, Endor, Naboo, " - + "Coruscant, Kamino, Geonosis, Utapau, Mustafar, Kashyyyk, Polis Massa, Mygeeto, Felucia, Cato Neimoidia, " - + "Saleucami, Stewjon, Eriadu, Corellia, Rodia, Nal Hutta, Dantooine, Bestine IV, Ord Mantell, unknown, " - + "Trandosha, Socorro, Mon Cala, Chandrila, Sullust, Toydaria, Malastare, Dathomir, Ryloth, Aleen Minor, " - + "Vulpter, Troiken, Tund, Haruun Kal, Cerea, Glee Anselm, Iridonia, Tholoth, Iktotch, Quermia, Dorin, " - + "Champala, Mirial, Serenno, Concord Dawn, Zolan, Ojom, Skako, Muunilinst, Shili, Kalee, Umbara") - .split("\\s*,\\s*") - )); - - AllPlanetsQuery.Planet firstPlanet = response.data().allPlanets().planets().get(0); - assertThat(firstPlanet.fragments().planetFragment().climates()).isEqualTo(Collections.singletonList("arid")); - assertThat(firstPlanet.fragments().planetFragment().surfaceWater()).isWithin(1d); - assertThat(firstPlanet.filmConnection().totalCount()).isEqualTo(5); - assertThat(firstPlanet.filmConnection().films().size()).isEqualTo(5); - assertThat(firstPlanet.filmConnection().films().get(0).fragments().filmFragment().title()).isEqualTo("A New Hope"); - assertThat(firstPlanet.filmConnection().films().get(0).fragments().filmFragment().producers()).isEqualTo(Arrays - .asList("Gary Kurtz", "Rick McCallum")); - return true; - } - } - ); - - String body = server.takeRequest().getBody().readString(Charsets.UTF_8); - Utils.INSTANCE.checkTestFixture(body, "IntegrationTest/allPlanets.json"); - } - - @Test public void error_response() throws Exception { - server.enqueue(mockResponse("ResponseError.json")); - assertResponse( - apolloClient.query(new AllPlanetsQuery()), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isTrue(); - //noinspection ConstantConditions - assertThat(response.errors()).containsExactly(new Error( - "Cannot query field \"names\" on type \"Species\".", - Collections.singletonList(new Error.Location(3, 5)), Collections.emptyMap())); - return true; - } - } - ); - } - - @Test public void error_response_with_nulls_and_custom_attributes() throws Exception { - server.enqueue(mockResponse("ResponseErrorWithNullsAndCustomAttributes.json")); - assertResponse( - apolloClient.query(new AllPlanetsQuery()), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isTrue(); - assertThat(response.errors()).hasSize(1); - assertThat(response.errors().get(0).message()).isEqualTo(""); - assertThat(response.errors().get(0).customAttributes()).hasSize(2); - assertThat(response.errors().get(0).customAttributes().get("code")).isEqualTo("userNotFound"); - assertThat(response.errors().get(0).customAttributes().get("path")).isEqualTo("loginWithPassword"); - assertThat(response.errors().get(0).locations()).hasSize(0); - return true; - } - } - ); - } - - @Test public void errorResponse_custom_attributes() throws Exception { - server.enqueue(mockResponse("ResponseErrorWithCustomAttributes.json")); - assertResponse( - apolloClient.query(new AllPlanetsQuery()), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isTrue(); - assertThat(response.errors().get(0).customAttributes()).hasSize(4); - assertThat(response.errors().get(0).customAttributes().get("code")).isEqualTo(new BigDecimal(500)); - assertThat(response.errors().get(0).customAttributes().get("status")).isEqualTo("Internal Error"); - assertThat(response.errors().get(0).customAttributes().get("fatal")).isEqualTo(true); - assertThat(response.errors().get(0).customAttributes().get("path")).isEqualTo(Arrays.asList("query")); - return true; - } - } - ); - } - - @Test public void errorResponse_with_data() throws Exception { - server.enqueue(mockResponse("ResponseErrorWithData.json")); - assertResponse( - apolloClient.query(new EpisodeHeroNameQuery(Input.fromNullable(JEDI))), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data()).isNotNull(); - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.errors()).containsExactly(new Error( - "Cannot query field \"names\" on type \"Species\".", - Collections.singletonList(new Error.Location(3, 5)), Collections.emptyMap())); - return true; - } - } - ); - } - - @Test public void allFilmsWithDate() throws Exception { - server.enqueue(mockResponse("HttpCacheTestAllFilms.json")); - assertResponse( - apolloClient.query(new AllFilmsQuery()), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isFalse(); - assertThat(response.data().allFilms().films()).hasSize(6); - List dates = FluentIterable.from(response.data().allFilms().films()) - .transform(new Function() { - @Override public String apply(AllFilmsQuery.Film film) { - Date releaseDate = film.releaseDate(); - return dateCustomTypeAdapter.encode(releaseDate).value.toString(); - } - }).copyInto(new ArrayList()); - assertThat(dates).isEqualTo(Arrays.asList("1977-05-25", "1980-05-17", "1983-05-25", "1999-05-19", - "2002-05-16", "2005-05-19")); - return true; - } - } - ); - } - - @Test public void dataNull() throws Exception { - server.enqueue(mockResponse("ResponseDataNull.json")); - assertResponse( - apolloClient.query(new HeroNameQuery()), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data()).isNull(); - assertThat(response.hasErrors()).isFalse(); - return true; - } - } - ); - } - - @Test public void fieldMissing() throws Exception { - server.enqueue(mockResponse("ResponseDataMissing.json")); - Rx2Apollo.from(apolloClient.query(new HeroNameQuery())) - .test() - .assertError(ApolloException.class); - } - - @Test public void statusEvents() throws Exception { - server.enqueue(mockResponse("HeroNameResponse.json")); - List statusEvents = enqueueCall(apolloClient.query(new HeroNameQuery())); - assertThat(statusEvents).isEqualTo(Arrays.asList(ApolloCall.StatusEvent.SCHEDULED, ApolloCall.StatusEvent - .FETCH_NETWORK, ApolloCall.StatusEvent.COMPLETED)); - - statusEvents = enqueueCall( - apolloClient.query(new HeroNameQuery()).responseFetcher(ApolloResponseFetchers.CACHE_ONLY)); - assertThat(statusEvents).isEqualTo(Arrays.asList(ApolloCall.StatusEvent.SCHEDULED, ApolloCall.StatusEvent - .FETCH_CACHE, ApolloCall.StatusEvent.COMPLETED)); - - server.enqueue(mockResponse("HeroNameResponse.json")); - statusEvents = enqueueCall( - apolloClient.query(new HeroNameQuery()).responseFetcher(ApolloResponseFetchers.CACHE_AND_NETWORK)); - assertThat(statusEvents).isEqualTo(Arrays.asList(ApolloCall.StatusEvent.SCHEDULED, ApolloCall.StatusEvent - .FETCH_CACHE, ApolloCall.StatusEvent.FETCH_NETWORK, ApolloCall.StatusEvent.COMPLETED)); - } - - @Test public void operationResponseParser() throws Exception { - String json = Utils.INSTANCE.readFileToString(getClass(), "/HeroNameResponse.json"); - - HeroNameQuery query = new HeroNameQuery(); - Response response = new OperationResponseParser<>(query, query.responseFieldMapper(), new ScalarTypeAdapters(Collections.EMPTY_MAP)) - .parse(new Buffer().writeUtf8(json)); - - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - } - - @Test public void operationJsonWriter() throws Exception { - String expected = Utils.INSTANCE.readFileToString(getClass(), "/OperationJsonWriter.json"); - AllPlanetsQuery query = new AllPlanetsQuery(); - Response response = new OperationResponseParser<>(query, query.responseFieldMapper(), ScalarTypeAdapters.DEFAULT) - .parse(new Buffer().writeUtf8(expected)); - - String actual = OperationDataJsonSerializer.serialize(response.data(), " "); - assertThat(actual).isEqualTo(expected); - } - - @Test public void parseSuccessOperationRawResponse() throws Exception { - final AllPlanetsQuery query = new AllPlanetsQuery(); - final Response response = query.parse( - new Buffer().readFrom(getClass().getResourceAsStream("/AllPlanetsNullableField.json")), - new ScalarTypeAdapters(Collections.>emptyMap()) - ); - - assertThat(response.operation()).isEqualTo(query); - assertThat(response.hasErrors()).isFalse(); - assertThat(response.data()).isNotNull(); - assertThat(response.data().allPlanets().planets()).isNotEmpty(); - } - - @Test public void parseErrorOperationRawResponse() throws Exception { - final EpisodeHeroNameQuery query = new EpisodeHeroNameQuery(Input.fromNullable(EMPIRE)); - final Response response = query.parse( - new Buffer().readFrom(getClass().getResourceAsStream("/ResponseErrorWithData.json")), - new ScalarTypeAdapters(Collections.>emptyMap()) - ); - - assertThat(response.data()).isNotNull(); - assertThat(response.data().hero()).isNotNull(); - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.errors()).containsExactly( - new Error( - "Cannot query field \"names\" on type \"Species\".", - Collections.singletonList(new Error.Location(3, 5)), - Collections.emptyMap() - ) - ); - } - - @Test public void writeOperationRawRequest() throws Exception { - final EpisodeHeroNameQuery query = new EpisodeHeroNameQuery(Input.fromNullable(EMPIRE)); - - final String payload = "{" + - "\"operationName\": " + query.name().name() + ", " + - "\"query\": " + query.queryDocument() + ", " + - "\"variables\": " + query.variables().marshal() + - "}"; - - assertThat(payload).isEqualTo("{\"operationName\": EpisodeHeroName, \"query\": query EpisodeHeroName($episode: Episode) { hero(episode: $episode) { __typename name } }, \"variables\": {\"episode\":\"EMPIRE\"}}"); - } - - @SuppressWarnings("ConstantConditions") - @Test public void operationResponseParserParseResponseWithExtensions() throws Exception { - final Buffer source = new Buffer().readFrom(getClass().getResourceAsStream("/HeroNameResponse.json")); - - final HeroNameQuery query = new HeroNameQuery(); - final Response response = new OperationResponseParser<>(query, query.responseFieldMapper(), - new ScalarTypeAdapters(Collections.>emptyMap())).parse(source); - - assertThat(response.extensions().toString()).isEqualTo("{cost={requestedQueryCost=3, actualQueryCost=3, throttleStatus={maximumAvailable=1000, currentlyAvailable=997, restoreRate=50}}}"); - } - - @SuppressWarnings("ConstantConditions") - @Test public void operationParseResponseWithExtensions() throws Exception { - final Buffer source = new Buffer().readFrom(getClass().getResourceAsStream("/HeroNameResponse.json")); - final Response response = new HeroNameQuery().parse(source); - assertThat(response.extensions().toString()).isEqualTo("{cost={requestedQueryCost=3, actualQueryCost=3, throttleStatus={maximumAvailable=1000, currentlyAvailable=997, restoreRate=50}}}"); - } - - @SuppressWarnings("ConstantConditions") - @Test public void operationResponseContainsHttpExecutionContext() throws Exception { - final MockResponse httpResponse = mockResponse("HttpCacheTestAllPlanets.json") - .setHeader("Header1", "Header1#value") - .setHeader("Header2", "Header2#value"); - server.enqueue(httpResponse); - assertResponse( - apolloClient.query(new AllPlanetsQuery()), - (Predicate>) response -> { - assertThat(response.getExecutionContext().get(OkHttpExecutionContext.KEY)).isNotNull(); - assertThat(response.getExecutionContext().get(OkHttpExecutionContext.KEY).getResponse()).isNotNull(); - assertThat(response.getExecutionContext().get(OkHttpExecutionContext.KEY).getResponse().headers().toString()) - .isEqualTo( - "Transfer-encoding: chunked\n" + - "Header1: Header1#value\n" + - "Header2: Header2#value\n" - ); - assertThat(response.getExecutionContext().get(OkHttpExecutionContext.KEY).getResponse().body()).isNull(); - return true; - } - ); - } - - private MockResponse mockResponse(String fileName) throws IOException { - return new MockResponse().setChunkedBody(Utils.INSTANCE.readFileToString(getClass(), "/" + fileName), 32); - } - - private static void assertResponse(ApolloCall call, Predicate> predicate) { - Rx2Apollo.from(call) - .test() - .assertValue(predicate); - } - - private List enqueueCall(ApolloQueryCall call) throws Exception { - final List statusEvents = new ArrayList<>(); - call.enqueue(new ApolloCall.Callback() { - @Override public void onResponse(@NotNull Response response) { - } - - @Override public void onFailure(@NotNull ApolloException e) { - } - - @Override public void onStatusEvent(@NotNull ApolloCall.StatusEvent event) { - statusEvents.add(event); - } - }); - return statusEvents; - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/JsonScalarTest.kt b/apollo-integration/src/test/java/com/apollographql/apollo/JsonScalarTest.kt deleted file mode 100644 index 555475eedfb..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/JsonScalarTest.kt +++ /dev/null @@ -1,60 +0,0 @@ -package com.apollographql.apollo - -import com.apollographql.apollo.integration.normalizer.GetJsonScalarQuery -import com.apollographql.apollo.Utils.cacheAndAssertCachedResponse -import com.apollographql.apollo.Utils.immediateExecutor -import com.apollographql.apollo.Utils.immediateExecutorService -import com.apollographql.apollo.api.BigDecimal -import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy -import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory -import com.google.common.truth.Truth.assertThat -import okhttp3.Dispatcher -import okhttp3.OkHttpClient -import okhttp3.mockwebserver.MockWebServer -import org.junit.Test - -class JsonScalarTest { - @Test - @Throws(Exception::class) - fun jsonScalar() { - val server = MockWebServer() - val okHttpClient = OkHttpClient.Builder() - .dispatcher(Dispatcher(immediateExecutorService())) - .build() - - val apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(okHttpClient) - .normalizedCache(LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), IdFieldCacheKeyResolver()) - .dispatcher(immediateExecutor()) - .build() - - cacheAndAssertCachedResponse( - server, - "JsonScalar.json", - apolloClient.query(GetJsonScalarQuery()) - ) { response -> - assertThat(response.hasErrors()).isFalse() - val expectedMap = mapOf( - "obj" to mapOf( "key" to "value"), - "list" to listOf(BigDecimal(0), BigDecimal(1), BigDecimal(2)) - ) - assertThat(response.data!!.json()).isEqualTo(expectedMap) - true - } - - // Trigger a merge - cacheAndAssertCachedResponse( - server, - "JsonScalarModified.json", - apolloClient.query(GetJsonScalarQuery()) - ) { response -> - assertThat(response.hasErrors()).isFalse() - val expectedMap = mapOf( - "obj" to mapOf( "key2" to "value2"), - ) - assertThat(response.data!!.json()).isEqualTo(expectedMap) - true - } - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/MockHttpCacheStore.java b/apollo-integration/src/test/java/com/apollographql/apollo/MockHttpCacheStore.java deleted file mode 100644 index c6dc48e6acf..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/MockHttpCacheStore.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.cache.http.HttpCacheRecord; -import com.apollographql.apollo.api.cache.http.HttpCacheRecordEditor; -import com.apollographql.apollo.api.cache.http.HttpCacheStore; - -import java.io.IOException; - -import org.jetbrains.annotations.NotNull; - -final class MockHttpCacheStore implements HttpCacheStore { - HttpCacheStore delegate; - - @Override public HttpCacheRecord cacheRecord(@NotNull String cacheKey) throws IOException { - return delegate.cacheRecord(cacheKey); - } - - @Override public HttpCacheRecordEditor cacheRecordEditor(@NotNull String cacheKey) throws IOException { - return delegate.cacheRecordEditor(cacheKey); - } - - @Override public void remove(@NotNull String cacheKey) throws IOException { - delegate.remove(cacheKey); - } - - @Override public void delete() throws IOException { - delegate.delete(); - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/NamedCountDownLatch.java b/apollo-integration/src/test/java/com/apollographql/apollo/NamedCountDownLatch.java deleted file mode 100644 index cc5da8ca162..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/NamedCountDownLatch.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.apollographql.apollo; - -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -/** - * {@link java.util.concurrent.CountDownLatch} with an associated name for debugging - */ -public class NamedCountDownLatch extends CountDownLatch { - - private String name; - - /** - * Constructs a {@code CountDownLatch} initialized with the given count. - * - * @param count the number of times {@link #countDown} must be invoked before threads can pass through {@link #await} - * @throws IllegalArgumentException if {@code count} is negative - */ - public NamedCountDownLatch(String name, int count) { - super(count); - this.name = name; - } - - public String name() { - return name; - } - - /** - * Waits until latch countdown goes to zero. If timeout expires before latch count has gone to zero, - * then a {@link TimeoutException} will be thrown. - */ - public void awaitOrThrowWithTimeout(long timeout, TimeUnit timeUnit) - throws InterruptedException, TimeoutException { - if (!this.await(timeout, timeUnit)) { - throw new TimeoutException("Time expired before latch, " + this.name() + " count went to zero."); - } - } - -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/NoFileSystem.java b/apollo-integration/src/test/java/com/apollographql/apollo/NoFileSystem.java deleted file mode 100644 index d418ddf5bb3..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/NoFileSystem.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.cache.http.internal.FileSystem; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import okio.Sink; -import okio.Source; - -class NoFileSystem implements FileSystem { - @Override public Source source(File file) throws FileNotFoundException { - throw new UnsupportedOperationException(); - } - - @Override public Sink sink(File file) throws FileNotFoundException { - throw new UnsupportedOperationException(); - } - - @Override public Sink appendingSink(File file) throws FileNotFoundException { - throw new UnsupportedOperationException(); - } - - @Override public void delete(File file) throws IOException { - throw new UnsupportedOperationException(); - } - - @Override public boolean exists(File file) { - throw new UnsupportedOperationException(); - } - - @Override public long size(File file) { - throw new UnsupportedOperationException(); - } - - @Override public void rename(File from, File to) throws IOException { - throw new UnsupportedOperationException(); - } - - @Override public void deleteContents(File directory) throws IOException { - throw new UnsupportedOperationException(); - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/NormalizedCacheTestCase.java b/apollo-integration/src/test/java/com/apollographql/apollo/NormalizedCacheTestCase.java deleted file mode 100644 index b0e470ab941..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/NormalizedCacheTestCase.java +++ /dev/null @@ -1,939 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.cache.normalized.CacheKey; -import com.apollographql.apollo.cache.normalized.NormalizedCache; -import com.apollographql.apollo.cache.normalized.Record; -import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy; -import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory; -import com.apollographql.apollo.integration.httpcache.AllPlanetsQuery; -import com.apollographql.apollo.integration.normalizer.CharacterDetailsQuery; -import com.apollographql.apollo.integration.normalizer.CharacterNameByIdQuery; -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery; -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsDirectivesQuery; -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesQuery; -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesWithIDForParentOnlyQuery; -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesWithIDsQuery; -import com.apollographql.apollo.integration.normalizer.HeroAppearsInQuery; -import com.apollographql.apollo.integration.normalizer.HeroParentTypeDependentFieldQuery; -import com.apollographql.apollo.integration.normalizer.HeroTypeDependentAliasedFieldQuery; -import com.apollographql.apollo.integration.normalizer.SameHeroTwiceQuery; -import com.apollographql.apollo.integration.normalizer.StarshipByIdQuery; -import com.apollographql.apollo.integration.normalizer.fragment.HeroWithFriendsFragment; -import com.apollographql.apollo.integration.normalizer.fragment.HumanWithIdFragment; -import com.apollographql.apollo.integration.normalizer.type.Episode; -import io.reactivex.functions.Predicate; -import kotlin.reflect.KClass; -import okhttp3.Dispatcher; -import okhttp3.OkHttpClient; -import okhttp3.mockwebserver.MockWebServer; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.util.Map; -import java.util.concurrent.TimeUnit; - -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.CACHE_FIRST; -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.CACHE_ONLY; -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.NETWORK_FIRST; -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.NETWORK_ONLY; -import static com.google.common.truth.Truth.assertThat; -import static java.util.Arrays.asList; - -public class NormalizedCacheTestCase { - private ApolloClient apolloClient; - @Rule public final MockWebServer server = new MockWebServer(); - - @Before public void setUp() { - OkHttpClient okHttpClient = new OkHttpClient.Builder() - .writeTimeout(2, TimeUnit.SECONDS) - .readTimeout(2, TimeUnit.SECONDS) - .dispatcher(new Dispatcher(Utils.INSTANCE.immediateExecutorService())) - .build(); - - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(okHttpClient) - .normalizedCache(new LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), new IdFieldCacheKeyResolver()) - .dispatcher(Utils.INSTANCE.immediateExecutor()) - .build(); - } - - @Test public void episodeHeroName() throws Exception { - Utils.INSTANCE.cacheAndAssertCachedResponse( - server, - "HeroNameResponse.json", - apolloClient.query(new EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isFalse(); - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - return true; - } - } - ); - } - - @Test public void heroAndFriendsNameResponse() throws Exception { - Utils.INSTANCE.cacheAndAssertCachedResponse( - server, - "HeroAndFriendsNameResponse.json", - apolloClient.query(new HeroAndFriendsNamesQuery(Input.fromNullable(Episode.JEDI))), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isFalse(); - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().friends()).hasSize(3); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("Luke Skywalker"); - assertThat(response.data().hero().friends().get(1).name()).isEqualTo("Han Solo"); - assertThat(response.data().hero().friends().get(2).name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - } - - @Test public void heroAndFriendsNamesWithIDs() throws Exception { - Utils.INSTANCE.cacheAndAssertCachedResponse( - server, - "HeroAndFriendsNameWithIdsResponse.json", - apolloClient.query(new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.NEWHOPE))), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isFalse(); - assertThat(response.data().hero().id()).isEqualTo("2001"); - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().friends()).hasSize(3); - assertThat(response.data().hero().friends().get(0).id()).isEqualTo("1000"); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("Luke Skywalker"); - assertThat(response.data().hero().friends().get(1).id()).isEqualTo("1002"); - assertThat(response.data().hero().friends().get(1).name()).isEqualTo("Han Solo"); - assertThat(response.data().hero().friends().get(2).id()).isEqualTo("1003"); - assertThat(response.data().hero().friends().get(2).name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - } - - @Test public void heroAndFriendsNameWithIdsForParentOnly() throws Exception { - Utils.INSTANCE.cacheAndAssertCachedResponse( - server, - "HeroAndFriendsNameWithIdsParentOnlyResponse.json", - apolloClient.query(new HeroAndFriendsNamesWithIDForParentOnlyQuery(Input.fromNullable(Episode.NEWHOPE))), - new Predicate>() { - @Override - public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isFalse(); - assertThat(response.data().hero().id()).isEqualTo("2001"); - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().friends()).hasSize(3); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("Luke Skywalker"); - assertThat(response.data().hero().friends().get(1).name()).isEqualTo("Han Solo"); - assertThat(response.data().hero().friends().get(2).name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - } - - @Test public void heroAppearsInResponse() throws Exception { - Utils.INSTANCE.cacheAndAssertCachedResponse( - server, - "HeroAppearsInResponse.json", - apolloClient.query(new HeroAppearsInQuery()), - new Predicate>() { - @Override - public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isFalse(); - assertThat(response.data().hero().appearsIn()).hasSize(3); - assertThat(response.data().hero().appearsIn().get(0).name()).isEqualTo("NEWHOPE"); - assertThat(response.data().hero().appearsIn().get(1).name()).isEqualTo("EMPIRE"); - assertThat(response.data().hero().appearsIn().get(2).name()).isEqualTo("JEDI"); - return true; - } - } - ); - } - - @Test public void heroAppearsInResponseWithNulls() throws Exception { - Utils.INSTANCE.cacheAndAssertCachedResponse( - server, - "HeroAppearsInResponseWithNulls.json", - apolloClient.query(new HeroAppearsInQuery()), - new Predicate>() { - @Override - public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isFalse(); - assertThat(response.data().hero().appearsIn()).hasSize(6); - assertThat(response.data().hero().appearsIn().get(0)).isNull(); - assertThat(response.data().hero().appearsIn().get(1).name()).isEqualTo("NEWHOPE"); - assertThat(response.data().hero().appearsIn().get(2).name()).isEqualTo("EMPIRE"); - assertThat(response.data().hero().appearsIn().get(3)).isNull(); - assertThat(response.data().hero().appearsIn().get(4).name()).isEqualTo("JEDI"); - assertThat(response.data().hero().appearsIn().get(5)).isNull(); - return true; - } - } - ); - } - - @SuppressWarnings("CheckReturnValue") - @Test public void heroParentTypeDependentField() throws Exception { - Utils.INSTANCE.cacheAndAssertCachedResponse( - server, - "HeroParentTypeDependentFieldDroidResponse.json", - apolloClient.query(new HeroParentTypeDependentFieldQuery(Input.fromNullable(Episode.NEWHOPE))), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isFalse(); - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - - HeroParentTypeDependentFieldQuery.AsDroid hero = (HeroParentTypeDependentFieldQuery.AsDroid) response.data().hero(); - assertThat(hero.friends()).hasSize(3); - assertThat(hero.friends().get(0).name()).isEqualTo("Luke Skywalker"); - assertThat(hero.friends().get(0).name()).isEqualTo("Luke Skywalker"); - - assertThat(((HeroParentTypeDependentFieldQuery.AsHuman2) hero.friends().get(0)).height()).isWithin(1.72); - return true; - } - } - ); - } - - @Test public void heroTypeDependentAliasedField() throws Exception { - Utils.INSTANCE.cacheAndAssertCachedResponse( - server, - "HeroTypeDependentAliasedFieldResponse.json", - apolloClient.query(new HeroTypeDependentAliasedFieldQuery(Input.fromNullable(Episode.NEWHOPE))), - new Predicate>() { - @Override - public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isFalse(); - assertThat(response.data().hero()).isInstanceOf(HeroTypeDependentAliasedFieldQuery.AsDroid.class); - assertThat(((HeroTypeDependentAliasedFieldQuery.AsDroid) response.data().hero()).property()).isEqualTo("Astromech"); - return true; - } - } - ); - server.enqueue(Utils.INSTANCE.mockResponse("HeroTypeDependentAliasedFieldResponseHuman.json")); - Utils.INSTANCE.cacheAndAssertCachedResponse( - server, - "HeroTypeDependentAliasedFieldResponse.json", - apolloClient.query(new HeroTypeDependentAliasedFieldQuery(Input.fromNullable(Episode.NEWHOPE))), - new Predicate>() { - @Override - public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isFalse(); - assertThat(response.data().hero()).isInstanceOf(HeroTypeDependentAliasedFieldQuery.AsHuman.class); - assertThat(((HeroTypeDependentAliasedFieldQuery.AsHuman) response.data().hero()).property()).isEqualTo("Tatooine"); - return true; - } - } - ); - } - - @Test public void sameHeroTwice() throws Exception { - Utils.INSTANCE.cacheAndAssertCachedResponse( - server, - "SameHeroTwiceResponse.json", - apolloClient.query(new SameHeroTwiceQuery()), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isFalse(); - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().r2().appearsIn()).hasSize(3); - assertThat(response.data().r2().appearsIn().get(0).name()).isEqualTo("NEWHOPE"); - assertThat(response.data().r2().appearsIn().get(1).name()).isEqualTo("EMPIRE"); - assertThat(response.data().r2().appearsIn().get(2).name()).isEqualTo("JEDI"); - return true; - } - } - ); - } - - @Test public void masterDetailSuccess() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsNameWithIdsResponse.json", - apolloClient.query(new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.NEWHOPE))) - .responseFetcher(NETWORK_ONLY), new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1002")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().character()).isNotNull(); - assertThat(((CharacterNameByIdQuery.AsHuman) response.data().character()).name()).isEqualTo("Han Solo"); - return true; - } - } - ); - } - - @Test public void masterDetailFailIncomplete() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsNameWithIdsResponse.json", - apolloClient.query(new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.NEWHOPE))) - .responseFetcher(NETWORK_ONLY), new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterDetailsQuery("1002")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data()).isNull(); - return true; - } - } - ); - } - - - @Test public void independentQueriesGoToNetworkWhenCacheMiss() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroNameResponse.json", - apolloClient.query(new EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isFalse(); - assertThat(response.data()).isNotNull(); - return true; - } - } - ); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "AllPlanetsNullableField.json", - apolloClient.query(new AllPlanetsQuery()), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.hasErrors()).isFalse(); - assertThat(response.data().allPlanets()).isNotNull(); - return true; - } - } - ); - } - - @Test public void cacheOnlyMissReturnsNullData() throws Exception { - Utils.INSTANCE.assertResponse( - apolloClient.query(new EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return response.data() == null; - } - } - ); - } - - @Test public void cacheResponseWithNullableFields() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "AllPlanetsNullableField.json", - apolloClient.query(new AllPlanetsQuery()).responseFetcher(NETWORK_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response).isNotNull(); - assertThat(response.hasErrors()).isFalse(); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new AllPlanetsQuery()).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response).isNotNull(); - assertThat(response.hasErrors()).isFalse(); - return true; - } - } - ); - } - - @Test public void readOperationFromStore() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsNameWithIdsResponse.json", - apolloClient.query(new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.NEWHOPE))), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().id()).isEqualTo("2001"); - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().friends()).hasSize(3); - assertThat(response.data().hero().friends().get(0).id()).isEqualTo("1000"); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("Luke Skywalker"); - assertThat(response.data().hero().friends().get(1).id()).isEqualTo("1002"); - assertThat(response.data().hero().friends().get(1).name()).isEqualTo("Han Solo"); - assertThat(response.data().hero().friends().get(2).id()).isEqualTo("1003"); - assertThat(response.data().hero().friends().get(2).name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - } - - @Test public void readFragmentFromStore() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsWithFragmentResponse.json", - apolloClient.query(new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.NEWHOPE))), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - - HeroWithFriendsFragment heroWithFriendsFragment = apolloClient.getApolloStore().read( - new HeroWithFriendsFragment.Mapper(), CacheKey.from("2001"), Operation.EMPTY_VARIABLES).execute(); - - assertThat(heroWithFriendsFragment.id()).isEqualTo("2001"); - assertThat(heroWithFriendsFragment.name()).isEqualTo("R2-D2"); - assertThat(heroWithFriendsFragment.friends()).hasSize(3); - assertThat(heroWithFriendsFragment.friends().get(0).fragments().humanWithIdFragment().id()).isEqualTo("1000"); - assertThat(heroWithFriendsFragment.friends().get(0).fragments().humanWithIdFragment().name()).isEqualTo("Luke Skywalker"); - assertThat(heroWithFriendsFragment.friends().get(1).fragments().humanWithIdFragment().id()).isEqualTo("1002"); - assertThat(heroWithFriendsFragment.friends().get(1).fragments().humanWithIdFragment().name()).isEqualTo("Han Solo"); - assertThat(heroWithFriendsFragment.friends().get(2).fragments().humanWithIdFragment().id()).isEqualTo("1003"); - assertThat(heroWithFriendsFragment.friends().get(2).fragments().humanWithIdFragment().name()).isEqualTo("Leia Organa"); - - HumanWithIdFragment fragment = apolloClient.getApolloStore().read(new HumanWithIdFragment.Mapper(), - CacheKey.from("1000"), Operation.EMPTY_VARIABLES).execute(); - assertThat(fragment.id()).isEqualTo("1000"); - assertThat(fragment.name()).isEqualTo("Luke Skywalker"); - - fragment = apolloClient.getApolloStore().read(new HumanWithIdFragment.Mapper(), CacheKey.from("1002"), - Operation.EMPTY_VARIABLES).execute(); - assertThat(fragment.id()).isEqualTo("1002"); - assertThat(fragment.name()).isEqualTo("Han Solo"); - - fragment = apolloClient.getApolloStore().read(new HumanWithIdFragment.Mapper(), CacheKey.from("1003"), - Operation.EMPTY_VARIABLES).execute(); - assertThat(fragment.id()).isEqualTo("1003"); - assertThat(fragment.name()).isEqualTo("Leia Organa"); - } - - @Test public void fromCacheFlag() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroNameResponse.json", - apolloClient.query(new EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.fromCache(); - } - } - ); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroNameResponse.json", - apolloClient.query(new EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))).responseFetcher(NETWORK_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.fromCache(); - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return response.fromCache(); - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))).responseFetcher(CACHE_FIRST), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return response.fromCache(); - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new EpisodeHeroNameQuery(Input.fromNullable(Episode.EMPIRE))).responseFetcher(NETWORK_FIRST), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return response.fromCache(); - } - } - ); - } - - @Test public void removeFromStore() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsNameWithIdsResponse.json", - apolloClient.query(new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.NEWHOPE))) - .responseFetcher(NETWORK_ONLY), new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().friends()).hasSize(3); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1002")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(((CharacterNameByIdQuery.AsHuman) response.data().character()).name()).isEqualTo("Han Solo"); - return true; - } - } - ); - - // test remove root query object - assertThat(apolloClient.getApolloStore().remove(CacheKey.from("2001")).execute()).isTrue(); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.NEWHOPE))) - .responseFetcher(CACHE_ONLY), new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(response.data()).isNull(); - return true; - } - } - ); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsNameWithIdsResponse.json", - apolloClient.query(new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.NEWHOPE))) - .responseFetcher(NETWORK_ONLY), new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1002")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(((CharacterNameByIdQuery.AsHuman) response.data().character()).name()).isEqualTo("Han Solo"); - return true; - } - } - ); - - // test remove object from the list - assertThat(apolloClient.getApolloStore().remove(CacheKey.from("1002")).execute()).isTrue(); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.NEWHOPE))) - .responseFetcher(CACHE_ONLY), new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(response.data()).isNull(); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1002")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(response.data()).isNull(); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1003")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(response.data()).isNotNull(); - assertThat(((CharacterNameByIdQuery.AsHuman) response.data().character()).name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - } - - @Test public void removeMultipleFromStore() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsNameWithIdsResponse.json", - apolloClient.query(new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.NEWHOPE))) - .responseFetcher(NETWORK_ONLY), new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().friends()).hasSize(3); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1000")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(((CharacterNameByIdQuery.AsHuman) response.data().character()).name()).isEqualTo("Luke Skywalker"); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1002")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(((CharacterNameByIdQuery.AsHuman) response.data().character()).name()).isEqualTo("Han Solo"); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1003")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(((CharacterNameByIdQuery.AsHuman) response.data().character()).name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - - assertThat(apolloClient.getApolloStore().remove(asList(CacheKey.from("1002"), CacheKey.from("1000"))) - .execute()).isEqualTo(2); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1000")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(response.data()).isNull(); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1002")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(response.data()).isNull(); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1003")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(((CharacterNameByIdQuery.AsHuman) response.data().character()).name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - } - - @Test public void skipIncludeDirective() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsNameResponse.json", - apolloClient.query(HeroAndFriendsDirectivesQuery.builder().episode(Episode.JEDI).includeName(true).skipFriends(false).build()), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(HeroAndFriendsDirectivesQuery.builder().episode(Episode.JEDI).includeName(true).skipFriends(false).build()).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().friends()).hasSize(3); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("Luke Skywalker"); - assertThat(response.data().hero().friends().get(1).name()).isEqualTo("Han Solo"); - assertThat(response.data().hero().friends().get(2).name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(HeroAndFriendsDirectivesQuery.builder().episode(Episode.JEDI).includeName(false).skipFriends(false).build()).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().name()).isNull(); - assertThat(response.data().hero().friends()).hasSize(3); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("Luke Skywalker"); - assertThat(response.data().hero().friends().get(1).name()).isEqualTo("Han Solo"); - assertThat(response.data().hero().friends().get(2).name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(HeroAndFriendsDirectivesQuery.builder().episode(Episode.JEDI).includeName(true).skipFriends(true).build()).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().friends()).isNull(); - return true; - } - } - ); - } - - @Test public void skipIncludeDirectiveUnsatisfiedCache() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroNameResponse.json", - apolloClient.query(HeroAndFriendsDirectivesQuery.builder().episode(Episode.JEDI).includeName(true).skipFriends(true).build()), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(HeroAndFriendsDirectivesQuery.builder().episode(Episode.JEDI).includeName(true).skipFriends(true).build()).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().friends()).isNull(); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(HeroAndFriendsDirectivesQuery.builder().episode(Episode.JEDI).includeName(true).skipFriends(false).build()).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data()).isNull(); - return true; - } - } - ); - } - - @Test public void listOfList() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "StarshipByIdResponse.json", - apolloClient.query(new StarshipByIdQuery("Starship1")), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().starship().__typename()).isEqualTo("Starship"); - assertThat(response.data().starship().name()).isEqualTo("SuperRocket"); - assertThat(response.data().starship().coordinates()).hasSize(3); - assertThat(response.data().starship().coordinates()).containsExactly(asList(100d, 200d), asList(300d, 400d), - asList(500d, 600d)); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new StarshipByIdQuery("Starship1")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().starship().__typename()).isEqualTo("Starship"); - assertThat(response.data().starship().name()).isEqualTo("SuperRocket"); - assertThat(response.data().starship().coordinates()).hasSize(3); - assertThat(response.data().starship().coordinates()).containsExactly(asList(100d, 200d), asList(300d, 400d), - asList(500d, 600d)); - return true; - } - } - ); - } - - @Test public void dump() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsNameWithIdsResponse.json", - apolloClient.query(new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.NEWHOPE))) - .responseFetcher(NETWORK_ONLY), new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - - Map, Map> dump = apolloClient.getApolloStore().normalizedCache().dump(); - assertThat(NormalizedCache.prettifyDump(dump)).isEqualTo("OptimisticNormalizedCache {}\n" + - "LruNormalizedCache {\n" + - " \"1002\" : {\n" + - " \"__typename\" : Human\n" + - " \"id\" : 1002\n" + - " \"name\" : Han Solo\n" + - " }\n" + - "\n" + - " \"QUERY_ROOT\" : {\n" + - " \"hero({\"episode\":\"NEWHOPE\"})\" : CacheRecordRef(2001)\n" + - " }\n" + - "\n" + - " \"1003\" : {\n" + - " \"__typename\" : Human\n" + - " \"id\" : 1003\n" + - " \"name\" : Leia Organa\n" + - " }\n" + - "\n" + - " \"1000\" : {\n" + - " \"__typename\" : Human\n" + - " \"id\" : 1000\n" + - " \"name\" : Luke Skywalker\n" + - " }\n" + - "\n" + - " \"2001\" : {\n" + - " \"__typename\" : Droid\n" + - " \"id\" : 2001\n" + - " \"name\" : R2-D2\n" + - " \"friends\" : [\n" + - " CacheRecordRef(1000)\n" + - " CacheRecordRef(1002)\n" + - " CacheRecordRef(1003)\n" + - " ]\n" + - " }\n" + - "}\n"); - } - - @Test public void cascadeRemove() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsNameWithIdsResponse.json", - apolloClient.query(new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.NEWHOPE))) - .responseFetcher(NETWORK_ONLY), new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().friends()).hasSize(3); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1000")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(((CharacterNameByIdQuery.AsHuman) response.data().character()).name()).isEqualTo("Luke Skywalker"); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1002")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(((CharacterNameByIdQuery.AsHuman) response.data().character()).name()).isEqualTo("Han Solo"); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1003")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(((CharacterNameByIdQuery.AsHuman) response.data().character()).name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - - // test remove root query object - assertThat(apolloClient.getApolloStore().remove(CacheKey.from("2001"), true).execute()).isTrue(); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.NEWHOPE))) - .responseFetcher(CACHE_ONLY), new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(response.data()).isNull(); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1000")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(response.data()).isNull(); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1002")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(response.data()).isNull(); - return true; - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new CharacterNameByIdQuery("1003")).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.fromCache()).isTrue(); - assertThat(response.data()).isNull(); - return true; - } - } - ); - - assertThat(NormalizedCache.prettifyDump(apolloClient.getApolloStore().normalizedCache().dump())).isEqualTo("" + - "OptimisticNormalizedCache {}\n" + - "LruNormalizedCache {\n" + - " \"QUERY_ROOT\" : {\n" + - " \"hero({\"episode\":\"NEWHOPE\"})\" : CacheRecordRef(2001)\n" + - " }\n" + - "}\n"); - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/OperationOutputTest.kt b/apollo-integration/src/test/java/com/apollographql/apollo/OperationOutputTest.kt deleted file mode 100644 index 51c159c035d..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/OperationOutputTest.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.apollographql.apollo - -import com.apollographql.apollo.compiler.operationoutput.OperationOutput -import com.apollographql.apollo.integration.httpcache.AllFilmsQuery -import com.google.common.truth.Truth.assertThat -import org.junit.Test -import java.io.File - -class OperationOutputTest { - @Test - fun operationOutputMatchesTheModels() { - val operationOutputFile = File("build/generated/operationOutput/apollo/main/httpcache/operationOutput.json") - val source = OperationOutput(operationOutputFile).values.first { it.name == "AllFilms"}.source - assertThat(AllFilmsQuery.builder().build().queryDocument()).isEqualTo(source) - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/OptimisticCacheTestCase.java b/apollo-integration/src/test/java/com/apollographql/apollo/OptimisticCacheTestCase.java deleted file mode 100644 index a2a92539a37..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/OptimisticCacheTestCase.java +++ /dev/null @@ -1,545 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy; -import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.fetcher.ApolloResponseFetchers; -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesQuery; -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesWithIDsQuery; -import com.apollographql.apollo.integration.normalizer.HeroNameQuery; -import com.apollographql.apollo.integration.normalizer.HeroNameWithEnumsQuery; -import com.apollographql.apollo.integration.normalizer.HeroNameWithIdQuery; -import com.apollographql.apollo.integration.normalizer.ReviewsByEpisodeQuery; -import com.apollographql.apollo.integration.normalizer.UpdateReviewMutation; -import com.apollographql.apollo.integration.normalizer.type.ColorInput; -import com.apollographql.apollo.integration.normalizer.type.Episode; -import com.apollographql.apollo.integration.normalizer.type.ReviewInput; -import io.reactivex.functions.Predicate; -import okhttp3.Dispatcher; -import okhttp3.OkHttpClient; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import org.jetbrains.annotations.NotNull; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; - -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.CACHE_ONLY; -import static com.google.common.truth.Truth.assertThat; - -public class OptimisticCacheTestCase { - private ApolloClient apolloClient; - @Rule public final MockWebServer server = new MockWebServer(); - - @Before public void setUp() { - OkHttpClient okHttpClient = new OkHttpClient.Builder() - .dispatcher(new Dispatcher(Utils.INSTANCE.immediateExecutorService())) - .build(); - - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(okHttpClient) - .normalizedCache(new LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), new IdFieldCacheKeyResolver()) - .dispatcher(Utils.INSTANCE.immediateExecutor()) - .build(); - } - - private MockResponse mockResponse(String fileName) throws IOException { - return new MockResponse().setChunkedBody(Utils.INSTANCE.readFileToString(getClass(), "/" + fileName), 32); - } - - @Test public void simple() throws Exception { - HeroAndFriendsNamesQuery query = new HeroAndFriendsNamesQuery(Input.fromNullable(Episode.JEDI)); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsNameResponse.json", - apolloClient.query(query), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - - UUID mutationId = UUID.randomUUID(); - HeroAndFriendsNamesQuery.Data data = new HeroAndFriendsNamesQuery.Data(new HeroAndFriendsNamesQuery.Hero( - "Droid", - "R222-D222", - Arrays.asList( - new HeroAndFriendsNamesQuery.Friend( - "Human", - "SuperMan" - ), - new HeroAndFriendsNamesQuery.Friend( - "Human", - "Batman" - ) - ) - )); - apolloClient.getApolloStore().writeOptimisticUpdatesAndPublish(query, data, mutationId).execute(); - - Utils.INSTANCE.assertResponse( - apolloClient.query(query).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().name()).isEqualTo("R222-D222"); - assertThat(response.data().hero().friends()).hasSize(2); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("SuperMan"); - assertThat(response.data().hero().friends().get(1).name()).isEqualTo("Batman"); - return true; - } - } - ); - - apolloClient.getApolloStore().rollbackOptimisticUpdates(mutationId).execute(); - - Utils.INSTANCE.assertResponse( - apolloClient.query(query).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().friends()).hasSize(3); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("Luke Skywalker"); - assertThat(response.data().hero().friends().get(1).name()).isEqualTo("Han Solo"); - assertThat(response.data().hero().friends().get(2).name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - } - - @Test public void two_optimistic_two_rollback() throws Exception { - HeroAndFriendsNamesWithIDsQuery query1 = new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.JEDI)); - UUID mutationId1 = UUID.randomUUID(); - - HeroNameWithIdQuery query2 = new HeroNameWithIdQuery(); - UUID mutationId2 = UUID.randomUUID(); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsNameWithIdsResponse.json", - apolloClient.query(query1), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - - HeroAndFriendsNamesWithIDsQuery.Data data1 = new HeroAndFriendsNamesWithIDsQuery.Data( - new HeroAndFriendsNamesWithIDsQuery.Hero( - "Droid", - "2001", - "R222-D222", - Arrays.asList( - new HeroAndFriendsNamesWithIDsQuery.Friend( - "Human", - "1000", - "SuperMan" - ), - new HeroAndFriendsNamesWithIDsQuery.Friend( - "Human", - "1003", - "Batman" - ) - ) - ) - ); - apolloClient.getApolloStore().writeOptimisticUpdatesAndPublish(query1, data1, mutationId1).execute(); - - // check if query1 see optimistic updates - Utils.INSTANCE.assertResponse( - apolloClient.query(query1).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().id()).isEqualTo("2001"); - assertThat(response.data().hero().name()).isEqualTo("R222-D222"); - assertThat(response.data().hero().friends()).hasSize(2); - assertThat(response.data().hero().friends().get(0).id()).isEqualTo("1000"); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("SuperMan"); - assertThat(response.data().hero().friends().get(1).id()).isEqualTo("1003"); - assertThat(response.data().hero().friends().get(1).name()).isEqualTo("Batman"); - return true; - } - } - ); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroNameWithIdResponse.json", - apolloClient.query(query2), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - - HeroNameWithIdQuery.Data data2 = new HeroNameWithIdQuery.Data(new HeroNameWithIdQuery.Hero( - "Human", - "1000", - "Beast" - )); - apolloClient.getApolloStore().writeOptimisticUpdatesAndPublish(query2, data2, mutationId2).execute(); - - // check if query1 see the latest optimistic updates - Utils.INSTANCE.assertResponse( - apolloClient.query(query1).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().id()).isEqualTo("2001"); - assertThat(response.data().hero().name()).isEqualTo("R222-D222"); - assertThat(response.data().hero().friends()).hasSize(2); - assertThat(response.data().hero().friends().get(0).id()).isEqualTo("1000"); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("Beast"); - assertThat(response.data().hero().friends().get(1).id()).isEqualTo("1003"); - assertThat(response.data().hero().friends().get(1).name()).isEqualTo("Batman"); - return true; - } - } - ); - - // check if query2 see the latest optimistic updates - Utils.INSTANCE.assertResponse( - apolloClient.query(query2).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().id()).isEqualTo("1000"); - assertThat(response.data().hero().name()).isEqualTo("Beast"); - return true; - } - } - ); - - // rollback query1 optimistic updates - apolloClient.getApolloStore().rollbackOptimisticUpdates(mutationId1).execute(); - - // check if query1 see the latest optimistic updates - Utils.INSTANCE.assertResponse( - apolloClient.query(query1).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().id()).isEqualTo("2001"); - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().friends()).hasSize(3); - assertThat(response.data().hero().friends().get(0).id()).isEqualTo("1000"); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("Beast"); - assertThat(response.data().hero().friends().get(1).id()).isEqualTo("1002"); - assertThat(response.data().hero().friends().get(1).name()).isEqualTo("Han Solo"); - assertThat(response.data().hero().friends().get(2).id()).isEqualTo("1003"); - assertThat(response.data().hero().friends().get(2).name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - - // check if query2 see the latest optimistic updates - Utils.INSTANCE.assertResponse( - apolloClient.query(query2).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().id()).isEqualTo("1000"); - assertThat(response.data().hero().name()).isEqualTo("Beast"); - return true; - } - } - ); - - // rollback query2 optimistic updates - apolloClient.getApolloStore().rollbackOptimisticUpdates(mutationId2).execute(); - - // check if query2 see the latest optimistic updates - Utils.INSTANCE.assertResponse( - apolloClient.query(query2).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().id()).isEqualTo("1000"); - assertThat(response.data().hero().name()).isEqualTo("SuperMan"); - return true; - } - } - ); - } - - @Test public void full_persisted_partial_optimistic() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroNameWithEnumsResponse.json", - apolloClient.query(new HeroNameWithEnumsQuery()), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - - UUID mutationId = UUID.randomUUID(); - apolloClient.getApolloStore().writeOptimisticUpdates( - new HeroNameQuery(), - new HeroNameQuery.Data(new HeroNameQuery.Hero("Droid", "R22-D22")), - mutationId - ).execute(); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new HeroNameWithEnumsQuery()).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().name()).isEqualTo("R22-D22"); - assertThat(response.data().hero().firstAppearsIn()).isEqualTo(Episode.EMPIRE); - assertThat(response.data().hero().appearsIn()).isEqualTo(Arrays.asList(Episode.NEWHOPE, Episode.EMPIRE, Episode.JEDI)); - return true; - } - } - ); - - apolloClient.getApolloStore().rollbackOptimisticUpdates(mutationId).execute(); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new HeroNameWithEnumsQuery()).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().firstAppearsIn()).isEqualTo(Episode.EMPIRE); - assertThat(response.data().hero().appearsIn()).isEqualTo(Arrays.asList(Episode.NEWHOPE, Episode.EMPIRE, Episode.JEDI)); - return true; - } - } - ); - } - - @Test public void mutation_and_query_watcher() throws Exception { - server.enqueue(mockResponse("ReviewsEmpireEpisodeResponse.json")); - final List watcherData = new ArrayList<>(); - apolloClient.query(new ReviewsByEpisodeQuery(Episode.EMPIRE)).responseFetcher(ApolloResponseFetchers.NETWORK_FIRST) - .watcher().refetchResponseFetcher(ApolloResponseFetchers.CACHE_FIRST) - .enqueueAndWatch(new ApolloCall.Callback() { - @Override public void onResponse(@NotNull Response response) { - watcherData.add(response.data()); - } - - @Override public void onFailure(@NotNull ApolloException e) { - - } - }); - - server.enqueue(mockResponse("UpdateReviewResponse.json")); - UpdateReviewMutation updateReviewMutation = new UpdateReviewMutation( - "empireReview2", - ReviewInput.builder() - .commentary("Great") - .stars(5) - .favoriteColor(ColorInput.builder().build()) - .build() - ); - apolloClient.mutate(updateReviewMutation, new UpdateReviewMutation.Data(new UpdateReviewMutation.UpdateReview( - "Review", "empireReview2", 5, "Great"))).enqueue( - new ApolloCall.Callback() { - @Override public void onResponse(@NotNull Response response) { - } - - @Override public void onFailure(@NotNull ApolloException e) { - - } - } - ); - assertThat(watcherData).hasSize(3); - - // before mutation and optimistic updates - assertThat(watcherData.get(0).reviews()).hasSize(3); - assertThat(watcherData.get(0).reviews().get(0).id()).isEqualTo("empireReview1"); - assertThat(watcherData.get(0).reviews().get(0).stars()).isEqualTo(1); - assertThat(watcherData.get(0).reviews().get(0).commentary()).isEqualTo("Boring"); - assertThat(watcherData.get(0).reviews().get(1).id()).isEqualTo("empireReview2"); - assertThat(watcherData.get(0).reviews().get(1).stars()).isEqualTo(2); - assertThat(watcherData.get(0).reviews().get(1).commentary()).isEqualTo("So-so"); - assertThat(watcherData.get(0).reviews().get(2).id()).isEqualTo("empireReview3"); - assertThat(watcherData.get(0).reviews().get(2).stars()).isEqualTo(5); - assertThat(watcherData.get(0).reviews().get(2).commentary()).isEqualTo("Amazing"); - - // optimistic updates - assertThat(watcherData.get(1).reviews()).hasSize(3); - assertThat(watcherData.get(1).reviews().get(0).id()).isEqualTo("empireReview1"); - assertThat(watcherData.get(1).reviews().get(0).stars()).isEqualTo(1); - assertThat(watcherData.get(1).reviews().get(0).commentary()).isEqualTo("Boring"); - assertThat(watcherData.get(1).reviews().get(1).id()).isEqualTo("empireReview2"); - assertThat(watcherData.get(1).reviews().get(1).stars()).isEqualTo(5); - assertThat(watcherData.get(1).reviews().get(1).commentary()).isEqualTo("Great"); - assertThat(watcherData.get(1).reviews().get(2).id()).isEqualTo("empireReview3"); - assertThat(watcherData.get(1).reviews().get(2).stars()).isEqualTo(5); - assertThat(watcherData.get(1).reviews().get(2).commentary()).isEqualTo("Amazing"); - - // after mutation with rolled back optimistic updates - assertThat(watcherData.get(2).reviews()).hasSize(3); - assertThat(watcherData.get(2).reviews().get(0).id()).isEqualTo("empireReview1"); - assertThat(watcherData.get(2).reviews().get(0).stars()).isEqualTo(1); - assertThat(watcherData.get(2).reviews().get(0).commentary()).isEqualTo("Boring"); - assertThat(watcherData.get(2).reviews().get(1).id()).isEqualTo("empireReview2"); - assertThat(watcherData.get(2).reviews().get(1).stars()).isEqualTo(4); - assertThat(watcherData.get(2).reviews().get(1).commentary()).isEqualTo("Not Bad"); - assertThat(watcherData.get(2).reviews().get(2).id()).isEqualTo("empireReview3"); - assertThat(watcherData.get(2).reviews().get(2).stars()).isEqualTo(5); - assertThat(watcherData.get(2).reviews().get(2).commentary()).isEqualTo("Amazing"); - } - - @Test public void two_optimistic_reverse_rollback_order() throws Exception { - HeroAndFriendsNamesWithIDsQuery query1 = new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(Episode.JEDI)); - UUID mutationId1 = UUID.randomUUID(); - - HeroNameWithIdQuery query2 = new HeroNameWithIdQuery(); - UUID mutationId2 = UUID.randomUUID(); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsNameWithIdsResponse.json", - apolloClient.query(query1), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroNameWithIdResponse.json", - apolloClient.query(query2), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - - HeroAndFriendsNamesWithIDsQuery.Data data1 = new HeroAndFriendsNamesWithIDsQuery.Data( - new HeroAndFriendsNamesWithIDsQuery.Hero( - "Droid", - "2001", - "R222-D222", - Arrays.asList( - new HeroAndFriendsNamesWithIDsQuery.Friend( - "Human", - "1000", - "Robocop" - ), - new HeroAndFriendsNamesWithIDsQuery.Friend( - "Human", - "1003", - "Batman" - ) - ) - ) - ); - apolloClient.getApolloStore().writeOptimisticUpdatesAndPublish(query1, data1, mutationId1).execute(); - - HeroNameWithIdQuery.Data data2 = new HeroNameWithIdQuery.Data(new HeroNameWithIdQuery.Hero( - "Human", - "1000", - "Spiderman" - )); - apolloClient.getApolloStore().writeOptimisticUpdatesAndPublish(query2, data2, mutationId2).execute(); - - // check if query1 see optimistic updates - Utils.INSTANCE.assertResponse( - apolloClient.query(query1).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().id()).isEqualTo("2001"); - assertThat(response.data().hero().name()).isEqualTo("R222-D222"); - assertThat(response.data().hero().friends()).hasSize(2); - assertThat(response.data().hero().friends().get(0).id()).isEqualTo("1000"); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("Spiderman"); - assertThat(response.data().hero().friends().get(1).id()).isEqualTo("1003"); - assertThat(response.data().hero().friends().get(1).name()).isEqualTo("Batman"); - return true; - } - } - ); - - // check if query2 see the latest optimistic updates - Utils.INSTANCE.assertResponse( - apolloClient.query(query2).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().id()).isEqualTo("1000"); - assertThat(response.data().hero().name()).isEqualTo("Spiderman"); - return true; - } - } - ); - - // rollback query2 optimistic updates - apolloClient.getApolloStore().rollbackOptimisticUpdates(mutationId2).execute(); - - // check if query1 see the latest optimistic updates - Utils.INSTANCE.assertResponse( - apolloClient.query(query1).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().id()).isEqualTo("2001"); - assertThat(response.data().hero().name()).isEqualTo("R222-D222"); - assertThat(response.data().hero().friends()).hasSize(2); - assertThat(response.data().hero().friends().get(0).id()).isEqualTo("1000"); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("Robocop"); - assertThat(response.data().hero().friends().get(1).id()).isEqualTo("1003"); - assertThat(response.data().hero().friends().get(1).name()).isEqualTo("Batman"); - return true; - } - } - ); - - // check if query2 see the latest optimistic updates - Utils.INSTANCE.assertResponse( - apolloClient.query(query2).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().id()).isEqualTo("1000"); - assertThat(response.data().hero().name()).isEqualTo("Robocop"); - return true; - } - } - ); - - // rollback query1 optimistic updates - apolloClient.getApolloStore().rollbackOptimisticUpdates(mutationId1).execute(); - - // check if query1 see the latest non-optimistic updates - Utils.INSTANCE.assertResponse( - apolloClient.query(query1).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().id()).isEqualTo("2001"); - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().friends()).hasSize(3); - assertThat(response.data().hero().friends().get(0).id()).isEqualTo("1000"); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("SuperMan"); - assertThat(response.data().hero().friends().get(1).id()).isEqualTo("1002"); - assertThat(response.data().hero().friends().get(1).name()).isEqualTo("Han Solo"); - assertThat(response.data().hero().friends().get(2).id()).isEqualTo("1003"); - assertThat(response.data().hero().friends().get(2).name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - - // check if query2 see the latest non-optimistic updates - Utils.INSTANCE.assertResponse( - apolloClient.query(query2).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().id()).isEqualTo("1000"); - assertThat(response.data().hero().name()).isEqualTo("SuperMan"); - return true; - } - } - ); - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/ResponseNormalizationTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/ResponseNormalizationTest.java deleted file mode 100644 index 6e296f81d30..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/ResponseNormalizationTest.java +++ /dev/null @@ -1,290 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.cache.CacheHeaders; -import com.apollographql.apollo.cache.normalized.CacheKey; -import com.apollographql.apollo.cache.normalized.CacheReference; -import com.apollographql.apollo.cache.normalized.NormalizedCache; -import com.apollographql.apollo.cache.normalized.Record; -import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy; -import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory; -import com.apollographql.apollo.integration.httpcache.AllPlanetsQuery; -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery; -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesQuery; -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesWithIDForParentOnlyQuery; -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesWithIDsQuery; -import com.apollographql.apollo.integration.normalizer.HeroAppearsInQuery; -import com.apollographql.apollo.integration.normalizer.HeroNameQuery; -import com.apollographql.apollo.integration.normalizer.HeroParentTypeDependentFieldQuery; -import com.apollographql.apollo.integration.normalizer.HeroTypeDependentAliasedFieldQuery; -import com.apollographql.apollo.integration.normalizer.SameHeroTwiceQuery; -import io.reactivex.functions.Predicate; -import okhttp3.Dispatcher; -import okhttp3.OkHttpClient; -import okhttp3.mockwebserver.MockWebServer; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.math.BigDecimal; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import static com.apollographql.apollo.integration.normalizer.type.Episode.EMPIRE; -import static com.apollographql.apollo.integration.normalizer.type.Episode.JEDI; -import static com.google.common.truth.Truth.assertThat; - -public class ResponseNormalizationTest { - private ApolloClient apolloClient; - @Rule public final MockWebServer server = new MockWebServer(); - private NormalizedCache normalizedCache; - - private static final String TEST_FIELD_KEY_JEDI = "hero({\"episode\":\"JEDI\"})"; - public static final String TEST_FIELD_KEY_EMPIRE = "hero({\"episode\":\"EMPIRE\"})"; - private final String QUERY_ROOT_KEY = "QUERY_ROOT"; - - @Before public void setUp() { - OkHttpClient okHttpClient = new OkHttpClient.Builder() - .dispatcher(new Dispatcher(Utils.INSTANCE.immediateExecutorService())) - .build(); - - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(okHttpClient) - .normalizedCache(new LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), new IdFieldCacheKeyResolver()) - .dispatcher(Utils.INSTANCE.immediateExecutor()) - .build(); - normalizedCache = apolloClient.getApolloStore().normalizedCache(); - } - - @Test public void testHeroName() throws Exception { - assertHasNoErrors("HeroNameResponse.json", new HeroNameQuery()); - - Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE); - CacheReference reference = (CacheReference) record.field("hero"); - assertThat(reference).isEqualTo(new CacheReference("hero")); - - final Record heroRecord = normalizedCache.loadRecord(reference.key(), CacheHeaders.NONE); - assertThat(heroRecord.field("name")).isEqualTo("R2-D2"); - } - - @Test public void testMergeNull() throws Exception { - Record record = Record.builder("Key") - .addField("field1", "value1") - .build(); - normalizedCache.merge(Collections.singletonList(record), CacheHeaders.NONE); - - Record newRecord = record.toBuilder() - .addField("field2", null) - .build(); - normalizedCache.merge(Collections.singletonList(newRecord), CacheHeaders.NONE); - - final Record finalRecord = normalizedCache.loadRecord(record.key(), CacheHeaders.NONE); - assertThat(finalRecord.hasField("field2")).isTrue(); - - normalizedCache.remove(CacheKey.from(record.key())); - } - - @Test - public void testHeroNameWithVariable() throws Exception { - assertHasNoErrors("EpisodeHeroNameResponse.json", new EpisodeHeroNameQuery(Input.fromNullable(JEDI))); - - Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE); - CacheReference reference = (CacheReference) record.field(TEST_FIELD_KEY_JEDI); - assertThat(reference).isEqualTo(new CacheReference(TEST_FIELD_KEY_JEDI)); - - final Record heroRecord = normalizedCache.loadRecord(reference.key(), CacheHeaders.NONE); - assertThat(heroRecord.field("name")).isEqualTo("R2-D2"); - } - - - @Test - public void testHeroAppearsInQuery() throws Exception { - assertHasNoErrors("HeroAppearsInResponse.json", new HeroAppearsInQuery()); - - Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE); - CacheReference heroReference = (CacheReference) record.field("hero"); - assertThat(heroReference).isEqualTo(new CacheReference("hero")); - - final Record hero = normalizedCache.loadRecord(heroReference.key(), CacheHeaders.NONE); - assertThat(hero.field("appearsIn")).isEqualTo(Arrays.asList("NEWHOPE", "EMPIRE", "JEDI")); - } - - @Test - public void testHeroAndFriendsNamesQueryWithoutIDs() throws Exception { - assertHasNoErrors("HeroAndFriendsNameResponse.json", new HeroAndFriendsNamesQuery(Input.fromNullable(JEDI))); - - Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE); - - CacheReference heroReference = (CacheReference) record.field(TEST_FIELD_KEY_JEDI); - assertThat(heroReference).isEqualTo(new CacheReference(TEST_FIELD_KEY_JEDI)); - - final Record heroRecord = normalizedCache.loadRecord(heroReference.key(), CacheHeaders.NONE); - assertThat(heroRecord.field("name")).isEqualTo("R2-D2"); - - assertThat(heroRecord.field("friends")).isEqualTo(Arrays.asList( - new CacheReference(TEST_FIELD_KEY_JEDI + ".friends.0"), - new CacheReference(TEST_FIELD_KEY_JEDI + ".friends.1"), - new CacheReference(TEST_FIELD_KEY_JEDI + ".friends.2") - )); - - final Record luke = normalizedCache.loadRecord(TEST_FIELD_KEY_JEDI + ".friends.0", CacheHeaders.NONE); - assertThat(luke.field("name")).isEqualTo("Luke Skywalker"); - } - - @Test - public void testHeroAndFriendsNamesQueryWithIDs() throws Exception { - assertHasNoErrors("HeroAndFriendsNameWithIdsResponse.json", new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(JEDI))); - - Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE); - CacheReference heroReference = (CacheReference) record.field(TEST_FIELD_KEY_JEDI); - assertThat(heroReference).isEqualTo(new CacheReference("2001")); - - final Record heroRecord = normalizedCache.loadRecord(heroReference.key(), CacheHeaders.NONE); - assertThat(heroRecord.field("name")).isEqualTo("R2-D2"); - - assertThat(heroRecord.field("friends")).isEqualTo(Arrays.asList( - new CacheReference("1000"), - new CacheReference("1002"), - new CacheReference("1003") - )); - - final Record luke = normalizedCache.loadRecord("1000", CacheHeaders.NONE); - assertThat(luke.field("name")).isEqualTo("Luke Skywalker"); - } - - @Test - public void testHeroAndFriendsNamesWithIDForParentOnly() throws Exception { - assertHasNoErrors("HeroAndFriendsNameWithIdsParentOnlyResponse.json", - new HeroAndFriendsNamesWithIDForParentOnlyQuery(Input.fromNullable(JEDI))); - - Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE); - CacheReference heroReference = (CacheReference) record.field(TEST_FIELD_KEY_JEDI); - assertThat(heroReference).isEqualTo(new CacheReference("2001")); - - final Record heroRecord = normalizedCache.loadRecord(heroReference.key(), CacheHeaders.NONE); - assertThat(heroRecord.field("name")).isEqualTo("R2-D2"); - - assertThat(heroRecord.field("friends")).isEqualTo(Arrays.asList( - new CacheReference("2001.friends.0"), - new CacheReference("2001.friends.1"), - new CacheReference("2001.friends.2") - )); - - final Record luke = normalizedCache.loadRecord("2001.friends.0", CacheHeaders.NONE); - assertThat(luke.field("name")).isEqualTo("Luke Skywalker"); - } - - @Test - public void testSameHeroTwiceQuery() throws Exception { - assertHasNoErrors("SameHeroTwiceResponse.json", new SameHeroTwiceQuery()); - - Record record = normalizedCache - .loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE); - CacheReference heroReference = (CacheReference) record.field("hero"); - - final Record hero = normalizedCache.loadRecord(heroReference.key(), CacheHeaders.NONE); - assertThat(hero.field("name")).isEqualTo("R2-D2"); - assertThat(hero.field("appearsIn")).isEqualTo(Arrays.asList("NEWHOPE", "EMPIRE", "JEDI")); - } - - @Test - public void testHeroTypeDependentAliasedFieldQueryDroid() throws Exception { - assertHasNoErrors("HeroTypeDependentAliasedFieldResponse.json", - new HeroTypeDependentAliasedFieldQuery(Input.fromNullable(JEDI))); - - Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE); - CacheReference heroReference = (CacheReference) record.field(TEST_FIELD_KEY_JEDI); - - final Record hero = normalizedCache.loadRecord(heroReference.key(), CacheHeaders.NONE); - assertThat(hero.field("primaryFunction")).isEqualTo("Astromech"); - assertThat(hero.field("__typename")).isEqualTo("Droid"); - } - - @Test - public void testHeroTypeDependentAliasedFieldQueryHuman() throws Exception { - assertHasNoErrors("HeroTypeDependentAliasedFieldResponseHuman.json", - new HeroTypeDependentAliasedFieldQuery(Input.fromNullable(EMPIRE))); - - Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE); - CacheReference heroReference = (CacheReference) record.field(TEST_FIELD_KEY_EMPIRE); - - final Record hero = normalizedCache.loadRecord(heroReference.key(), CacheHeaders.NONE); - assertThat(hero.field("homePlanet")).isEqualTo("Tatooine"); - assertThat(hero.field("__typename")).isEqualTo("Human"); - } - - @Test - public void testHeroParentTypeDependentAliasedFieldQueryHuman() throws Exception { - assertHasNoErrors("HeroTypeDependentAliasedFieldResponseHuman.json", - new HeroTypeDependentAliasedFieldQuery(Input.fromNullable(EMPIRE))); - - Record record = normalizedCache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE); - CacheReference heroReference = (CacheReference) record.field(TEST_FIELD_KEY_EMPIRE); - - final Record hero = normalizedCache.loadRecord(heroReference.key(), CacheHeaders.NONE); - assertThat(hero.field("homePlanet")).isEqualTo("Tatooine"); - assertThat(hero.field("__typename")).isEqualTo("Human"); - } - - @Test - public void testHeroParentTypeDependentFieldDroid() throws Exception { - assertHasNoErrors("HeroParentTypeDependentFieldDroidResponse.json", - new HeroParentTypeDependentFieldQuery(Input.fromNullable(JEDI))); - - Record lukeRecord = normalizedCache - .loadRecord(TEST_FIELD_KEY_JEDI + ".friends.0", CacheHeaders.NONE); - assertThat(lukeRecord.field("name")).isEqualTo("Luke Skywalker"); - assertThat(lukeRecord.field("height({\"unit\":\"METER\"})")).isEqualTo(BigDecimal.valueOf(1.72)); - - final List friends = (List) normalizedCache - .loadRecord(TEST_FIELD_KEY_JEDI, CacheHeaders.NONE).field("friends"); - assertThat(friends.get(0)).isEqualTo(new CacheReference(TEST_FIELD_KEY_JEDI + ".friends.0")); - assertThat(friends.get(1)).isEqualTo(new CacheReference(TEST_FIELD_KEY_JEDI + ".friends.1")); - assertThat(friends.get(2)).isEqualTo(new CacheReference(TEST_FIELD_KEY_JEDI + ".friends.2")); - } - - @Test - public void testHeroParentTypeDependentFieldHuman() throws Exception { - assertHasNoErrors("HeroParentTypeDependentFieldHumanResponse.json", - new HeroParentTypeDependentFieldQuery(Input.fromNullable(EMPIRE))); - - Record lukeRecord = normalizedCache - .loadRecord(TEST_FIELD_KEY_EMPIRE + ".friends.0", CacheHeaders.NONE); - assertThat(lukeRecord.field("name")).isEqualTo("Han Solo"); - assertThat(lukeRecord.field("height({\"unit\":\"FOOT\"})")).isEqualTo(BigDecimal.valueOf(5.905512)); - } - - @Test public void list_of_objects_with_null_object() throws Exception { - assertHasNoErrors("AllPlanetsListOfObjectWithNullObject.json", new AllPlanetsQuery()); - - String fieldKey = "allPlanets({\"first\":300})"; - Record record = normalizedCache - .loadRecord(fieldKey + ".planets.0", CacheHeaders.NONE); - assertThat(record.field("filmConnection")).isNull(); - - record = normalizedCache - .loadRecord(fieldKey + ".planets.0.filmConnection", CacheHeaders.NONE); - assertThat(record).isNull(); - - record = normalizedCache - .loadRecord(fieldKey + ".planets.1.filmConnection", CacheHeaders.NONE); - assertThat(record).isNotNull(); - } - - private void assertHasNoErrors(String mockResponse, Query query) throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - mockResponse, - apolloClient.query(query), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/ResponseWriteTestCase.java b/apollo-integration/src/test/java/com/apollographql/apollo/ResponseWriteTestCase.java deleted file mode 100644 index 827b8244ec3..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/ResponseWriteTestCase.java +++ /dev/null @@ -1,586 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.CustomTypeAdapter; -import com.apollographql.apollo.api.CustomTypeValue; -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.cache.normalized.CacheKey; -import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy; -import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory; -import com.apollographql.apollo.integration.normalizer.EpisodeHeroWithDatesQuery; -import com.apollographql.apollo.integration.normalizer.EpisodeHeroWithInlineFragmentQuery; -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesWithIDsQuery; -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsWithFragmentsQuery; -import com.apollographql.apollo.integration.normalizer.HeroNameWithEnumsQuery; -import com.apollographql.apollo.integration.normalizer.StarshipByIdQuery; -import com.apollographql.apollo.integration.normalizer.fragment.HeroWithFriendsFragment; -import com.apollographql.apollo.integration.normalizer.fragment.HumanWithIdFragment; -import com.apollographql.apollo.integration.normalizer.type.CustomType; -import com.apollographql.apollo.integration.normalizer.type.Episode; -import io.reactivex.functions.Predicate; -import okhttp3.Dispatcher; -import okhttp3.OkHttpClient; -import okhttp3.mockwebserver.MockWebServer; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Collections; -import java.util.Date; -import java.util.Locale; - -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.CACHE_ONLY; -import static com.apollographql.apollo.integration.normalizer.type.Episode.JEDI; -import static com.google.common.truth.Truth.assertThat; -import static java.util.Arrays.asList; -import static java.util.Collections.singletonList; - -@SuppressWarnings("SimpleDateFormatConstant") -public class ResponseWriteTestCase { - private ApolloClient apolloClient; - @Rule public final MockWebServer server = new MockWebServer(); - private SimpleDateFormat DATE_TIME_FORMAT = new SimpleDateFormat("yyyy-mm-dd", Locale.US); - - @Before public void setUp() { - OkHttpClient okHttpClient = new OkHttpClient.Builder() - .dispatcher(new Dispatcher(Utils.INSTANCE.immediateExecutorService())) - .build(); - - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(okHttpClient) - .normalizedCache(new LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), new IdFieldCacheKeyResolver()) - .dispatcher(Utils.INSTANCE.immediateExecutor()) - .addCustomTypeAdapter(CustomType.DATE, new CustomTypeAdapter() { - @Override public Date decode(CustomTypeValue value) { - try { - return DATE_TIME_FORMAT.parse(value.value.toString()); - } catch (ParseException e) { - throw new RuntimeException(e); - } - } - - @Override public CustomTypeValue encode(Date value) { - return new CustomTypeValue.GraphQLString(DATE_TIME_FORMAT.format(value)); - } - }) - .build(); - } - - @Test - public void customType() throws Exception { - EpisodeHeroWithDatesQuery query = new EpisodeHeroWithDatesQuery(Input.fromNullable(JEDI)); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "EpisodeHeroWithDatesResponse.json", - apolloClient.query(query), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().heroName()).isEqualTo("R2-D2"); - assertThat(DATE_TIME_FORMAT.format(response.data().hero().birthDate())).isEqualTo("1984-04-16"); - assertThat(response.data().hero().showUpDates()).hasSize(3); - assertThat(DATE_TIME_FORMAT.format(response.data().hero().showUpDates().get(0))).isEqualTo("2017-01-16"); - assertThat(DATE_TIME_FORMAT.format(response.data().hero().showUpDates().get(1))).isEqualTo("2017-02-16"); - assertThat(DATE_TIME_FORMAT.format(response.data().hero().showUpDates().get(2))).isEqualTo("2017-03-16"); - return true; - } - } - ); - - EpisodeHeroWithDatesQuery.Hero hero = new EpisodeHeroWithDatesQuery.Hero( - "Droid", - "R222-D222", - DATE_TIME_FORMAT.parse("1985-04-16"), - Collections.emptyList() - ); - apolloClient.getApolloStore().write(query, new EpisodeHeroWithDatesQuery.Data(hero)).execute(); - - assertCachedQueryResponse( - query, - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().heroName()).isEqualTo("R222-D222"); - assertThat(DATE_TIME_FORMAT.format(response.data().hero().birthDate())).isEqualTo("1985-04-16"); - assertThat(response.data().hero().showUpDates()).hasSize(0); - return true; - } - } - ); - - hero = new EpisodeHeroWithDatesQuery.Hero( - hero.__typename(), - "R22-D22", - DATE_TIME_FORMAT.parse("1986-04-16"), - asList( - DATE_TIME_FORMAT.parse("2017-04-16"), - DATE_TIME_FORMAT.parse("2017-05-16") - ) - ); - apolloClient.getApolloStore().write(query, new EpisodeHeroWithDatesQuery.Data(hero)).execute(); - - assertCachedQueryResponse( - query, - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().heroName()).isEqualTo("R22-D22"); - assertThat(DATE_TIME_FORMAT.format(response.data().hero().birthDate())).isEqualTo("1986-04-16"); - assertThat(response.data().hero().showUpDates()).hasSize(2); - assertThat(DATE_TIME_FORMAT.format(response.data().hero().showUpDates().get(0))).isEqualTo("2017-04-16"); - assertThat(DATE_TIME_FORMAT.format(response.data().hero().showUpDates().get(1))).isEqualTo("2017-05-16"); - return true; - } - } - ); - } - - @Test - public void enums() throws Exception { - HeroNameWithEnumsQuery query = new HeroNameWithEnumsQuery(); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroNameWithEnumsResponse.json", - apolloClient.query(query), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().firstAppearsIn()).isEqualTo(Episode.EMPIRE); - assertThat(response.data().hero().appearsIn()).hasSize(3); - assertThat(response.data().hero().appearsIn().get(0)).isEqualTo(Episode.NEWHOPE); - assertThat(response.data().hero().appearsIn().get(1)).isEqualTo(Episode.EMPIRE); - assertThat(response.data().hero().appearsIn().get(2)).isEqualTo(Episode.JEDI); - return true; - } - } - ); - - HeroNameWithEnumsQuery.Hero hero = new HeroNameWithEnumsQuery.Hero( - "Droid", - "R222-D222", - Episode.JEDI, - Collections.emptyList() - ); - apolloClient.getApolloStore().write(query, new HeroNameWithEnumsQuery.Data(hero)).execute(); - - assertCachedQueryResponse( - query, - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().name()).isEqualTo("R222-D222"); - assertThat(response.data().hero().firstAppearsIn()).isEqualTo(Episode.JEDI); - assertThat(response.data().hero().appearsIn()).hasSize(0); - return true; - } - } - ); - - hero = new HeroNameWithEnumsQuery.Hero( - hero.__typename(), - "R22-D22", - Episode.JEDI, - asList(Episode.EMPIRE) - ); - apolloClient.getApolloStore().write(query, new HeroNameWithEnumsQuery.Data(hero)).execute(); - - assertCachedQueryResponse( - query, - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().name()).isEqualTo("R22-D22"); - assertThat(response.data().hero().firstAppearsIn()).isEqualTo(Episode.JEDI); - assertThat(response.data().hero().appearsIn()).hasSize(1); - assertThat(response.data().hero().appearsIn().get(0)).isEqualTo(Episode.EMPIRE); - return true; - } - } - ); - } - - @Test - public void objects() throws Exception { - HeroAndFriendsNamesWithIDsQuery query = new HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(JEDI)); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsNameWithIdsResponse.json", - apolloClient.query(query), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().id()).isEqualTo("2001"); - assertThat(response.data().hero().friends()).hasSize(3); - assertThat(response.data().hero().friends().get(0).__typename()).isEqualTo("Human"); - assertThat(response.data().hero().friends().get(0).id()).isEqualTo("1000"); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("Luke Skywalker"); - assertThat(response.data().hero().friends().get(1).__typename()).isEqualTo("Human"); - assertThat(response.data().hero().friends().get(1).id()).isEqualTo("1002"); - assertThat(response.data().hero().friends().get(1).name()).isEqualTo("Han Solo"); - assertThat(response.data().hero().friends().get(2).__typename()).isEqualTo("Human"); - assertThat(response.data().hero().friends().get(2).id()).isEqualTo("1003"); - assertThat(response.data().hero().friends().get(2).name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - - HeroAndFriendsNamesWithIDsQuery.Hero hero = new HeroAndFriendsNamesWithIDsQuery.Hero( - "Droid", - "2001", - "R222-D222", - null - ); - apolloClient.getApolloStore().write(query, new HeroAndFriendsNamesWithIDsQuery.Data(hero)).execute(); - - assertCachedQueryResponse( - query, - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().name()).isEqualTo("R222-D222"); - assertThat(response.data().hero().id()).isEqualTo("2001"); - assertThat(response.data().hero().friends()).isNull(); - return true; - } - } - ); - - HeroAndFriendsNamesWithIDsQuery.Friend friend = new HeroAndFriendsNamesWithIDsQuery.Friend( - "Human", - "1002", - "Han Soloooo" - ); - hero = new HeroAndFriendsNamesWithIDsQuery.Hero( - hero.__typename(), - hero.id(), - "R222-D222", - singletonList(friend) - ); - apolloClient.getApolloStore().write(query, new HeroAndFriendsNamesWithIDsQuery.Data(hero)).execute(); - - assertCachedQueryResponse( - query, - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().name()).isEqualTo("R222-D222"); - assertThat(response.data().hero().id()).isEqualTo("2001"); - assertThat(response.data().hero().friends()).hasSize(1); - assertThat(response.data().hero().friends().get(0).__typename()).isEqualTo("Human"); - assertThat(response.data().hero().friends().get(0).id()).isEqualTo("1002"); - assertThat(response.data().hero().friends().get(0).name()).isEqualTo("Han Soloooo"); - return true; - } - } - ); - } - - @Test - public void operation_with_fragments() throws Exception { - HeroAndFriendsWithFragmentsQuery query = new HeroAndFriendsWithFragmentsQuery(Input.fromNullable(Episode.NEWHOPE)); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsWithFragmentResponse.json", - apolloClient.query(query), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().id()).isEqualTo("2001"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends()).hasSize(3); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(0).fragments().humanWithIdFragment().__typename()).isEqualTo("Human"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(0).fragments().humanWithIdFragment().id()).isEqualTo("1000"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(0).fragments().humanWithIdFragment().name()).isEqualTo("Luke Skywalker"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(1).fragments().humanWithIdFragment().__typename()).isEqualTo("Human"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(1).fragments().humanWithIdFragment().id()).isEqualTo("1002"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(1).fragments().humanWithIdFragment().name()).isEqualTo("Han Solo"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(2).fragments().humanWithIdFragment().__typename()).isEqualTo("Human"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(2).fragments().humanWithIdFragment().id()).isEqualTo("1003"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(2).fragments().humanWithIdFragment().name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - - HeroAndFriendsWithFragmentsQuery.Hero hero = new HeroAndFriendsWithFragmentsQuery.Hero( - "Droid", - new HeroAndFriendsWithFragmentsQuery.Hero.Fragments( - new HeroWithFriendsFragment( - "Droid", - "2001", - "R222-D222", - asList( - new HeroWithFriendsFragment.Friend( - "Human", - new HeroWithFriendsFragment.Friend.Fragments( - new HumanWithIdFragment( - "Human", - "1006", - "SuperMan" - ) - ) - ), - new HeroWithFriendsFragment.Friend( - "Human", - new HeroWithFriendsFragment.Friend.Fragments( - new HumanWithIdFragment( - "Human", - "1004", - "Beast" - ) - ) - ) - ) - ) - ) - ); - apolloClient.getApolloStore().write(query, new HeroAndFriendsWithFragmentsQuery.Data(hero)).execute(); - - assertCachedQueryResponse( - query, - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().id()).isEqualTo("2001"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().name()).isEqualTo("R222-D222"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends()).hasSize(2); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(0).fragments().humanWithIdFragment().__typename()).isEqualTo("Human"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(0).fragments().humanWithIdFragment().id()).isEqualTo("1006"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(0).fragments().humanWithIdFragment().name()).isEqualTo("SuperMan"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(1).fragments().humanWithIdFragment().__typename()).isEqualTo("Human"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(1).fragments().humanWithIdFragment().id()).isEqualTo("1004"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(1).fragments().humanWithIdFragment().name()).isEqualTo("Beast"); - return true; - } - } - ); - } - - @SuppressWarnings("CheckReturnValue") - @Test - public void operation_with_inline_fragments() throws Exception { - EpisodeHeroWithInlineFragmentQuery query = new EpisodeHeroWithInlineFragmentQuery(Input.fromNullable(Episode.NEWHOPE)); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "EpisodeHeroWithInlineFragmentResponse.json", - apolloClient.query(query), - new Predicate>() { - @Override - public boolean test(Response response) throws Exception { - assertThat(response.data().hero().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().friends()).hasSize(3); - - EpisodeHeroWithInlineFragmentQuery.AsHuman asHuman = (EpisodeHeroWithInlineFragmentQuery.AsHuman) response.data().hero().friends().get(0); - assertThat(asHuman.__typename()).isEqualTo("Human"); - assertThat(asHuman.id()).isEqualTo("1000"); - assertThat(asHuman.name()).isEqualTo("Luke Skywalker"); - assertThat(asHuman.height()).isWithin(1.5); - - EpisodeHeroWithInlineFragmentQuery.AsDroid asDroid1 = (EpisodeHeroWithInlineFragmentQuery.AsDroid) response.data().hero().friends().get(1); - assertThat(asDroid1.__typename()).isEqualTo("Droid"); - assertThat(asDroid1.name()).isEqualTo("Android"); - assertThat(asDroid1.primaryFunction()).isEqualTo("Hunt and destroy iOS devices"); - - EpisodeHeroWithInlineFragmentQuery.AsDroid asDroid2 = (EpisodeHeroWithInlineFragmentQuery.AsDroid) response.data().hero().friends().get(2); - assertThat(asDroid2.__typename()).isEqualTo("Droid"); - assertThat(asDroid2.name()).isEqualTo("Battle Droid"); - assertThat(asDroid2.primaryFunction()).isEqualTo("Controlled alternative to human soldiers"); - return true; - } - } - ); - - EpisodeHeroWithInlineFragmentQuery.Hero hero = new EpisodeHeroWithInlineFragmentQuery.Hero( - "Droid", - "R22-D22", - asList( - new EpisodeHeroWithInlineFragmentQuery.AsHuman( - "Human", - "1002", - "Han Solo", - 2.5 - ), - new EpisodeHeroWithInlineFragmentQuery.AsDroid( - "Droid", - "RD", - "Entertainment" - ) - ) - ); - apolloClient.getApolloStore().write(query, new EpisodeHeroWithInlineFragmentQuery.Data(hero)).execute(); - - assertCachedQueryResponse( - query, - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().name()).isEqualTo("R22-D22"); - assertThat(response.data().hero().friends()).hasSize(2); - - EpisodeHeroWithInlineFragmentQuery.AsHuman asHuman = (EpisodeHeroWithInlineFragmentQuery.AsHuman) response.data().hero().friends().get(0); - assertThat(asHuman.__typename()).isEqualTo("Human"); - assertThat(asHuman.id()).isEqualTo("1002"); - assertThat(asHuman.name()).isEqualTo("Han Solo"); - assertThat(asHuman.height()).isWithin(2.5); - - EpisodeHeroWithInlineFragmentQuery.AsDroid asDroid = (EpisodeHeroWithInlineFragmentQuery.AsDroid) response.data().hero().friends().get(1); - assertThat(asDroid.__typename()).isEqualTo("Droid"); - assertThat(asDroid.name()).isEqualTo("RD"); - assertThat(asDroid.primaryFunction()).isEqualTo("Entertainment"); - return true; - } - } - ); - } - - @Test - public void fragments() throws Exception { - HeroAndFriendsWithFragmentsQuery query = new HeroAndFriendsWithFragmentsQuery(Input.fromNullable(Episode.NEWHOPE)); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsWithFragmentResponse.json", - apolloClient.query(query), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().id()).isEqualTo("2001"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().name()).isEqualTo("R2-D2"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends()).hasSize(3); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(0).fragments().humanWithIdFragment().__typename()).isEqualTo("Human"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(0).fragments().humanWithIdFragment().id()).isEqualTo("1000"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(0).fragments().humanWithIdFragment().name()).isEqualTo("Luke Skywalker"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(1).fragments().humanWithIdFragment().__typename()).isEqualTo("Human"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(1).fragments().humanWithIdFragment().id()).isEqualTo("1002"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(1).fragments().humanWithIdFragment().name()).isEqualTo("Han Solo"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(2).fragments().humanWithIdFragment().__typename()).isEqualTo("Human"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(2).fragments().humanWithIdFragment().id()).isEqualTo("1003"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(2).fragments().humanWithIdFragment().name()).isEqualTo("Leia Organa"); - return true; - } - } - ); - - apolloClient.getApolloStore().write( - new HeroWithFriendsFragment( - "Droid", - "2001", - "R222-D222", - asList( - new HeroWithFriendsFragment.Friend( - "Human", - new HeroWithFriendsFragment.Friend.Fragments( - new HumanWithIdFragment( - "Human", - "1000", - "SuperMan" - ) - ) - ), - new HeroWithFriendsFragment.Friend( - "Human", - new HeroWithFriendsFragment.Friend.Fragments( - new HumanWithIdFragment( - "Human", - "1002", - "Han Solo" - ) - ) - ) - ) - ), CacheKey.from("2001"), query.variables() - ).execute(); - - apolloClient.getApolloStore().write( - new HumanWithIdFragment( - "Human", - "1002", - "Beast" - ), CacheKey.from("1002"), query.variables() - ).execute(); - - assertCachedQueryResponse( - query, - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().hero().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().__typename()).isEqualTo("Droid"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().id()).isEqualTo("2001"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().name()).isEqualTo("R222-D222"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends()).hasSize(2); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(0).fragments().humanWithIdFragment().__typename()).isEqualTo("Human"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(0).fragments().humanWithIdFragment().id()).isEqualTo("1000"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(0).fragments().humanWithIdFragment().name()).isEqualTo("SuperMan"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(1).fragments().humanWithIdFragment().__typename()).isEqualTo("Human"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(1).fragments().humanWithIdFragment().id()).isEqualTo("1002"); - assertThat(response.data().hero().fragments().heroWithFriendsFragment().friends().get(1).fragments().humanWithIdFragment().name()).isEqualTo("Beast"); - return true; - } - } - ); - } - - @Test public void listOfList() throws Exception { - StarshipByIdQuery query = new StarshipByIdQuery("Starship1"); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "StarshipByIdResponse.json", - apolloClient.query(query), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().starship().__typename()).isEqualTo("Starship"); - assertThat(response.data().starship().name()).isEqualTo("SuperRocket"); - assertThat(response.data().starship().coordinates()).hasSize(3); - assertThat(response.data().starship().coordinates()).containsExactly(asList(100d, 200d), asList(300d, 400d), - asList(500d, 600d)); - return true; - } - } - ); - - StarshipByIdQuery.Starship starship = new StarshipByIdQuery.Starship( - "Starship", - "Starship1", - "SuperRocket", - asList(asList(900d, 800d), asList(700d, 600d)) - ); - apolloClient.getApolloStore().write(query, new StarshipByIdQuery.Data(starship)).execute(); - - assertCachedQueryResponse( - query, - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().starship().__typename()).isEqualTo("Starship"); - assertThat(response.data().starship().name()).isEqualTo("SuperRocket"); - assertThat(response.data().starship().coordinates()).hasSize(2); - assertThat(response.data().starship().coordinates()).containsExactly(asList(900d, 800d), asList(700d, 600d)); - return true; - } - } - ); - } - - private void assertCachedQueryResponse(Query query, Predicate> predicate) throws Exception { - Utils.INSTANCE.assertResponse( - apolloClient.query(query).responseFetcher(CACHE_ONLY), - predicate - ); - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/Rx2ApolloTest.kt b/apollo-integration/src/test/java/com/apollographql/apollo/Rx2ApolloTest.kt deleted file mode 100644 index 3e4a04086d3..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/Rx2ApolloTest.kt +++ /dev/null @@ -1,275 +0,0 @@ -package com.apollographql.apollo - -import com.apollographql.apollo.Utils.immediateExecutor -import com.apollographql.apollo.Utils.immediateExecutorService -import com.apollographql.apollo.Utils.mockResponse -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.cache.CacheHeaders -import com.apollographql.apollo.cache.normalized.Record -import com.apollographql.apollo.cache.normalized.CacheKey -import com.apollographql.apollo.cache.normalized.NormalizedCache -import com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter -import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy -import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory -import com.apollographql.apollo.cache.normalized.NormalizedCacheFactory -import com.apollographql.apollo.fetcher.ApolloResponseFetchers.NETWORK_ONLY -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesWithIDsQuery -import com.apollographql.apollo.integration.normalizer.type.Episode.EMPIRE -import com.apollographql.apollo.integration.normalizer.type.Episode.NEWHOPE -import com.apollographql.apollo.rx2.Rx2Apollo -import com.google.common.truth.Truth -import com.google.common.truth.Truth.assertThat -import io.reactivex.disposables.Disposable -import io.reactivex.observers.TestObserver -import io.reactivex.plugins.RxJavaPlugins -import io.reactivex.schedulers.TestScheduler -import okhttp3.Dispatcher -import okhttp3.OkHttpClient -import okhttp3.mockwebserver.MockWebServer -import okhttp3.mockwebserver.MockResponse -import org.junit.Before -import org.junit.Rule -import org.junit.Test - - -class Rx2ApolloTest { - private lateinit var apolloClient: ApolloClient - - @get:Rule - val server = MockWebServer() - - @Before - fun setup() { - val okHttpClient = OkHttpClient.Builder() - .dispatcher(Dispatcher(immediateExecutorService())) - .build() - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .dispatcher(immediateExecutor()) - .okHttpClient(okHttpClient) - .normalizedCache(LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), IdFieldCacheKeyResolver()) - .build() - } - - @Test - @Throws(Exception::class) - fun callProducesValue() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - Rx2Apollo - .from(apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE)))) - .test() - .assertNoErrors() - .assertComplete() - .assertValue({ response -> - assertThat(response.data()?.hero()?.name()).isEqualTo("R2-D2") - true - }) - } - - @Test - @Throws(Exception::class) - fun callIsCanceledWhenDisposed() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - val testObserver: TestObserver> = TestObserver>() - val disposable: Disposable = Rx2Apollo - .from(apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE)))) - .subscribeWith(testObserver) - disposable.dispose() - testObserver.assertComplete() - Truth.assertThat(testObserver.isDisposed()).isTrue() - } - - @Test - @Throws(Exception::class) - fun prefetchCompletes() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - Rx2Apollo - .from(apolloClient.prefetch(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE)))) - .test() - .assertNoErrors() - .assertComplete() - } - - @Test - @Throws(Exception::class) - fun prefetchIsCanceledWhenDisposed() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - val testObserver: TestObserver = TestObserver() - val disposable: Disposable = Rx2Apollo - .from(apolloClient.prefetch(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE)))) - .observeOn(TestScheduler()) - .subscribeWith(testObserver) - disposable.dispose() - testObserver.assertNotComplete() - Truth.assertThat(testObserver.isDisposed()).isTrue() - } - - @Test - @Throws(Exception::class) - fun retryDoesNotThrow() { - server.enqueue(MockResponse().setResponseCode(500)) - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - val observer: TestObserver = TestObserver() - Rx2Apollo - .from(apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))).watcher()) - .retry(1) - .map({ response -> response.data() }) - .subscribeWith(observer) - observer.assertValueCount(1) - .assertValueAt(0) { data -> - assertThat(data?.hero()?.name()).isEqualTo("R2-D2") - true - } - } - - @Test - @Throws(Exception::class) - fun queryWatcherUpdatedSameQueryDifferentResults() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - val observer: TestObserver = TestObserver() - Rx2Apollo - .from(apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))).watcher()) - .map({ response -> response.data() }) - .subscribeWith(observer) - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_CHANGE)) - apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))) - .responseFetcher(NETWORK_ONLY) - .enqueue(null) - observer.assertValueCount(2) - .assertValueAt(0) { data -> - assertThat(data?.hero()?.name()).isEqualTo("R2-D2") - true - } - .assertValueAt(1) { data -> - assertThat(data?.hero()?.name()).isEqualTo("Artoo") - true - } - } - - @Test - @Throws(Exception::class) - fun queryWatcherNotUpdatedSameQuerySameResults() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - val observer: TestObserver = TestObserver() - Rx2Apollo - .from(apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))).watcher()) - .map({ response -> response.data() }) - .subscribeWith(observer) - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))).responseFetcher(NETWORK_ONLY) - .enqueue(null) - observer - .assertValueCount(1) - .assertValueAt(0) { data -> - assertThat(data?.hero()?.name()).isEqualTo("R2-D2") - true - } - } - - @Test - @Throws(Exception::class) - fun queryWatcherUpdatedDifferentQueryDifferentResults() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - val observer: TestObserver = TestObserver() - Rx2Apollo - .from(apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))).watcher()) - .map({ response -> response.data() }) - .subscribeWith(observer) - server.enqueue(mockResponse("HeroAndFriendsNameWithIdsNameChange.json")) - apolloClient.query(HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(NEWHOPE))).enqueue(null) - observer - .assertValueCount(2) - .assertValueAt(0) { data -> - assertThat(data?.hero()?.name()).isEqualTo("R2-D2") - true - } - .assertValueAt(1) { data -> - assertThat(data?.hero()?.name()).isEqualTo("Artoo") - true - } - } - - @Test - @Throws(Exception::class) - fun queryWatcherNotCalledWhenCanceled() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - val testObserver: TestObserver = TestObserver() - val scheduler = TestScheduler() - val disposable: Disposable = Rx2Apollo - .from(apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))).watcher()) - .map({ response -> response.data() }) - .observeOn(scheduler) - .subscribeWith(testObserver) - scheduler.triggerActions() - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_CHANGE)) - apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))).responseFetcher(NETWORK_ONLY) - .enqueue(null) - disposable.dispose() - scheduler.triggerActions() - testObserver - .assertValueCount(1) - .assertValueAt(0) { data -> - assertThat(data?.hero()?.name()).isEqualTo("R2-D2") - true - } - } - - @Test - fun disposingAnOperationDoesNotThrowUndeliverableException() { - /* - * A simple cache that will always throw errors - */ - val cacheFactory = object: NormalizedCacheFactory() { - override fun create(recordFieldAdapter: RecordFieldJsonAdapter): NormalizedCache { - return object: NormalizedCache() { - override fun clearAll() { - throw Exception("not implemented") - } - - override fun loadRecord(key: String, cacheHeaders: CacheHeaders): Record? { - throw Exception("not implemented") - } - - override fun performMerge(apolloRecord: Record, oldRecord: Record?, cacheHeaders: CacheHeaders): Set { - throw Exception("not implemented") - } - - override fun remove(cacheKey: CacheKey, cascade: Boolean): Boolean { - throw Exception("not implemented") - } - } - } - } - - val apolloClient = ApolloClient.builder() - .normalizedCache(cacheFactory) - .serverUrl("https://unused/") - .build() - - - val savedHandler = RxJavaPlugins.getErrorHandler() - - var undeliverableException: Throwable? = null - RxJavaPlugins.setErrorHandler { - undeliverableException = it - } - - val operation = apolloClient.apolloStore.write(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE)), EpisodeHeroNameQuery.Data(EpisodeHeroNameQuery.Hero("", ""))) - val testObserver = Rx2Apollo.from(operation) - .test() - - testObserver.dispose() - - // Since there is no cancellation mechanism for the ApolloStoreOperation, the only way to see if an error is thrown is to wait here - Thread.sleep(200) - Truth.assertThat(undeliverableException == null).isTrue() - RxJavaPlugins.setErrorHandler(savedHandler) - } - - companion object { - private const val FILE_EPISODE_HERO_NAME_WITH_ID = "EpisodeHeroNameResponseWithId.json" - private const val FILE_EPISODE_HERO_NAME_CHANGE = "EpisodeHeroNameResponseNameChange.json" - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/Rx3ApolloTest.kt b/apollo-integration/src/test/java/com/apollographql/apollo/Rx3ApolloTest.kt deleted file mode 100644 index ac806272ddc..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/Rx3ApolloTest.kt +++ /dev/null @@ -1,277 +0,0 @@ -package com.apollographql.apollo - -import com.apollographql.apollo.Utils.immediateExecutor -import com.apollographql.apollo.Utils.immediateExecutorService -import com.apollographql.apollo.Utils.mockResponse -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.cache.CacheHeaders -import com.apollographql.apollo.cache.normalized.Record -import com.apollographql.apollo.cache.normalized.CacheKey -import com.apollographql.apollo.cache.normalized.NormalizedCache -import com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter -import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy -import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory -import com.apollographql.apollo.cache.normalized.NormalizedCacheFactory -import com.apollographql.apollo.fetcher.ApolloResponseFetchers.NETWORK_ONLY -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesWithIDsQuery -import com.apollographql.apollo.integration.normalizer.type.Episode.EMPIRE -import com.apollographql.apollo.integration.normalizer.type.Episode.NEWHOPE -import com.apollographql.apollo.rx3.Rx3Apollo -import com.google.common.truth.Truth -import com.google.common.truth.Truth.assertThat -import io.reactivex.rxjava3.disposables.Disposable -import io.reactivex.rxjava3.functions.Function -import io.reactivex.rxjava3.functions.Predicate -import io.reactivex.rxjava3.observers.TestObserver -import io.reactivex.rxjava3.schedulers.TestScheduler -import io.reactivex.rxjava3.plugins.RxJavaPlugins -import okhttp3.Dispatcher -import okhttp3.OkHttpClient -import okhttp3.mockwebserver.MockWebServer -import okhttp3.mockwebserver.MockResponse -import org.junit.Before -import org.junit.Rule -import org.junit.Test - - -class Rx3ApolloTest { - private lateinit var apolloClient: ApolloClient - - @get:Rule - val server = MockWebServer() - - @Before - fun setup() { - val okHttpClient = OkHttpClient.Builder() - .dispatcher(Dispatcher(immediateExecutorService())) - .build() - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .dispatcher(immediateExecutor()) - .okHttpClient(okHttpClient) - .normalizedCache(LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), IdFieldCacheKeyResolver()) - .build() - } - - @Test - @Throws(Exception::class) - fun callProducesValue() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - Rx3Apollo - .from(apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE)))) - .test() - .assertNoErrors() - .assertComplete() - .assertValue({ response -> - assertThat(response.data()?.hero()?.name()).isEqualTo("R2-D2") - true - }) - } - - @Test - @Throws(Exception::class) - fun callIsCanceledWhenDisposed() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - val testObserver = TestObserver>() - val disposable: Disposable = Rx3Apollo - .from(apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE)))) - .subscribeWith(testObserver) - disposable.dispose() - testObserver.assertComplete() - Truth.assertThat(testObserver.isDisposed()).isTrue() - } - - @Test - @Throws(Exception::class) - fun prefetchCompletes() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - Rx3Apollo - .from(apolloClient.prefetch(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE)))) - .test() - .assertNoErrors() - .assertComplete() - } - - @Test - @Throws(Exception::class) - fun prefetchIsCanceledWhenDisposed() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - val testObserver: TestObserver = TestObserver() - val disposable: Disposable = Rx3Apollo - .from(apolloClient.prefetch(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE)))) - .observeOn(TestScheduler()) - .subscribeWith(testObserver) - disposable.dispose() - testObserver.assertNotComplete() - Truth.assertThat(testObserver.isDisposed()).isTrue() - } - - @Test - @Throws(Exception::class) - fun queryWatcherUpdatedSameQueryDifferentResults() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - val observer: TestObserver = TestObserver() - Rx3Apollo - .from(apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))).watcher()) - .map({ response -> response.data() }) - .subscribeWith(observer) - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_CHANGE)) - apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))) - .responseFetcher(NETWORK_ONLY) - .enqueue(null) - observer.assertValueCount(2) - .assertValueAt(0) { data -> - assertThat(data?.hero()?.name()).isEqualTo("R2-D2") - true - } - .assertValueAt(1) { data -> - assertThat(data?.hero()?.name()).isEqualTo("Artoo") - true - } - } - - @Test - @Throws(Exception::class) - fun retryDoesNotThrow() { - server.enqueue(MockResponse().setResponseCode(500)) - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - val observer: TestObserver = TestObserver() - Rx3Apollo - .from(apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))).watcher()) - .retry(1) - .map({ response -> response.data() }) - .subscribeWith(observer) - observer.assertValueCount(1) - .assertValueAt(0) { data -> - assertThat(data?.hero()?.name()).isEqualTo("R2-D2") - true - } - } - - @Test - @Throws(Exception::class) - fun queryWatcherNotUpdatedSameQuerySameResults() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - val observer: TestObserver = TestObserver() - Rx3Apollo - .from(apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))).watcher()) - .map({ response -> response.data() }) - .subscribeWith(observer) - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))).responseFetcher(NETWORK_ONLY) - .enqueue(null) - observer - .assertValueCount(1) - .assertValueAt(0) { data -> - assertThat(data?.hero()?.name()).isEqualTo("R2-D2") - true - } - } - - @Test - @Throws(Exception::class) - fun queryWatcherUpdatedDifferentQueryDifferentResults() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - val observer: TestObserver = TestObserver() - Rx3Apollo - .from(apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))).watcher()) - .map({ response -> response.data() }) - .subscribeWith(observer) - server.enqueue(mockResponse("HeroAndFriendsNameWithIdsNameChange.json")) - apolloClient.query(HeroAndFriendsNamesWithIDsQuery(Input.fromNullable(NEWHOPE))).enqueue(null) - observer - .assertValueCount(2) - .assertValueAt(0) { data -> - assertThat(data?.hero()?.name()).isEqualTo("R2-D2") - true - } - .assertValueAt(1) { data -> - assertThat(data?.hero()?.name()).isEqualTo("Artoo") - true - } - } - - @Test - @Throws(Exception::class) - fun queryWatcherNotCalledWhenCanceled() { - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_WITH_ID)) - val testObserver: TestObserver = TestObserver() - val scheduler = TestScheduler() - val disposable: Disposable = Rx3Apollo - .from(apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))).watcher()) - .map({ response -> response.data() }) - .observeOn(scheduler) - .subscribeWith(testObserver) - scheduler.triggerActions() - server.enqueue(mockResponse(FILE_EPISODE_HERO_NAME_CHANGE)) - apolloClient.query(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE))).responseFetcher(NETWORK_ONLY) - .enqueue(null) - disposable.dispose() - scheduler.triggerActions() - testObserver - .assertValueCount(1) - .assertValueAt(0) { data -> - assertThat(data?.hero()?.name()).isEqualTo("R2-D2") - true - } - } - - @Test - fun disposingAnOperationDoesNotThrowUndeliverableException() { - /* - * A simple cache that will always throw errors - */ - val cacheFactory = object: NormalizedCacheFactory() { - override fun create(recordFieldAdapter: RecordFieldJsonAdapter): NormalizedCache { - return object: NormalizedCache() { - override fun clearAll() { - throw Exception("not implemented") - } - - override fun loadRecord(key: String, cacheHeaders: CacheHeaders): Record? { - throw Exception("not implemented") - } - - override fun performMerge(apolloRecord: Record, oldRecord: Record?, cacheHeaders: CacheHeaders): Set { - throw Exception("not implemented") - } - - override fun remove(cacheKey: CacheKey, cascade: Boolean): Boolean { - throw Exception("not implemented") - } - } - } - } - - val apolloClient = ApolloClient.builder() - .normalizedCache(cacheFactory) - .serverUrl("https://unused/") - .build() - - - val savedHandler = RxJavaPlugins.getErrorHandler() - - var undeliverableException: Throwable? = null - RxJavaPlugins.setErrorHandler { - undeliverableException = it - } - - val operation = apolloClient.apolloStore.write(EpisodeHeroNameQuery(Input.fromNullable(EMPIRE)), EpisodeHeroNameQuery.Data(EpisodeHeroNameQuery.Hero("", ""))) - val testObserver = Rx3Apollo.from(operation) - .test() - - testObserver.dispose() - - // Since there is no cancellation mechanism for the ApolloStoreOperation, the only way to see if an error is thrown is to wait here - Thread.sleep(200) - Truth.assertThat(undeliverableException == null).isTrue() - RxJavaPlugins.setErrorHandler(savedHandler) - } - - companion object { - private const val FILE_EPISODE_HERO_NAME_WITH_ID = "EpisodeHeroNameResponseWithId.json" - private const val FILE_EPISODE_HERO_NAME_CHANGE = "EpisodeHeroNameResponseNameChange.json" - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/SealedClassesTest.kt b/apollo-integration/src/test/java/com/apollographql/apollo/SealedClassesTest.kt deleted file mode 100644 index 0c201ba7643..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/SealedClassesTest.kt +++ /dev/null @@ -1,38 +0,0 @@ -package com.apollographql.apollo - -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.cache.normalized.internal.RealCacheKeyBuilder -import com.apollographql.apollo.integration.sealedclasses.type.Direction -import com.google.common.truth.Truth -import org.junit.Test - - -class SealedClassesTest { - - // see https://github.com/apollographql/apollo-android/issues/2775 - @Test - fun `cache keys are correct for sealed classes`() { - - val arguments = mapOf("direction" to - mapOf( - "kind" to "Variable", - "variableName" to "direction" - ) - ) - - val field = ResponseField.forString( - "path", - "path", - arguments, - false, - emptyList()) - - - val variables = object : Operation.Variables() { - override fun valueMap() = mapOf("direction" to Direction.NORTH) - } - val cacheKey = RealCacheKeyBuilder().build(field, variables) - Truth.assertThat(cacheKey).isEqualTo("path({\"direction\":\"NORTH\"})") - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/SendOperationIdentifiersTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/SendOperationIdentifiersTest.java deleted file mode 100644 index 80ae50b6d19..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/SendOperationIdentifiersTest.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.Input; -import com.apollographql.apollo.integration.normalizer.HeroAndFriendsNamesQuery; - -import org.junit.Rule; -import org.junit.Test; - -import java.io.IOException; -import java.util.concurrent.atomic.AtomicBoolean; - -import io.reactivex.functions.Predicate; -import okhttp3.Dispatcher; -import okhttp3.Interceptor; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.mockwebserver.MockWebServer; - -import static com.apollographql.apollo.integration.normalizer.type.Episode.EMPIRE; -import static com.google.common.truth.Truth.assertThat; - -public class SendOperationIdentifiersTest { - @Rule public final MockWebServer server = new MockWebServer(); - - @Test public void sendOperationIdsTrue() throws Exception { - final HeroAndFriendsNamesQuery query = new HeroAndFriendsNamesQuery(Input.fromNullable(EMPIRE)); - ApolloClient apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .enableAutoPersistedQueries(true) - .build(); - apolloClient.query(query).enqueue(null); - - String serverRequest = server.takeRequest().getBody().readUtf8(); - assertThat(serverRequest.contains("extensions")).isTrue(); - assertThat(serverRequest.contains("persistedQuery")).isTrue(); - assertThat(serverRequest.contains(String.format("\"sha256Hash\":\"%s\"", query.operationId()))).isTrue(); - assertThat(serverRequest.contains("\"query\":")).isFalse(); - } - - @Test public void doesNotSendOperationIdsWhenFalse() throws Exception { - final HeroAndFriendsNamesQuery query = new HeroAndFriendsNamesQuery(Input.fromNullable(EMPIRE)); - ApolloClient apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .enableAutoPersistedQueries(false) - .build(); - apolloClient.query(query).enqueue(null); - - String serverRequest = server.takeRequest().getBody().readUtf8(); - assertThat(serverRequest.contains("extensions")).isFalse(); - assertThat(serverRequest.contains("persistedQuery")).isFalse(); - assertThat(serverRequest.contains("sha256Hash")).isFalse(); - assertThat(serverRequest.contains("\"query\":")).isTrue(); - } - - @Test public void operationIdHttpRequestHeader() throws Exception { - final HeroAndFriendsNamesQuery heroAndFriendsNamesQuery = new HeroAndFriendsNamesQuery(Input.fromNullable(EMPIRE)); - final AtomicBoolean applicationInterceptorHeader = new AtomicBoolean(); - final AtomicBoolean networkInterceptorHeader = new AtomicBoolean(); - OkHttpClient okHttpClient = new OkHttpClient.Builder() - .dispatcher(new Dispatcher(Utils.INSTANCE.immediateExecutorService())) - .addInterceptor(new Interceptor() { - @Override public okhttp3.Response intercept(Chain chain) throws IOException { - Request request = chain.request(); - if (request.header("X-APOLLO-OPERATION-ID").equals(heroAndFriendsNamesQuery.operationId())) { - applicationInterceptorHeader.set(true); - } - return chain.proceed(chain.request()); - } - }) - .addNetworkInterceptor(new Interceptor() { - @Override public Response intercept(Chain chain) throws IOException { - Request request = chain.request(); - if (request.header("X-APOLLO-OPERATION-ID").equals(heroAndFriendsNamesQuery.operationId())) { - networkInterceptorHeader.set(true); - } - return chain.proceed(chain.request()); - } - }) - .build(); - - ApolloClient apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(okHttpClient) - .dispatcher(Utils.INSTANCE.immediateExecutor()) - .build(); - - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "HeroAndFriendsNameResponse.json", - apolloClient.query(heroAndFriendsNamesQuery), - new Predicate>() { - @Override - public boolean test(com.apollographql.apollo.api.Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - - assertThat(applicationInterceptorHeader.get()).isTrue(); - assertThat(networkInterceptorHeader.get()).isTrue(); - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/Utils.kt b/apollo-integration/src/test/java/com/apollographql/apollo/Utils.kt deleted file mode 100644 index 63f233c0fa8..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/Utils.kt +++ /dev/null @@ -1,132 +0,0 @@ -package com.apollographql.apollo - -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.fetcher.ApolloResponseFetchers.CACHE_ONLY -import com.apollographql.apollo.fetcher.ApolloResponseFetchers.NETWORK_ONLY -import com.apollographql.apollo.rx2.Rx2Apollo -import com.google.common.io.CharStreams -import io.reactivex.functions.Predicate -import okhttp3.mockwebserver.MockResponse -import okhttp3.mockwebserver.MockWebServer -import java.io.File -import java.io.FileNotFoundException -import java.io.IOException -import java.io.InputStreamReader -import java.nio.charset.Charset -import java.util.concurrent.AbstractExecutorService -import java.util.concurrent.ConcurrentLinkedQueue -import java.util.concurrent.Executor -import java.util.concurrent.ExecutorService -import java.util.concurrent.TimeUnit - -object Utils { - - @Throws(IOException::class) - fun readFileToString(contextClass: Class<*>, - streamIdentifier: String): String { - - var inputStreamReader: InputStreamReader? = null - try { - inputStreamReader = InputStreamReader(contextClass.getResourceAsStream(streamIdentifier), Charset.defaultCharset()) - return CharStreams.toString(inputStreamReader) - } catch (e: IOException) { - throw IOException() - } finally { - inputStreamReader?.close() - } - } - - fun immediateExecutor(): Executor { - return Executor { command -> command.run() } - } - - @Throws(IOException::class) - fun mockResponse(fileName: String): MockResponse { - return MockResponse().setChunkedBody(readFileToString(Utils::class.java, "/$fileName"), 32) - } - - fun assertResponse(call: ApolloCall, predicate: Predicate>) { - Rx2Apollo.from(call) - .test() - .assertValue(predicate) - } - - @Throws(Exception::class) - fun enqueueAndAssertResponse(server: MockWebServer, mockResponse: String, call: ApolloCall, - predicate: Predicate>) { - server.enqueue(mockResponse(mockResponse)) - assertResponse(call, predicate) - } - - @Throws(Exception::class) - fun cacheAndAssertCachedResponse(server: MockWebServer, mockResponse: String, call: ApolloQueryCall, - predicate: Predicate>) { - server.enqueue(mockResponse(mockResponse)) - assertResponse( - call.responseFetcher(NETWORK_ONLY), - Predicate { response -> !response.hasErrors() } - ) - - assertResponse( - call.clone().responseFetcher(CACHE_ONLY), - predicate - ) - } - - fun immediateExecutorService(): ExecutorService { - return object : AbstractExecutorService() { - override fun shutdown() = Unit - - override fun shutdownNow(): List? = null - - override fun isShutdown(): Boolean = false - - override fun isTerminated(): Boolean = false - - @Throws(InterruptedException::class) - override fun awaitTermination(l: Long, timeUnit: TimeUnit): Boolean = false - - override fun execute(runnable: Runnable) = runnable.run() - } - } - - class TestExecutor : Executor { - - private val commands = ConcurrentLinkedQueue() - - override fun execute(command: Runnable) { - commands.add(command) - } - - fun triggerActions() { - for (command in commands) { - command.run() - } - } - } - - fun checkTestFixture(actualText: String, expectedPath: String) { - val expected = File("src/test/fixtures/$expectedPath") - val expectedText = try { - expected.readText().removeSuffix("\n") - } catch (e: FileNotFoundException) { - "" - } - - expected.parentFile.mkdirs() - if (actualText != expectedText) { - when (System.getProperty("updateTestFixtures")?.trim()) { - "on", "true", "1" -> { - expected.writeText(actualText) - } - else -> { - throw java.lang.Exception("""generatedText doesn't match the expectedText. - |If you changed the compiler recently, you need to update the testFixtures. - |Run the tests with `-DupdateTestFixtures=true` to do so. - |generatedText: $actualText - |expectedText: $expectedText""".trimMargin()) - } - } - } - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/directives/DirectivesTest.kt b/apollo-integration/src/test/java/com/apollographql/apollo/directives/DirectivesTest.kt deleted file mode 100644 index 1424f054ab5..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/directives/DirectivesTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.apollographql.apollo.directives - -import com.apollographql.apollo.integration.directives.MyQuery -import com.google.common.truth.Truth -import okio.buffer -import okio.source -import org.junit.Test -import com.apollographql.apollo.api.Input - -class DirectivesTest { - @Test - fun `parse does not crash with absent input`() { - val responseJson = """ - { - "data": { - "getCityByName": { - "__typename": "City", - "id": "2643743" - } - } - } - """.trimIndent() - val data = MyQuery(Input.absent()).parse(responseJson.byteInputStream().source().buffer()).data - Truth.assertThat(data?.getCityByName?.__typename).isEqualTo("City") - } - - @Test - fun `parse does not over fetch with skip directive`() { - val responseJson = """ - { - "data": { - "getCityByName": { - "__typename": "City", - "id": "2643743" - } - } - } - """.trimIndent() - val data = MyQuery(Input.optional(false)).parse(responseJson.byteInputStream().source().buffer()).data - Truth.assertThat(data!!.getCityByName!!.id).isEqualTo(null) - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/internal/ApolloStoreTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/internal/ApolloStoreTest.java deleted file mode 100644 index 04dad2af07a..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/internal/ApolloStoreTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.apollographql.apollo.internal; - -import com.apollographql.apollo.NamedCountDownLatch; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.cache.CacheHeaders; -import com.apollographql.apollo.cache.normalized.CacheKey; -import com.apollographql.apollo.cache.normalized.CacheKeyResolver; -import com.apollographql.apollo.cache.normalized.NormalizedCache; -import com.apollographql.apollo.cache.normalized.Record; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.junit.Test; - -import java.util.Collections; -import java.util.Set; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; - -import static java.util.Collections.emptySet; - -public class ApolloStoreTest { - - @Test public void storeClearAllCallsNormalizedCacheClearAll() throws Exception { - final NamedCountDownLatch latch = new NamedCountDownLatch("storeClearAllCallsNormalizedCacheClearAll", 1); - final RealApolloStore realApolloStore = new RealApolloStore( - new NormalizedCache() { - @Nullable @Override public Record loadRecord(@NotNull String key, @NotNull CacheHeaders cacheHeaders) { - return null; - } - - @NotNull @Override public Set merge(@NotNull Record record, @NotNull CacheHeaders cacheHeaders) { - return emptySet(); - } - - @Override public void clearAll() { - latch.countDown(); - } - - @Override public boolean remove(@NotNull CacheKey cacheKey, boolean cascade) { - return false; - } - - @NotNull @Override - protected Set performMerge(@NotNull Record apolloRecord, @Nullable Record oldRecord, @NotNull CacheHeaders cacheHeaders) { - return emptySet(); - } - }, - CacheKeyResolver.DEFAULT, - new ScalarTypeAdapters(Collections.EMPTY_MAP), - Executors.newSingleThreadExecutor(), - new ApolloLogger(null) - ); - realApolloStore.clearAll().execute(); - latch.awaitOrThrowWithTimeout(3, TimeUnit.SECONDS); - } - -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/internal/QueryRefetchTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/internal/QueryRefetchTest.java deleted file mode 100644 index 889ab3c31c8..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/internal/QueryRefetchTest.java +++ /dev/null @@ -1,177 +0,0 @@ -package com.apollographql.apollo.internal; - - -import com.apollographql.apollo.ApolloCall; -import com.apollographql.apollo.ApolloClient; -import com.apollographql.apollo.ApolloQueryWatcher; -import com.apollographql.apollo.IdFieldCacheKeyResolver; -import com.apollographql.apollo.Utils; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy; -import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.integration.normalizer.CreateReviewMutation; -import com.apollographql.apollo.integration.normalizer.ReviewsByEpisodeQuery; -import com.apollographql.apollo.integration.normalizer.type.ColorInput; -import com.apollographql.apollo.integration.normalizer.type.Episode; -import com.apollographql.apollo.integration.normalizer.type.ReviewInput; -import com.apollographql.apollo.rx2.Rx2Apollo; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; -import java.util.concurrent.atomic.AtomicReference; - -import org.jetbrains.annotations.NotNull; - -import io.reactivex.functions.Predicate; -import okhttp3.Dispatcher; -import okhttp3.OkHttpClient; -import okhttp3.mockwebserver.MockWebServer; - -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.CACHE_ONLY; -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.NETWORK_FIRST; -import static com.google.common.truth.Truth.assertThat; - -public class QueryRefetchTest { - private ApolloClient apolloClient; - private MockWebServer server; - - @Before public void setUp() throws IOException { - server = new MockWebServer(); - server.start(); - OkHttpClient okHttpClient = new OkHttpClient.Builder() - .dispatcher(new Dispatcher(Utils.INSTANCE.immediateExecutorService())) - .build(); - - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .dispatcher(Utils.INSTANCE.immediateExecutor()) - .okHttpClient(okHttpClient) - .normalizedCache(new LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), new IdFieldCacheKeyResolver()) - .build(); - } - - @After public void tearDown() { - try { - server.shutdown(); - } catch (IOException ignored) { - } - } - - @Test @SuppressWarnings("CheckReturnValue") public void refetchNoPreCachedQuery() throws Exception { - CreateReviewMutation mutation = new CreateReviewMutation( - Episode.EMPIRE, - ReviewInput.builder().stars(5).commentary("Awesome").favoriteColor(ColorInput.builder().build()).build() - ); - - server.enqueue(Utils.INSTANCE.mockResponse("CreateReviewResponse.json")); - server.enqueue(Utils.INSTANCE.mockResponse("ReviewsEmpireEpisodeResponse.json")); - - RealApolloCall call = (RealApolloCall) apolloClient.mutate(mutation).refetchQueries(new ReviewsByEpisodeQuery(Episode.EMPIRE)); - Rx2Apollo - .from(call) - .test(); - - assertThat(server.getRequestCount()).isEqualTo(2); - Utils.INSTANCE.assertResponse( - apolloClient.query(new ReviewsByEpisodeQuery(Episode.EMPIRE)).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().reviews()).hasSize(3); - assertThat(response.data().reviews().get(2).stars()).isEqualTo(5); - assertThat(response.data().reviews().get(2).commentary()).isEqualTo("Amazing"); - return true; - } - } - ); - } - - @Test @SuppressWarnings("CheckReturnValue") public void refetchPreCachedQuery() throws Exception { - Utils.INSTANCE.enqueueAndAssertResponse( - server, - "ReviewsEmpireEpisodeResponse.json", - apolloClient.query(new ReviewsByEpisodeQuery(Episode.EMPIRE)).responseFetcher(NETWORK_FIRST), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - return !response.hasErrors(); - } - } - ); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new ReviewsByEpisodeQuery(Episode.EMPIRE)).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().reviews()).hasSize(3); - assertThat(response.data().reviews().get(2).stars()).isEqualTo(5); - assertThat(response.data().reviews().get(2).commentary()).isEqualTo("Amazing"); - return true; - } - } - ); - - CreateReviewMutation mutation = new CreateReviewMutation( - Episode.EMPIRE, - ReviewInput.builder().stars(5).commentary("Awesome").favoriteColor(ColorInput.builder().build()).build() - ); - - server.enqueue(Utils.INSTANCE.mockResponse("CreateReviewResponse.json")); - server.enqueue(Utils.INSTANCE.mockResponse("ReviewsEmpireEpisodeResponseUpdated.json")); - - RealApolloCall call = (RealApolloCall) apolloClient.mutate(mutation).refetchQueries(new ReviewsByEpisodeQuery(Episode.EMPIRE)); - Rx2Apollo - .from(call) - .test(); - assertThat(server.getRequestCount()).isEqualTo(3); - - Utils.INSTANCE.assertResponse( - apolloClient.query(new ReviewsByEpisodeQuery(Episode.EMPIRE)).responseFetcher(CACHE_ONLY), - new Predicate>() { - @Override public boolean test(Response response) throws Exception { - assertThat(response.data().reviews()).hasSize(4); - assertThat(response.data().reviews().get(3).stars()).isEqualTo(5); - assertThat(response.data().reviews().get(3).commentary()).isEqualTo("Awesome"); - return true; - } - } - ); - } - - @Test @SuppressWarnings("CheckReturnValue") public void refetchWatchers() throws Exception { - server.enqueue(Utils.INSTANCE.mockResponse("ReviewsEmpireEpisodeResponse.json")); - server.enqueue(Utils.INSTANCE.mockResponse("CreateReviewResponse.json")); - server.enqueue(Utils.INSTANCE.mockResponse("ReviewsEmpireEpisodeResponseUpdated.json")); - - final AtomicReference> empireReviewsWatchResponse = new AtomicReference<>(); - ApolloQueryWatcher queryWatcher = apolloClient.query(new ReviewsByEpisodeQuery(Episode.EMPIRE)) - .watcher() - .refetchResponseFetcher(NETWORK_FIRST) - .enqueueAndWatch(new ApolloCall.Callback() { - @Override public void onResponse(@NotNull Response response) { - empireReviewsWatchResponse.set(response); - } - - @Override public void onFailure(@NotNull ApolloException e) { - } - }); - - CreateReviewMutation mutation = new CreateReviewMutation( - Episode.EMPIRE, - ReviewInput.builder().stars(5).commentary("Awesome").favoriteColor(ColorInput.builder().build()).build() - ); - Rx2Apollo - .from(apolloClient.mutate(mutation).refetchQueries(queryWatcher.operation().name())) - .test(); - assertThat(server.getRequestCount()).isEqualTo(3); - - Response empireReviewsQueryResponse = empireReviewsWatchResponse.get(); - assertThat(empireReviewsQueryResponse.data().reviews()).hasSize(4); - assertThat(empireReviewsQueryResponse.data().reviews().get(3).stars()).isEqualTo(5); - assertThat(empireReviewsQueryResponse.data().reviews().get(3).commentary()).isEqualTo("Awesome"); - - queryWatcher.cancel(); - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/BaseFetcherTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/BaseFetcherTest.java deleted file mode 100644 index 79773b6e238..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/BaseFetcherTest.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.apollographql.apollo.internal.fetcher; - -import com.apollographql.apollo.ApolloCall; -import com.apollographql.apollo.ApolloClient; -import com.apollographql.apollo.IdFieldCacheKeyResolver; -import com.apollographql.apollo.Utils; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy; -import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery; - -import org.junit.After; -import org.junit.Before; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.TimeUnit; - -import org.jetbrains.annotations.NotNull; - -import okhttp3.Dispatcher; -import okhttp3.OkHttpClient; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; - -class BaseFetcherTest { - - ApolloClient apolloClient; - MockWebServer server; - - @Before public void setUp() { - server = new MockWebServer(); - OkHttpClient okHttpClient = new OkHttpClient.Builder() - .writeTimeout(2, TimeUnit.SECONDS) - .readTimeout(2, TimeUnit.SECONDS) - .dispatcher(new Dispatcher(Utils.INSTANCE.immediateExecutorService())) - .build(); - - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(okHttpClient) - .normalizedCache(new LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), new IdFieldCacheKeyResolver()) - .dispatcher(Utils.INSTANCE.immediateExecutor()) - .build(); - } - - @After public void shutdown() throws IOException { - server.shutdown(); - } - - static class TrackingCallback extends ApolloCall.Callback { - final List> responseList = new ArrayList<>(); - final List exceptions = new ArrayList<>(); - volatile boolean completed; - - @Override public void onResponse(@NotNull Response response) { - if (completed) throw new IllegalStateException("onCompleted already called Do not reuse tracking callback."); - responseList.add(response); - } - - @Override public void onFailure(@NotNull ApolloException e) { - if (completed) throw new IllegalStateException("onCompleted already called Do not reuse tracking callback."); - exceptions.add(e); - } - - @Override public void onStatusEvent(@NotNull ApolloCall.StatusEvent event) { - if (event == ApolloCall.StatusEvent.COMPLETED) { - if (completed) throw new IllegalStateException("onCompleted already called Do not reuse tracking callback."); - completed = true; - } - } - } - - MockResponse mockResponse(String fileName) throws IOException { - return new MockResponse().setChunkedBody(Utils.INSTANCE.readFileToString(getClass(), "/" + fileName), 32); - } - -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/CacheAndNetworkFetcherTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/CacheAndNetworkFetcherTest.java deleted file mode 100644 index 25bf7ac5317..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/CacheAndNetworkFetcherTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.apollographql.apollo.internal.fetcher; - -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery; -import com.apollographql.apollo.integration.normalizer.type.Episode; - -import org.junit.Test; - -import java.io.IOException; -import java.util.concurrent.TimeoutException; - -import okhttp3.mockwebserver.MockResponse; - -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.CACHE_AND_NETWORK; -import static com.google.common.truth.Truth.assertThat; -import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR; - -public class CacheAndNetworkFetcherTest extends BaseFetcherTest { - @Test public void enqueue() throws IOException, ApolloException { - EpisodeHeroNameQuery query = EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build(); - TrackingCallback trackingCallback; - - // Has error when cache empty, and network error - server.enqueue(new MockResponse().setResponseCode(HTTP_INTERNAL_ERROR).setBody("Server Error")); - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(CACHE_AND_NETWORK).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions.size()).isEqualTo(1); - - // Goes to network when cache empty, one response - server.enqueue(mockResponse("HeroNameResponse.json")); - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(CACHE_AND_NETWORK).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions).isEmpty(); - assertThat(trackingCallback.responseList.size()).isEqualTo(1); - assertThat(trackingCallback.responseList.get(0).fromCache()).isFalse(); - assertThat(trackingCallback.responseList.get(0).data().hero().name()).isEqualTo("R2-D2"); - - // Goes to network and cache after cache populated - server.enqueue(mockResponse("HeroNameResponse.json")); - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(CACHE_AND_NETWORK).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions).isEmpty(); - assertThat(trackingCallback.responseList.size()).isEqualTo(2); - - // Cache is always first - assertThat(trackingCallback.responseList.get(0).fromCache()).isTrue(); - assertThat(trackingCallback.responseList.get(0).data().hero().name()).isEqualTo("R2-D2"); - - assertThat(trackingCallback.responseList.get(1).fromCache()).isFalse(); - assertThat(trackingCallback.responseList.get(1).data().hero().name()).isEqualTo("R2-D2"); - - // Falls back to cache if network error - server.enqueue(new MockResponse().setResponseCode(HTTP_INTERNAL_ERROR).setBody("Server Error")); - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(CACHE_AND_NETWORK).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions).hasSize(1); - assertThat(trackingCallback.responseList.size()).isEqualTo(1); - assertThat(trackingCallback.responseList.get(0).fromCache()).isTrue(); - assertThat(trackingCallback.responseList.get(0).data().hero().name()).isEqualTo("R2-D2"); - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/CacheFirstFetcherTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/CacheFirstFetcherTest.java deleted file mode 100644 index 123599ff300..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/CacheFirstFetcherTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.apollographql.apollo.internal.fetcher; - -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery; -import com.apollographql.apollo.integration.normalizer.type.Episode; - -import org.junit.Test; - -import java.io.IOException; -import java.util.concurrent.TimeoutException; - -import okhttp3.mockwebserver.MockResponse; - -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.CACHE_FIRST; -import static com.google.common.truth.Truth.assertThat; -import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR; - -public class CacheFirstFetcherTest extends BaseFetcherTest { - @Test public void enqueue() throws IOException, ApolloException, TimeoutException, InterruptedException { - - EpisodeHeroNameQuery query = EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build(); - TrackingCallback trackingCallback; - - // Has error when cache empty, and network error - server.enqueue(new MockResponse().setResponseCode(HTTP_INTERNAL_ERROR).setBody("Server Error")); - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(CACHE_FIRST).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions.size()).isEqualTo(1); - - // Goes to network when empty - trackingCallback = new TrackingCallback(); - server.enqueue(mockResponse("HeroNameResponse.json")); - apolloClient.query(query).responseFetcher(CACHE_FIRST).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions).isEmpty(); - assertThat(trackingCallback.responseList.size()).isEqualTo(1); - assertThat(trackingCallback.responseList.get(0).fromCache()).isFalse(); - assertThat(trackingCallback.responseList.get(0).data().hero().name()).isEqualTo("R2-D2"); - assertThat(server.getRequestCount()).isEqualTo(2); - - // Hits only cache after populated - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(CACHE_FIRST).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions).isEmpty(); - assertThat(trackingCallback.responseList.size()).isEqualTo(1); - assertThat(trackingCallback.responseList.get(0).fromCache()).isTrue(); - assertThat(trackingCallback.responseList.get(0).data().hero().name()).isEqualTo("R2-D2"); - assertThat(server.getRequestCount()).isEqualTo(2); - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/CacheOnlyFetcherTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/CacheOnlyFetcherTest.java deleted file mode 100644 index 59129f401a4..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/CacheOnlyFetcherTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.apollographql.apollo.internal.fetcher; - -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery; -import com.apollographql.apollo.integration.normalizer.type.Episode; -import com.apollographql.apollo.rx2.Rx2Apollo; - -import org.junit.Test; - -import java.io.IOException; -import java.util.concurrent.TimeoutException; - -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.CACHE_ONLY; -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.NETWORK_ONLY; -import static com.google.common.truth.Truth.assertThat; - -public class CacheOnlyFetcherTest extends BaseFetcherTest { - @Test public void enqueue() throws IOException, ApolloException, TimeoutException, InterruptedException { - EpisodeHeroNameQuery query = EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build(); - TrackingCallback trackingCallback; - - // Is null when cache empty - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(CACHE_ONLY).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions.size()).isEqualTo(0); - assertThat(trackingCallback.responseList.size()).isEqualTo(1); - assertThat(trackingCallback.responseList.get(0).fromCache()).isTrue(); - assertThat(trackingCallback.responseList.get(0).data()).isNull(); - assertThat(server.getRequestCount()).isEqualTo(0); - - // Populate cache - server.enqueue(mockResponse("HeroNameResponse.json")); - - final Response responseData - = Rx2Apollo.from(apolloClient.query(query).responseFetcher(NETWORK_ONLY)).blockingFirst(); - assertThat(responseData.hasErrors()).isFalse(); - assertThat(responseData.data().hero().name()).isEqualTo("R2-D2"); - assertThat(server.getRequestCount()).isEqualTo(1); - - // Success after cache populated - server.enqueue(mockResponse("HeroNameResponse.json")); - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(CACHE_ONLY).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions.size()).isEqualTo(0); - assertThat(trackingCallback.responseList.size()).isEqualTo(1); - assertThat(trackingCallback.responseList.get(0).fromCache()).isTrue(); - assertThat(trackingCallback.responseList.get(0).data().hero().name()).isEqualTo("R2-D2"); - assertThat(server.getRequestCount()).isEqualTo(1); - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/NetworkFirstFetcherTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/NetworkFirstFetcherTest.java deleted file mode 100644 index 507989abb1e..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/NetworkFirstFetcherTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.apollographql.apollo.internal.fetcher; - -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery; -import com.apollographql.apollo.integration.normalizer.type.Episode; - -import org.junit.Test; - -import java.io.IOException; -import java.util.concurrent.TimeoutException; - -import okhttp3.mockwebserver.MockResponse; - -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.NETWORK_FIRST; -import static com.google.common.truth.Truth.assertThat; -import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR; - -public class NetworkFirstFetcherTest extends BaseFetcherTest { - @Test public void enqueue() throws IOException, ApolloException, TimeoutException, InterruptedException { - EpisodeHeroNameQuery query = EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build(); - TrackingCallback trackingCallback; - - // Has error when cache empty, and network error - server.enqueue(new MockResponse().setResponseCode(HTTP_INTERNAL_ERROR).setBody("Server Error")); - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(NETWORK_FIRST).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions.size()).isEqualTo(1); - - // Goes to network when empty - server.enqueue(mockResponse("HeroNameResponse.json")); - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(NETWORK_FIRST).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions).isEmpty(); - assertThat(trackingCallback.responseList.size()).isEqualTo(1); - assertThat(trackingCallback.responseList.get(0).fromCache()).isFalse(); - assertThat(trackingCallback.responseList.get(0).data().hero().name()).isEqualTo("R2-D2"); - - // Goes to network after cache populated - server.enqueue(mockResponse("HeroNameResponse.json")); - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(NETWORK_FIRST).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions).isEmpty(); - assertThat(trackingCallback.responseList.size()).isEqualTo(1); - assertThat(trackingCallback.responseList.get(0).fromCache()).isFalse(); - assertThat(trackingCallback.responseList.get(0).data().hero().name()).isEqualTo("R2-D2"); - - // Falls back to cache if network error - server.enqueue(new MockResponse().setResponseCode(HTTP_INTERNAL_ERROR).setBody("Server Error")); - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(NETWORK_FIRST).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions).isEmpty(); - assertThat(trackingCallback.responseList.size()).isEqualTo(1); - assertThat(trackingCallback.responseList.get(0).fromCache()).isTrue(); - assertThat(trackingCallback.responseList.get(0).data().hero().name()).isEqualTo("R2-D2"); - } - -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/NetworkOnlyFetcherTest.java b/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/NetworkOnlyFetcherTest.java deleted file mode 100644 index 06c8eb9be8b..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/internal/fetcher/NetworkOnlyFetcherTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.apollographql.apollo.internal.fetcher; - -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.integration.normalizer.EpisodeHeroNameQuery; -import com.apollographql.apollo.integration.normalizer.type.Episode; - -import org.junit.Test; - -import java.io.IOException; -import java.util.concurrent.TimeoutException; - -import okhttp3.mockwebserver.MockResponse; - -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.NETWORK_ONLY; -import static com.google.common.truth.Truth.assertThat; -import static java.net.HttpURLConnection.HTTP_INTERNAL_ERROR; - -public class NetworkOnlyFetcherTest extends BaseFetcherTest { - @Test public void enqueue() throws IOException, ApolloException, TimeoutException, InterruptedException { - EpisodeHeroNameQuery query = EpisodeHeroNameQuery.builder().episode(Episode.EMPIRE).build(); - TrackingCallback trackingCallback; - - // Has error when cache empty, and network error - server.enqueue(new MockResponse().setResponseCode(HTTP_INTERNAL_ERROR).setBody("Server Error")); - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(NETWORK_ONLY).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions.size()).isEqualTo(1); - - // Goes to network when empty - server.enqueue(mockResponse("HeroNameResponse.json")); - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(NETWORK_ONLY).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions).isEmpty(); - assertThat(trackingCallback.responseList.size()).isEqualTo(1); - assertThat(trackingCallback.responseList.get(0).fromCache()).isFalse(); - assertThat(trackingCallback.responseList.get(0).data().hero().name()).isEqualTo("R2-D2"); - - // Goes to network after cache populated - server.enqueue(mockResponse("HeroNameResponse.json")); - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(NETWORK_ONLY).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions).isEmpty(); - assertThat(trackingCallback.responseList.size()).isEqualTo(1); - assertThat(trackingCallback.responseList.get(0).fromCache()).isFalse(); - assertThat(trackingCallback.responseList.get(0).data().hero().name()).isEqualTo("R2-D2"); - - // Has error when cache empty, and network error - server.enqueue(new MockResponse().setResponseCode(HTTP_INTERNAL_ERROR).setBody("Server Error")); - trackingCallback = new TrackingCallback(); - apolloClient.query(query).responseFetcher(NETWORK_ONLY).enqueue(trackingCallback); - assertThat(trackingCallback.exceptions.size()).isEqualTo(1); - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/internal/interceptor/ApolloServerInterceptorFileUploadTest.kt b/apollo-integration/src/test/java/com/apollographql/apollo/internal/interceptor/ApolloServerInterceptorFileUploadTest.kt deleted file mode 100755 index bc59eabe99f..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/internal/interceptor/ApolloServerInterceptorFileUploadTest.kt +++ /dev/null @@ -1,389 +0,0 @@ -package com.apollographql.apollo.internal.interceptor - -import com.apollographql.apollo.Utils.checkTestFixture -import com.apollographql.apollo.api.CustomTypeAdapter -import com.apollographql.apollo.api.FileUpload -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.ScalarType -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.cache.http.HttpCache -import com.apollographql.apollo.api.internal.ApolloLogger -import com.apollographql.apollo.cache.CacheHeaders -import com.apollographql.apollo.integration.upload.MultipleUploadMutation -import com.apollographql.apollo.integration.upload.NestedUploadMutation -import com.apollographql.apollo.integration.upload.SingleUploadMutation -import com.apollographql.apollo.integration.upload.SingleUploadTwiceMutation -import com.apollographql.apollo.integration.upload.type.NestedObject -import com.apollographql.apollo.request.RequestHeaders -import com.google.common.base.Predicate -import com.google.common.truth.Truth -import junit.framework.Assert -import okhttp3.* -import okio.* -import okio.ByteString.Companion.encodeUtf8 -import org.junit.Before -import org.junit.Test -import java.io.File -import java.lang.UnsupportedOperationException -import java.nio.charset.StandardCharsets -import java.nio.file.Files -import java.util.* - -class ApolloServerInterceptorFileUploadTest { - private val serverUrl = HttpUrl.parse("http://google.com")!! - private val file0 = createFile("file0.txt", "content_file0") - private val file1 = createFile("file1.jpg", "content_file1") - private val file2 = createFile("file2.png", "content_file2") - private val upload0 = FileUpload("plain/txt", file0) - private val upload1 = FileUpload("image/jpeg", file1) - private val upload2 = FileUpload("image/png", file2) - private val uploadSource = object: FileUpload("image/png") { - val content = "content_source".encodeUtf8() - override fun contentLength() = content.size.toLong() - override fun fileName() = "source" - override fun writeTo(sink: BufferedSink) { - sink.writeAll(Buffer().let { it.write(content) }) - } - } - - private val nestedObject0 = NestedObject.builder() - .file(upload0) - .fileList(listOf(upload1, upload2)) - .build() - - private val nestedObject1 = NestedObject.builder() - .file(upload1) - .fileList(listOf(upload0, upload2)) - .build() - - private val nestedObject2 = NestedObject.builder() - .file(upload2) - .fileList(listOf(upload0, upload1)) - .recursiveNested(listOf(nestedObject0, nestedObject1)) - .build() - - private val mutationSingle = SingleUploadMutation.builder() - .file(upload1) - .build() - - private val mutationSource = SingleUploadMutation.builder() - .file(uploadSource) - .build() - - private val mutationTwice = SingleUploadTwiceMutation.builder() - .file1(upload1) - .file2(upload2) - .build() - - private lateinit var mutationMultiple: MultipleUploadMutation - - private val mutationNested = NestedUploadMutation.builder() - .nested(nestedObject2) - .topFile(upload2) - .topFileList(listOf(upload1, upload0)) - .build() - - private fun createFile(fileName: String, content: String): String { - val tempDir = System.getProperty("java.io.tmpdir") - val filePath = "$tempDir/$fileName" - val f = File(filePath) - try { - val bw = Files.newBufferedWriter(f.toPath(), StandardCharsets.UTF_8) - bw.write(content) - bw.close() - } catch (e: Exception) { - } - return f.path - } - - @Before - fun prepare() { - val uploads = listOf(upload1, upload2) - - mutationMultiple = MultipleUploadMutation.builder() - .files(uploads) - .build() - } - - @Test - @Throws(Exception::class) - fun testDefaultHttpCallWithUploadSingle() { - val requestAssertPredicate = Predicate { request -> - Truth.assertThat(request).isNotNull() - assertDefaultRequestHeaders(request!!, mutationSingle) - Truth.assertThat(request.header(HttpCache.CACHE_KEY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_FETCH_STRATEGY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_TIMEOUT_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_AFTER_READ_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_PREFETCH_HEADER)).isNull() - assertRequestBodySingle(request) - true - } - val interceptor = ApolloServerInterceptor(serverUrl, - AssertHttpCallFactory(requestAssertPredicate), null, false, - ScalarTypeAdapters(emptyMap>()), - ApolloLogger(null)) - interceptor.httpPostCall(mutationSingle, CacheHeaders.NONE, RequestHeaders.NONE, true, false) - } - - @Test - @Throws(Exception::class) - fun testDefaultHttpCallWithUploadSource() { - val requestAssertPredicate = Predicate { request -> - Truth.assertThat(request).isNotNull() - assertDefaultRequestHeaders(request!!, mutationSource) - Truth.assertThat(request.header(HttpCache.CACHE_KEY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_FETCH_STRATEGY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_TIMEOUT_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_AFTER_READ_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_PREFETCH_HEADER)).isNull() - - val buffer = Buffer() - (request.body() as MultipartBody).part(2).body().writeTo(buffer) - Truth.assertThat(buffer.readUtf8()).isEqualTo("content_source") - true - } - val interceptor = ApolloServerInterceptor(serverUrl, - AssertHttpCallFactory(requestAssertPredicate), null, false, - ScalarTypeAdapters(emptyMap>()), - ApolloLogger(null)) - interceptor.httpPostCall(mutationSource, CacheHeaders.NONE, RequestHeaders.NONE, true, false) - } - - @Test - @Throws(Exception::class) - fun testDefaultHttpCallWithUploadTwice() { - val requestAssertPredicate = Predicate { request -> - Truth.assertThat(request).isNotNull() - assertDefaultRequestHeaders(request!!, mutationTwice) - Truth.assertThat(request.header(HttpCache.CACHE_KEY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_FETCH_STRATEGY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_TIMEOUT_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_AFTER_READ_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_PREFETCH_HEADER)).isNull() - assertRequestBodyTwice(request) - true - } - val interceptor = ApolloServerInterceptor(serverUrl, - AssertHttpCallFactory(requestAssertPredicate), null, false, - ScalarTypeAdapters(emptyMap>()), - ApolloLogger(null)) - interceptor.httpPostCall(mutationTwice, CacheHeaders.NONE, RequestHeaders.NONE, true, false) - } - - @Test - @Throws(Exception::class) - fun testDefaultHttpCallWithUploadMultiple() { - val requestAssertPredicate = Predicate { request -> - Truth.assertThat(request).isNotNull() - assertDefaultRequestHeaders(request!!, mutationMultiple) - Truth.assertThat(request.header(HttpCache.CACHE_KEY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_FETCH_STRATEGY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_TIMEOUT_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_AFTER_READ_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_PREFETCH_HEADER)).isNull() - assertRequestBodyMultiple(request) - true - } - val interceptor = ApolloServerInterceptor(serverUrl, - AssertHttpCallFactory(requestAssertPredicate), null, false, - ScalarTypeAdapters(emptyMap>()), - ApolloLogger(null)) - interceptor.httpPostCall(mutationMultiple, CacheHeaders.NONE, RequestHeaders.NONE, true, false) - } - - @Test - @Throws(Exception::class) - fun testDefaultHttpCallWithUploadNested() { - val requestAssertPredicate = Predicate { request -> - Truth.assertThat(request).isNotNull() - assertDefaultRequestHeaders(request!!, mutationNested) - assertRequestBodyNested(request) - true - } - val interceptor = ApolloServerInterceptor(serverUrl, - AssertHttpCallFactory(requestAssertPredicate), null, false, - ScalarTypeAdapters(emptyMap>()), - ApolloLogger(null)) - interceptor.httpPostCall(mutationNested, CacheHeaders.NONE, RequestHeaders.NONE, true, false) - } - - @Test - @Throws(Exception::class) - fun testAdditionalHeaders() { - val testHeader1 = "TEST_HEADER_1" - val testHeaderValue1 = "crappy_value" - val testHeader2 = "TEST_HEADER_2" - val testHeaderValue2 = "fantastic_value" - val testHeader3 = "TEST_HEADER_3" - val testHeaderValue3 = "awesome_value" - val requestAssertPredicate = Predicate { request -> - Truth.assertThat(request).isNotNull() - assertDefaultRequestHeaders(request!!, mutationSingle) - Truth.assertThat(request.header(HttpCache.CACHE_KEY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_FETCH_STRATEGY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_TIMEOUT_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_AFTER_READ_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_PREFETCH_HEADER)).isNull() - Truth.assertThat(request.header(testHeader1)).isEqualTo(testHeaderValue1) - Truth.assertThat(request.header(testHeader2)).isEqualTo(testHeaderValue2) - Truth.assertThat(request.header(testHeader3)).isEqualTo(testHeaderValue3) - assertRequestBodySingle(request) - true - } - val requestHeaders: RequestHeaders = RequestHeaders.builder() - .addHeader(testHeader1, testHeaderValue1) - .addHeader(testHeader2, testHeaderValue2) - .addHeader(testHeader3, testHeaderValue3) - .build() - val interceptor = ApolloServerInterceptor(serverUrl, - AssertHttpCallFactory(requestAssertPredicate), null, false, - ScalarTypeAdapters(emptyMap>()), - ApolloLogger(null)) - interceptor.httpPostCall(mutationSingle, CacheHeaders.NONE, requestHeaders, true, false) - } - - private fun assertDefaultRequestHeaders(request: Request, mutation: Operation<*, *, *>) { - Truth.assertThat(request.url()).isEqualTo(serverUrl) - Truth.assertThat(request.method()).isEqualTo("POST") - Truth.assertThat(request.header(ApolloServerInterceptor.HEADER_ACCEPT_TYPE)).isEqualTo(ApolloServerInterceptor.ACCEPT_TYPE) - Truth.assertThat(request.header(ApolloServerInterceptor.HEADER_CONTENT_TYPE)).isEqualTo(ApolloServerInterceptor.CONTENT_TYPE) - Truth.assertThat(request.header(ApolloServerInterceptor.HEADER_APOLLO_OPERATION_ID)).isEqualTo(mutation.operationId()) - Truth.assertThat(request.header(ApolloServerInterceptor.HEADER_APOLLO_OPERATION_NAME)).isEqualTo(mutation.name().name()) - Truth.assertThat(request.tag()).isEqualTo(mutation.operationId()) - } - - private fun assertRequestBodySingle(request: Request) { - Truth.assertThat(request.body()).isInstanceOf(MultipartBody::class.java) - val body = request.body() as MultipartBody - Truth.assertThat(body.contentType()!!.type()).isEqualTo("multipart") - Truth.assertThat(body.contentType()!!.subtype()).isEqualTo("form-data") - Truth.assertThat(body.parts().size).isEqualTo(3) - - // Check - val part0 = body.parts()[0] - assertOperationsPart(part0, "expectedOperationsPartBodySingle.json") - val part1 = body.parts()[1] - assertMapPart(part1, "expectedMapPartBodySingle.json") - val part2 = body.parts()[2] - assertFileContentPart(part2, "0", "file1.jpg", "image/jpeg") - } - - private fun assertRequestBodyTwice(request: Request) { - Truth.assertThat(request.body()).isInstanceOf(MultipartBody::class.java) - val body = request.body() as MultipartBody? - Truth.assertThat(body!!.contentType()!!.type()).isEqualTo("multipart") - Truth.assertThat(body.contentType()!!.subtype()).isEqualTo("form-data") - Truth.assertThat(body.parts().size).isEqualTo(4) - - // Check - val part0 = body.parts()[0] - assertOperationsPart(part0, "expectedOperationsPartBodyTwice.json") - val part1 = body.parts()[1] - assertMapPart(part1, "expectedMapPartBodyTwice.json") - val part2 = body.parts()[2] - assertFileContentPart(part2, "0", "file1.jpg", "image/jpeg") - val part3 = body.parts()[3] - assertFileContentPart(part3, "1", "file2.png", "image/png") - } - - private fun assertRequestBodyMultiple(request: Request) { - Truth.assertThat(request!!.body()).isInstanceOf(MultipartBody::class.java) - val body = request.body() as MultipartBody? - Truth.assertThat(body!!.contentType()!!.type()).isEqualTo("multipart") - Truth.assertThat(body.contentType()!!.subtype()).isEqualTo("form-data") - Truth.assertThat(body.parts().size).isEqualTo(4) - - // Check - val part0 = body.parts()[0] - assertOperationsPart(part0, "expectedOperationsPartBodyMultiple.json") - val part1 = body.parts()[1] - assertMapPart(part1, "expectedMapPartBodyMultiple.json") - val part2 = body.parts()[2] - assertFileContentPart(part2, "0", "file1.jpg", "image/jpeg") - val part3 = body.parts()[3] - assertFileContentPart(part3, "1", "file2.png", "image/png") - } - - private fun assertRequestBodyNested(request: Request) { - Truth.assertThat(request!!.body()).isInstanceOf(MultipartBody::class.java) - val body = request.body() as MultipartBody? - Truth.assertThat(body!!.contentType()!!.type()).isEqualTo("multipart") - Truth.assertThat(body.contentType()!!.subtype()).isEqualTo("form-data") - Truth.assertThat(body.parts().size).isEqualTo(14) - - // Check - val part0 = body.parts()[0] - assertOperationsPart(part0, "expectedOperationsPartBodyNested.json") - val part1 = body.parts()[1] - assertMapPart(part1, "expectedMapPartBodyNested.json") - } - - private fun assertOperationsPart(part: MultipartBody.Part, expectedPath: String) { - Truth.assertThat(part.headers()!!["Content-Disposition"]).isEqualTo("form-data; name=\"operations\"") - Truth.assertThat(part.body().contentType()).isEqualTo(ApolloServerInterceptor.MEDIA_TYPE) - val bodyBuffer = Buffer() - try { - part.body().writeTo(bodyBuffer) - } catch (e: Exception) { - throw RuntimeException(e) - } - checkTestFixture(bodyBuffer.readUtf8(), "ApolloServerInterceptorFileUploadTest/$expectedPath") - } - - private fun assertMapPart(part: MultipartBody.Part, expectedPath: String) { - Truth.assertThat(part.headers()!!["Content-Disposition"]).isEqualTo("form-data; name=\"map\"") - Truth.assertThat(part.body().contentType()).isEqualTo(ApolloServerInterceptor.MEDIA_TYPE) - val bodyBuffer = Buffer() - try { - part.body().writeTo(bodyBuffer) - } catch (e: Exception) { - throw RuntimeException(e) - } - checkTestFixture(bodyBuffer.readUtf8(), "ApolloServerInterceptorFileUploadTest/$expectedPath") - } - - private fun assertFileContentPart(part: MultipartBody.Part, expectedName: String, expectedFileName: String, - expectedMimeType: String) { - Truth.assertThat(part.headers()!!["Content-Disposition"]).isEqualTo("form-data; name=\"" + expectedName + - "\"; filename=\"" + expectedFileName + "\"") - Truth.assertThat(part.body().contentType()).isEqualTo(MediaType.parse(expectedMimeType)) - } - - private class AssertHttpCallFactory internal constructor(val predicate: Predicate) : Call.Factory { - override fun newCall(request: Request): Call { - if (!predicate.apply(request)) { - Assert.fail("Assertion failed") - } - return NoOpCall() - } - } - - private class NoOpCall : Call { - override fun request(): Request { - throw UnsupportedOperationException() - } - - override fun execute(): Response { - throw UnsupportedOperationException() - } - - override fun enqueue(responseCallback: Callback) {} - override fun cancel() {} - override fun isExecuted(): Boolean { - return false - } - - override fun isCanceled(): Boolean { - return false - } - - override fun clone(): Call { - throw UnsupportedOperationException() - } - - override fun timeout(): Timeout { - throw UnsupportedOperationException() - } - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/internal/interceptor/ApolloServerInterceptorTest.kt b/apollo-integration/src/test/java/com/apollographql/apollo/internal/interceptor/ApolloServerInterceptorTest.kt deleted file mode 100644 index 1aaeb99585e..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/internal/interceptor/ApolloServerInterceptorTest.kt +++ /dev/null @@ -1,208 +0,0 @@ -package com.apollographql.apollo.internal.interceptor - -import com.apollographql.apollo.Logger -import com.apollographql.apollo.Utils.checkTestFixture -import com.apollographql.apollo.api.CustomTypeAdapter -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.ScalarType -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.cache.http.HttpCache -import com.apollographql.apollo.api.cache.http.HttpCachePolicy -import com.apollographql.apollo.api.internal.ApolloLogger -import com.apollographql.apollo.api.internal.Optional -import com.apollographql.apollo.cache.ApolloCacheHeaders -import com.apollographql.apollo.cache.CacheHeaders -import com.apollographql.apollo.integration.interceptor.AllFilmsQuery -import com.apollographql.apollo.request.RequestHeaders -import com.google.common.base.Predicate -import com.google.common.truth.Truth -import junit.framework.Assert -import okhttp3.* -import okio.Buffer -import okio.Timeout -import org.junit.Test -import java.io.IOException -import java.lang.UnsupportedOperationException -import java.util.concurrent.TimeUnit - -class ApolloServerInterceptorTest { - private val serverUrl = HttpUrl.parse("http://google.com")!! - private val query = AllFilmsQuery.builder() - .after("some cursor") - .beforeInput(Input.absent()) - .firstInput(Input.fromNullable(null)) - .last(100) - .build() - - @Test - @Throws(Exception::class) - fun testDefaultHttpCall() { - val requestAssertPredicate = Predicate { request -> - Truth.assertThat(request).isNotNull() - assertDefaultRequestHeaders(request) - Truth.assertThat(request!!.url()).isEqualTo(serverUrl) - Truth.assertThat(request.method()).isEqualTo("POST") - Truth.assertThat(request.header(ApolloServerInterceptor.HEADER_CONTENT_TYPE)).isEqualTo(ApolloServerInterceptor.CONTENT_TYPE) - Truth.assertThat(request.header(HttpCache.CACHE_KEY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_FETCH_STRATEGY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_TIMEOUT_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_AFTER_READ_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_PREFETCH_HEADER)).isNull() - assertRequestBody(request) - true - } - val interceptor = ApolloServerInterceptor(serverUrl, - AssertHttpCallFactory(requestAssertPredicate), null, false, - ScalarTypeAdapters(emptyMap>()), - ApolloLogger(null)) - interceptor.httpPostCall(query, CacheHeaders.NONE, RequestHeaders.NONE, true, false) - } - - @Test - @Throws(Exception::class) - fun testCachedHttpCall() { - val scalarTypeAdapters = ScalarTypeAdapters(emptyMap>()) - val cacheKey: String = ApolloServerInterceptor.cacheKey(query, scalarTypeAdapters) - val requestAssertPredicate = Predicate { request -> - Truth.assertThat(request).isNotNull() - assertDefaultRequestHeaders(request) - Truth.assertThat(request!!.url()).isEqualTo(serverUrl) - Truth.assertThat(request.method()).isEqualTo("POST") - Truth.assertThat(request.header(ApolloServerInterceptor.HEADER_CONTENT_TYPE)).isEqualTo(ApolloServerInterceptor.CONTENT_TYPE) - Truth.assertThat(request.header(HttpCache.CACHE_KEY_HEADER)).isEqualTo(cacheKey) - Truth.assertThat(request.header(HttpCache.CACHE_FETCH_STRATEGY_HEADER)).isEqualTo("NETWORK_FIRST") - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_TIMEOUT_HEADER)).isEqualTo("10000") - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_AFTER_READ_HEADER)).isEqualTo("false") - Truth.assertThat(request.header(HttpCache.CACHE_PREFETCH_HEADER)).isEqualTo("false") - Truth.assertThat(request.header(HttpCache.CACHE_DO_NOT_STORE)).isEqualTo("true") - assertRequestBody(request) - true - } - val interceptor = ApolloServerInterceptor(serverUrl, - AssertHttpCallFactory(requestAssertPredicate), - HttpCachePolicy.NETWORK_FIRST.expireAfter(10, TimeUnit.SECONDS), false, - scalarTypeAdapters, ApolloLogger(null)) - interceptor.httpPostCall(query, CacheHeaders.builder().addHeader(ApolloCacheHeaders.DO_NOT_STORE, "true").build(), - RequestHeaders.NONE, true, false) - } - - @Test - @Throws(Exception::class) - fun testAdditionalHeaders() { - val testHeader1 = "TEST_HEADER_1" - val testHeaderValue1 = "crappy_value" - val testHeader2 = "TEST_HEADER_2" - val testHeaderValue2 = "fantastic_value" - val testHeader3 = "TEST_HEADER_3" - val testHeaderValue3 = "awesome_value" - val requestAssertPredicate = Predicate { request -> - Truth.assertThat(request).isNotNull() - assertDefaultRequestHeaders(request) - Truth.assertThat(request!!.url()).isEqualTo(serverUrl) - Truth.assertThat(request.method()).isEqualTo("POST") - Truth.assertThat(request.header(ApolloServerInterceptor.HEADER_CONTENT_TYPE)).isEqualTo(ApolloServerInterceptor.CONTENT_TYPE) - Truth.assertThat(request.header(HttpCache.CACHE_KEY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_FETCH_STRATEGY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_TIMEOUT_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_AFTER_READ_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_PREFETCH_HEADER)).isNull() - Truth.assertThat(request.header(testHeader1)).isEqualTo(testHeaderValue1) - Truth.assertThat(request.header(testHeader2)).isEqualTo(testHeaderValue2) - Truth.assertThat(request.header(testHeader3)).isEqualTo(testHeaderValue3) - assertRequestBody(request) - true - } - val requestHeaders: RequestHeaders = RequestHeaders.builder() - .addHeader(testHeader1, testHeaderValue1) - .addHeader(testHeader2, testHeaderValue2) - .addHeader(testHeader3, testHeaderValue3) - .build() - val interceptor = ApolloServerInterceptor(serverUrl, - AssertHttpCallFactory(requestAssertPredicate), null, false, - ScalarTypeAdapters(emptyMap>()), - ApolloLogger(null)) - interceptor.httpPostCall(query, CacheHeaders.NONE, requestHeaders, true, false) - } - - @Test - @Throws(IOException::class) - fun testUseHttpGetForQueries() { - val requestAssertPredicate = Predicate { request -> - Truth.assertThat(request).isNotNull() - assertDefaultRequestHeaders(request) - Truth.assertThat(request!!.method()).isEqualTo("GET") - Truth.assertThat(request.header(ApolloServerInterceptor.HEADER_CONTENT_TYPE)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_KEY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_FETCH_STRATEGY_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_TIMEOUT_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_EXPIRE_AFTER_READ_HEADER)).isNull() - Truth.assertThat(request.header(HttpCache.CACHE_PREFETCH_HEADER)).isNull() - Truth.assertThat(request.url().queryParameter("query")).isEqualTo(query.queryDocument().replace("\n", "")) - Truth.assertThat(request.url().queryParameter("operationName")).isEqualTo(query.name().name()) - Truth.assertThat(request.url().queryParameter("variables")).isEqualTo("{\"after\":\"some cursor\",\"first\":null,\"last\":100}") - Truth.assertThat(request.url().queryParameter("extensions")).isEqualTo("{\"persistedQuery\":{\"version\":1," + - "\"sha256Hash\":\"" + query.operationId() + "\"}}") - true - } - val interceptor = ApolloServerInterceptor(serverUrl, - AssertHttpCallFactory(requestAssertPredicate), null, false, - ScalarTypeAdapters(emptyMap>()), - ApolloLogger(null)) - interceptor.httpGetCall(query, CacheHeaders.NONE, RequestHeaders.NONE, true, true) - } - - private fun assertDefaultRequestHeaders(request: Request?) { - Truth.assertThat(request!!.header(ApolloServerInterceptor.HEADER_ACCEPT_TYPE)).isEqualTo(ApolloServerInterceptor.ACCEPT_TYPE) - Truth.assertThat(request.header(ApolloServerInterceptor.HEADER_APOLLO_OPERATION_ID)).isEqualTo(query.operationId()) - Truth.assertThat(request.header(ApolloServerInterceptor.HEADER_APOLLO_OPERATION_NAME)).isEqualTo(query.name().name()) - Truth.assertThat(request.tag()).isEqualTo(query.operationId()) - } - - private fun assertRequestBody(request: Request?) { - Truth.assertThat(request!!.body()!!.contentType()).isEqualTo(ApolloServerInterceptor.MEDIA_TYPE) - val bodyBuffer = Buffer() - try { - request.body()!!.writeTo(bodyBuffer) - } catch (e: Exception) { - throw RuntimeException(e) - } - checkTestFixture(bodyBuffer.readUtf8(), "ApolloServerInterceptorTest/interceptorRequestBody.json") - } - - private class AssertHttpCallFactory internal constructor(val predicate: Predicate) : Call.Factory { - override fun newCall(request: Request): Call { - if (!predicate.apply(request)) { - Assert.fail("Assertion failed") - } - return NoOpCall() - } - } - - private class NoOpCall : Call { - override fun request(): Request { - throw UnsupportedOperationException() - } - - override fun execute(): Response { - throw UnsupportedOperationException() - } - - override fun enqueue(responseCallback: Callback) {} - override fun cancel() {} - override fun isExecuted(): Boolean { - return false - } - - override fun isCanceled(): Boolean { - return false - } - - override fun clone(): Call { - throw UnsupportedOperationException() - } - - override fun timeout(): Timeout { - throw UnsupportedOperationException() - } - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/internal/subscription/SubscriptionNormalizedCacheTest.kt b/apollo-integration/src/test/java/com/apollographql/apollo/internal/subscription/SubscriptionNormalizedCacheTest.kt deleted file mode 100644 index e7ff6694fdb..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/internal/subscription/SubscriptionNormalizedCacheTest.kt +++ /dev/null @@ -1,275 +0,0 @@ -package com.apollographql.apollo.internal.subscription - -import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.ApolloSubscriptionCall -import com.apollographql.apollo.IdFieldCacheKeyResolver -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.cache.normalized.NormalizedCache -import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy -import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory -import com.apollographql.apollo.exception.ApolloException -import com.apollographql.apollo.integration.subscription.NewRepoCommentSubscription -import com.apollographql.apollo.subscription.OperationClientMessage -import com.apollographql.apollo.subscription.OperationServerMessage -import com.apollographql.apollo.subscription.SubscriptionTransport -import com.google.common.truth.Truth.assertThat -import org.junit.Before -import org.junit.Test -import java.math.BigDecimal -import java.util.concurrent.AbstractExecutorService -import java.util.concurrent.TimeUnit - -class SubscriptionNormalizedCacheTest { - private lateinit var subscriptionTransportFactory: MockSubscriptionTransportFactory - private lateinit var apolloClient: ApolloClient - private lateinit var subscriptionCall: ApolloSubscriptionCall - private lateinit var networkOperationData: Map - - @Before - fun setUp() { - subscriptionTransportFactory = MockSubscriptionTransportFactory() - apolloClient = ApolloClient.builder() - .serverUrl("http://google.com") - .dispatcher(TrampolineExecutor()) - .subscriptionTransportFactory(subscriptionTransportFactory) - .normalizedCache(LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION), IdFieldCacheKeyResolver()) - .build() - subscriptionCall = apolloClient.subscribe(NewRepoCommentSubscription("repo")) - networkOperationData = mapOf( - "data" to mapOf( - "commentAdded" to mapOf( - "__typename" to "Comment", - "id" to BigDecimal(100), - "content" to "Network comment content", - "postedBy" to mapOf( - "__typename" to "User", - "login" to "user@user.com" - ) - ) - ) - ) - } - - @Test - fun `when no cache policy then response not cached`() { - val callback = SubscriptionManagerCallbackAdapter() - subscriptionCall.execute(callback) - - with(subscriptionTransportFactory.callback!!) { - onConnected() - onMessage(OperationServerMessage.ConnectionAcknowledge()) - } - - val uuid = (apolloClient.subscriptionManager as RealSubscriptionManager).subscriptions.keys.first() - subscriptionTransportFactory.callback?.onMessage( - OperationServerMessage.Data(uuid.toString(), networkOperationData) - ) - - callback.response.assertResponse( - expectedFromCache = false, - expectedContent = "Network comment content" - ) - - val cacheDump = apolloClient.apolloStore.normalizedCache().dump() - assertThat(NormalizedCache.prettifyDump(cacheDump)).isEqualTo(""" - OptimisticNormalizedCache {} - LruNormalizedCache {} - - """.trimIndent()) - } - - @Test - fun `when network only cache policy then response is cached`() { - val operation = NewRepoCommentSubscription("repo") - val data = NewRepoCommentSubscription.Data( - NewRepoCommentSubscription.CommentAdded( - "Comment", 100, "Cached comment content", NewRepoCommentSubscription.PostedBy("User", "user@user.com") - ) - ) - apolloClient.apolloStore.write(operation, data).execute() - - val callback = SubscriptionManagerCallbackAdapter() - subscriptionCall.cachePolicy(ApolloSubscriptionCall.CachePolicy.NETWORK_ONLY).execute(callback) - - with(subscriptionTransportFactory.callback!!) { - onConnected() - onMessage(OperationServerMessage.ConnectionAcknowledge()) - } - - val uuid = (apolloClient.subscriptionManager as RealSubscriptionManager).subscriptions.keys.first() - subscriptionTransportFactory.callback?.onMessage( - OperationServerMessage.Data(uuid.toString(), networkOperationData) - ) - - callback.response.assertResponse( - expectedFromCache = false, - expectedContent = "Network comment content" - ) - - val cacheDump = apolloClient.apolloStore.normalizedCache().dump() - assertThat(NormalizedCache.prettifyDump(cacheDump)).isEqualTo(""" - OptimisticNormalizedCache {} - LruNormalizedCache { - "100" : { - "__typename" : Comment - "id" : 100 - "content" : Network comment content - "postedBy" : CacheRecordRef(100.postedBy) - } - - "QUERY_ROOT" : { - "commentAdded({"repoFullName":"repo"})" : CacheRecordRef(100) - } - - "100.postedBy" : { - "__typename" : User - "login" : user@user.com - } - } - - """.trimIndent()) - } - - @Test - fun `when cache and network policy then first response from cache next one from network`() { - val operation = NewRepoCommentSubscription("repo") - val data = NewRepoCommentSubscription.Data( - NewRepoCommentSubscription.CommentAdded( - "Comment", 100, "Cached comment content", NewRepoCommentSubscription.PostedBy("User", "user@user.com") - ) - ) - apolloClient.apolloStore.write(operation, data).execute() - - val callback = SubscriptionManagerCallbackAdapter() - subscriptionCall.cachePolicy(ApolloSubscriptionCall.CachePolicy.CACHE_AND_NETWORK).execute(callback) - - callback.response.assertResponse( - expectedFromCache = true, - expectedContent = "Cached comment content" - ) - - subscriptionTransportFactory.callback?.onConnected() - subscriptionTransportFactory.callback?.onMessage(OperationServerMessage.ConnectionAcknowledge()) - - val uuid = (apolloClient.subscriptionManager as RealSubscriptionManager).subscriptions.keys.first() - subscriptionTransportFactory.callback?.onMessage( - OperationServerMessage.Data(uuid.toString(), networkOperationData) - ) - - callback.response.assertResponse( - expectedFromCache = false, - expectedContent = "Network comment content" - ) - - val cacheDump = apolloClient.apolloStore.normalizedCache().dump() - assertThat(NormalizedCache.prettifyDump(cacheDump)).isEqualTo(""" - OptimisticNormalizedCache {} - LruNormalizedCache { - "100" : { - "__typename" : Comment - "id" : 100 - "content" : Network comment content - "postedBy" : CacheRecordRef(100.postedBy) - } - - "QUERY_ROOT" : { - "commentAdded({"repoFullName":"repo"})" : CacheRecordRef(100) - } - - "100.postedBy" : { - "__typename" : User - "login" : user@user.com - } - } - - """.trimIndent()) - } - - private fun Response?.assertResponse(expectedFromCache: Boolean, expectedContent: String) { - assertThat(this).isNotNull() - assertThat(this!!.fromCache).isEqualTo(expectedFromCache) - assertThat(data).isNotNull() - with(data!!) { - assertThat(commentAdded()!!.id()).isEqualTo(100) - assertThat(commentAdded()!!.content()).isEqualTo(expectedContent) - assertThat(commentAdded()!!.postedBy()!!.login()).isEqualTo("user@user.com") - } - } -} - -private class TrampolineExecutor : AbstractExecutorService() { - override fun shutdown() {} - - override fun shutdownNow(): List { - return emptyList() - } - - override fun isShutdown(): Boolean { - return false - } - - override fun isTerminated(): Boolean { - return false - } - - override fun awaitTermination(l: Long, timeUnit: TimeUnit): Boolean { - return false - } - - override fun execute(runnable: Runnable) { - runnable.run() - } -} - -private class MockSubscriptionTransportFactory : SubscriptionTransport.Factory { - var subscriptionTransport: MockSubscriptionTransport? = null - var callback: SubscriptionTransport.Callback? = null - - override fun create(callback: SubscriptionTransport.Callback): SubscriptionTransport { - this.callback = callback - return MockSubscriptionTransport().also { subscriptionTransport = it } - } -} - -private class MockSubscriptionTransport : SubscriptionTransport { - var lastSentMessage: OperationClientMessage? = null - var disconnectMessage: OperationClientMessage? = null - - override fun connect() { - } - - override fun disconnect(message: OperationClientMessage) { - disconnectMessage = message - } - - override fun send(message: OperationClientMessage) { - lastSentMessage = message - } -} - -private class SubscriptionManagerCallbackAdapter : ApolloSubscriptionCall.Callback { - var response: Response? = null - var completed = false - var terminated = false - var connected = false - - override fun onResponse(response: Response) { - this.response = response - } - - override fun onFailure(e: ApolloException) { - throw UnsupportedOperationException() - } - - override fun onCompleted() { - completed = true - } - - override fun onTerminated() { - terminated = true - } - - override fun onConnected() { - connected = true - } -} diff --git a/apollo-integration/src/test/java/com/apollographql/apollo/performance/NumberParsingTest.kt b/apollo-integration/src/test/java/com/apollographql/apollo/performance/NumberParsingTest.kt deleted file mode 100644 index ffa772410fa..00000000000 --- a/apollo-integration/src/test/java/com/apollographql/apollo/performance/NumberParsingTest.kt +++ /dev/null @@ -1,89 +0,0 @@ -package com.apollographql.apollo.performance - -import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.Utils.immediateExecutor -import com.apollographql.apollo.Utils.immediateExecutorService -import com.apollographql.apollo.api.internal.SimpleOperationResponseParser -import com.apollographql.apollo.api.internal.json.JsonWriter -import com.apollographql.apollo.fetcher.ApolloResponseFetchers -import com.apollographql.apollo.integration.performance.GetFloatsQuery -import com.apollographql.apollo.integration.performance.GetIntsQuery -import kotlinx.coroutines.runBlocking -import okhttp3.Dispatcher -import okhttp3.OkHttpClient -import okio.Buffer -import okio.ByteString -import okio.ByteString.Companion.encodeUtf8 -import kotlin.random.Random -import kotlin.test.Test -import kotlin.time.ExperimentalTime -import kotlin.time.measureTime - -data class Data( - val randomInts: List -) - -/** - * These tests are disabled by default. Set the `runPerformanceTests` property to run them: - * ./gradlew :apollo-integration:testDebug --tests '*parseFloats*' -DrunPerformanceTests=true - */ -@OptIn(ExperimentalTime::class) -class NumberParsingTest { - private fun mockJson(block: (JsonWriter) -> Unit): ByteString { - val buffer = Buffer() - val writer = JsonWriter.of(buffer) - writer.beginObject() - writer.name("data") - writer.beginObject() - writer.name("randomFloats") - writer.beginArray() - repeat(10000) { - block(writer) - } - writer.endArray() - writer.endObject() - writer.endObject() - - return buffer.readByteString() - } - - /** - * A test to benchmark the parsing of integers in Json. - */ - @Test - fun parseInts() { - val random = Random.Default - val json = mockJson { it.jsonValue(random.nextDouble().toString()) } - - val time = measureTime { - val operation = GetIntsQuery() - repeat(10000) { - operation.parse(json) - } - } - println("parseInts: ${time}") - } - - /** - * A test to benchmark the parsing of floats in Json. At the time of writing, it takes ~21s on my MacBook - * - * From the first tests, Switching to Double instead of BigDecimal isn't way faster but makes a bit less allocations - * Number of GC is down to 228 with Double (from 274 with BigDecimal) so it might be worth at some point. - */ - @Test - fun parseFloats() { - - val random = Random.Default - val json = mockJson { it.jsonValue(random.nextDouble().toString()) } - - Runtime.getRuntime().gc() - val time = measureTime { - val operation = GetFloatsQuery() - repeat(4000) { - operation.parse(json) - } - } - Runtime.getRuntime().gc() - println("parseFloats: ${time}") - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/resources/AllPlanetsListOfObjectWithNullObject.json b/apollo-integration/src/test/resources/AllPlanetsListOfObjectWithNullObject.json deleted file mode 100644 index 02241807bcd..00000000000 --- a/apollo-integration/src/test/resources/AllPlanetsListOfObjectWithNullObject.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "data": { - "allPlanets": { - "__typename": "PlanetsConnection", - "planets": [ - { - "__typename": "Planet", - "name": "Tatooine", - "climates": [ - "arid" - ], - "surfaceWater": 1, - "filmConnection": null - }, - { - "__typename": "Planet", - "name": "Alderaan", - "climates": [ - "temperate" - ], - "surfaceWater": 40, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 2, - "films": [ - { - "__typename": "Film", - "title": "A New Hope", - "producers": [ - "Gary Kurtz", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - } - ] - } - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/resources/AllPlanetsNullableField.json b/apollo-integration/src/test/resources/AllPlanetsNullableField.json deleted file mode 100644 index 78c2b1e540d..00000000000 --- a/apollo-integration/src/test/resources/AllPlanetsNullableField.json +++ /dev/null @@ -1,1073 +0,0 @@ -{ - "data": { - "allPlanets": { - "__typename": "PlanetsConnection", - "planets": [ - { - "__typename": "Planet", - "name": "Tatooine", - "climates": [ - "arid" - ], - "surfaceWater": 1, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 5, - "films": [ - { - "__typename": "Film", - "title": "A New Hope", - "producers": [ - "Gary Kurtz", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Return of the Jedi", - "producers": [ - "Howard G. Kazanjian", - "George Lucas", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "The Phantom Menace", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Attack of the Clones", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Alderaan", - "climates": [ - "temperate" - ], - "surfaceWater": 40, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 2, - "films": [ - { - "__typename": "Film", - "title": "A New Hope", - "producers": [ - "Gary Kurtz", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Yavin IV", - "climates": [ - "temperate", - "tropical" - ], - "surfaceWater": 8, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "A New Hope", - "producers": [ - "Gary Kurtz", - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Hoth", - "climates": [ - "frozen" - ], - "surfaceWater": 100, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "The Empire Strikes Back", - "producers": [ - "Gary Kutz", - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Dagobah", - "climates": [ - "murky" - ], - "surfaceWater": 8, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 3, - "films": [ - { - "__typename": "Film", - "title": "The Empire Strikes Back", - "producers": [ - "Gary Kutz", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Return of the Jedi", - "producers": [ - "Howard G. Kazanjian", - "George Lucas", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Bespin", - "climates": [ - "temperate" - ], - "surfaceWater": 0, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "The Empire Strikes Back", - "producers": [ - "Gary Kutz", - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Endor", - "climates": [ - "temperate" - ], - "surfaceWater": 8, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Return of the Jedi", - "producers": [ - "Howard G. Kazanjian", - "George Lucas", - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Naboo", - "climates": [ - "temperate" - ], - "surfaceWater": 12, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 4, - "films": [ - { - "__typename": "Film", - "title": "Return of the Jedi", - "producers": [ - "Howard G. Kazanjian", - "George Lucas", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "The Phantom Menace", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Attack of the Clones", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Coruscant", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 4, - "films": [ - { - "__typename": "Film", - "title": "Return of the Jedi", - "producers": [ - "Howard G. Kazanjian", - "George Lucas", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "The Phantom Menace", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Attack of the Clones", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Kamino", - "climates": [ - "temperate" - ], - "surfaceWater": 100, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Attack of the Clones", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Geonosis", - "climates": [ - "temperate", - "arid" - ], - "surfaceWater": 5, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Attack of the Clones", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Utapau", - "climates": [ - "temperate", - "arid", - "windy" - ], - "surfaceWater": 0.9, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Mustafar", - "climates": [ - "hot" - ], - "surfaceWater": 0, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Kashyyyk", - "climates": [ - "tropical" - ], - "surfaceWater": 60, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Polis Massa", - "climates": [ - "artificial temperate" - ], - "surfaceWater": 0, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Mygeeto", - "climates": [ - "frigid" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Felucia", - "climates": [ - "hot", - "humid" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Cato Neimoidia", - "climates": [ - "temperate", - "moist" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Saleucami", - "climates": [ - "hot" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Stewjon", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Eriadu", - "climates": [ - "polluted" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Corellia", - "climates": [ - "temperate" - ], - "surfaceWater": 70, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Rodia", - "climates": [ - "hot" - ], - "surfaceWater": 60, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Nal Hutta", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Dantooine", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Bestine IV", - "climates": [ - "temperate" - ], - "surfaceWater": 98, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Ord Mantell", - "climates": [ - "temperate" - ], - "surfaceWater": 10, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "The Empire Strikes Back", - "producers": [ - "Gary Kutz", - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "unknown", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Trandosha", - "climates": [ - "arid" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Socorro", - "climates": [ - "arid" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Mon Cala", - "climates": [ - "temperate" - ], - "surfaceWater": 100, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Chandrila", - "climates": [ - "temperate" - ], - "surfaceWater": 40, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Sullust", - "climates": [ - "superheated" - ], - "surfaceWater": 5, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Toydaria", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Malastare", - "climates": [ - "arid", - "temperate", - "tropical" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Dathomir", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Ryloth", - "climates": [ - "temperate", - "arid", - "subartic" - ], - "surfaceWater": 5, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Aleen Minor", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Vulpter", - "climates": [ - "temperate", - "artic" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Troiken", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Tund", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Haruun Kal", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Cerea", - "climates": [ - "temperate" - ], - "surfaceWater": 20, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Glee Anselm", - "climates": [ - "tropical", - "temperate" - ], - "surfaceWater": 80, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Iridonia", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Tholoth", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Iktotch", - "climates": [ - "arid", - "rocky", - "windy" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Quermia", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Dorin", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Champala", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Mirial", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Serenno", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Concord Dawn", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Zolan", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Ojom", - "climates": [ - "frigid" - ], - "surfaceWater": 100, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Skako", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Muunilinst", - "climates": [ - "temperate" - ], - "surfaceWater": 25, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Shili", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Kalee", - "climates": [ - "arid", - "temperate", - "tropical" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Umbara", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - } - ] - } - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/resources/CreateReviewResponse.json b/apollo-integration/src/test/resources/CreateReviewResponse.json deleted file mode 100644 index 94e5a8e5dea..00000000000 --- a/apollo-integration/src/test/resources/CreateReviewResponse.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "data": { - "createReview": { - "__typename": "Review", - "id" : "review6", - "stars": 5, - "commentary": "Awesome" - } - } -} diff --git a/apollo-integration/src/test/resources/EpisodeHeroNameResponse.json b/apollo-integration/src/test/resources/EpisodeHeroNameResponse.json deleted file mode 100644 index fbdf24a63d6..00000000000 --- a/apollo-integration/src/test/resources/EpisodeHeroNameResponse.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "name": "R2-D2" - } - } -} diff --git a/apollo-integration/src/test/resources/EpisodeHeroNameResponseNameChange.json b/apollo-integration/src/test/resources/EpisodeHeroNameResponseNameChange.json deleted file mode 100644 index c479f59d08e..00000000000 --- a/apollo-integration/src/test/resources/EpisodeHeroNameResponseNameChange.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "id": "2001", - "name": "Artoo" - } - } -} diff --git a/apollo-integration/src/test/resources/EpisodeHeroNameResponseNameChangeTwo.json b/apollo-integration/src/test/resources/EpisodeHeroNameResponseNameChangeTwo.json deleted file mode 100644 index e8f2a7ef1f5..00000000000 --- a/apollo-integration/src/test/resources/EpisodeHeroNameResponseNameChangeTwo.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "id": "2001", - "name": "ArTwo" - } - } -} diff --git a/apollo-integration/src/test/resources/EpisodeHeroNameResponseWithId.json b/apollo-integration/src/test/resources/EpisodeHeroNameResponseWithId.json deleted file mode 100644 index e69a011147c..00000000000 --- a/apollo-integration/src/test/resources/EpisodeHeroNameResponseWithId.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "id": "2001", - "name": "R2-D2" - } - } -} diff --git a/apollo-integration/src/test/resources/EpisodeHeroWithDatesResponse.json b/apollo-integration/src/test/resources/EpisodeHeroWithDatesResponse.json deleted file mode 100644 index 9d20a53a97e..00000000000 --- a/apollo-integration/src/test/resources/EpisodeHeroWithDatesResponse.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "heroName": "R2-D2", - "birthDate": "1984-04-16", - "showUpDates": [ - "2017-01-16", - "2017-02-16", - "2017-03-16" - ] - } - } -} diff --git a/apollo-integration/src/test/resources/EpisodeHeroWithInlineFragmentResponse.json b/apollo-integration/src/test/resources/EpisodeHeroWithInlineFragmentResponse.json deleted file mode 100644 index 867802c5013..00000000000 --- a/apollo-integration/src/test/resources/EpisodeHeroWithInlineFragmentResponse.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "name": "R2-D2", - "friends": [ - { - "__typename": "Human", - "id": "1000", - "name": "Luke Skywalker", - "height": 1.5 - }, - { - "__typename": "Droid", - "name": "Android", - "primaryFunction": "Hunt and destroy iOS devices" - }, - { - "__typename": "Droid", - "name": "Battle Droid", - "primaryFunction": "Controlled alternative to human soldiers" - } - ] - } - } -} diff --git a/apollo-integration/src/test/resources/HeroAndFriendsNameResponse.json b/apollo-integration/src/test/resources/HeroAndFriendsNameResponse.json deleted file mode 100644 index a7822134622..00000000000 --- a/apollo-integration/src/test/resources/HeroAndFriendsNameResponse.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "name": "R2-D2", - "friends": [ - { - "__typename": "Human", - "name": "Luke Skywalker" - }, - { - "__typename": "Human", - "name": "Han Solo" - }, - { - "__typename": "Human", - "name": "Leia Organa" - } - ] - } - } -} diff --git a/apollo-integration/src/test/resources/HeroAndFriendsNameWithIdsNameChange.json b/apollo-integration/src/test/resources/HeroAndFriendsNameWithIdsNameChange.json deleted file mode 100644 index 25b90baaa8f..00000000000 --- a/apollo-integration/src/test/resources/HeroAndFriendsNameWithIdsNameChange.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Human", - "id": "1000", - "name": "Luke Skywalker", - "friends": [ - { - "__typename": "Droid", - "id": "2001", - "name": "Artoo" - }, - { - "__typename": "Human", - "id": "1002", - "name": "Han Solo" - }, - { - "__typename": "Human", - "id": "1003", - "name": "Leia Organa" - } - ] - } - } -} diff --git a/apollo-integration/src/test/resources/HeroAndFriendsNameWithIdsParentOnlyResponse.json b/apollo-integration/src/test/resources/HeroAndFriendsNameWithIdsParentOnlyResponse.json deleted file mode 100644 index 7e510e96d8b..00000000000 --- a/apollo-integration/src/test/resources/HeroAndFriendsNameWithIdsParentOnlyResponse.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "id": "2001", - "name": "R2-D2", - "friends": [ - { - "__typename": "Human", - "name": "Luke Skywalker" - }, - { - "__typename": "Human", - "name": "Han Solo" - }, - { - "__typename": "Human", - "name": "Leia Organa" - } - ] - } - } -} diff --git a/apollo-integration/src/test/resources/HeroAndFriendsNameWithIdsResponse.json b/apollo-integration/src/test/resources/HeroAndFriendsNameWithIdsResponse.json deleted file mode 100644 index 9fa71b226df..00000000000 --- a/apollo-integration/src/test/resources/HeroAndFriendsNameWithIdsResponse.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "id": "2001", - "name": "R2-D2", - "friends": [ - { - "__typename": "Human", - "id": "1000", - "name": "Luke Skywalker" - }, - { - "__typename": "Human", - "id": "1002", - "name": "Han Solo" - }, - { - "__typename": "Human", - "id": "1003", - "name": "Leia Organa" - } - ] - } - } -} diff --git a/apollo-integration/src/test/resources/HeroAndFriendsWithFragmentResponse.json b/apollo-integration/src/test/resources/HeroAndFriendsWithFragmentResponse.json deleted file mode 100644 index 9fa71b226df..00000000000 --- a/apollo-integration/src/test/resources/HeroAndFriendsWithFragmentResponse.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "id": "2001", - "name": "R2-D2", - "friends": [ - { - "__typename": "Human", - "id": "1000", - "name": "Luke Skywalker" - }, - { - "__typename": "Human", - "id": "1002", - "name": "Han Solo" - }, - { - "__typename": "Human", - "id": "1003", - "name": "Leia Organa" - } - ] - } - } -} diff --git a/apollo-integration/src/test/resources/HeroAppearsInResponse.json b/apollo-integration/src/test/resources/HeroAppearsInResponse.json deleted file mode 100644 index ba257ab32e8..00000000000 --- a/apollo-integration/src/test/resources/HeroAppearsInResponse.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Human", - "appearsIn": [ - "NEWHOPE", - "EMPIRE", - "JEDI" - ] - } - } -} diff --git a/apollo-integration/src/test/resources/HeroAppearsInResponseWithNulls.json b/apollo-integration/src/test/resources/HeroAppearsInResponseWithNulls.json deleted file mode 100644 index 5934160b179..00000000000 --- a/apollo-integration/src/test/resources/HeroAppearsInResponseWithNulls.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Human", - "appearsIn": [ - null, - "NEWHOPE", - "EMPIRE", - null, - "JEDI", - null - ] - } - } -} diff --git a/apollo-integration/src/test/resources/HeroNameResponse.json b/apollo-integration/src/test/resources/HeroNameResponse.json deleted file mode 100644 index 220b90e7658..00000000000 --- a/apollo-integration/src/test/resources/HeroNameResponse.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "name": "R2-D2" - } - }, - "extensions": { - "cost": { - "requestedQueryCost": 3, - "actualQueryCost": 3, - "throttleStatus": { - "maximumAvailable": 1000, - "currentlyAvailable": 997, - "restoreRate": 50 - } - } - } -} diff --git a/apollo-integration/src/test/resources/HeroNameWithEnumsResponse.json b/apollo-integration/src/test/resources/HeroNameWithEnumsResponse.json deleted file mode 100644 index e3f5b4864dc..00000000000 --- a/apollo-integration/src/test/resources/HeroNameWithEnumsResponse.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "name": "R2-D2", - "firstAppearsIn": "EMPIRE", - "appearsIn": [ - "NEWHOPE", - "EMPIRE", - "JEDI" - ] - } - } -} diff --git a/apollo-integration/src/test/resources/HeroNameWithIdResponse.json b/apollo-integration/src/test/resources/HeroNameWithIdResponse.json deleted file mode 100644 index 2c115c71a20..00000000000 --- a/apollo-integration/src/test/resources/HeroNameWithIdResponse.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Human", - "id": "1000", - "name": "SuperMan" - } - } -} diff --git a/apollo-integration/src/test/resources/HeroParentTypeDependentFieldDroidResponse.json b/apollo-integration/src/test/resources/HeroParentTypeDependentFieldDroidResponse.json deleted file mode 100644 index 8dd725ea7b2..00000000000 --- a/apollo-integration/src/test/resources/HeroParentTypeDependentFieldDroidResponse.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "data": { - "hero": { - "name": "R2-D2", - "__typename": "Droid", - "friends": [ - { - "__typename": "Human", - "name": "Luke Skywalker", - "height": 1.72 - }, - { - "__typename": "Human", - "name": "Han Solo", - "height": 1.8 - }, - { - "__typename": "Human", - "name": "Leia Organa", - "height": 1.5 - } - ] - } - } -} diff --git a/apollo-integration/src/test/resources/HeroParentTypeDependentFieldHumanResponse.json b/apollo-integration/src/test/resources/HeroParentTypeDependentFieldHumanResponse.json deleted file mode 100644 index 6a5c7fbdbdd..00000000000 --- a/apollo-integration/src/test/resources/HeroParentTypeDependentFieldHumanResponse.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "data": { - "hero": { - "name": "Luke Skywalker", - "__typename": "Human", - "friends": [ - { - "__typename": "Human", - "name": "Han Solo", - "height": 5.905512 - }, - { - "__typename": "Human", - "name": "Leia Organa", - "height": 4.92126 - }, - { - "__typename": "Droid", - "name": "C-3PO" - }, - { - "__typename": "Droid", - "name": "R2-D2" - } - ] - } - } -} diff --git a/apollo-integration/src/test/resources/HeroTypeDependentAliasedFieldResponse.json b/apollo-integration/src/test/resources/HeroTypeDependentAliasedFieldResponse.json deleted file mode 100644 index c4abfde0886..00000000000 --- a/apollo-integration/src/test/resources/HeroTypeDependentAliasedFieldResponse.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "property": "Astromech" - } - } -} diff --git a/apollo-integration/src/test/resources/HeroTypeDependentAliasedFieldResponseHuman.json b/apollo-integration/src/test/resources/HeroTypeDependentAliasedFieldResponseHuman.json deleted file mode 100644 index 2690b25efd6..00000000000 --- a/apollo-integration/src/test/resources/HeroTypeDependentAliasedFieldResponseHuman.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Human", - "property": "Tatooine" - } - } -} diff --git a/apollo-integration/src/test/resources/HeroTypeDependentFieldResponseDroid.json b/apollo-integration/src/test/resources/HeroTypeDependentFieldResponseDroid.json deleted file mode 100644 index ba414a2f548..00000000000 --- a/apollo-integration/src/test/resources/HeroTypeDependentFieldResponseDroid.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "name": "R2-D2", - "friends": [ - { - "__typename": "Human", - "name": "Luke Skywalker", - "height": 1.72 - }, - { - "__typename": "Human", - "name": "Han Solo", - "height": 1.8 - }, - { - "__typename": "Human", - "name": "Leia Organa", - "height": 1.5 - } - ] - } - } -} diff --git a/apollo-integration/src/test/resources/HttpCacheTestAllFilms.json b/apollo-integration/src/test/resources/HttpCacheTestAllFilms.json deleted file mode 100644 index 967addfc727..00000000000 --- a/apollo-integration/src/test/resources/HttpCacheTestAllFilms.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "data": { - "allFilms": { - "__typename": "FilmsConnection", - "totalCount": 6, - "films": [ - { - "__typename": "Film", - "title": "A New Hope", - "releaseDate": "1977-05-25" - }, - { - "__typename": "Film", - "title": "The Empire Strikes Back", - "releaseDate": "1980-05-17" - }, - { - "__typename": "Film", - "title": "Return of the Jedi", - "releaseDate": "1983-05-25" - }, - { - "__typename": "Film", - "title": "The Phantom Menace", - "releaseDate": "1999-05-19" - }, - { - "__typename": "Film", - "title": "Attack of the Clones", - "releaseDate": "2002-05-16" - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "releaseDate": "2005-05-19" - } - ] - } - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/resources/HttpCacheTestAllPlanets.json b/apollo-integration/src/test/resources/HttpCacheTestAllPlanets.json deleted file mode 100644 index 78c2b1e540d..00000000000 --- a/apollo-integration/src/test/resources/HttpCacheTestAllPlanets.json +++ /dev/null @@ -1,1073 +0,0 @@ -{ - "data": { - "allPlanets": { - "__typename": "PlanetsConnection", - "planets": [ - { - "__typename": "Planet", - "name": "Tatooine", - "climates": [ - "arid" - ], - "surfaceWater": 1, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 5, - "films": [ - { - "__typename": "Film", - "title": "A New Hope", - "producers": [ - "Gary Kurtz", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Return of the Jedi", - "producers": [ - "Howard G. Kazanjian", - "George Lucas", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "The Phantom Menace", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Attack of the Clones", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Alderaan", - "climates": [ - "temperate" - ], - "surfaceWater": 40, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 2, - "films": [ - { - "__typename": "Film", - "title": "A New Hope", - "producers": [ - "Gary Kurtz", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Yavin IV", - "climates": [ - "temperate", - "tropical" - ], - "surfaceWater": 8, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "A New Hope", - "producers": [ - "Gary Kurtz", - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Hoth", - "climates": [ - "frozen" - ], - "surfaceWater": 100, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "The Empire Strikes Back", - "producers": [ - "Gary Kutz", - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Dagobah", - "climates": [ - "murky" - ], - "surfaceWater": 8, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 3, - "films": [ - { - "__typename": "Film", - "title": "The Empire Strikes Back", - "producers": [ - "Gary Kutz", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Return of the Jedi", - "producers": [ - "Howard G. Kazanjian", - "George Lucas", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Bespin", - "climates": [ - "temperate" - ], - "surfaceWater": 0, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "The Empire Strikes Back", - "producers": [ - "Gary Kutz", - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Endor", - "climates": [ - "temperate" - ], - "surfaceWater": 8, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Return of the Jedi", - "producers": [ - "Howard G. Kazanjian", - "George Lucas", - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Naboo", - "climates": [ - "temperate" - ], - "surfaceWater": 12, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 4, - "films": [ - { - "__typename": "Film", - "title": "Return of the Jedi", - "producers": [ - "Howard G. Kazanjian", - "George Lucas", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "The Phantom Menace", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Attack of the Clones", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Coruscant", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 4, - "films": [ - { - "__typename": "Film", - "title": "Return of the Jedi", - "producers": [ - "Howard G. Kazanjian", - "George Lucas", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "The Phantom Menace", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Attack of the Clones", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Kamino", - "climates": [ - "temperate" - ], - "surfaceWater": 100, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Attack of the Clones", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Geonosis", - "climates": [ - "temperate", - "arid" - ], - "surfaceWater": 5, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Attack of the Clones", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Utapau", - "climates": [ - "temperate", - "arid", - "windy" - ], - "surfaceWater": 0.9, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Mustafar", - "climates": [ - "hot" - ], - "surfaceWater": 0, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Kashyyyk", - "climates": [ - "tropical" - ], - "surfaceWater": 60, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Polis Massa", - "climates": [ - "artificial temperate" - ], - "surfaceWater": 0, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Mygeeto", - "climates": [ - "frigid" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Felucia", - "climates": [ - "hot", - "humid" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Cato Neimoidia", - "climates": [ - "temperate", - "moist" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Saleucami", - "climates": [ - "hot" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "Stewjon", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Eriadu", - "climates": [ - "polluted" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Corellia", - "climates": [ - "temperate" - ], - "surfaceWater": 70, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Rodia", - "climates": [ - "hot" - ], - "surfaceWater": 60, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Nal Hutta", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Dantooine", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Bestine IV", - "climates": [ - "temperate" - ], - "surfaceWater": 98, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Ord Mantell", - "climates": [ - "temperate" - ], - "surfaceWater": 10, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "The Empire Strikes Back", - "producers": [ - "Gary Kutz", - "Rick McCallum" - ] - } - ] - } - }, - { - "__typename": "Planet", - "name": "unknown", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Trandosha", - "climates": [ - "arid" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Socorro", - "climates": [ - "arid" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Mon Cala", - "climates": [ - "temperate" - ], - "surfaceWater": 100, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Chandrila", - "climates": [ - "temperate" - ], - "surfaceWater": 40, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Sullust", - "climates": [ - "superheated" - ], - "surfaceWater": 5, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Toydaria", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Malastare", - "climates": [ - "arid", - "temperate", - "tropical" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Dathomir", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Ryloth", - "climates": [ - "temperate", - "arid", - "subartic" - ], - "surfaceWater": 5, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Aleen Minor", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Vulpter", - "climates": [ - "temperate", - "artic" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Troiken", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Tund", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Haruun Kal", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Cerea", - "climates": [ - "temperate" - ], - "surfaceWater": 20, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Glee Anselm", - "climates": [ - "tropical", - "temperate" - ], - "surfaceWater": 80, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Iridonia", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Tholoth", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Iktotch", - "climates": [ - "arid", - "rocky", - "windy" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Quermia", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Dorin", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Champala", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Mirial", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Serenno", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Concord Dawn", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Zolan", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Ojom", - "climates": [ - "frigid" - ], - "surfaceWater": 100, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Skako", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Muunilinst", - "climates": [ - "temperate" - ], - "surfaceWater": 25, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Shili", - "climates": [ - "temperate" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Kalee", - "climates": [ - "arid", - "temperate", - "tropical" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - }, - { - "__typename": "Planet", - "name": "Umbara", - "climates": [ - "unknown" - ], - "surfaceWater": null, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - } - } - ] - } - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/resources/HttpCacheTestAllPlanets2.json b/apollo-integration/src/test/resources/HttpCacheTestAllPlanets2.json deleted file mode 100644 index 91913c1dee5..00000000000 --- a/apollo-integration/src/test/resources/HttpCacheTestAllPlanets2.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "data": { - "allPlanets": { - "__typename": "PlanetsConnection", - "planets": [ - { - "__typename": "Planet", - "name": "Tatooine", - "climates": [ - "arid" - ], - "surfaceWater": 1, - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 5, - "films": [ - { - "__typename": "Film", - "title": "A New Hope", - "producers": [ - "Gary Kurtz", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Return of the Jedi", - "producers": [ - "Howard G. Kazanjian", - "George Lucas", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "The Phantom Menace", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Attack of the Clones", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - } - } - ] - } - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/resources/HttpCacheTestDroidDetails.json b/apollo-integration/src/test/resources/HttpCacheTestDroidDetails.json deleted file mode 100644 index cdde32eb744..00000000000 --- a/apollo-integration/src/test/resources/HttpCacheTestDroidDetails.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "data": { - "species": { - "__typename": "Species", - "id": "c3BlY2llczoy", - "name": "Droid", - "filmConnection": { - "__typename": "SpeciesFilmsConnection", - "edges": [ - { - "__typename": "SpeciesFilmsEdge", - "node": { - "__typename": "Film", - "id": "ZmlsbXM6MQ==", - "title": "A New Hope" - } - }, - { - "__typename": "SpeciesFilmsEdge", - "node": { - "__typename": "Film", - "id": "ZmlsbXM6Mg==", - "title": "The Empire Strikes Back" - } - }, - { - "__typename": "SpeciesFilmsEdge", - "node": { - "__typename": "Film", - "id": "ZmlsbXM6Mw==", - "title": "Return of the Jedi" - } - }, - { - "__typename": "SpeciesFilmsEdge", - "node": { - "__typename": "Film", - "id": "ZmlsbXM6NA==", - "title": "The Phantom Menace" - } - }, - { - "__typename": "SpeciesFilmsEdge", - "node": { - "__typename": "Film", - "id": "ZmlsbXM6NQ==", - "title": "Attack of the Clones" - } - }, - { - "__typename": "SpeciesFilmsEdge", - "node": { - "__typename": "Film", - "id": "ZmlsbXM6Ng==", - "title": "Revenge of the Sith" - } - } - ] - } - } - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/resources/JsonScalar.json b/apollo-integration/src/test/resources/JsonScalar.json deleted file mode 100644 index e4cbc8909a7..00000000000 --- a/apollo-integration/src/test/resources/JsonScalar.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "data": { - "json": { - "obj": { - "key": "value" - }, - "list": [0, 1, 2] - } - } -} diff --git a/apollo-integration/src/test/resources/JsonScalarModified.json b/apollo-integration/src/test/resources/JsonScalarModified.json deleted file mode 100644 index 50a42d7dc65..00000000000 --- a/apollo-integration/src/test/resources/JsonScalarModified.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "data": { - "json": { - "obj": { - "key2": "value2" - } - } - } -} diff --git a/apollo-integration/src/test/resources/OperationJsonWriter.json b/apollo-integration/src/test/resources/OperationJsonWriter.json deleted file mode 100644 index f889c82bf82..00000000000 --- a/apollo-integration/src/test/resources/OperationJsonWriter.json +++ /dev/null @@ -1,992 +0,0 @@ -{ - "data": { - "allPlanets": { - "__typename": "PlanetsConnection", - "planets": [ - { - "__typename": "Planet", - "name": "Tatooine", - "surfaceWater": 1.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 2, - "films": [ - { - "__typename": "Film", - "title": "A New Hope", - "producers": [ - "Gary Kurtz", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - }, - "name": "Alderaan", - "climates": [ - "temperate" - ], - "surfaceWater": 40.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "A New Hope", - "producers": [ - "Gary Kurtz", - "Rick McCallum" - ] - } - ] - }, - "name": "Yavin IV", - "climates": [ - "temperate", - "tropical" - ], - "surfaceWater": 8.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "The Empire Strikes Back", - "producers": [ - "Gary Kutz", - "Rick McCallum" - ] - } - ] - }, - "name": "Hoth", - "climates": [ - "frozen" - ], - "surfaceWater": 100.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 3, - "films": [ - { - "__typename": "Film", - "title": "The Empire Strikes Back", - "producers": [ - "Gary Kutz", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Return of the Jedi", - "producers": [ - "Howard G. Kazanjian", - "George Lucas", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - }, - "name": "Dagobah", - "climates": [ - "murky" - ], - "surfaceWater": 8.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "The Empire Strikes Back", - "producers": [ - "Gary Kutz", - "Rick McCallum" - ] - } - ] - }, - "name": "Bespin", - "climates": [ - "temperate" - ], - "surfaceWater": 0.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Return of the Jedi", - "producers": [ - "Howard G. Kazanjian", - "George Lucas", - "Rick McCallum" - ] - } - ] - }, - "name": "Endor", - "climates": [ - "temperate" - ], - "surfaceWater": 8.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 4, - "films": [ - { - "__typename": "Film", - "title": "Return of the Jedi", - "producers": [ - "Howard G. Kazanjian", - "George Lucas", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "The Phantom Menace", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Attack of the Clones", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - }, - "name": "Naboo", - "climates": [ - "temperate" - ], - "surfaceWater": 12.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 4, - "films": [ - { - "__typename": "Film", - "title": "Return of the Jedi", - "producers": [ - "Howard G. Kazanjian", - "George Lucas", - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "The Phantom Menace", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Attack of the Clones", - "producers": [ - "Rick McCallum" - ] - }, - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - }, - "name": "Coruscant", - "climates": [ - "temperate" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Attack of the Clones", - "producers": [ - "Rick McCallum" - ] - } - ] - }, - "name": "Kamino", - "climates": [ - "temperate" - ], - "surfaceWater": 100.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Attack of the Clones", - "producers": [ - "Rick McCallum" - ] - } - ] - }, - "name": "Geonosis", - "climates": [ - "temperate", - "arid" - ], - "surfaceWater": 5.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - }, - "name": "Utapau", - "climates": [ - "temperate", - "arid", - "windy" - ], - "surfaceWater": 0.9 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - }, - "name": "Mustafar", - "climates": [ - "hot" - ], - "surfaceWater": 0.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - }, - "name": "Kashyyyk", - "climates": [ - "tropical" - ], - "surfaceWater": 60.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - }, - "name": "Polis Massa", - "climates": [ - "artificial temperate" - ], - "surfaceWater": 0.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - }, - "name": "Mygeeto", - "climates": [ - "frigid" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - }, - "name": "Felucia", - "climates": [ - "hot", - "humid" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - }, - "name": "Cato Neimoidia", - "climates": [ - "temperate", - "moist" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "Revenge of the Sith", - "producers": [ - "Rick McCallum" - ] - } - ] - }, - "name": "Saleucami", - "climates": [ - "hot" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Stewjon", - "climates": [ - "temperate" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Eriadu", - "climates": [ - "polluted" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Corellia", - "climates": [ - "temperate" - ], - "surfaceWater": 70.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Rodia", - "climates": [ - "hot" - ], - "surfaceWater": 60.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Nal Hutta", - "climates": [ - "temperate" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Dantooine", - "climates": [ - "temperate" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Bestine IV", - "climates": [ - "temperate" - ], - "surfaceWater": 98.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 1, - "films": [ - { - "__typename": "Film", - "title": "The Empire Strikes Back", - "producers": [ - "Gary Kutz", - "Rick McCallum" - ] - } - ] - }, - "name": "Ord Mantell", - "climates": [ - "temperate" - ], - "surfaceWater": 10.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "unknown", - "climates": [ - "unknown" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Trandosha", - "climates": [ - "arid" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Socorro", - "climates": [ - "arid" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Mon Cala", - "climates": [ - "temperate" - ], - "surfaceWater": 100.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Chandrila", - "climates": [ - "temperate" - ], - "surfaceWater": 40.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Sullust", - "climates": [ - "superheated" - ], - "surfaceWater": 5.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Toydaria", - "climates": [ - "temperate" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Malastare", - "climates": [ - "arid", - "temperate", - "tropical" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Dathomir", - "climates": [ - "temperate" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Ryloth", - "climates": [ - "temperate", - "arid", - "subartic" - ], - "surfaceWater": 5.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Aleen Minor", - "climates": [ - "unknown" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Vulpter", - "climates": [ - "temperate", - "artic" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Troiken", - "climates": [ - "unknown" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Tund", - "climates": [ - "unknown" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Haruun Kal", - "climates": [ - "temperate" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Cerea", - "climates": [ - "temperate" - ], - "surfaceWater": 20.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Glee Anselm", - "climates": [ - "tropical", - "temperate" - ], - "surfaceWater": 80.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Iridonia", - "climates": [ - "unknown" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Tholoth", - "climates": [ - "unknown" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Iktotch", - "climates": [ - "arid", - "rocky", - "windy" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Quermia", - "climates": [ - "unknown" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Dorin", - "climates": [ - "temperate" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Champala", - "climates": [ - "temperate" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Mirial", - "climates": [ - "unknown" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Serenno", - "climates": [ - "unknown" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Concord Dawn", - "climates": [ - "unknown" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Zolan", - "climates": [ - "unknown" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Ojom", - "climates": [ - "frigid" - ], - "surfaceWater": 100.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Skako", - "climates": [ - "temperate" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Muunilinst", - "climates": [ - "temperate" - ], - "surfaceWater": 25.0 - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Shili", - "climates": [ - "temperate" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Kalee", - "climates": [ - "arid", - "temperate", - "tropical" - ] - }, - { - "__typename": "Planet", - "filmConnection": { - "__typename": "PlanetFilmsConnection", - "totalCount": 0, - "films": [] - }, - "name": "Umbara", - "climates": [ - "unknown" - ] - } - ] - } - } -} \ No newline at end of file diff --git a/apollo-integration/src/test/resources/ResponseDataEmpty.json b/apollo-integration/src/test/resources/ResponseDataEmpty.json deleted file mode 100644 index b7741a36458..00000000000 --- a/apollo-integration/src/test/resources/ResponseDataEmpty.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "data": { } -} diff --git a/apollo-integration/src/test/resources/ResponseDataMissing.json b/apollo-integration/src/test/resources/ResponseDataMissing.json deleted file mode 100644 index 26699bbf0d7..00000000000 --- a/apollo-integration/src/test/resources/ResponseDataMissing.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid" - } - } -} diff --git a/apollo-integration/src/test/resources/ResponseDataNull.json b/apollo-integration/src/test/resources/ResponseDataNull.json deleted file mode 100644 index 3356af5ffc5..00000000000 --- a/apollo-integration/src/test/resources/ResponseDataNull.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "data": null -} diff --git a/apollo-integration/src/test/resources/ResponseError.json b/apollo-integration/src/test/resources/ResponseError.json deleted file mode 100644 index 9fecfa9cd35..00000000000 --- a/apollo-integration/src/test/resources/ResponseError.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "errors": [ - { - "message": "Cannot query field \"names\" on type \"Species\".", - "locations": [ - { - "line": 3, - "column": 5 - } - ] - } - ] -} \ No newline at end of file diff --git a/apollo-integration/src/test/resources/ResponseErrorWithCustomAttributes.json b/apollo-integration/src/test/resources/ResponseErrorWithCustomAttributes.json deleted file mode 100644 index d05cdb3bd67..00000000000 --- a/apollo-integration/src/test/resources/ResponseErrorWithCustomAttributes.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "errors": [ - { - "message": "Cannot query field \"names\" on type \"Species\".", - "locations": [ - { - "line": 3, - "column": 5 - } - ], - "code": 500, - "status": "Internal Error", - "fatal": true, - "path":["query"] - } - ] -} \ No newline at end of file diff --git a/apollo-integration/src/test/resources/ResponseErrorWithData.json b/apollo-integration/src/test/resources/ResponseErrorWithData.json deleted file mode 100644 index 327f34e1870..00000000000 --- a/apollo-integration/src/test/resources/ResponseErrorWithData.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "name": "R2-D2" - } - }, - "errors": [ - { - "message": "Cannot query field \"names\" on type \"Species\".", - "locations": [ - { - "line": 3, - "column": 5 - } - ] - } - ] -} \ No newline at end of file diff --git a/apollo-integration/src/test/resources/ResponseErrorWithNullsAndCustomAttributes.json b/apollo-integration/src/test/resources/ResponseErrorWithNullsAndCustomAttributes.json deleted file mode 100644 index a2cc8ae3ac1..00000000000 --- a/apollo-integration/src/test/resources/ResponseErrorWithNullsAndCustomAttributes.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "errors": [ - { - "message": null, - "locations": null, - "code":"userNotFound", - "path":"loginWithPassword" - } - ] -} \ No newline at end of file diff --git a/apollo-integration/src/test/resources/ReviewsEmpireEpisodeResponse.json b/apollo-integration/src/test/resources/ReviewsEmpireEpisodeResponse.json deleted file mode 100644 index e050ab076a7..00000000000 --- a/apollo-integration/src/test/resources/ReviewsEmpireEpisodeResponse.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "data": { - "reviews": [ - { - "__typename": "Review", - "id" : "empireReview1", - "stars": 1, - "commentary": "Boring" - }, - { - "__typename": "Review", - "id" : "empireReview2", - "stars": 2, - "commentary": "So-so" - }, - { - "__typename": "Review", - "id" : "empireReview3", - "stars": 5, - "commentary": "Amazing" - } - ] - } -} diff --git a/apollo-integration/src/test/resources/ReviewsEmpireEpisodeResponseUpdated.json b/apollo-integration/src/test/resources/ReviewsEmpireEpisodeResponseUpdated.json deleted file mode 100644 index e12f4975327..00000000000 --- a/apollo-integration/src/test/resources/ReviewsEmpireEpisodeResponseUpdated.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "data": { - "reviews": [ - { - "__typename": "Review", - "id" : "empireReview1", - "stars": 1, - "commentary": "Boring" - }, - { - "__typename": "Review", - "id" : "empireReview2", - "stars": 2, - "commentary": "So so" - }, - { - "__typename": "Review", - "id" : "empireReview3", - "stars": 5, - "commentary": "Amazing" - }, - { - "__typename": "Review", - "id" : "empireReview4", - "stars": 5, - "commentary": "Awesome" - } - ] - } -} diff --git a/apollo-integration/src/test/resources/ReviewsJediEpisodeResponse.json b/apollo-integration/src/test/resources/ReviewsJediEpisodeResponse.json deleted file mode 100644 index 6f3ba669f65..00000000000 --- a/apollo-integration/src/test/resources/ReviewsJediEpisodeResponse.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "data": { - "reviews": [ - { - "__typename": "Review", - "id" : "jediReview1", - "stars": 5, - "commentary": "Fascinating" - } - ] - } -} diff --git a/apollo-integration/src/test/resources/SameHeroTwiceResponse.json b/apollo-integration/src/test/resources/SameHeroTwiceResponse.json deleted file mode 100644 index a20119a2bf1..00000000000 --- a/apollo-integration/src/test/resources/SameHeroTwiceResponse.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "data": { - "hero": { - "__typename": "Droid", - "name": "R2-D2" - }, - "r2": { - "__typename": "Droid", - "appearsIn": [ - "NEWHOPE", - "EMPIRE", - "JEDI" - ] - } - } -} diff --git a/apollo-integration/src/test/resources/StarshipByIdResponse.json b/apollo-integration/src/test/resources/StarshipByIdResponse.json deleted file mode 100644 index 71c696e0775..00000000000 --- a/apollo-integration/src/test/resources/StarshipByIdResponse.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "data": { - "starship": { - "__typename": "Starship", - "id": "Starship1", - "name": "SuperRocket", - "coordinates": [ - [100, 200], - [300, 400], - [500, 600] - ] - } - } -} diff --git a/apollo-integration/src/test/resources/UpdateReviewResponse.json b/apollo-integration/src/test/resources/UpdateReviewResponse.json deleted file mode 100644 index 1ec964243b8..00000000000 --- a/apollo-integration/src/test/resources/UpdateReviewResponse.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "data": { - "updateReview": { - "__typename": "Review", - "id" : "empireReview2", - "stars": 4, - "commentary": "Not Bad" - } - } -} diff --git a/apollo-normalized-cache-api/api.txt b/apollo-normalized-cache-api/api.txt index d305144dd0f..47799036932 100644 --- a/apollo-normalized-cache-api/api.txt +++ b/apollo-normalized-cache-api/api.txt @@ -1,116 +1,116 @@ // Signature format: 3.0 -package com.apollographql.apollo.cache { +package com.homer.apollographql.apollo.cache { public final class ApolloCacheHeaders { field public static final String DO_NOT_STORE = "do-not-store"; field public static final String EVICT_AFTER_READ = "evict-after-read"; - field public static final com.apollographql.apollo.cache.ApolloCacheHeaders INSTANCE; + field public static final com.homer.apollographql.apollo.cache.ApolloCacheHeaders INSTANCE; field public static final String STORE_PARTIAL_RESPONSES = "store-partial-responses"; } public final class CacheHeaders { - method public static com.apollographql.apollo.cache.CacheHeaders.Builder builder(); + method public static com.homer.apollographql.apollo.cache.CacheHeaders.Builder builder(); method public boolean hasHeader(String headerName); method public String? headerValue(String header); - method public com.apollographql.apollo.cache.CacheHeaders.Builder toBuilder(); - field public static final com.apollographql.apollo.cache.CacheHeaders.Companion Companion; - field public static final com.apollographql.apollo.cache.CacheHeaders NONE; + method public com.homer.apollographql.apollo.cache.CacheHeaders.Builder toBuilder(); + field public static final com.homer.apollographql.apollo.cache.CacheHeaders.Companion Companion; + field public static final com.homer.apollographql.apollo.cache.CacheHeaders NONE; } public static final class CacheHeaders.Builder { ctor public CacheHeaders.Builder(); - method public com.apollographql.apollo.cache.CacheHeaders.Builder addHeader(String headerName, String headerValue); - method public com.apollographql.apollo.cache.CacheHeaders.Builder addHeaders(java.util.Map headerMap); - method public com.apollographql.apollo.cache.CacheHeaders build(); + method public com.homer.apollographql.apollo.cache.CacheHeaders.Builder addHeader(String headerName, String headerValue); + method public com.homer.apollographql.apollo.cache.CacheHeaders.Builder addHeaders(java.util.Map headerMap); + method public com.homer.apollographql.apollo.cache.CacheHeaders build(); } public static final class CacheHeaders.Companion { - method public com.apollographql.apollo.cache.CacheHeaders.Builder builder(); + method public com.homer.apollographql.apollo.cache.CacheHeaders.Builder builder(); } } -package com.apollographql.apollo.cache.normalized { +package com.homer.apollographql.apollo.cache.normalized { public final class CacheKey { ctor public CacheKey(String key); method public boolean equals(Object? other); - method public static com.apollographql.apollo.cache.normalized.CacheKey from(String key); + method public static com.homer.apollographql.apollo.cache.normalized.CacheKey from(String key); method public String getKey(); method public int hashCode(); method @Deprecated public String key(); method public String toString(); - field public static final com.apollographql.apollo.cache.normalized.CacheKey.Companion Companion; - field public static final com.apollographql.apollo.cache.normalized.CacheKey NO_KEY; + field public static final com.homer.apollographql.apollo.cache.normalized.CacheKey.Companion Companion; + field public static final com.homer.apollographql.apollo.cache.normalized.CacheKey NO_KEY; } public static final class CacheKey.Companion { - method public com.apollographql.apollo.cache.normalized.CacheKey from(String key); + method public com.homer.apollographql.apollo.cache.normalized.CacheKey from(String key); } public abstract class CacheKeyResolver { ctor public CacheKeyResolver(); - method public abstract com.apollographql.apollo.cache.normalized.CacheKey fromFieldArguments(com.apollographql.apollo.api.ResponseField field, com.apollographql.apollo.api.Operation.Variables variables); - method public abstract com.apollographql.apollo.cache.normalized.CacheKey fromFieldRecordSet(com.apollographql.apollo.api.ResponseField field, java.util.Map recordSet); - method public static final com.apollographql.apollo.cache.normalized.CacheKey rootKeyForOperation(com.apollographql.apollo.api.Operation operation); - field public static final com.apollographql.apollo.cache.normalized.CacheKeyResolver.Companion Companion; - field public static final com.apollographql.apollo.cache.normalized.CacheKeyResolver DEFAULT; + method public abstract com.homer.apollographql.apollo.cache.normalized.CacheKey fromFieldArguments(com.homer.apollographql.apollo.api.ResponseField field, com.homer.apollographql.apollo.api.Operation.Variables variables); + method public abstract com.homer.apollographql.apollo.cache.normalized.CacheKey fromFieldRecordSet(com.homer.apollographql.apollo.api.ResponseField field, java.util.Map recordSet); + method public static final com.homer.apollographql.apollo.cache.normalized.CacheKey rootKeyForOperation(com.homer.apollographql.apollo.api.Operation operation); + field public static final com.homer.apollographql.apollo.cache.normalized.CacheKeyResolver.Companion Companion; + field public static final com.homer.apollographql.apollo.cache.normalized.CacheKeyResolver DEFAULT; } public static final class CacheKeyResolver.Companion { - method public com.apollographql.apollo.cache.normalized.CacheKey rootKeyForOperation(com.apollographql.apollo.api.Operation operation); + method public com.homer.apollographql.apollo.cache.normalized.CacheKey rootKeyForOperation(com.homer.apollographql.apollo.api.Operation operation); } public final class CacheReference { ctor public CacheReference(String key); method public static boolean canDeserialize(String value); - method public static com.apollographql.apollo.cache.normalized.CacheReference deserialize(String serializedCacheReference); + method public static com.homer.apollographql.apollo.cache.normalized.CacheReference deserialize(String serializedCacheReference); method public boolean equals(Object? other); method public String getKey(); method public int hashCode(); method @Deprecated public String key(); method public String serialize(); method public String toString(); - field public static final com.apollographql.apollo.cache.normalized.CacheReference.Companion Companion; + field public static final com.homer.apollographql.apollo.cache.normalized.CacheReference.Companion Companion; } public static final class CacheReference.Companion { method public boolean canDeserialize(String value); - method public com.apollographql.apollo.cache.normalized.CacheReference deserialize(String serializedCacheReference); + method public com.homer.apollographql.apollo.cache.normalized.CacheReference deserialize(String serializedCacheReference); } public abstract class NormalizedCache { ctor public NormalizedCache(); - method public final com.apollographql.apollo.cache.normalized.NormalizedCache chain(com.apollographql.apollo.cache.normalized.NormalizedCache cache); + method public final com.homer.apollographql.apollo.cache.normalized.NormalizedCache chain(com.homer.apollographql.apollo.cache.normalized.NormalizedCache cache); method public abstract void clearAll(); - method public java.util.Map,java.util.Map> dump(); - method public final com.apollographql.apollo.cache.normalized.NormalizedCache? getNextCache(); - method public abstract com.apollographql.apollo.cache.normalized.Record? loadRecord(String key, com.apollographql.apollo.cache.CacheHeaders cacheHeaders); - method public java.util.Collection loadRecords(java.util.Collection keys, com.apollographql.apollo.cache.CacheHeaders cacheHeaders); - method public java.util.Set merge(com.apollographql.apollo.cache.normalized.Record record, com.apollographql.apollo.cache.CacheHeaders cacheHeaders); - method public java.util.Set merge(java.util.Collection recordSet, com.apollographql.apollo.cache.CacheHeaders cacheHeaders); - method protected abstract java.util.Set performMerge(com.apollographql.apollo.cache.normalized.Record apolloRecord, com.apollographql.apollo.cache.normalized.Record? oldRecord, com.apollographql.apollo.cache.CacheHeaders cacheHeaders); - method public static final String prettifyDump(java.util.Map,? extends java.util.Map> dump); - method public final boolean remove(com.apollographql.apollo.cache.normalized.CacheKey cacheKey); - method public abstract boolean remove(com.apollographql.apollo.cache.normalized.CacheKey cacheKey, boolean cascade); - property public final com.apollographql.apollo.cache.normalized.NormalizedCache? nextCache; - field public static final com.apollographql.apollo.cache.normalized.NormalizedCache.Companion Companion; + method public java.util.Map,java.util.Map> dump(); + method public final com.homer.apollographql.apollo.cache.normalized.NormalizedCache? getNextCache(); + method public abstract com.homer.apollographql.apollo.cache.normalized.Record? loadRecord(String key, com.homer.apollographql.apollo.cache.CacheHeaders cacheHeaders); + method public java.util.Collection loadRecords(java.util.Collection keys, com.homer.apollographql.apollo.cache.CacheHeaders cacheHeaders); + method public java.util.Set merge(com.homer.apollographql.apollo.cache.normalized.Record record, com.homer.apollographql.apollo.cache.CacheHeaders cacheHeaders); + method public java.util.Set merge(java.util.Collection recordSet, com.homer.apollographql.apollo.cache.CacheHeaders cacheHeaders); + method protected abstract java.util.Set performMerge(com.homer.apollographql.apollo.cache.normalized.Record apolloRecord, com.homer.apollographql.apollo.cache.normalized.Record? oldRecord, com.homer.apollographql.apollo.cache.CacheHeaders cacheHeaders); + method public static final String prettifyDump(java.util.Map,? extends java.util.Map> dump); + method public final boolean remove(com.homer.apollographql.apollo.cache.normalized.CacheKey cacheKey); + method public abstract boolean remove(com.homer.apollographql.apollo.cache.normalized.CacheKey cacheKey, boolean cascade); + property public final com.homer.apollographql.apollo.cache.normalized.NormalizedCache? nextCache; + field public static final com.homer.apollographql.apollo.cache.normalized.NormalizedCache.Companion Companion; } public static final class NormalizedCache.Companion { - method public String prettifyDump(java.util.Map,? extends java.util.Map> dump); + method public String prettifyDump(java.util.Map,? extends java.util.Map> dump); } - public abstract class NormalizedCacheFactory { + public abstract class NormalizedCacheFactory { ctor public NormalizedCacheFactory(); - method public final com.apollographql.apollo.cache.normalized.NormalizedCacheFactory chain(com.apollographql.apollo.cache.normalized.NormalizedCacheFactory factory); - method public abstract T create(com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter recordFieldAdapter); - method public final com.apollographql.apollo.cache.normalized.NormalizedCache createChain(com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter recordFieldAdapter); + method public final com.homer.apollographql.apollo.cache.normalized.NormalizedCacheFactory chain(com.homer.apollographql.apollo.cache.normalized.NormalizedCacheFactory factory); + method public abstract T create(com.homer.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter recordFieldAdapter); + method public final com.homer.apollographql.apollo.cache.normalized.NormalizedCache createChain(com.homer.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter recordFieldAdapter); } public final class Record { - method public static com.apollographql.apollo.cache.normalized.Record.Builder builder(String key); - method @Deprecated public com.apollographql.apollo.cache.normalized.Record clone(); + method public static com.homer.apollographql.apollo.cache.normalized.Record.Builder builder(String key); + method @Deprecated public com.homer.apollographql.apollo.cache.normalized.Record clone(); method public Object? field(String fieldKey); method @Deprecated public java.util.Map fields(); method public java.util.Map getFields(); @@ -119,48 +119,48 @@ package com.apollographql.apollo.cache.normalized { method public boolean hasField(String fieldKey); method @Deprecated public String key(); method public java.util.Set keys(); - method public java.util.Set mergeWith(com.apollographql.apollo.cache.normalized.Record otherRecord); + method public java.util.Set mergeWith(com.homer.apollographql.apollo.cache.normalized.Record otherRecord); method @Deprecated public java.util.UUID? mutationId(); - method public java.util.List referencedFields(); + method public java.util.List referencedFields(); method @kotlin.jvm.Synchronized public int sizeEstimateBytes(); - method public com.apollographql.apollo.cache.normalized.Record.Builder toBuilder(); + method public com.homer.apollographql.apollo.cache.normalized.Record.Builder toBuilder(); method public String toString(); property public final java.util.Map fields; property public final java.util.UUID? mutationId; - field public static final com.apollographql.apollo.cache.normalized.Record.Companion Companion; + field public static final com.homer.apollographql.apollo.cache.normalized.Record.Companion Companion; } public static final class Record.Builder { ctor public Record.Builder(String key, java.util.Map fields, java.util.UUID? mutationId); - method public com.apollographql.apollo.cache.normalized.Record.Builder addField(String key, Object? value); - method public com.apollographql.apollo.cache.normalized.Record.Builder addFields(java.util.Map fields); - method public com.apollographql.apollo.cache.normalized.Record build(); + method public com.homer.apollographql.apollo.cache.normalized.Record.Builder addField(String key, Object? value); + method public com.homer.apollographql.apollo.cache.normalized.Record.Builder addFields(java.util.Map fields); + method public com.homer.apollographql.apollo.cache.normalized.Record build(); method public String getKey(); method @Deprecated public String key(); - method public com.apollographql.apollo.cache.normalized.Record.Builder mutationId(java.util.UUID? mutationId); + method public com.homer.apollographql.apollo.cache.normalized.Record.Builder mutationId(java.util.UUID? mutationId); } public static final class Record.Companion { - method public com.apollographql.apollo.cache.normalized.Record.Builder builder(String key); + method public com.homer.apollographql.apollo.cache.normalized.Record.Builder builder(String key); } public final class RecordFieldJsonAdapter { ctor public RecordFieldJsonAdapter(); - method @Deprecated public static com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter create(); + method @Deprecated public static com.homer.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter create(); method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public java.util.Map? from(String jsonFieldSource); method public String toJson(java.util.Map fields); - field public static final com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter.Companion Companion; + field public static final com.homer.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter.Companion Companion; } public static final class RecordFieldJsonAdapter.Companion { - method @Deprecated public com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter create(); + method @Deprecated public com.homer.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter create(); } public final class RecordSet { ctor public RecordSet(); - method public java.util.Collection allRecords(); - method public operator com.apollographql.apollo.cache.normalized.Record? get(String key); - method public java.util.Set merge(com.apollographql.apollo.cache.normalized.Record apolloRecord); + method public java.util.Collection allRecords(); + method public operator com.homer.apollographql.apollo.cache.normalized.Record? get(String key); + method public java.util.Set merge(com.homer.apollographql.apollo.cache.normalized.Record apolloRecord); } } diff --git a/apollo-normalized-cache-api/build.gradle.kts b/apollo-normalized-cache-api/build.gradle.kts index 0dbc3d19ff7..444eeab3917 100644 --- a/apollo-normalized-cache-api/build.gradle.kts +++ b/apollo-normalized-cache-api/build.gradle.kts @@ -4,22 +4,6 @@ plugins { } kotlin { - @Suppress("ClassName") - data class iOSTarget(val name: String, val preset: String, val id: String) - - val iosTargets = listOf( - iOSTarget("ios", "iosArm64", "ios-arm64"), - iOSTarget("iosSim", "iosX64", "ios-x64") - ) - - for ((targetName, presetName, id) in iosTargets) { - targetFromPreset(presets.getByName(presetName), targetName) { - mavenPublication { - artifactId = "${project.name}-$id" - } - } - } - jvm() sourceSets { @@ -36,33 +20,11 @@ kotlin { dependencies { } } - - val iosMain by getting { - dependsOn(commonMain) - } - - val iosSimMain by getting { - dependsOn(iosMain) - } - - val commonTest by getting { - dependencies { - implementation(kotlin("test-common")) - implementation(kotlin("test-annotations-common")) - } - } - - val jvmTest by getting { - dependsOn(jvmMain) - dependencies { - implementation(kotlin("test-junit")) - } - } } } metalava { - hiddenPackages += setOf("com.apollographql.apollo.cache.normalized.internal") + hiddenPackages += setOf("com.homer.apollographql.apollo.cache.normalized.internal") } tasks.withType { diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/CacheKeyBuilder.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/CacheKeyBuilder.kt deleted file mode 100644 index 625a3416891..00000000000 --- a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/CacheKeyBuilder.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.apollographql.apollo.cache.normalized.internal - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.ResponseField - -interface CacheKeyBuilder { - fun build(field: ResponseField, variables: Operation.Variables): String -} diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/ReadableStore.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/ReadableStore.kt deleted file mode 100644 index 5010822662d..00000000000 --- a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/ReadableStore.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.apollographql.apollo.cache.normalized.internal - -import com.apollographql.apollo.cache.CacheHeaders -import com.apollographql.apollo.cache.normalized.Record - -interface ReadableStore { - fun read(key: String, cacheHeaders: CacheHeaders): Record? - fun read(keys: Collection, cacheHeaders: CacheHeaders): Collection -} diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/ApolloCacheHeaders.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/ApolloCacheHeaders.kt similarity index 83% rename from apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/ApolloCacheHeaders.kt rename to apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/ApolloCacheHeaders.kt index 48b31173e5f..3566007724e 100644 --- a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/ApolloCacheHeaders.kt +++ b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/ApolloCacheHeaders.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.cache +package com.homer.apollographql.apollo.cache -import com.apollographql.apollo.cache.normalized.NormalizedCache +import com.homer.apollographql.apollo.cache.normalized.NormalizedCache /** * A collection of cache headers that Apollo's implementations of [NormalizedCache] respect. diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/CacheHeaders.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/CacheHeaders.kt similarity index 82% rename from apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/CacheHeaders.kt rename to apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/CacheHeaders.kt index 49c0578b7c7..d361cc73ef4 100644 --- a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/CacheHeaders.kt +++ b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/CacheHeaders.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.cache +package com.homer.apollographql.apollo.cache -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.cache.normalized.NormalizedCache -import com.apollographql.apollo.cache.normalized.Record +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.cache.normalized.NormalizedCache +import com.homer.apollographql.apollo.cache.normalized.Record import kotlin.jvm.JvmField import kotlin.jvm.JvmStatic diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/CacheKey.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/CacheKey.kt similarity index 92% rename from apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/CacheKey.kt rename to apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/CacheKey.kt index fee30c24624..b971965727a 100644 --- a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/CacheKey.kt +++ b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/CacheKey.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.cache.normalized +package com.homer.apollographql.apollo.cache.normalized import kotlin.jvm.JvmField import kotlin.jvm.JvmStatic diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/CacheKeyResolver.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/CacheKeyResolver.kt similarity index 85% rename from apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/CacheKeyResolver.kt rename to apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/CacheKeyResolver.kt index aa603fe46b0..db91cf0021a 100644 --- a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/CacheKeyResolver.kt +++ b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/CacheKeyResolver.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.cache.normalized +package com.homer.apollographql.apollo.cache.normalized -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.ResponseField +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.ResponseField import kotlin.jvm.JvmField import kotlin.jvm.JvmStatic import kotlin.jvm.JvmSuppressWildcards diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/CacheReference.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/CacheReference.kt similarity index 95% rename from apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/CacheReference.kt rename to apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/CacheReference.kt index 6e9fb158465..d9a2f8b7b32 100644 --- a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/CacheReference.kt +++ b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/CacheReference.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.cache.normalized +package com.homer.apollographql.apollo.cache.normalized import kotlin.jvm.JvmStatic diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/NormalizedCache.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/NormalizedCache.kt similarity index 95% rename from apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/NormalizedCache.kt rename to apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/NormalizedCache.kt index cee596e8354..bb4addeea71 100644 --- a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/NormalizedCache.kt +++ b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/NormalizedCache.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.cache.normalized +package com.homer.apollographql.apollo.cache.normalized -import com.apollographql.apollo.cache.ApolloCacheHeaders -import com.apollographql.apollo.cache.CacheHeaders +import com.homer.apollographql.apollo.cache.ApolloCacheHeaders +import com.homer.apollographql.apollo.cache.CacheHeaders import kotlin.jvm.JvmStatic import kotlin.jvm.JvmSuppressWildcards import kotlin.reflect.KClass @@ -19,7 +19,7 @@ import kotlin.reflect.KClass * * A [NormalizedCache] can choose to store records in any manner. * - * See [com.apollographql.apollo.cache.normalized.lru.LruNormalizedCache] for a in memory cache. + * See [com.homer.apollographql.apollo.cache.normalized.lru.LruNormalizedCache] for a in memory cache. */ abstract class NormalizedCache { var nextCache: NormalizedCache? = null diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/NormalizedCacheFactory.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/NormalizedCacheFactory.kt similarity index 95% rename from apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/NormalizedCacheFactory.kt rename to apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/NormalizedCacheFactory.kt index b1e6d61d4ba..737fde9f8b5 100644 --- a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/NormalizedCacheFactory.kt +++ b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/NormalizedCacheFactory.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.cache.normalized +package com.homer.apollographql.apollo.cache.normalized /** * A Factory used to construct an instance of a [NormalizedCache] configured with the custom scalar adapters set in diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/Record.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/Record.kt similarity index 95% rename from apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/Record.kt rename to apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/Record.kt index 9f5f0a72c5a..e6067402345 100644 --- a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/Record.kt +++ b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/Record.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.cache.normalized +package com.homer.apollographql.apollo.cache.normalized -import com.apollographql.apollo.cache.normalized.internal.RecordWeigher.byteChange -import com.apollographql.apollo.cache.normalized.internal.RecordWeigher.calculateBytes +import com.homer.apollographql.apollo.cache.normalized.internal.RecordWeigher.byteChange +import com.homer.apollographql.apollo.cache.normalized.internal.RecordWeigher.calculateBytes import com.benasher44.uuid.Uuid import kotlin.jvm.JvmStatic import kotlin.jvm.Synchronized diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/RecordFieldJsonAdapter.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/RecordFieldJsonAdapter.kt similarity index 85% rename from apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/RecordFieldJsonAdapter.kt rename to apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/RecordFieldJsonAdapter.kt index 3c88cd6a4db..a5c9ee51e73 100644 --- a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/RecordFieldJsonAdapter.kt +++ b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/RecordFieldJsonAdapter.kt @@ -1,10 +1,10 @@ -package com.apollographql.apollo.cache.normalized +package com.homer.apollographql.apollo.cache.normalized -import com.apollographql.apollo.api.internal.Throws -import com.apollographql.apollo.api.internal.json.BufferedSourceJsonReader -import com.apollographql.apollo.api.internal.json.JsonWriter -import com.apollographql.apollo.api.internal.json.use -import com.apollographql.apollo.cache.normalized.internal.CacheJsonStreamReader +import com.homer.apollographql.apollo.api.internal.Throws +import com.homer.apollographql.apollo.api.internal.json.BufferedSourceJsonReader +import com.homer.apollographql.apollo.api.internal.json.JsonWriter +import com.homer.apollographql.apollo.api.internal.json.use +import com.homer.apollographql.apollo.cache.normalized.internal.CacheJsonStreamReader import okio.Buffer import okio.BufferedSource import okio.ByteString.Companion.encodeUtf8 diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/RecordSet.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/RecordSet.kt similarity index 89% rename from apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/RecordSet.kt rename to apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/RecordSet.kt index 2f7439f4e62..2f0482eddd3 100644 --- a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/RecordSet.kt +++ b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/RecordSet.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.cache.normalized +package com.homer.apollographql.apollo.cache.normalized class RecordSet { private val recordMap = mutableMapOf() diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/CacheJsonStreamReader.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/CacheJsonStreamReader.kt similarity index 58% rename from apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/CacheJsonStreamReader.kt rename to apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/CacheJsonStreamReader.kt index 70622509f87..d3decbf4383 100644 --- a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/CacheJsonStreamReader.kt +++ b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/CacheJsonStreamReader.kt @@ -1,9 +1,9 @@ -package com.apollographql.apollo.cache.normalized.internal +package com.homer.apollographql.apollo.cache.normalized.internal -import com.apollographql.apollo.api.internal.Throws -import com.apollographql.apollo.api.internal.json.JsonReader -import com.apollographql.apollo.api.internal.json.ResponseJsonStreamReader -import com.apollographql.apollo.cache.normalized.CacheReference +import com.homer.apollographql.apollo.api.internal.Throws +import com.homer.apollographql.apollo.api.internal.json.JsonReader +import com.homer.apollographql.apollo.api.internal.json.ResponseJsonStreamReader +import com.homer.apollographql.apollo.cache.normalized.CacheReference import okio.IOException /** diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/CacheKeyBuilder.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/CacheKeyBuilder.kt new file mode 100644 index 00000000000..90a1effa111 --- /dev/null +++ b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/CacheKeyBuilder.kt @@ -0,0 +1,8 @@ +package com.homer.apollographql.apollo.cache.normalized.internal + +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.ResponseField + +interface CacheKeyBuilder { + fun build(field: ResponseField, variables: Operation.Variables): String +} diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/ReadableStore.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/ReadableStore.kt new file mode 100644 index 00000000000..97dc3294196 --- /dev/null +++ b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/ReadableStore.kt @@ -0,0 +1,9 @@ +package com.homer.apollographql.apollo.cache.normalized.internal + +import com.homer.apollographql.apollo.cache.CacheHeaders +import com.homer.apollographql.apollo.cache.normalized.Record + +interface ReadableStore { + fun read(key: String, cacheHeaders: CacheHeaders): Record? + fun read(keys: Collection, cacheHeaders: CacheHeaders): Collection +} diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/RecordWeigher.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/RecordWeigher.kt similarity index 86% rename from apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/RecordWeigher.kt rename to apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/RecordWeigher.kt index 4349f3de946..d22720a67be 100644 --- a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/RecordWeigher.kt +++ b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/RecordWeigher.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.cache.normalized.internal +package com.homer.apollographql.apollo.cache.normalized.internal -import com.apollographql.apollo.api.BigDecimal -import com.apollographql.apollo.cache.normalized.CacheReference -import com.apollographql.apollo.cache.normalized.Record +import com.homer.apollographql.apollo.api.BigDecimal +import com.homer.apollographql.apollo.cache.normalized.CacheReference +import com.homer.apollographql.apollo.cache.normalized.Record import okio.internal.commonAsUtf8ToByteArray import kotlin.jvm.JvmStatic diff --git a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/WriteableStore.kt b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/WriteableStore.kt similarity index 53% rename from apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/WriteableStore.kt rename to apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/WriteableStore.kt index a7ffdecb011..85ad62414e7 100644 --- a/apollo-normalized-cache-api/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/WriteableStore.kt +++ b/apollo-normalized-cache-api/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/WriteableStore.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.cache.normalized.internal +package com.homer.apollographql.apollo.cache.normalized.internal -import com.apollographql.apollo.cache.CacheHeaders -import com.apollographql.apollo.cache.normalized.Record +import com.homer.apollographql.apollo.cache.CacheHeaders +import com.homer.apollographql.apollo.cache.normalized.Record interface WriteableStore : ReadableStore { diff --git a/apollo-normalized-cache-api/src/commonTest/kotlin/com/apollographql/apollo/cache/normalized/RecordFieldJsonAdapterTest.kt b/apollo-normalized-cache-api/src/commonTest/kotlin/com/apollographql/apollo/cache/normalized/RecordFieldJsonAdapterTest.kt deleted file mode 100644 index 766b86c24d4..00000000000 --- a/apollo-normalized-cache-api/src/commonTest/kotlin/com/apollographql/apollo/cache/normalized/RecordFieldJsonAdapterTest.kt +++ /dev/null @@ -1,53 +0,0 @@ -package com.apollographql.apollo.cache.normalized - -import com.apollographql.apollo.api.BigDecimal -import com.apollographql.apollo.cache.normalized.Record.Companion.builder -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertNull -import kotlin.test.assertTrue - -class RecordFieldJsonAdapterTest { - private val recordFieldAdapter = RecordFieldJsonAdapter() - - @Test - fun testFieldsAdapterSerializationDeserialization() { - val recordBuilder = builder("root") - val expectedBigDecimal = BigDecimal("1.23") - val expectedStringValue = "StringValue" - val expectedBooleanValue = true - val expectedCacheReference = CacheReference("foo") - val expectedCacheReferenceList = listOf(CacheReference("bar"), CacheReference("baz")) - val expectedScalarList = listOf("scalarOne", "scalarTwo") - val expectedListOfScalarList = listOf(listOf("scalarOne", "scalarTwo")) - val expectedMapKey = "foo" - val expectedMapValue = "bar" - val expectedMap = mapOf(expectedMapKey to expectedMapValue) - recordBuilder.addField("bigDecimal", expectedBigDecimal) - recordBuilder.addField("string", expectedStringValue) - recordBuilder.addField("boolean", expectedBooleanValue) - recordBuilder.addField("cacheReference", expectedCacheReference) - recordBuilder.addField("scalarList", expectedScalarList) - recordBuilder.addField("referenceList", expectedCacheReferenceList) - recordBuilder.addField("nullValue", null) - recordBuilder.addField("listOfScalarList", expectedListOfScalarList) - recordBuilder.addField("map", expectedMap) - val record = recordBuilder.build() - val json = recordFieldAdapter.toJson(record.fields) - val deserializedMap = requireNotNull(recordFieldAdapter.from(json)) - - assertEquals(actual = deserializedMap["bigDecimal"], expected = expectedBigDecimal) - assertEquals(actual = deserializedMap["string"], expected = expectedStringValue) - assertEquals(actual = deserializedMap["boolean"], expected = expectedBooleanValue) - assertEquals(actual = deserializedMap["cacheReference"], expected = expectedCacheReference) - assertEquals(actual = deserializedMap["scalarList"], expected = expectedScalarList) - assertEquals(actual = deserializedMap["referenceList"], expected = expectedCacheReferenceList) - assertTrue { deserializedMap.containsKey("nullValue") } - assertNull(deserializedMap["nullValue"]) - assertEquals(actual = (deserializedMap["listOfScalarList"] as List<*>).size, expected = 1) - assertEquals( - actual = (deserializedMap["listOfScalarList"] as List<*>)[0] as Iterable<*>?, - expected = expectedScalarList) - assertEquals(actual = (deserializedMap["map"] as Map<*, *>)[expectedMapKey], expected = expectedMapValue) - } -} diff --git a/apollo-normalized-cache-api/src/commonTest/kotlin/com/apollographql/apollo/cache/normalized/RecordWeigherTest.kt b/apollo-normalized-cache-api/src/commonTest/kotlin/com/apollographql/apollo/cache/normalized/RecordWeigherTest.kt deleted file mode 100644 index d7345677840..00000000000 --- a/apollo-normalized-cache-api/src/commonTest/kotlin/com/apollographql/apollo/cache/normalized/RecordWeigherTest.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.apollographql.apollo.cache.normalized - -import com.apollographql.apollo.api.BigDecimal -import kotlin.test.Test -import kotlin.test.assertEquals - -class RecordWeigherTest { - - @Test - fun testRecordWeigher() { - val recordBuilder = Record.builder("root") - val expectedBigDecimal = BigDecimal(1.23) - val expectedStringValue = "StringValue" - val expectedBooleanValue = true - val expectedCacheReference = CacheReference("foo") - val expectedCacheReferenceList = listOf(CacheReference("bar"), CacheReference("baz")) - val expectedScalarList = listOf("scalarOne", "scalarTwo") - recordBuilder.addField("bigDecimal", expectedBigDecimal) - recordBuilder.addField("string", expectedStringValue) - recordBuilder.addField("boolean", expectedBooleanValue) - recordBuilder.addField("cacheReference", expectedCacheReference) - recordBuilder.addField("scalarList", expectedScalarList) - recordBuilder.addField("referenceList", expectedCacheReferenceList) - val record = recordBuilder.build() - record.sizeEstimateBytes() - - assertEquals(actual = record.sizeEstimateBytes(), expected = 246) - } -} diff --git a/apollo-normalized-cache-api/src/commonTest/kotlin/com/apollographql/apollo/cache/normalized/TestCustomScalar.kt b/apollo-normalized-cache-api/src/commonTest/kotlin/com/apollographql/apollo/cache/normalized/TestCustomScalar.kt deleted file mode 100644 index a89d9af6329..00000000000 --- a/apollo-normalized-cache-api/src/commonTest/kotlin/com/apollographql/apollo/cache/normalized/TestCustomScalar.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.apollographql.apollo.cache.normalized - -data class TestCustomScalar(val fieldOne: String?) diff --git a/apollo-normalized-cache-sqlite/api.txt b/apollo-normalized-cache-sqlite/api.txt index 0cfb2f5441f..60461f00415 100644 --- a/apollo-normalized-cache-sqlite/api.txt +++ b/apollo-normalized-cache-sqlite/api.txt @@ -1,53 +1,53 @@ // Signature format: 3.0 -package com.apollographql.apollo.cache.normalized.sql { +package com.homer.apollographql.apollo.cache.normalized.sql { @Deprecated public final class ApolloSqlHelper { ctor @Deprecated public ApolloSqlHelper(android.content.Context context, String? name); - method @Deprecated public static com.apollographql.apollo.cache.normalized.sql.ApolloSqlHelper create(android.content.Context context, String? name = "apollo.db"); - method @Deprecated public static com.apollographql.apollo.cache.normalized.sql.ApolloSqlHelper create(android.content.Context context); - field @Deprecated public static final com.apollographql.apollo.cache.normalized.sql.ApolloSqlHelper.Companion Companion; + method @Deprecated public static com.homer.apollographql.apollo.cache.normalized.sql.ApolloSqlHelper create(android.content.Context context, String? name = "apollo.db"); + method @Deprecated public static com.homer.apollographql.apollo.cache.normalized.sql.ApolloSqlHelper create(android.content.Context context); + field @Deprecated public static final com.homer.apollographql.apollo.cache.normalized.sql.ApolloSqlHelper.Companion Companion; } @Deprecated public static final class ApolloSqlHelper.Companion { - method @Deprecated public com.apollographql.apollo.cache.normalized.sql.ApolloSqlHelper create(android.content.Context context, String? name = "apollo.db"); - method @Deprecated public com.apollographql.apollo.cache.normalized.sql.ApolloSqlHelper create(android.content.Context context); + method @Deprecated public com.homer.apollographql.apollo.cache.normalized.sql.ApolloSqlHelper create(android.content.Context context, String? name = "apollo.db"); + method @Deprecated public com.homer.apollographql.apollo.cache.normalized.sql.ApolloSqlHelper create(android.content.Context context); } - public final class SqlNormalizedCache extends com.apollographql.apollo.cache.normalized.NormalizedCache { + public final class SqlNormalizedCache extends com.homer.apollographql.apollo.cache.normalized.NormalizedCache { method public void clearAll(); method public void createRecord(String key, String fields); method public boolean deleteRecord(String key); method public boolean deleteRecords(java.util.Collection keys); - method public com.apollographql.apollo.cache.normalized.Record? loadRecord(String key, com.apollographql.apollo.cache.CacheHeaders cacheHeaders); - method protected java.util.Set performMerge(com.apollographql.apollo.cache.normalized.Record apolloRecord, com.apollographql.apollo.cache.normalized.Record? oldRecord, com.apollographql.apollo.cache.CacheHeaders cacheHeaders); - method public boolean remove(com.apollographql.apollo.cache.normalized.CacheKey cacheKey, boolean cascade); - method public com.apollographql.apollo.cache.normalized.Record? selectRecordForKey(String key); - method public java.util.List selectRecordsForKey(java.util.Collection keys); + method public com.homer.apollographql.apollo.cache.normalized.Record? loadRecord(String key, com.homer.apollographql.apollo.cache.CacheHeaders cacheHeaders); + method protected java.util.Set performMerge(com.homer.apollographql.apollo.cache.normalized.Record apolloRecord, com.homer.apollographql.apollo.cache.normalized.Record? oldRecord, com.homer.apollographql.apollo.cache.CacheHeaders cacheHeaders); + method public boolean remove(com.homer.apollographql.apollo.cache.normalized.CacheKey cacheKey, boolean cascade); + method public com.homer.apollographql.apollo.cache.normalized.Record? selectRecordForKey(String key); + method public java.util.List selectRecordsForKey(java.util.Collection keys); } - public final class SqlNormalizedCacheFactory extends com.apollographql.apollo.cache.normalized.NormalizedCacheFactory { + public final class SqlNormalizedCacheFactory extends com.homer.apollographql.apollo.cache.normalized.NormalizedCacheFactory { ctor public SqlNormalizedCacheFactory(); ctor public SqlNormalizedCacheFactory(String name); - method public com.apollographql.apollo.cache.normalized.sql.SqlNormalizedCache create(com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter recordFieldAdapter); + method public com.homer.apollographql.apollo.cache.normalized.sql.SqlNormalizedCache create(com.homer.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter recordFieldAdapter); } - public final class SqlNormalizedCacheFactory extends com.apollographql.apollo.cache.normalized.NormalizedCacheFactory { + public final class SqlNormalizedCacheFactory extends com.homer.apollographql.apollo.cache.normalized.NormalizedCacheFactory { ctor public SqlNormalizedCacheFactory(String url, java.util.Properties properties); ctor public SqlNormalizedCacheFactory(String url); - method public com.apollographql.apollo.cache.normalized.sql.SqlNormalizedCache create(com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter recordFieldAdapter); - field public static final com.apollographql.apollo.cache.normalized.sql.SqlNormalizedCacheFactory.Companion Companion; + method public com.homer.apollographql.apollo.cache.normalized.sql.SqlNormalizedCache create(com.homer.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter recordFieldAdapter); + field public static final com.homer.apollographql.apollo.cache.normalized.sql.SqlNormalizedCacheFactory.Companion Companion; } public static final class SqlNormalizedCacheFactory.Companion { } - public final class SqlNormalizedCacheFactory extends com.apollographql.apollo.cache.normalized.NormalizedCacheFactory { + public final class SqlNormalizedCacheFactory extends com.homer.apollographql.apollo.cache.normalized.NormalizedCacheFactory { ctor public SqlNormalizedCacheFactory(android.content.Context context, String? name, androidx.sqlite.db.SupportSQLiteOpenHelper.Factory factory, boolean useNoBackupDirectory); ctor public SqlNormalizedCacheFactory(android.content.Context context, String? name, androidx.sqlite.db.SupportSQLiteOpenHelper.Factory factory); ctor public SqlNormalizedCacheFactory(android.content.Context context, String? name); ctor public SqlNormalizedCacheFactory(android.content.Context context); - ctor public SqlNormalizedCacheFactory(com.apollographql.apollo.cache.normalized.sql.ApolloSqlHelper apolloSqlHelper); - method public com.apollographql.apollo.cache.normalized.sql.SqlNormalizedCache create(com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter recordFieldAdapter); + ctor public SqlNormalizedCacheFactory(com.homer.apollographql.apollo.cache.normalized.sql.ApolloSqlHelper apolloSqlHelper); + method public com.homer.apollographql.apollo.cache.normalized.sql.SqlNormalizedCache create(com.homer.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter recordFieldAdapter); } } diff --git a/apollo-normalized-cache-sqlite/build.gradle.kts b/apollo-normalized-cache-sqlite/build.gradle.kts index 133d3df3717..a39b0ef5fa4 100644 --- a/apollo-normalized-cache-sqlite/build.gradle.kts +++ b/apollo-normalized-cache-sqlite/build.gradle.kts @@ -6,28 +6,12 @@ plugins { sqldelight { database("ApolloDatabase") { - packageName = "com.apollographql.apollo.cache.normalized.sql" + packageName = "com.homer.apollographql.apollo.cache.normalized.sql" schemaOutputDirectory = file("src/main/sqldelight/schemas") } } kotlin { - @Suppress("ClassName") - data class iOSTarget(val name: String, val preset: String, val id: String) - - val iosTargets = listOf( - iOSTarget("ios", "iosArm64", "ios-arm64"), - iOSTarget("iosSim", "iosX64", "ios-x64") - ) - - for ((targetName, presetName, id) in iosTargets) { - targetFromPreset(presets.getByName(presetName), targetName) { - mavenPublication { - artifactId = "${project.name}-$id" - } - } - } - android { publishAllLibraryVariants() } @@ -56,46 +40,6 @@ kotlin { implementation(groovy.util.Eval.x(project, "x.dep.androidx.sqliteFramework")) } } - - val iosMain by getting { - dependsOn(commonMain) - dependencies { - implementation(groovy.util.Eval.x(project, "x.dep.sqldelight.native")) - } - } - - val iosSimMain by getting { - dependsOn(iosMain) - } - - val commonTest by getting { - dependencies { - implementation(kotlin("test-common")) - implementation(kotlin("test-annotations-common")) - } - } - - val jvmTest by getting { - dependsOn(commonTest) - dependencies { - implementation(kotlin("test-junit")) - - implementation(groovy.util.Eval.x(project, "x.dep.junit")) - implementation(groovy.util.Eval.x(project, "x.dep.truth")) - } - } - - val androidTest by getting { - dependsOn(jvmTest) - } - - val iosTest by getting { - dependsOn(commonTest) - } - - val iosSimTest by getting { - dependsOn(iosTest) - } } } @@ -118,4 +62,3 @@ android { tasks.withType { options.encoding = "UTF-8" } - diff --git a/apollo-normalized-cache-sqlite/src/androidMain/kotlin/com/apollographql/apollo/cache/normalized/sql/ApolloSqlHelper.kt b/apollo-normalized-cache-sqlite/src/androidMain/kotlin/com/homer/apollographql/apollo/cache/normalized/sql/ApolloSqlHelper.kt similarity index 93% rename from apollo-normalized-cache-sqlite/src/androidMain/kotlin/com/apollographql/apollo/cache/normalized/sql/ApolloSqlHelper.kt rename to apollo-normalized-cache-sqlite/src/androidMain/kotlin/com/homer/apollographql/apollo/cache/normalized/sql/ApolloSqlHelper.kt index 2b6fb242d01..84f4b859097 100644 --- a/apollo-normalized-cache-sqlite/src/androidMain/kotlin/com/apollographql/apollo/cache/normalized/sql/ApolloSqlHelper.kt +++ b/apollo-normalized-cache-sqlite/src/androidMain/kotlin/com/homer/apollographql/apollo/cache/normalized/sql/ApolloSqlHelper.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.cache.normalized.sql +package com.homer.apollographql.apollo.cache.normalized.sql import android.content.Context import com.squareup.sqldelight.android.AndroidSqliteDriver diff --git a/apollo-normalized-cache-sqlite/src/androidMain/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt b/apollo-normalized-cache-sqlite/src/androidMain/kotlin/com/homer/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt similarity index 86% rename from apollo-normalized-cache-sqlite/src/androidMain/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt rename to apollo-normalized-cache-sqlite/src/androidMain/kotlin/com/homer/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt index ab49294d588..f3106c3197d 100644 --- a/apollo-normalized-cache-sqlite/src/androidMain/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt +++ b/apollo-normalized-cache-sqlite/src/androidMain/kotlin/com/homer/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt @@ -1,10 +1,10 @@ -package com.apollographql.apollo.cache.normalized.sql +package com.homer.apollographql.apollo.cache.normalized.sql import android.content.Context import androidx.sqlite.db.SupportSQLiteOpenHelper import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory -import com.apollographql.apollo.cache.normalized.NormalizedCacheFactory -import com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter +import com.homer.apollographql.apollo.cache.normalized.NormalizedCacheFactory +import com.homer.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter import com.squareup.sqldelight.android.AndroidSqliteDriver import com.squareup.sqldelight.db.SqlDriver diff --git a/apollo-normalized-cache-sqlite/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCache.kt b/apollo-normalized-cache-sqlite/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/sql/SqlNormalizedCache.kt similarity index 88% rename from apollo-normalized-cache-sqlite/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCache.kt rename to apollo-normalized-cache-sqlite/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/sql/SqlNormalizedCache.kt index 9eb113129ce..7dcddaa11d5 100644 --- a/apollo-normalized-cache-sqlite/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCache.kt +++ b/apollo-normalized-cache-sqlite/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/sql/SqlNormalizedCache.kt @@ -1,11 +1,12 @@ -package com.apollographql.apollo.cache.normalized.sql - -import com.apollographql.apollo.cache.ApolloCacheHeaders.EVICT_AFTER_READ -import com.apollographql.apollo.cache.CacheHeaders -import com.apollographql.apollo.cache.normalized.CacheKey -import com.apollographql.apollo.cache.normalized.NormalizedCache -import com.apollographql.apollo.cache.normalized.Record -import com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter +package com.homer.apollographql.apollo.cache.normalized.sql + +import com.homer.apollographql.apollo.cache.normalized.sql.CacheQueries +import com.homer.apollographql.apollo.cache.ApolloCacheHeaders.EVICT_AFTER_READ +import com.homer.apollographql.apollo.cache.CacheHeaders +import com.homer.apollographql.apollo.cache.normalized.CacheKey +import com.homer.apollographql.apollo.cache.normalized.NormalizedCache +import com.homer.apollographql.apollo.cache.normalized.Record +import com.homer.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter import okio.IOException import kotlin.reflect.KClass diff --git a/apollo-normalized-cache-sqlite/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt b/apollo-normalized-cache-sqlite/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt similarity index 56% rename from apollo-normalized-cache-sqlite/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt rename to apollo-normalized-cache-sqlite/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt index da1a6fd1139..908dc12b268 100644 --- a/apollo-normalized-cache-sqlite/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt +++ b/apollo-normalized-cache-sqlite/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.cache.normalized.sql +package com.homer.apollographql.apollo.cache.normalized.sql -import com.apollographql.apollo.cache.normalized.NormalizedCacheFactory +import com.homer.apollographql.apollo.cache.normalized.NormalizedCacheFactory import com.squareup.sqldelight.db.SqlDriver expect class SqlNormalizedCacheFactory internal constructor( diff --git a/apollo-normalized-cache-sqlite/src/commonMain/sqldelight/com/apollographql/apollo/cache/normalized/sql/cache.sq b/apollo-normalized-cache-sqlite/src/commonMain/sqldelight/com/homer/apollographql/apollo/cache/normalized/sql/cache.sq similarity index 100% rename from apollo-normalized-cache-sqlite/src/commonMain/sqldelight/com/apollographql/apollo/cache/normalized/sql/cache.sq rename to apollo-normalized-cache-sqlite/src/commonMain/sqldelight/com/homer/apollographql/apollo/cache/normalized/sql/cache.sq diff --git a/apollo-normalized-cache-sqlite/src/commonTest/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheTest.kt b/apollo-normalized-cache-sqlite/src/commonTest/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheTest.kt deleted file mode 100644 index 1184ecb2c59..00000000000 --- a/apollo-normalized-cache-sqlite/src/commonTest/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheTest.kt +++ /dev/null @@ -1,164 +0,0 @@ -package com.apollographql.apollo.cache.normalized.sql - -import com.apollographql.apollo.cache.ApolloCacheHeaders -import com.apollographql.apollo.cache.CacheHeaders -import com.apollographql.apollo.cache.normalized.Record -import com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter -import kotlin.test.BeforeTest -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertNull -import kotlin.test.assertTrue - -class SqlNormalizedCacheTest { - - private val cache: SqlNormalizedCache = SqlNormalizedCacheFactory(createDriver()).create(RecordFieldJsonAdapter()) - - @BeforeTest - fun setUp() { - cache.clearAll() - } - - @Test - fun testRecordCreation() { - createRecord(STANDARD_KEY) - assertNotNull(cache.loadRecord(STANDARD_KEY, CacheHeaders.NONE)) - } - - @Test - fun testRecordCreation_root() { - createRecord(QUERY_ROOT_KEY) - assertNotNull(cache.loadRecord(QUERY_ROOT_KEY, CacheHeaders.NONE)) - } - - @Test - fun testRecordSelection() { - createRecord(STANDARD_KEY) - val record = cache.selectRecordForKey(STANDARD_KEY) - assertNotNull(record) - assertEquals(expected = STANDARD_KEY, actual = record.key) - } - - @Test - fun testMultipleRecordSelection() { - createRecord(STANDARD_KEY) - createRecord(QUERY_ROOT_KEY) - val selectionKeys = setOf(STANDARD_KEY, QUERY_ROOT_KEY) - val records = cache.selectRecordsForKey(selectionKeys) - val selectedKeys = records.map { it.key }.toSet() - assertEquals(selectionKeys, selectedKeys) - } - - @Test - fun testRecordSelection_root() { - createRecord(QUERY_ROOT_KEY) - val record = requireNotNull(cache.selectRecordForKey(QUERY_ROOT_KEY)) - assertNotNull(record) - assertEquals(expected = QUERY_ROOT_KEY, actual = record.key) - } - - @Test - fun testRecordSelection_recordNotPresent() { - val record = cache.loadRecord(STANDARD_KEY, CacheHeaders.NONE) - assertNull(record) - } - - @Test - fun testRecordMerge() { - cache.merge(Record.builder(STANDARD_KEY) - .addField("fieldKey", "valueUpdated") - .addField("newFieldKey", true).build(), CacheHeaders.NONE) - val record = cache.selectRecordForKey(STANDARD_KEY) - assertNotNull(record) - assertEquals(expected = "valueUpdated", actual = record.fields["fieldKey"]) - assertEquals(expected = true, actual = record.fields["newFieldKey"]) - } - - @Test - fun testRecordDelete() { - createRecord(STANDARD_KEY) - cache.merge(Record.builder(STANDARD_KEY) - .addField("fieldKey", "valueUpdated") - .addField("newFieldKey", true).build(), CacheHeaders.NONE) - cache.deleteRecord(STANDARD_KEY) - val record = cache.selectRecordForKey(STANDARD_KEY) - assertNull(record) - } - - @Test - fun testClearAll() { - createRecord(QUERY_ROOT_KEY) - createRecord(STANDARD_KEY) - cache.clearAll() - assertNull(cache.selectRecordForKey(QUERY_ROOT_KEY)) - assertNull(cache.selectRecordForKey(STANDARD_KEY)) - } - - // Tests for StandardCacheHeader compliance - @Test - fun testHeader_evictAfterRead() { - createRecord(STANDARD_KEY) - val record = cache.loadRecord(STANDARD_KEY, CacheHeaders.builder() - .addHeader(ApolloCacheHeaders.EVICT_AFTER_READ, "true").build()) - assertNotNull(record) - val nullRecord = cache.loadRecord(STANDARD_KEY, CacheHeaders.builder() - .addHeader(ApolloCacheHeaders.EVICT_AFTER_READ, "true").build()) - assertNull(nullRecord) - } - - @Test - fun testHeader_evictAfterBatchRead() { - createRecord(STANDARD_KEY) - createRecord(QUERY_ROOT_KEY) - val selectionSet = setOf(STANDARD_KEY, QUERY_ROOT_KEY) - val records = cache.loadRecords(selectionSet, CacheHeaders.builder() - .addHeader(ApolloCacheHeaders.EVICT_AFTER_READ, "true").build()) - assertEquals(records.size, 2) - val emptyRecords = cache.loadRecords(selectionSet, CacheHeaders.builder() - .addHeader(ApolloCacheHeaders.EVICT_AFTER_READ, "true").build()) - assertTrue(emptyRecords.isEmpty()) - } - - @Test - fun testHeader_noCache() { - cache.merge(Record.builder(STANDARD_KEY).build(), - CacheHeaders.builder().addHeader(ApolloCacheHeaders.DO_NOT_STORE, "true").build()) - val record = cache.loadRecord(STANDARD_KEY, CacheHeaders.NONE) - assertNull(record) - } - - @Test - fun testRecordMerge_noOldRecord() { - val changedKeys = cache.merge(Record.builder(STANDARD_KEY) - .addField("fieldKey", "valueUpdated") - .addField("newFieldKey", true).build(), CacheHeaders.NONE) - val record = cache.selectRecordForKey(STANDARD_KEY) - assertNotNull(record) - assertEquals(expected = setOf("$STANDARD_KEY.fieldKey", "$STANDARD_KEY.newFieldKey"), actual = changedKeys) - assertEquals(expected = "valueUpdated", actual = record.fields["fieldKey"]) - assertEquals(expected = true, actual = record.fields["newFieldKey"]) - } - - @Test - fun testRecordMerge_withOldRecord() { - createRecord(STANDARD_KEY) - cache.merge(Record.builder(STANDARD_KEY) - .addField("fieldKey", "valueUpdated") - .addField("newFieldKey", true).build(), CacheHeaders.NONE) - val record = cache.selectRecordForKey(STANDARD_KEY) - assertNotNull(record) - assertEquals(expected = "valueUpdated", actual = record.fields["fieldKey"]) - assertEquals(expected = true, actual = record.fields["newFieldKey"]) - } - - private fun createRecord(key: String) { - cache.createRecord(key, FIELDS) - } - - companion object { - const val STANDARD_KEY = "key" - const val QUERY_ROOT_KEY = "QUERY_ROOT" - const val FIELDS = "{\"fieldKey\": \"value\"}" - } -} diff --git a/apollo-normalized-cache-sqlite/src/commonTest/kotlin/com/apollographql/apollo/cache/normalized/sql/createDriver.kt b/apollo-normalized-cache-sqlite/src/commonTest/kotlin/com/apollographql/apollo/cache/normalized/sql/createDriver.kt deleted file mode 100644 index 9ebbc2e2abf..00000000000 --- a/apollo-normalized-cache-sqlite/src/commonTest/kotlin/com/apollographql/apollo/cache/normalized/sql/createDriver.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.apollographql.apollo.cache.normalized.sql - -import com.squareup.sqldelight.db.SqlDriver - -expect fun createDriver(): SqlDriver diff --git a/apollo-normalized-cache-sqlite/src/iosMain/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt b/apollo-normalized-cache-sqlite/src/iosMain/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt deleted file mode 100644 index 8b1d097785c..00000000000 --- a/apollo-normalized-cache-sqlite/src/iosMain/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.apollographql.apollo.cache.normalized.sql - -import com.apollographql.apollo.cache.normalized.NormalizedCacheFactory -import com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter -import com.squareup.sqldelight.db.SqlDriver -import com.squareup.sqldelight.drivers.native.NativeSqliteDriver - -actual class SqlNormalizedCacheFactory internal actual constructor( - driver: SqlDriver -) : NormalizedCacheFactory() { - - constructor() : this("apollo.db") - - constructor(name: String) : this(NativeSqliteDriver(ApolloDatabase.Schema, name)) - - private val apolloDatabase = ApolloDatabase(driver) - - override fun create(recordFieldAdapter: RecordFieldJsonAdapter) = - SqlNormalizedCache(recordFieldAdapter, apolloDatabase, apolloDatabase.cacheQueries) -} diff --git a/apollo-normalized-cache-sqlite/src/iosTest/kotlin/com/apollographql/apollo/cache/normalized/sql/CreateDriver.kt b/apollo-normalized-cache-sqlite/src/iosTest/kotlin/com/apollographql/apollo/cache/normalized/sql/CreateDriver.kt deleted file mode 100644 index 5b17f01bb79..00000000000 --- a/apollo-normalized-cache-sqlite/src/iosTest/kotlin/com/apollographql/apollo/cache/normalized/sql/CreateDriver.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.apollographql.apollo.cache.normalized.sql - -import com.squareup.sqldelight.db.SqlDriver -import com.squareup.sqldelight.drivers.native.NativeSqliteDriver - -actual fun createDriver(): SqlDriver = - NativeSqliteDriver(ApolloDatabase.Schema, "apollo.db") diff --git a/apollo-normalized-cache-sqlite/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt b/apollo-normalized-cache-sqlite/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt similarity index 82% rename from apollo-normalized-cache-sqlite/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt rename to apollo-normalized-cache-sqlite/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt index 78d352534c1..fffd6d6277c 100644 --- a/apollo-normalized-cache-sqlite/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt +++ b/apollo-normalized-cache-sqlite/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/sql/SqlNormalizedCacheFactory.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.cache.normalized.sql +package com.homer.apollographql.apollo.cache.normalized.sql -import com.apollographql.apollo.cache.normalized.NormalizedCacheFactory -import com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter +import com.homer.apollographql.apollo.cache.normalized.NormalizedCacheFactory +import com.homer.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter import com.squareup.sqldelight.db.SqlDriver import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver import java.util.Properties diff --git a/apollo-normalized-cache-sqlite/src/jvmTest/kotlin/com/apollographql/apollo/cache/normalized/sql/CreateDriver.kt b/apollo-normalized-cache-sqlite/src/jvmTest/kotlin/com/apollographql/apollo/cache/normalized/sql/CreateDriver.kt deleted file mode 100644 index b827fd7013d..00000000000 --- a/apollo-normalized-cache-sqlite/src/jvmTest/kotlin/com/apollographql/apollo/cache/normalized/sql/CreateDriver.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.apollographql.apollo.cache.normalized.sql - -import com.squareup.sqldelight.db.SqlDriver -import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver - -actual fun createDriver(): SqlDriver = - JdbcSqliteDriver(JdbcSqliteDriver.IN_MEMORY).also { - ApolloDatabase.Schema.create(it) - } diff --git a/apollo-normalized-cache-sqlite/src/main/AndroidManifest.xml b/apollo-normalized-cache-sqlite/src/main/AndroidManifest.xml index f27653966e4..ef9387b9127 100644 --- a/apollo-normalized-cache-sqlite/src/main/AndroidManifest.xml +++ b/apollo-normalized-cache-sqlite/src/main/AndroidManifest.xml @@ -1 +1 @@ - + diff --git a/apollo-normalized-cache/api.txt b/apollo-normalized-cache/api.txt index 762d5f4cc1c..9c5fe9b89a3 100644 --- a/apollo-normalized-cache/api.txt +++ b/apollo-normalized-cache/api.txt @@ -1,33 +1,33 @@ // Signature format: 3.0 -package com.apollographql.apollo.cache.normalized { +package com.homer.apollographql.apollo.cache.normalized { public interface ApolloStore { - method public com.apollographql.apollo.cache.normalized.CacheKeyResolver cacheKeyResolver(); - method public com.apollographql.apollo.cache.normalized.internal.ResponseNormalizer cacheResponseNormalizer(); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation clearAll(); - method public com.apollographql.apollo.cache.normalized.internal.ResponseNormalizer> networkResponseNormalizer(); - method public com.apollographql.apollo.cache.normalized.NormalizedCache normalizedCache(); + method public com.homer.apollographql.apollo.cache.normalized.CacheKeyResolver cacheKeyResolver(); + method public com.homer.apollographql.apollo.cache.normalized.internal.ResponseNormalizer cacheResponseNormalizer(); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation clearAll(); + method public com.homer.apollographql.apollo.cache.normalized.internal.ResponseNormalizer> networkResponseNormalizer(); + method public com.homer.apollographql.apollo.cache.normalized.NormalizedCache normalizedCache(); method public void publish(java.util.Set keys); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation read(com.apollographql.apollo.api.Operation operation); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation> read(com.apollographql.apollo.api.Operation operation, com.apollographql.apollo.api.internal.ResponseFieldMapper responseFieldMapper, com.apollographql.apollo.cache.normalized.internal.ResponseNormalizer responseNormalizer, com.apollographql.apollo.cache.CacheHeaders cacheHeaders); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation read(com.apollographql.apollo.api.internal.ResponseFieldMapper fieldMapper, com.apollographql.apollo.cache.normalized.CacheKey cacheKey, com.apollographql.apollo.api.Operation.Variables variables); - method public R! readTransaction(com.apollographql.apollo.cache.normalized.internal.Transaction transaction); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation remove(com.apollographql.apollo.cache.normalized.CacheKey cacheKey); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation remove(com.apollographql.apollo.cache.normalized.CacheKey cacheKey, boolean cascade); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation remove(java.util.List cacheKeys); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation> rollbackOptimisticUpdates(error.NonExistentClass mutationId); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation rollbackOptimisticUpdatesAndPublish(error.NonExistentClass mutationId); - method public void subscribe(com.apollographql.apollo.cache.normalized.ApolloStore.RecordChangeSubscriber subscriber); - method public void unsubscribe(com.apollographql.apollo.cache.normalized.ApolloStore.RecordChangeSubscriber subscriber); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation> write(com.apollographql.apollo.api.Operation operation, D operationData); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation> write(com.apollographql.apollo.api.GraphqlFragment fragment, com.apollographql.apollo.cache.normalized.CacheKey cacheKey, com.apollographql.apollo.api.Operation.Variables variables); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation writeAndPublish(com.apollographql.apollo.api.Operation operation, D operationData); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation writeAndPublish(com.apollographql.apollo.api.GraphqlFragment fragment, com.apollographql.apollo.cache.normalized.CacheKey cacheKey, com.apollographql.apollo.api.Operation.Variables variables); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation> writeOptimisticUpdates(com.apollographql.apollo.api.Operation operation, D operationData, error.NonExistentClass mutationId); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation writeOptimisticUpdatesAndPublish(com.apollographql.apollo.api.Operation operation, D operationData, error.NonExistentClass mutationId); - method public R! writeTransaction(com.apollographql.apollo.cache.normalized.internal.Transaction transaction); - field public static final com.apollographql.apollo.cache.normalized.ApolloStore.Companion Companion; - field public static final com.apollographql.apollo.cache.normalized.ApolloStore NO_APOLLO_STORE; + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation read(com.homer.apollographql.apollo.api.Operation operation); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation> read(com.homer.apollographql.apollo.api.Operation operation, com.homer.apollographql.apollo.api.internal.ResponseFieldMapper responseFieldMapper, com.homer.apollographql.apollo.cache.normalized.internal.ResponseNormalizer responseNormalizer, com.homer.apollographql.apollo.cache.CacheHeaders cacheHeaders); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation read(com.homer.apollographql.apollo.api.internal.ResponseFieldMapper fieldMapper, com.homer.apollographql.apollo.cache.normalized.CacheKey cacheKey, com.homer.apollographql.apollo.api.Operation.Variables variables); + method public R! readTransaction(com.homer.apollographql.apollo.cache.normalized.internal.Transaction transaction); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation remove(com.homer.apollographql.apollo.cache.normalized.CacheKey cacheKey); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation remove(com.homer.apollographql.apollo.cache.normalized.CacheKey cacheKey, boolean cascade); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation remove(java.util.List cacheKeys); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation> rollbackOptimisticUpdates(error.NonExistentClass mutationId); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation rollbackOptimisticUpdatesAndPublish(error.NonExistentClass mutationId); + method public void subscribe(com.homer.apollographql.apollo.cache.normalized.ApolloStore.RecordChangeSubscriber subscriber); + method public void unsubscribe(com.homer.apollographql.apollo.cache.normalized.ApolloStore.RecordChangeSubscriber subscriber); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation> write(com.homer.apollographql.apollo.api.Operation operation, D operationData); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation> write(com.homer.apollographql.apollo.api.GraphqlFragment fragment, com.homer.apollographql.apollo.cache.normalized.CacheKey cacheKey, com.homer.apollographql.apollo.api.Operation.Variables variables); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation writeAndPublish(com.homer.apollographql.apollo.api.Operation operation, D operationData); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation writeAndPublish(com.homer.apollographql.apollo.api.GraphqlFragment fragment, com.homer.apollographql.apollo.cache.normalized.CacheKey cacheKey, com.homer.apollographql.apollo.api.Operation.Variables variables); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation> writeOptimisticUpdates(com.homer.apollographql.apollo.api.Operation operation, D operationData, error.NonExistentClass mutationId); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation writeOptimisticUpdatesAndPublish(com.homer.apollographql.apollo.api.Operation operation, D operationData, error.NonExistentClass mutationId); + method public R! writeTransaction(com.homer.apollographql.apollo.cache.normalized.internal.Transaction transaction); + field public static final com.homer.apollographql.apollo.cache.normalized.ApolloStore.Companion Companion; + field public static final com.homer.apollographql.apollo.cache.normalized.ApolloStore NO_APOLLO_STORE; } public static final class ApolloStore.Companion { @@ -40,13 +40,13 @@ package com.apollographql.apollo.cache.normalized { public abstract class ApolloStoreOperation { ctor protected ApolloStoreOperation(error.NonExistentClass dispatcher); method public static final error.NonExistentClass! emptyExecutor(); - method public static final com.apollographql.apollo.cache.normalized.ApolloStoreOperation emptyOperation(T? result); - method public void enqueue(com.apollographql.apollo.cache.normalized.ApolloStoreOperation.Callback? callback); - method @kotlin.jvm.Throws(exceptionClasses=ApolloException::class) public final T! execute() throws com.apollographql.apollo.exception.ApolloException; + method public static final com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation emptyOperation(T? result); + method public void enqueue(com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation.Callback? callback); + method @kotlin.jvm.Throws(exceptionClasses=ApolloException::class) public final T! execute() throws com.homer.apollographql.apollo.exception.ApolloException; method public final void notifyFailure(Throwable t); method public final void notifySuccess(T? result); method protected abstract T! perform(); - field public static final com.apollographql.apollo.cache.normalized.ApolloStoreOperation.Companion Companion; + field public static final com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation.Companion Companion; } public static interface ApolloStoreOperation.Callback { @@ -56,64 +56,64 @@ package com.apollographql.apollo.cache.normalized { public static final class ApolloStoreOperation.Companion { method public error.NonExistentClass! emptyExecutor(); - method public com.apollographql.apollo.cache.normalized.ApolloStoreOperation emptyOperation(T? result); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation emptyOperation(T? result); } - public final class OptimisticNormalizedCache extends com.apollographql.apollo.cache.normalized.NormalizedCache { + public final class OptimisticNormalizedCache extends com.homer.apollographql.apollo.cache.normalized.NormalizedCache { ctor public OptimisticNormalizedCache(); method public void clearAll(); - method public com.apollographql.apollo.cache.normalized.Record? loadRecord(String key, com.apollographql.apollo.cache.CacheHeaders cacheHeaders); - method public java.util.Set mergeOptimisticUpdate(com.apollographql.apollo.cache.normalized.Record record); - method public java.util.Set mergeOptimisticUpdates(java.util.Collection recordSet); - method protected java.util.Set performMerge(com.apollographql.apollo.cache.normalized.Record apolloRecord, com.apollographql.apollo.cache.normalized.Record? oldRecord, com.apollographql.apollo.cache.CacheHeaders cacheHeaders); - method public boolean remove(com.apollographql.apollo.cache.normalized.CacheKey cacheKey, boolean cascade); + method public com.homer.apollographql.apollo.cache.normalized.Record? loadRecord(String key, com.homer.apollographql.apollo.cache.CacheHeaders cacheHeaders); + method public java.util.Set mergeOptimisticUpdate(com.homer.apollographql.apollo.cache.normalized.Record record); + method public java.util.Set mergeOptimisticUpdates(java.util.Collection recordSet); + method protected java.util.Set performMerge(com.homer.apollographql.apollo.cache.normalized.Record apolloRecord, com.homer.apollographql.apollo.cache.normalized.Record? oldRecord, com.homer.apollographql.apollo.cache.CacheHeaders cacheHeaders); + method public boolean remove(com.homer.apollographql.apollo.cache.normalized.CacheKey cacheKey, boolean cascade); method public java.util.Set removeOptimisticUpdates(error.NonExistentClass mutationId); } } -package com.apollographql.apollo.cache.normalized.lru { +package com.homer.apollographql.apollo.cache.normalized.lru { public final class EvictionPolicy { - method public static com.apollographql.apollo.cache.normalized.lru.EvictionPolicy.Builder builder(); - method @Deprecated public com.apollographql.apollo.api.internal.Optional expireAfterAccess(); - method @Deprecated public com.apollographql.apollo.api.internal.Optional expireAfterAccessTimeUnit(); - method @Deprecated public com.apollographql.apollo.api.internal.Optional expireAfterWrite(); - method @Deprecated public com.apollographql.apollo.api.internal.Optional expireAfterWriteTimeUnit(); + method public static com.homer.apollographql.apollo.cache.normalized.lru.EvictionPolicy.Builder builder(); + method @Deprecated public com.homer.apollographql.apollo.api.internal.Optional expireAfterAccess(); + method @Deprecated public com.homer.apollographql.apollo.api.internal.Optional expireAfterAccessTimeUnit(); + method @Deprecated public com.homer.apollographql.apollo.api.internal.Optional expireAfterWrite(); + method @Deprecated public com.homer.apollographql.apollo.api.internal.Optional expireAfterWriteTimeUnit(); method public Long? getExpireAfterAccess(); method public error.NonExistentClass? getExpireAfterAccessTimeUnit(); method public Long? getExpireAfterWrite(); method public error.NonExistentClass? getExpireAfterWriteTimeUnit(); method public Long? getMaxEntries(); method public Long? getMaxSizeBytes(); - method @Deprecated public com.apollographql.apollo.api.internal.Optional maxEntries(); - method @Deprecated public com.apollographql.apollo.api.internal.Optional maxSizeBytes(); - field public static final com.apollographql.apollo.cache.normalized.lru.EvictionPolicy.Companion Companion; - field public static final com.apollographql.apollo.cache.normalized.lru.EvictionPolicy NO_EVICTION; + method @Deprecated public com.homer.apollographql.apollo.api.internal.Optional maxEntries(); + method @Deprecated public com.homer.apollographql.apollo.api.internal.Optional maxSizeBytes(); + field public static final com.homer.apollographql.apollo.cache.normalized.lru.EvictionPolicy.Companion Companion; + field public static final com.homer.apollographql.apollo.cache.normalized.lru.EvictionPolicy NO_EVICTION; } public static final class EvictionPolicy.Builder { - method public com.apollographql.apollo.cache.normalized.lru.EvictionPolicy build(); - method public com.apollographql.apollo.cache.normalized.lru.EvictionPolicy.Builder expireAfterAccess(long time, error.NonExistentClass timeUnit); - method public com.apollographql.apollo.cache.normalized.lru.EvictionPolicy.Builder expireAfterWrite(long time, error.NonExistentClass timeUnit); - method public com.apollographql.apollo.cache.normalized.lru.EvictionPolicy.Builder maxEntries(long maxEntries); - method public com.apollographql.apollo.cache.normalized.lru.EvictionPolicy.Builder maxSizeBytes(long maxSizeBytes); + method public com.homer.apollographql.apollo.cache.normalized.lru.EvictionPolicy build(); + method public com.homer.apollographql.apollo.cache.normalized.lru.EvictionPolicy.Builder expireAfterAccess(long time, error.NonExistentClass timeUnit); + method public com.homer.apollographql.apollo.cache.normalized.lru.EvictionPolicy.Builder expireAfterWrite(long time, error.NonExistentClass timeUnit); + method public com.homer.apollographql.apollo.cache.normalized.lru.EvictionPolicy.Builder maxEntries(long maxEntries); + method public com.homer.apollographql.apollo.cache.normalized.lru.EvictionPolicy.Builder maxSizeBytes(long maxSizeBytes); } public static final class EvictionPolicy.Companion { - method public com.apollographql.apollo.cache.normalized.lru.EvictionPolicy.Builder builder(); + method public com.homer.apollographql.apollo.cache.normalized.lru.EvictionPolicy.Builder builder(); } - public final class LruNormalizedCache extends com.apollographql.apollo.cache.normalized.NormalizedCache { + public final class LruNormalizedCache extends com.homer.apollographql.apollo.cache.normalized.NormalizedCache { method public void clearAll(); - method public com.apollographql.apollo.cache.normalized.Record? loadRecord(String key, com.apollographql.apollo.cache.CacheHeaders cacheHeaders); - method protected java.util.Set performMerge(com.apollographql.apollo.cache.normalized.Record apolloRecord, com.apollographql.apollo.cache.normalized.Record? oldRecord, com.apollographql.apollo.cache.CacheHeaders cacheHeaders); - method public boolean remove(com.apollographql.apollo.cache.normalized.CacheKey cacheKey, boolean cascade); + method public com.homer.apollographql.apollo.cache.normalized.Record? loadRecord(String key, com.homer.apollographql.apollo.cache.CacheHeaders cacheHeaders); + method protected java.util.Set performMerge(com.homer.apollographql.apollo.cache.normalized.Record apolloRecord, com.homer.apollographql.apollo.cache.normalized.Record? oldRecord, com.homer.apollographql.apollo.cache.CacheHeaders cacheHeaders); + method public boolean remove(com.homer.apollographql.apollo.cache.normalized.CacheKey cacheKey, boolean cascade); } - public final class LruNormalizedCacheFactory extends com.apollographql.apollo.cache.normalized.NormalizedCacheFactory { - ctor public LruNormalizedCacheFactory(com.apollographql.apollo.cache.normalized.lru.EvictionPolicy evictionPolicy); - method public com.apollographql.apollo.cache.normalized.lru.LruNormalizedCache create(com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter recordFieldAdapter); + public final class LruNormalizedCacheFactory extends com.homer.apollographql.apollo.cache.normalized.NormalizedCacheFactory { + ctor public LruNormalizedCacheFactory(com.homer.apollographql.apollo.cache.normalized.lru.EvictionPolicy evictionPolicy); + method public com.homer.apollographql.apollo.cache.normalized.lru.LruNormalizedCache create(com.homer.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter recordFieldAdapter); } } diff --git a/apollo-normalized-cache/build.gradle.kts b/apollo-normalized-cache/build.gradle.kts index 353dc6d0d9f..59ee54d4988 100644 --- a/apollo-normalized-cache/build.gradle.kts +++ b/apollo-normalized-cache/build.gradle.kts @@ -4,22 +4,6 @@ plugins { } kotlin { - @Suppress("ClassName") - data class iOSTarget(val name: String, val preset: String, val id: String) - - val iosTargets = listOf( - iOSTarget("ios", "iosArm64", "ios-arm64"), - iOSTarget("iosSim", "iosX64", "ios-x64") - ) - - for ((targetName, presetName, id) in iosTargets) { - targetFromPreset(presets.getByName(presetName), targetName) { - mavenPublication { - artifactId = "${project.name}-$id" - } - } - } - jvm { withJava() } @@ -28,7 +12,9 @@ kotlin { val commonMain by getting { dependencies { api(project(":apollo-api")) - api(project(":apollo-normalized-cache-api")) + api(project(":apollo-normalized-cache-api")) { + targetConfiguration = "jvmApiElements" + } } } @@ -38,20 +24,11 @@ kotlin { implementation(groovy.util.Eval.x(project, "x.dep.cache")) } } - - val jvmTest by getting { - dependsOn(jvmMain) - dependencies { - implementation(groovy.util.Eval.x(project, "x.dep.junit")) - implementation(groovy.util.Eval.x(project, "x.dep.truth")) - } - } - } } metalava { - hiddenPackages += setOf("com.apollographql.apollo.cache.normalized.internal") + hiddenPackages += setOf("com.homer.apollographql.apollo.cache.normalized.internal") } tasks.withType { diff --git a/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/Transaction.kt b/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/Transaction.kt deleted file mode 100644 index 384bac98001..00000000000 --- a/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/Transaction.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.apollographql.apollo.cache.normalized.internal - -interface Transaction { - fun execute(cache: T): R? -} \ No newline at end of file diff --git a/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/CacheFieldValueResolver.kt b/apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/CacheFieldValueResolver.kt similarity index 76% rename from apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/CacheFieldValueResolver.kt rename to apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/CacheFieldValueResolver.kt index 2af4b5a2916..41358ccfcde 100644 --- a/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/CacheFieldValueResolver.kt +++ b/apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/CacheFieldValueResolver.kt @@ -1,15 +1,15 @@ -package com.apollographql.apollo.cache.normalized.internal +package com.homer.apollographql.apollo.cache.normalized.internal -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ResponseField.Type.LIST -import com.apollographql.apollo.api.ResponseField.Type.OBJECT -import com.apollographql.apollo.api.internal.FieldValueResolver -import com.apollographql.apollo.cache.CacheHeaders -import com.apollographql.apollo.cache.normalized.CacheKey.Companion.NO_KEY -import com.apollographql.apollo.cache.normalized.CacheKeyResolver -import com.apollographql.apollo.cache.normalized.CacheReference -import com.apollographql.apollo.cache.normalized.Record +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.ResponseField +import com.homer.apollographql.apollo.api.ResponseField.Type.LIST +import com.homer.apollographql.apollo.api.ResponseField.Type.OBJECT +import com.homer.apollographql.apollo.api.internal.FieldValueResolver +import com.homer.apollographql.apollo.cache.CacheHeaders +import com.homer.apollographql.apollo.cache.normalized.CacheKey.Companion.NO_KEY +import com.homer.apollographql.apollo.cache.normalized.CacheKeyResolver +import com.homer.apollographql.apollo.cache.normalized.CacheReference +import com.homer.apollographql.apollo.cache.normalized.Record class CacheFieldValueResolver( private val readableCache: ReadableStore, diff --git a/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/CacheMissException.kt b/apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/CacheMissException.kt similarity index 65% rename from apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/CacheMissException.kt rename to apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/CacheMissException.kt index aa0de0863bd..b3fdc8c216b 100644 --- a/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/CacheMissException.kt +++ b/apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/CacheMissException.kt @@ -1,8 +1,8 @@ @file:Suppress("MemberVisibilityCanBePrivate") -package com.apollographql.apollo.cache.normalized.internal +package com.homer.apollographql.apollo.cache.normalized.internal -import com.apollographql.apollo.cache.normalized.Record +import com.homer.apollographql.apollo.cache.normalized.Record class CacheMissException( val record: Record, diff --git a/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/RealCacheKeyBuilder.kt b/apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/RealCacheKeyBuilder.kt similarity index 80% rename from apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/RealCacheKeyBuilder.kt rename to apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/RealCacheKeyBuilder.kt index 34a0dd21292..1ba91ba1259 100644 --- a/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/RealCacheKeyBuilder.kt +++ b/apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/RealCacheKeyBuilder.kt @@ -1,11 +1,11 @@ -package com.apollographql.apollo.cache.normalized.internal +package com.homer.apollographql.apollo.cache.normalized.internal -import com.apollographql.apollo.api.InputType -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ResponseField.Companion.isArgumentValueVariableType -import com.apollographql.apollo.api.internal.json.JsonWriter -import com.apollographql.apollo.api.internal.json.Utils +import com.homer.apollographql.apollo.api.InputType +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.ResponseField +import com.homer.apollographql.apollo.api.ResponseField.Companion.isArgumentValueVariableType +import com.homer.apollographql.apollo.api.internal.json.JsonWriter +import com.homer.apollographql.apollo.api.internal.json.Utils import okio.Buffer import okio.IOException diff --git a/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/ResponseNormalizer.kt b/apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/ResponseNormalizer.kt similarity index 87% rename from apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/ResponseNormalizer.kt rename to apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/ResponseNormalizer.kt index 839b4ea5b36..2998e4e2098 100644 --- a/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/ResponseNormalizer.kt +++ b/apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/ResponseNormalizer.kt @@ -1,14 +1,14 @@ -package com.apollographql.apollo.cache.normalized.internal - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.internal.ResolveDelegate -import com.apollographql.apollo.cache.normalized.CacheKey -import com.apollographql.apollo.cache.normalized.CacheKeyResolver.Companion.rootKeyForOperation -import com.apollographql.apollo.cache.normalized.CacheReference -import com.apollographql.apollo.cache.normalized.Record -import com.apollographql.apollo.cache.normalized.Record.Companion.builder -import com.apollographql.apollo.cache.normalized.RecordSet +package com.homer.apollographql.apollo.cache.normalized.internal + +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.ResponseField +import com.homer.apollographql.apollo.api.internal.ResolveDelegate +import com.homer.apollographql.apollo.cache.normalized.CacheKey +import com.homer.apollographql.apollo.cache.normalized.CacheKeyResolver.Companion.rootKeyForOperation +import com.homer.apollographql.apollo.cache.normalized.CacheReference +import com.homer.apollographql.apollo.cache.normalized.Record +import com.homer.apollographql.apollo.cache.normalized.Record.Companion.builder +import com.homer.apollographql.apollo.cache.normalized.RecordSet import kotlin.jvm.JvmField abstract class ResponseNormalizer : ResolveDelegate { diff --git a/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/SimpleStack.kt b/apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/SimpleStack.kt similarity index 88% rename from apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/SimpleStack.kt rename to apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/SimpleStack.kt index 9c402960648..dd1675148f6 100644 --- a/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/SimpleStack.kt +++ b/apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/SimpleStack.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.cache.normalized.internal +package com.homer.apollographql.apollo.cache.normalized.internal /** * Simple stack data structure which accepts null elements. Backed by list. diff --git a/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/SortedInputFieldMapWriter.kt b/apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/SortedInputFieldMapWriter.kt similarity index 91% rename from apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/SortedInputFieldMapWriter.kt rename to apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/SortedInputFieldMapWriter.kt index bbd5a1cdd07..582a63b48bd 100644 --- a/apollo-normalized-cache/src/commonMain/kotlin/com/apollographql/apollo/cache/normalized/internal/SortedInputFieldMapWriter.kt +++ b/apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/SortedInputFieldMapWriter.kt @@ -1,9 +1,9 @@ -package com.apollographql.apollo.cache.normalized.internal +package com.homer.apollographql.apollo.cache.normalized.internal -import com.apollographql.apollo.api.ScalarType -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.InputFieldWriter -import com.apollographql.apollo.api.internal.Throws +import com.homer.apollographql.apollo.api.ScalarType +import com.homer.apollographql.apollo.api.internal.InputFieldMarshaller +import com.homer.apollographql.apollo.api.internal.InputFieldWriter +import com.homer.apollographql.apollo.api.internal.Throws import okio.IOException class SortedInputFieldMapWriter() : InputFieldWriter { diff --git a/apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/Transaction.kt b/apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/Transaction.kt new file mode 100644 index 00000000000..ddbfa5b46fe --- /dev/null +++ b/apollo-normalized-cache/src/commonMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/Transaction.kt @@ -0,0 +1,5 @@ +package com.homer.apollographql.apollo.cache.normalized.internal + +interface Transaction { + fun execute(cache: T): R? +} \ No newline at end of file diff --git a/apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/ApolloStore.kt b/apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/ApolloStore.kt similarity index 88% rename from apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/ApolloStore.kt rename to apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/ApolloStore.kt index 848bc864dc3..c888caa5d2d 100644 --- a/apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/ApolloStore.kt +++ b/apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/ApolloStore.kt @@ -1,20 +1,20 @@ -package com.apollographql.apollo.cache.normalized +package com.homer.apollographql.apollo.cache.normalized -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.cache.CacheHeaders -import com.apollographql.apollo.cache.normalized.ApolloStore.RecordChangeSubscriber -import com.apollographql.apollo.cache.normalized.internal.NoOpApolloStore -import com.apollographql.apollo.cache.normalized.internal.ReadableStore -import com.apollographql.apollo.cache.normalized.internal.ResponseNormalizer -import com.apollographql.apollo.cache.normalized.internal.Transaction -import com.apollographql.apollo.cache.normalized.internal.WriteableStore +import com.homer.apollographql.apollo.api.GraphqlFragment +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.Response +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper +import com.homer.apollographql.apollo.cache.CacheHeaders +import com.homer.apollographql.apollo.cache.normalized.ApolloStore.RecordChangeSubscriber +import com.homer.apollographql.apollo.cache.normalized.internal.NoOpApolloStore +import com.homer.apollographql.apollo.cache.normalized.internal.ReadableStore +import com.homer.apollographql.apollo.cache.normalized.internal.ResponseNormalizer +import com.homer.apollographql.apollo.cache.normalized.internal.Transaction +import com.homer.apollographql.apollo.cache.normalized.internal.WriteableStore import java.util.UUID /** - * ApolloStore exposes a thread-safe api to access a [com.apollographql.apollo.cache.normalized.NormalizedCache]. + * ApolloStore exposes a thread-safe api to access a [com.homer.apollographql.apollo.cache.normalized.NormalizedCache]. * It also maintains a list of [RecordChangeSubscriber] that will be notified with changed records. * * Most clients should have no need to directly interface with an [ApolloStore]. @@ -175,7 +175,7 @@ interface ApolloStore { ): ApolloStoreOperation> /** - * Write operation to the store and publish changes of [Record] which have changed, that will notify any [com.apollographql.apollo.ApolloQueryWatcher] that depends on these [Record] to re-fetch. + * Write operation to the store and publish changes of [Record] which have changed, that will notify any [com.homer.apollographql.apollo.ApolloQueryWatcher] that depends on these [Record] to re-fetch. * * @param operation [Operation] response data of which should be written to the store * @param operationData [Operation.Data] operation response data to be written to the store @@ -236,7 +236,7 @@ interface ApolloStore { /** * Write operation data to the optimistic store and publish changes of [Record]s which have changed, that will - * notify any [com.apollographql.apollo.ApolloQueryWatcher] that depends on these [Record] to re-fetch. + * notify any [com.homer.apollographql.apollo.ApolloQueryWatcher] that depends on these [Record] to re-fetch. * * @param operation [Operation] response data of which should be written to the store * @param operationData [Operation.Data] operation response data to be written to the store @@ -259,7 +259,7 @@ interface ApolloStore { /** * Rollback operation data optimistic updates and publish changes of [Record]s which have changed, that will - * notify any [com.apollographql.apollo.ApolloQueryWatcher] that depends on these [Record] to re-fetch. + * notify any [com.homer.apollographql.apollo.ApolloQueryWatcher] that depends on these [Record] to re-fetch. * * @param mutationId mutation unique identifier * @return {@ApolloStoreOperation} to be performed, that will be resolved with set of keys of [Record] which diff --git a/apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/ApolloStoreOperation.kt b/apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/ApolloStoreOperation.kt similarity index 95% rename from apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/ApolloStoreOperation.kt rename to apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/ApolloStoreOperation.kt index fa426acb4bc..f1867600999 100644 --- a/apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/ApolloStoreOperation.kt +++ b/apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/ApolloStoreOperation.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.cache.normalized +package com.homer.apollographql.apollo.cache.normalized -import com.apollographql.apollo.exception.ApolloException +import com.homer.apollographql.apollo.exception.ApolloException import java.util.concurrent.Executor import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicReference diff --git a/apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/OptimisticNormalizedCache.kt b/apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/OptimisticNormalizedCache.kt similarity index 97% rename from apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/OptimisticNormalizedCache.kt rename to apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/OptimisticNormalizedCache.kt index 4bdeb7eea9b..0de6d6707ba 100644 --- a/apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/OptimisticNormalizedCache.kt +++ b/apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/OptimisticNormalizedCache.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.cache.normalized +package com.homer.apollographql.apollo.cache.normalized -import com.apollographql.apollo.cache.CacheHeaders +import com.homer.apollographql.apollo.cache.CacheHeaders import com.nytimes.android.external.cache.CacheBuilder import java.util.UUID import kotlin.math.max diff --git a/apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/internal/NoOpApolloStore.kt b/apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/NoOpApolloStore.kt similarity index 84% rename from apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/internal/NoOpApolloStore.kt rename to apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/NoOpApolloStore.kt index 56c8c20ecce..bf7b49acc65 100644 --- a/apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/internal/NoOpApolloStore.kt +++ b/apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/internal/NoOpApolloStore.kt @@ -1,18 +1,18 @@ -package com.apollographql.apollo.cache.normalized.internal - -import com.apollographql.apollo.api.GraphqlFragment -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.Response.Companion.builder -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.cache.CacheHeaders -import com.apollographql.apollo.cache.normalized.ApolloStore -import com.apollographql.apollo.cache.normalized.ApolloStoreOperation -import com.apollographql.apollo.cache.normalized.ApolloStoreOperation.Companion.emptyOperation -import com.apollographql.apollo.cache.normalized.CacheKey -import com.apollographql.apollo.cache.normalized.CacheKeyResolver -import com.apollographql.apollo.cache.normalized.NormalizedCache -import com.apollographql.apollo.cache.normalized.Record +package com.homer.apollographql.apollo.cache.normalized.internal + +import com.homer.apollographql.apollo.api.GraphqlFragment +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.Response +import com.homer.apollographql.apollo.api.Response.Companion.builder +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper +import com.homer.apollographql.apollo.cache.CacheHeaders +import com.homer.apollographql.apollo.cache.normalized.ApolloStore +import com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation +import com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation.Companion.emptyOperation +import com.homer.apollographql.apollo.cache.normalized.CacheKey +import com.homer.apollographql.apollo.cache.normalized.CacheKeyResolver +import com.homer.apollographql.apollo.cache.normalized.NormalizedCache +import com.homer.apollographql.apollo.cache.normalized.Record import java.util.UUID /** diff --git a/apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/lru/EvictionPolicy.kt b/apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/lru/EvictionPolicy.kt similarity index 63% rename from apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/lru/EvictionPolicy.kt rename to apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/lru/EvictionPolicy.kt index 7c826b889ec..e77c7c5f141 100644 --- a/apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/lru/EvictionPolicy.kt +++ b/apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/lru/EvictionPolicy.kt @@ -1,10 +1,10 @@ -package com.apollographql.apollo.cache.normalized.lru +package com.homer.apollographql.apollo.cache.normalized.lru -import com.apollographql.apollo.api.internal.Optional +import com.homer.apollographql.apollo.api.internal.Optional import java.util.concurrent.TimeUnit /** - * Controls how long a [com.apollographql.apollo.cache.normalized.Record] will + * Controls how long a [com.homer.apollographql.apollo.cache.normalized.Record] will * stay in a [LruNormalizedCache]. */ class EvictionPolicy internal constructor( @@ -17,22 +17,22 @@ class EvictionPolicy internal constructor( ) { @Deprecated("Use property instead", replaceWith = ReplaceWith("maxSizeBytes")) - fun maxSizeBytes(): Optional = Optional.fromNullable(maxSizeBytes) + fun maxSizeBytes(): com.homer.apollographql.apollo.api.internal.Optional = com.homer.apollographql.apollo.api.internal.Optional.fromNullable(maxSizeBytes) @Deprecated("Use property instead", replaceWith = ReplaceWith("maxEntries")) - fun maxEntries(): Optional = Optional.fromNullable(maxEntries) + fun maxEntries(): com.homer.apollographql.apollo.api.internal.Optional = com.homer.apollographql.apollo.api.internal.Optional.fromNullable(maxEntries) @Deprecated("Use property instead", replaceWith = ReplaceWith("expireAfterAccess")) - fun expireAfterAccess(): Optional = Optional.fromNullable(expireAfterAccess) + fun expireAfterAccess(): com.homer.apollographql.apollo.api.internal.Optional = com.homer.apollographql.apollo.api.internal.Optional.fromNullable(expireAfterAccess) @Deprecated("Use property instead", replaceWith = ReplaceWith("expireAfterAccessTimeUnit")) - fun expireAfterAccessTimeUnit(): Optional = Optional.fromNullable(expireAfterAccessTimeUnit) + fun expireAfterAccessTimeUnit(): com.homer.apollographql.apollo.api.internal.Optional = com.homer.apollographql.apollo.api.internal.Optional.fromNullable(expireAfterAccessTimeUnit) @Deprecated("Use property instead", replaceWith = ReplaceWith("expireAfterWrite")) - fun expireAfterWrite(): Optional = Optional.fromNullable(expireAfterWrite) + fun expireAfterWrite(): com.homer.apollographql.apollo.api.internal.Optional = com.homer.apollographql.apollo.api.internal.Optional.fromNullable(expireAfterWrite) @Deprecated("Use property instead", replaceWith = ReplaceWith("expireAfterWriteTimeUnit")) - fun expireAfterWriteTimeUnit(): Optional = Optional.fromNullable(expireAfterWriteTimeUnit) + fun expireAfterWriteTimeUnit(): com.homer.apollographql.apollo.api.internal.Optional = com.homer.apollographql.apollo.api.internal.Optional.fromNullable(expireAfterWriteTimeUnit) class Builder internal constructor() { private var maxSizeBytes: Long? = null diff --git a/apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/lru/LruNormalizedCache.kt b/apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/lru/LruNormalizedCache.kt similarity index 89% rename from apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/lru/LruNormalizedCache.kt rename to apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/lru/LruNormalizedCache.kt index 423702e09c7..5641c8b03a7 100644 --- a/apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/lru/LruNormalizedCache.kt +++ b/apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/lru/LruNormalizedCache.kt @@ -1,10 +1,10 @@ -package com.apollographql.apollo.cache.normalized.lru +package com.homer.apollographql.apollo.cache.normalized.lru -import com.apollographql.apollo.cache.ApolloCacheHeaders -import com.apollographql.apollo.cache.CacheHeaders -import com.apollographql.apollo.cache.normalized.CacheKey -import com.apollographql.apollo.cache.normalized.NormalizedCache -import com.apollographql.apollo.cache.normalized.Record +import com.homer.apollographql.apollo.cache.ApolloCacheHeaders +import com.homer.apollographql.apollo.cache.CacheHeaders +import com.homer.apollographql.apollo.cache.normalized.CacheKey +import com.homer.apollographql.apollo.cache.normalized.NormalizedCache +import com.homer.apollographql.apollo.cache.normalized.Record import com.nytimes.android.external.cache.Cache import com.nytimes.android.external.cache.CacheBuilder import com.nytimes.android.external.cache.Weigher diff --git a/apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/lru/LruNormalizedCacheFactory.kt b/apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/lru/LruNormalizedCacheFactory.kt similarity index 60% rename from apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/lru/LruNormalizedCacheFactory.kt rename to apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/lru/LruNormalizedCacheFactory.kt index d7b118ae975..e2b9333559a 100644 --- a/apollo-normalized-cache/src/jvmMain/kotlin/com/apollographql/apollo/cache/normalized/lru/LruNormalizedCacheFactory.kt +++ b/apollo-normalized-cache/src/jvmMain/kotlin/com/homer/apollographql/apollo/cache/normalized/lru/LruNormalizedCacheFactory.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.cache.normalized.lru +package com.homer.apollographql.apollo.cache.normalized.lru -import com.apollographql.apollo.cache.normalized.NormalizedCacheFactory -import com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter +import com.homer.apollographql.apollo.cache.normalized.NormalizedCacheFactory +import com.homer.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter class LruNormalizedCacheFactory( /** diff --git a/apollo-normalized-cache/src/jvmTest/java/com/apollographql/apollo/cache/normalized/internal/CacheKeyBuilderTest.kt b/apollo-normalized-cache/src/jvmTest/java/com/apollographql/apollo/cache/normalized/internal/CacheKeyBuilderTest.kt deleted file mode 100644 index 107e0c8c70b..00000000000 --- a/apollo-normalized-cache/src/jvmTest/java/com/apollographql/apollo/cache/normalized/internal/CacheKeyBuilderTest.kt +++ /dev/null @@ -1,393 +0,0 @@ -package com.apollographql.apollo.cache.normalized.internal - -import com.apollographql.apollo.api.InputType -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ResponseField.Companion.forString -import com.apollographql.apollo.api.ScalarType -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.InputFieldWriter -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder -import com.google.common.truth.Truth -import org.junit.Test -import java.io.IOException -import java.math.BigDecimal -import java.util.HashMap - -class CacheKeyBuilderTest { - private val cacheKeyBuilder: CacheKeyBuilder = RealCacheKeyBuilder() - - internal enum class Episode { - JEDI - } - - @Test - fun testFieldWithNoArguments() { - val field = forString("hero", "hero", null, false, emptyList()) - val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map { - return super.valueMap() - } - } - Truth.assertThat(cacheKeyBuilder.build(field, variables)).isEqualTo("hero") - } - - @Test - fun testFieldWithNoArgumentsWithAlias() { - val field = forString("r2", "hero", null, false, emptyList()) - val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map { - return super.valueMap() - } - } - Truth.assertThat(cacheKeyBuilder.build(field, variables)).isEqualTo("hero") - } - - @Test - fun testFieldWithArgument() { - val arguments = UnmodifiableMapBuilder(1) - .put("episode", "JEDI") - .build() - val field = createResponseField("hero", "hero", arguments) - val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map { - return super.valueMap() - } - } - Truth.assertThat(cacheKeyBuilder.build(field, variables)).isEqualTo("hero({\"episode\":\"JEDI\"})") - } - - @Test - fun testFieldWithArgumentAndAlias() { - val arguments = UnmodifiableMapBuilder(1) - .put("episode", "JEDI") - .build() - val field = createResponseField("r2", "hero", arguments) - val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map { - return super.valueMap() - } - } - Truth.assertThat(cacheKeyBuilder.build(field, variables)).isEqualTo("hero({\"episode\":\"JEDI\"})") - } - - @Test - fun testFieldWithVariableArgument() { - val argument = UnmodifiableMapBuilder(1) - .put("episode", UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "episode") - .build()) - val field = createResponseField("hero", "hero", argument - .build()) - val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map { - val map = HashMap() - map["episode"] = Episode.JEDI - return map - } - } - Truth.assertThat(cacheKeyBuilder.build(field, variables)).isEqualTo("hero({\"episode\":\"JEDI\"})") - } - - @Test - fun testFieldWithVariableArgumentNull() { - val argument = UnmodifiableMapBuilder(1) - .put("episode", UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "episode") - .build()) - val field = createResponseField("hero", "hero", argument - .build()) - val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map { - val map = HashMap() - map["episode"] = null - return map - } - } - Truth.assertThat(cacheKeyBuilder.build(field, variables)).isEqualTo("hero({\"episode\":null})") - } - - @Test - fun testFieldWithMultipleArgument() { - val build = UnmodifiableMapBuilder(1) - .put("episode", "JEDI") - .put("color", "blue") - .build() - val field = createResponseField("hero", "hero", build) - val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map { - return super.valueMap() - } - } - Truth.assertThat(cacheKeyBuilder.build(field, variables)).isEqualTo("hero({\"color\":\"blue\",\"episode\":\"JEDI\"})") - } - - @Test - fun testFieldWithMultipleArgumentsOrderIndependent() { - val arguments = UnmodifiableMapBuilder(1) - .put("episode", "JEDI") - .put("color", "blue") - .build() - val field = createResponseField("hero", "hero", arguments) - val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map { - return super.valueMap() - } - } - val fieldTwoArguments = UnmodifiableMapBuilder(1) - .put("color", "blue") - .put("episode", "JEDI") - .build() - val fieldTwo = createResponseField("hero", "hero", fieldTwoArguments) - Truth.assertThat(cacheKeyBuilder.build(fieldTwo, variables)).isEqualTo(cacheKeyBuilder.build(field, variables)) - } - - @Test - fun testFieldWithNestedObject() { - val arguments = UnmodifiableMapBuilder(1) - .put("episode", "JEDI") - .put("nested", UnmodifiableMapBuilder(2) - .put("foo", 1) - .put("bar", 2) - .build()) - .build() - val field = createResponseField("hero", "hero", arguments) - val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map { - return super.valueMap() - } - } - Truth.assertThat(cacheKeyBuilder.build(field, variables)).isEqualTo("hero({\"episode\":\"JEDI\",\"nested\":{\"bar\":2,\"foo\":1}})") - } - - @Test - fun testFieldWithNonPrimitiveValue() { - val field = forString("hero", "hero", UnmodifiableMapBuilder(1) - .put("episode", Episode.JEDI) - .build(), false, emptyList()) - val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map { - return super.valueMap() - } - } - Truth.assertThat(cacheKeyBuilder.build(field, variables)).isEqualTo("hero({\"episode\":\"JEDI\"})") - } - - @Test - fun testFieldWithNestedObjectAndVariables() { - val arguments = UnmodifiableMapBuilder(1) - .put("episode", "JEDI") - .put("nested", UnmodifiableMapBuilder(2) - .put("foo", UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "stars") - .build()) - .put("bar", "2") - .build()) - .build() - val field = createResponseField("hero", "hero", arguments) - val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map { - val map = HashMap() - map["stars"] = 1 - return map - } - } - Truth.assertThat(cacheKeyBuilder.build(field, variables)).isEqualTo("hero({\"episode\":\"JEDI\",\"nested\":{\"bar\":\"2\",\"foo\":1}})") - } - - @Test - fun fieldInputTypeArgument() { - val arguments = UnmodifiableMapBuilder(1) - .put("episode", "JEDI") - .put("nested", UnmodifiableMapBuilder(2) - .put("foo", UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "testInput") - .build()) - .put("bar", "2") - .build()) - .build() - val field = createResponseField("hero", "hero", arguments) - val testInput: InputType = object : InputType { - override fun marshaller(): InputFieldMarshaller { - return object : InputFieldMarshaller { - @Throws(IOException::class) - override fun marshal(writer: InputFieldWriter) { - writer.writeString("string", "string") - writer.writeInt("int", 1) - writer.writeLong("long", 2L) - writer.writeDouble("double", 3.0) - writer.writeNumber("number", BigDecimal.valueOf(4)) - writer.writeBoolean("boolean", true) - writer.writeCustom("custom", object : ScalarType { - override fun typeName(): String { - return "EPISODE" - } - - override fun className(): String { - return String::class.java.name - } - }, "JEDI") - writer.writeObject("object", object : InputFieldMarshaller { - @Throws(IOException::class) - override fun marshal(writer: InputFieldWriter) { - writer.writeString("string", "string") - writer.writeInt("int", 1) - } - }) - writer.writeList("list") { listItemWriter -> - listItemWriter.writeString("string") - listItemWriter.writeInt(1) - listItemWriter.writeLong(2L) - listItemWriter.writeDouble(3.0) - listItemWriter.writeNumber(BigDecimal.valueOf(4)) - listItemWriter.writeBoolean(true) - listItemWriter.writeCustom(object : ScalarType { - override fun typeName(): String { - return "EPISODE" - } - - override fun className(): String { - return String::class.java.name - } - }, "JEDI") - listItemWriter.writeObject(object : InputFieldMarshaller { - @Throws(IOException::class) - override fun marshal(writer: InputFieldWriter) { - writer.writeString("string", "string") - writer.writeInt("int", 1) - } - }) - listItemWriter.writeList(object : InputFieldWriter.ListWriter { - @Throws(IOException::class) - override fun write(listItemWriter: InputFieldWriter.ListItemWriter) { - listItemWriter.writeString("string") - listItemWriter.writeInt(1) - } - }) - } - } - } - } - } - val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map { - val map = HashMap() - map["testInput"] = testInput - return map - } - } - Truth.assertThat(cacheKeyBuilder.build(field, variables)).isEqualTo( - "hero({\"episode\":\"JEDI\",\"nested\":{\"bar\":\"2\",\"foo\":{\"boolean\":true,\"custom\":\"JEDI\",\"double\":3.0,\"int\":1," - + "\"list\":[\"string\",1,2,3.0,4,true,\"JEDI\",{\"int\":1,\"string\":\"string\"},[\"string\",1]],\"long\":2," - + "\"number\":4,\"object\":{\"int\":1,\"string\":\"string\"},\"string\":\"string\"}}})") - } - - @Test - fun testFieldArgumentInputTypeWithNulls() { - val arguments = UnmodifiableMapBuilder(1) - .put("episode", null) - .put("nested", UnmodifiableMapBuilder(2) - .put("foo", UnmodifiableMapBuilder(2) - .put("kind", "Variable") - .put("variableName", "testInput") - .build()) - .put("bar", null) - .build()) - .build() - val field = createResponseField("hero", "hero", arguments) - val testInput: InputType = object : InputType { - override fun marshaller(): InputFieldMarshaller { - return object : InputFieldMarshaller { - @Throws(IOException::class) - override fun marshal(writer: InputFieldWriter) { - writer.writeString("string", null) - writer.writeInt("int", null) - writer.writeLong("long", null) - writer.writeDouble("double", null) - writer.writeNumber("number", null) - writer.writeBoolean("boolean", null) - writer.writeCustom("custom", object : ScalarType { - override fun typeName(): String { - return "EPISODE" - } - - override fun className(): String { - return String::class.java.name - } - }, null) - writer.writeObject("object", null) - writer.writeList("listNull", null) - writer.writeList("listWithNulls", object : InputFieldWriter.ListWriter { - @Throws(IOException::class) - override fun write(listItemWriter: InputFieldWriter.ListItemWriter) { - listItemWriter.writeString(null) - listItemWriter.writeInt(null) - listItemWriter.writeLong(null) - listItemWriter.writeDouble(null) - listItemWriter.writeNumber(null) - listItemWriter.writeBoolean(null) - listItemWriter.writeCustom(object : ScalarType { - override fun typeName(): String { - return "EPISODE" - } - - override fun className(): String { - return String::class.java.name - } - }, null) - listItemWriter.writeObject(null) - listItemWriter.writeList(null) - } - }) - writer.writeString("null", null) - } - } - } - } - val variables: Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map { - val map = HashMap() - map["testInput"] = testInput - return map - } - } - Truth.assertThat(cacheKeyBuilder.build(field, variables)).isEqualTo("hero({\"episode\":null,\"nested\":{\"bar\":null,\"foo\":{\"boolean\":null,\"custom\":null,\"double\":null,\"int\":null,\"listNull" - + "\":null,\"listWithNulls\":[],\"long\":null,\"null\":null,\"number\":null,\"object\":null,\"string\":null}}})") - } - - private fun createResponseField(responseName: String, fieldName: String, arguments: Map): ResponseField { - return forString( - responseName, - fieldName, - arguments, - false, emptyList()) - } - - @Test - fun testFieldWithVariablesInLists() { - val arguments = mutableMapOf().apply { - put("where", mutableMapOf().apply { - put("and", mutableListOf().apply { - add(mutableMapOf().apply { - put("kind", "Variable") - put("variableName", "stars") - }) - }) - }) - } - - val field = createResponseField("hero", "hero", arguments) - val variables0: Operation.Variables = object : Operation.Variables() { - override fun valueMap() = mapOf("stars" to listOf(0)) - } - val variables1: Operation.Variables = object : Operation.Variables() { - override fun valueMap() = mapOf("stars" to listOf(1)) - } - - Truth.assertThat(cacheKeyBuilder.build(field, variables0)).isNotEqualTo(cacheKeyBuilder.build(field, variables1)) - } -} \ No newline at end of file diff --git a/apollo-normalized-cache/src/jvmTest/java/com/apollographql/apollo/cache/normalized/lru/LruNormalizedCacheTest.kt b/apollo-normalized-cache/src/jvmTest/java/com/apollographql/apollo/cache/normalized/lru/LruNormalizedCacheTest.kt deleted file mode 100644 index f1e9d16294c..00000000000 --- a/apollo-normalized-cache/src/jvmTest/java/com/apollographql/apollo/cache/normalized/lru/LruNormalizedCacheTest.kt +++ /dev/null @@ -1,374 +0,0 @@ -package com.apollographql.apollo.cache.normalized.lru - -import com.apollographql.apollo.cache.ApolloCacheHeaders -import com.apollographql.apollo.cache.CacheHeaders -import com.apollographql.apollo.cache.CacheHeaders.Companion.builder -import com.apollographql.apollo.cache.normalized.CacheKey -import com.apollographql.apollo.cache.normalized.CacheReference -import com.apollographql.apollo.cache.normalized.NormalizedCache -import com.apollographql.apollo.cache.normalized.Record -import com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter -import com.google.common.truth.Truth.assertThat -import org.junit.Test -import java.lang.IllegalStateException -import java.util.concurrent.TimeUnit - -class LruNormalizedCacheTest { - private val basicFieldAdapter = RecordFieldJsonAdapter() - - @Test - fun testEvictionPolicyBuilder() { - val policy = EvictionPolicy.builder() - .maxSizeBytes(100) - .maxEntries(50) - .expireAfterAccess(5, TimeUnit.HOURS) - .expireAfterWrite(10, TimeUnit.DAYS) - .build() - - with(policy) { - assertThat(maxSizeBytes).isEqualTo(100) - assertThat(maxEntries).isEqualTo(50) - assertThat(expireAfterAccess).isEqualTo(5) - assertThat(expireAfterAccessTimeUnit).isEqualTo(TimeUnit.HOURS) - assertThat(expireAfterWrite).isEqualTo(10) - assertThat(expireAfterWriteTimeUnit).isEqualTo(TimeUnit.DAYS) - } - } - - @Test - fun testSaveAndLoad_singleRecord() { - val lruCache = createLruNormalizedCache() - val testRecord = createTestRecord("1") - lruCache.merge(testRecord, CacheHeaders.NONE) - - assertTestRecordPresentAndAccurate(testRecord, lruCache) - } - - @Test - fun testSaveAndLoad_multipleRecord_readSingle() { - val lruCache = createLruNormalizedCache() - val testRecord1 = createTestRecord("1") - val testRecord2 = createTestRecord("2") - val testRecord3 = createTestRecord("3") - val records = listOf(testRecord1, testRecord2, testRecord3) - lruCache.merge(records, CacheHeaders.NONE) - - assertTestRecordPresentAndAccurate(testRecord1, lruCache) - assertTestRecordPresentAndAccurate(testRecord2, lruCache) - assertTestRecordPresentAndAccurate(testRecord3, lruCache) - } - - @Test - fun testSaveAndLoad_multipleRecord_readMultiple() { - val lruCache = createLruNormalizedCache() - val testRecord1 = createTestRecord("1") - val testRecord2 = createTestRecord("2") - val testRecord3 = createTestRecord("3") - val inputRecords = listOf(testRecord1, testRecord2, testRecord3) - lruCache.merge(inputRecords, CacheHeaders.NONE) - - val readRecords = lruCache.loadRecords(listOf("key1", "key2", "key3"), CacheHeaders.NONE) - assertThat(readRecords).containsExactlyElementsIn(inputRecords) - } - - @Test - fun testLoad_recordNotPresent() { - val lruCache = createLruNormalizedCache() - val record = lruCache.loadRecord("key1", CacheHeaders.NONE) - assertThat(record).isNull() - } - - @Test - fun testEviction() { - val lruCache = LruNormalizedCacheFactory(EvictionPolicy.builder().maxSizeBytes(2000) - .build()).create(basicFieldAdapter) - val testRecord1Builder = Record.builder("key1") - testRecord1Builder.addField("a", String(ByteArray(1100))) - val testRecord1 = testRecord1Builder.build() - val testRecord2Builder = Record.builder("key2") - testRecord2Builder.addField("a", String(ByteArray(1100))) - val testRecord2 = testRecord2Builder.build() - val testRecord3Builder = Record.builder("key3") - testRecord3Builder.addField("a", String(ByteArray(10))) - val testRecord3 = testRecord3Builder.build() - val records = listOf(testRecord1, testRecord2, testRecord3) - lruCache.merge(records, CacheHeaders.NONE) - - //Cache does not reveal exactly how it handles eviction, but appears - //to evict more than is strictly necessary. Regardless, any sane eviction - //strategy should leave the third record in this test case, and evict the first record. - assertThat(lruCache.loadRecord("key1", CacheHeaders.NONE)).isNull() - assertThat(lruCache.loadRecord("key3", CacheHeaders.NONE)).isNotNull() - } - - @Test - fun testEviction_recordChange() { - val lruCache = LruNormalizedCacheFactory(EvictionPolicy.builder().maxSizeBytes(2000) - .build()).create(basicFieldAdapter) - val testRecord1Builder = Record.builder("key1") - testRecord1Builder.addField("a", String(ByteArray(10))) - val testRecord1 = testRecord1Builder.build() - val testRecord2Builder = Record.builder("key2") - testRecord2Builder.addField("a", String(ByteArray(10))) - val testRecord2 = testRecord2Builder.build() - val testRecord3Builder = Record.builder("key3") - testRecord3Builder.addField("a", String(ByteArray(10))) - val testRecord3 = testRecord3Builder.build() - val records = listOf(testRecord1, testRecord2, testRecord3) - lruCache.merge(records, CacheHeaders.NONE) - - //All records should present - assertThat(lruCache.loadRecord("key1", CacheHeaders.NONE)).isNotNull() - assertThat(lruCache.loadRecord("key2", CacheHeaders.NONE)).isNotNull() - assertThat(lruCache.loadRecord("key3", CacheHeaders.NONE)).isNotNull() - val largeTestRecordBuilder = Record.builder("key1") - largeTestRecordBuilder.addField("a", String(ByteArray(2000))) - val largeTestRecord = largeTestRecordBuilder.build() - lruCache.merge(largeTestRecord, CacheHeaders.NONE) - //The large record (Record 1) should be evicted. the other small records should remain. - assertThat(lruCache.loadRecord("key1", CacheHeaders.NONE)).isNull() - assertThat(lruCache.loadRecord("key2", CacheHeaders.NONE)).isNotNull() - assertThat(lruCache.loadRecord("key3", CacheHeaders.NONE)).isNotNull() - } - - @Test - fun testDualCacheSingleRecord() { - val secondaryCacheFactory = LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION) - val primaryCache = LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION) - .chain(secondaryCacheFactory).createChain(basicFieldAdapter) - val recordBuilder = Record.builder("root") - recordBuilder.addField("bar", "bar") - val record = recordBuilder.build() - primaryCache.merge(record, CacheHeaders.NONE) - - //verify write through behavior - assertThat(primaryCache.loadRecord("root", CacheHeaders.NONE)!!.field("bar")).isEqualTo("bar") - assertThat(primaryCache.nextCache!!.loadRecord("root", CacheHeaders.NONE)!!.field("bar")).isEqualTo("bar") - } - - @Test - fun testDualCacheMultipleRecord() { - val secondaryCacheFactory = LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION) - val primaryCache = LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION) - .chain(secondaryCacheFactory).createChain(basicFieldAdapter) - - var recordBuilder = Record.builder("root1") - recordBuilder.addField("bar", "bar") - val record1 = recordBuilder.build() - recordBuilder = Record.builder("root2") - recordBuilder.addField("bar", "bar") - val record2 = recordBuilder.build() - recordBuilder = Record.builder("root3") - recordBuilder.addField("bar", "bar") - val record3 = recordBuilder.build() - val records = listOf(record1, record2, record3) - val keys = listOf(record1.key, record2.key, record3.key) - primaryCache.merge(records, CacheHeaders.NONE) - assertThat(primaryCache.loadRecords(keys, CacheHeaders.NONE)).hasSize(3) - - //verify write through behavior - assertThat(primaryCache.loadRecords(keys, CacheHeaders.NONE)).hasSize(3) - assertThat(primaryCache.nextCache!!.loadRecords(keys, CacheHeaders.NONE)).hasSize(3) - } - - @Test - fun testDualCache_recordNotPresent() { - val secondaryCacheFactory = LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION) - val primaryCacheStore = LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION) - .chain(secondaryCacheFactory).createChain(basicFieldAdapter) - - assertThat(primaryCacheStore.loadRecord("not_present_id", CacheHeaders.NONE)).isNull() - } - - @Test - fun testClearAll() { - val secondaryCacheFactory = LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION) - val primaryCacheStore = LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION) - .chain(secondaryCacheFactory).createChain(basicFieldAdapter) - val record = Record.builder("key").build() - primaryCacheStore.merge(record, CacheHeaders.NONE) - primaryCacheStore.clearAll() - - assertThat(primaryCacheStore.loadRecord("key", CacheHeaders.NONE)).isNull() - } - - @Test - fun testClearPrimaryCache() { - val secondaryCacheFactory = LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION) - val primaryCache = LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION) - .chain(secondaryCacheFactory).createChain(basicFieldAdapter) as LruNormalizedCache - val record = Record.builder("key").build() - primaryCache.merge(record, CacheHeaders.NONE) - primaryCache.clearCurrentCache() - - val nextCache = requireNotNull(primaryCache.nextCache) - assertThat(nextCache.loadRecord("key", CacheHeaders.NONE)).isNotNull() - assertThat(nextCache.loadRecord("key", CacheHeaders.NONE)).isNotNull() - } - - @Test - fun testClearSecondaryCache() { - val secondaryCacheFactory = LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION) - val primaryCache = LruNormalizedCacheFactory(EvictionPolicy.NO_EVICTION) - .chain(secondaryCacheFactory).createChain(basicFieldAdapter) - val record = Record.builder("key").build() - - val nextCache = requireNotNull(primaryCache.nextCache) - primaryCache.merge(record, CacheHeaders.NONE) - nextCache.clearAll() - - assertThat(nextCache.loadRecord("key", CacheHeaders.NONE)).isNull() - } - - // Tests for StandardCacheHeader compliance. - @Test - fun testHeader_evictAfterRead() { - val lruCache = createLruNormalizedCache() - val testRecord = createTestRecord("1") - lruCache.merge(testRecord, CacheHeaders.NONE) - val record = lruCache.loadRecord("key1", builder().addHeader(ApolloCacheHeaders.EVICT_AFTER_READ, "true") - .build()) - assertThat(record).isNotNull() - val nullRecord = lruCache.loadRecord("key1", builder().addHeader(ApolloCacheHeaders.EVICT_AFTER_READ, "true") - .build()) - assertThat(nullRecord).isNull() - } - - @Test - fun testHeader_noCache() { - val lruCache = createLruNormalizedCache() - val testRecord = createTestRecord("1") - lruCache.merge(testRecord, builder().addHeader(ApolloCacheHeaders.DO_NOT_STORE, "true").build()) - val record = lruCache.loadRecord("key1", CacheHeaders.NONE) - assertThat(record).isNull() - val testRecord1 = createTestRecord("1") - val testRecord2 = createTestRecord("2") - val testRecordSet: MutableCollection = HashSet() - testRecordSet.add(testRecord1) - testRecordSet.add(testRecord2) - lruCache.merge(testRecordSet, builder().addHeader(ApolloCacheHeaders.DO_NOT_STORE, "true").build()) - val record1 = lruCache.loadRecord("key1", CacheHeaders.NONE) - val record2 = lruCache.loadRecord("key2", CacheHeaders.NONE) - assertThat(record1).isNull() - assertThat(record2).isNull() - } - - @Test - fun testSettingMaxSizeAndMaxEntries() { - val policy = EvictionPolicy.builder() - .maxSizeBytes(100) - .maxEntries(50) - .build() - - val exception: Throwable? = try { - createLruNormalizedCache(policy) - null - } catch (e: Throwable) { - e - } - - assertThat(exception!!).let { - it.isInstanceOf(IllegalStateException::class.java) - it.hasMessage("maximum weight was already set to 100") - } - } - - @Test - fun testRemove_nonExistentRecord() { - val lruCache = createLruNormalizedCache() - assertThat(lruCache.remove(CacheKey("fake"), true)).isFalse() - } - - @Test - fun testRemove_nonReferencedRecord() { - val lruCache = createLruNormalizedCache() - lruCache.merge(listOf(createTestRecord("id_1")), CacheHeaders.NONE) - assertThat(lruCache.remove(CacheKey("keyid_1"), false)).isTrue() - } - - @Test - fun testDump() { - val lruCache = createLruNormalizedCache() - - val record1 = createTestRecord("id_1") - val record2 = createTestRecord("id_2") - val record3 = createTestRecord("id_3") - - lruCache.merge(listOf( - record1, - record2, - record3 - ), CacheHeaders.NONE) - - with(lruCache.dump()) { - assertThat(size).isEqualTo(1) - val cache = this[LruNormalizedCache::class]!! - - assertThat(cache.keys).containsExactly("keyid_1", "keyid_2", "keyid_3") - assertThat(cache["keyid_1"]).isEqualTo(record1) - assertThat(cache["keyid_2"]).isEqualTo(record2) - assertThat(cache["keyid_3"]).isEqualTo(record3) - } - } - - @Test - fun testRemove_referencedRecord_cascadeFalse() { - - val lruCache = createLruNormalizedCache() - - val record1 = Record.builder("id_1") - .addField("a", "stringValueA") - .addField("b", "stringValueB") - .build() - - val record2 = Record.builder("id_2") - .addField("a", CacheReference("id_1")) - .build() - - lruCache.merge( - listOf(record1, record2), CacheHeaders.NONE - ) - - assertThat(lruCache.remove(CacheKey("id_2"), cascade = false)).isTrue() - assertThat(lruCache.loadRecord("id_1", CacheHeaders.NONE)).isNotNull() - } - - @Test - fun testRemove_referencedRecord_cascadeTrue() { - - val lruCache = createLruNormalizedCache() - - val record1 = Record.builder("id_1") - .addField("a", "stringValueA") - .addField("b", "stringValueB") - .build() - - val record2 = Record.builder("id_2") - .addField("a", CacheReference("id_1")) - .build() - - lruCache.merge( - listOf(record1, record2), CacheHeaders.NONE - ) - - assertThat(lruCache.remove(CacheKey("id_2"), cascade = true)).isTrue() - assertThat(lruCache.loadRecord("id_1", CacheHeaders.NONE)).isNull() - } - - private fun createLruNormalizedCache(policy: EvictionPolicy = EvictionPolicy.builder().maxSizeBytes(10 * 1024.toLong()).build()) = - LruNormalizedCacheFactory(policy).create(basicFieldAdapter) - - private fun assertTestRecordPresentAndAccurate(testRecord: Record, store: NormalizedCache) { - val cacheRecord = requireNotNull(store.loadRecord(testRecord.key, CacheHeaders.NONE)) - - assertThat(cacheRecord.key).isEqualTo(testRecord.key) - assertThat(cacheRecord.field("a")).isEqualTo(testRecord.field("a")) - assertThat(cacheRecord.field("b")).isEqualTo(testRecord.field("b")) - } - - private fun createTestRecord(id: String): Record = - Record.builder("key$id") - .addField("a", "stringValueA$id") - .addField("b", "stringValueB$id") - .build() -} diff --git a/apollo-runtime-kotlin/build.gradle.kts b/apollo-runtime-kotlin/build.gradle.kts index c84c537052d..8b85a6a9bf6 100644 --- a/apollo-runtime-kotlin/build.gradle.kts +++ b/apollo-runtime-kotlin/build.gradle.kts @@ -4,22 +4,6 @@ plugins { } kotlin { - @Suppress("ClassName") - data class iOSTarget(val name: String, val preset: String, val id: String) - - val iosTargets = listOf( - iOSTarget("ios", "iosArm64", "ios-arm64"), - iOSTarget("iosSim", "iosX64", "ios-x64") - ) - - for ((targetName, presetName, id) in iosTargets) { - targetFromPreset(presets.getByName(presetName), targetName) { - mavenPublication { - artifactId = "${project.name}-$id" - } - } - } - jvm() sourceSets { @@ -38,44 +22,5 @@ kotlin { api(groovy.util.Eval.x(project, "x.dep.okHttp.okHttp4")) } } - - val iosMain by getting { - dependsOn(commonMain) - dependencies { - } - } - - val iosSimMain by getting { - dependsOn(iosMain) - } - - val commonTest by getting { - dependencies { - implementation(kotlin("test-common")) - implementation(kotlin("test-annotations-common")) - } - } - - val jvmTest by getting { - dependencies { - implementation(kotlin("test-junit")) - implementation(groovy.util.Eval.x(project, "x.dep.truth")) - implementation(groovy.util.Eval.x(project, "x.dep.okHttp.okHttp")) - } - } - - val iosSimTest by getting { - dependsOn(commonTest) - } - } -} - -tasks.register("iOSSimTest") { - dependsOn("iosSimTestBinaries") - doLast { - val binary = kotlin.targets.getByName("iosSim").binaries.getTest("DEBUG").outputFile - exec { - commandLine = listOf("xcrun", "simctl", "spawn", "iPhone 8", binary.absolutePath) - } } } diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/ApolloRequest.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/ApolloRequest.kt deleted file mode 100644 index d1c34057d9f..00000000000 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/ApolloRequest.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.apollographql.apollo.interceptor - -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.benasher44.uuid.uuid4 - -@ApolloExperimental -class ApolloRequest( - val operation: Operation, - val scalarTypeAdapters: ScalarTypeAdapters, - val executionContext: ExecutionContext -) { - val requestUuid = uuid4() -} diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/ApolloResponse.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/ApolloResponse.kt deleted file mode 100644 index 5df1c169157..00000000000 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/ApolloResponse.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.apollographql.apollo.interceptor - -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.Response -import com.benasher44.uuid.Uuid - -@ApolloExperimental -class ApolloResponse( - val requestUuid: Uuid, - val response: Response, - val executionContext: ExecutionContext -) diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/HttpMethod.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/HttpMethod.kt deleted file mode 100644 index c7506a0ee01..00000000000 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/HttpMethod.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.apollographql.apollo.network - -enum class HttpMethod { - Get, Post -} diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/NetworkTransport.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/NetworkTransport.kt deleted file mode 100644 index 6fcaf741b31..00000000000 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/NetworkTransport.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.apollographql.apollo.network - -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.interceptor.ApolloRequest -import com.apollographql.apollo.interceptor.ApolloResponse -import kotlinx.coroutines.flow.Flow - -@ApolloExperimental -interface NetworkTransport { - - fun execute(request: ApolloRequest, executionContext: ExecutionContext): Flow> -} diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/ApolloCall.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/ApolloCall.kt similarity index 61% rename from apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/ApolloCall.kt rename to apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/ApolloCall.kt index f64e8799fb0..c27e01d5dc8 100644 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/ApolloCall.kt +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/ApolloCall.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo +package com.homer.apollographql.apollo -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext -import com.apollographql.apollo.api.Response +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.api.ExecutionContext +import com.homer.apollographql.apollo.api.Response import kotlinx.coroutines.flow.Flow interface ApolloCall { diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/ApolloClient.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/ApolloClient.kt similarity index 67% rename from apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/ApolloClient.kt rename to apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/ApolloClient.kt index a79abae0f34..b7c2b9b9736 100644 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/ApolloClient.kt +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/ApolloClient.kt @@ -1,17 +1,17 @@ -package com.apollographql.apollo +package com.homer.apollographql.apollo -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext -import com.apollographql.apollo.api.Mutation -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.Subscription -import com.apollographql.apollo.dispatcher.ApolloCoroutineDispatcherContext -import com.apollographql.apollo.interceptor.ApolloRequestInterceptor -import com.apollographql.apollo.interceptor.NetworkRequestInterceptor -import com.apollographql.apollo.internal.RealApolloCall -import com.apollographql.apollo.network.NetworkTransport +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.api.ExecutionContext +import com.homer.apollographql.apollo.api.Mutation +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.Query +import com.homer.apollographql.apollo.api.ScalarTypeAdapters +import com.homer.apollographql.apollo.api.Subscription +import com.homer.apollographql.apollo.dispatcher.ApolloCoroutineDispatcherContext +import com.homer.apollographql.apollo.interceptor.ApolloRequestInterceptor +import com.homer.apollographql.apollo.interceptor.NetworkRequestInterceptor +import com.homer.apollographql.apollo.internal.RealApolloCall +import com.homer.apollographql.apollo.network.NetworkTransport import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/ApolloException.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/ApolloException.kt similarity index 96% rename from apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/ApolloException.kt rename to apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/ApolloException.kt index 5efc3fdcf6b..236055d8b20 100644 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/ApolloException.kt +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/ApolloException.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo +package com.homer.apollographql.apollo sealed class ApolloException(message: String, cause: Throwable?) : RuntimeException(message, cause) diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/dispatcher/ApolloCoroutineDispatcherContext.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/dispatcher/ApolloCoroutineDispatcherContext.kt similarity index 69% rename from apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/dispatcher/ApolloCoroutineDispatcherContext.kt rename to apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/dispatcher/ApolloCoroutineDispatcherContext.kt index c9f1df604b7..dcf60af4a7e 100644 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/dispatcher/ApolloCoroutineDispatcherContext.kt +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/dispatcher/ApolloCoroutineDispatcherContext.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.dispatcher +package com.homer.apollographql.apollo.dispatcher -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.api.ExecutionContext import kotlinx.coroutines.CoroutineDispatcher import kotlin.jvm.JvmField diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/ApolloRequest.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/ApolloRequest.kt new file mode 100644 index 00000000000..fe80a1dda92 --- /dev/null +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/ApolloRequest.kt @@ -0,0 +1,16 @@ +package com.homer.apollographql.apollo.interceptor + +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.api.ExecutionContext +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.ScalarTypeAdapters +import com.benasher44.uuid.uuid4 + +@ApolloExperimental +class ApolloRequest( + val operation: Operation, + val scalarTypeAdapters: ScalarTypeAdapters, + val executionContext: ExecutionContext +) { + val requestUuid = uuid4() +} diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/ApolloRequestInterceptor.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/ApolloRequestInterceptor.kt similarity index 86% rename from apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/ApolloRequestInterceptor.kt rename to apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/ApolloRequestInterceptor.kt index 996146dab7f..bb10b136b6a 100644 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/ApolloRequestInterceptor.kt +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/ApolloRequestInterceptor.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.interceptor +package com.homer.apollographql.apollo.interceptor -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.api.Operation import kotlinx.coroutines.flow.Flow @ApolloExperimental diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/ApolloResponse.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/ApolloResponse.kt new file mode 100644 index 00000000000..f9f1bb056b8 --- /dev/null +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/ApolloResponse.kt @@ -0,0 +1,14 @@ +package com.homer.apollographql.apollo.interceptor + +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.api.ExecutionContext +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.Response +import com.benasher44.uuid.Uuid + +@ApolloExperimental +class ApolloResponse( + val requestUuid: Uuid, + val response: Response, + val executionContext: ExecutionContext +) diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/BearerTokenInterceptor.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/BearerTokenInterceptor.kt similarity index 85% rename from apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/BearerTokenInterceptor.kt rename to apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/BearerTokenInterceptor.kt index 04e0eb155be..3dd6232311d 100644 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/BearerTokenInterceptor.kt +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/BearerTokenInterceptor.kt @@ -1,10 +1,10 @@ -package com.apollographql.apollo.interceptor +package com.homer.apollographql.apollo.interceptor -import com.apollographql.apollo.ApolloHttpException -import com.apollographql.apollo.ApolloBearerTokenException -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.network.HttpExecutionContext +import com.homer.apollographql.apollo.ApolloHttpException +import com.homer.apollographql.apollo.ApolloBearerTokenException +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.network.HttpExecutionContext import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.FlowPreview import kotlinx.coroutines.flow.Flow diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/NetworkRequestInterceptor.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/NetworkRequestInterceptor.kt similarity index 70% rename from apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/NetworkRequestInterceptor.kt rename to apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/NetworkRequestInterceptor.kt index 16427a81f9d..9fbdcafed54 100644 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/NetworkRequestInterceptor.kt +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/NetworkRequestInterceptor.kt @@ -1,11 +1,11 @@ -package com.apollographql.apollo.interceptor +package com.homer.apollographql.apollo.interceptor -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.Mutation -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Subscription -import com.apollographql.apollo.network.NetworkTransport +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.api.Mutation +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.Query +import com.homer.apollographql.apollo.api.Subscription +import com.homer.apollographql.apollo.network.NetworkTransport import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.emptyFlow diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/TokenProvider.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/TokenProvider.kt similarity index 70% rename from apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/TokenProvider.kt rename to apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/TokenProvider.kt index 7b5e9f04804..77709a456db 100644 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/interceptor/TokenProvider.kt +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/interceptor/TokenProvider.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.interceptor +package com.homer.apollographql.apollo.interceptor interface TokenProvider { suspend fun currentToken(): String diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/internal/RealApolloCall.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/internal/RealApolloCall.kt similarity index 60% rename from apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/internal/RealApolloCall.kt rename to apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/internal/RealApolloCall.kt index 90332e537a9..61b24fb1b3e 100644 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/internal/RealApolloCall.kt +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/internal/RealApolloCall.kt @@ -1,16 +1,16 @@ -package com.apollographql.apollo.internal +package com.homer.apollographql.apollo.internal -import com.apollographql.apollo.ApolloMutationCall -import com.apollographql.apollo.ApolloQueryCall -import com.apollographql.apollo.ApolloSubscriptionCall -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.interceptor.ApolloRequest -import com.apollographql.apollo.interceptor.ApolloRequestInterceptor -import com.apollographql.apollo.interceptor.RealInterceptorChain +import com.homer.apollographql.apollo.ApolloMutationCall +import com.homer.apollographql.apollo.ApolloQueryCall +import com.homer.apollographql.apollo.ApolloSubscriptionCall +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.api.ExecutionContext +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.Response +import com.homer.apollographql.apollo.api.ScalarTypeAdapters +import com.homer.apollographql.apollo.interceptor.ApolloRequest +import com.homer.apollographql.apollo.interceptor.ApolloRequestInterceptor +import com.homer.apollographql.apollo.interceptor.RealInterceptorChain import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flatMapLatest diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/HttpExecutionContext.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/HttpExecutionContext.kt similarity index 74% rename from apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/HttpExecutionContext.kt rename to apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/HttpExecutionContext.kt index 9f0bd88ba2d..b5a2ff07bef 100644 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/HttpExecutionContext.kt +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/HttpExecutionContext.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.network +package com.homer.apollographql.apollo.network -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.api.ExecutionContext @ApolloExperimental sealed class HttpExecutionContext { diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/HttpMethod.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/HttpMethod.kt new file mode 100644 index 00000000000..feaa7fcea7b --- /dev/null +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/HttpMethod.kt @@ -0,0 +1,5 @@ +package com.homer.apollographql.apollo.network + +enum class HttpMethod { + Get, Post +} diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/NetworkTransport.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/NetworkTransport.kt new file mode 100644 index 00000000000..45488b33bf1 --- /dev/null +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/NetworkTransport.kt @@ -0,0 +1,14 @@ +package com.homer.apollographql.apollo.network + +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.api.ExecutionContext +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.interceptor.ApolloRequest +import com.homer.apollographql.apollo.interceptor.ApolloResponse +import kotlinx.coroutines.flow.Flow + +@ApolloExperimental +interface NetworkTransport { + + fun execute(request: ApolloRequest, executionContext: ExecutionContext): Flow> +} diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/http/ApolloHttpNetworkTransport.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/http/ApolloHttpNetworkTransport.kt similarity index 76% rename from apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/http/ApolloHttpNetworkTransport.kt rename to apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/http/ApolloHttpNetworkTransport.kt index 7b51e542795..38d679ec58d 100644 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/http/ApolloHttpNetworkTransport.kt +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/http/ApolloHttpNetworkTransport.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.network.http +package com.homer.apollographql.apollo.network.http -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.network.HttpMethod -import com.apollographql.apollo.network.NetworkTransport +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.network.HttpMethod +import com.homer.apollographql.apollo.network.NetworkTransport @ApolloExperimental expect class ApolloHttpNetworkTransport constructor( diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/ws/ApolloGraphQLClientMessage.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/ws/ApolloGraphQLClientMessage.kt similarity index 85% rename from apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/ws/ApolloGraphQLClientMessage.kt rename to apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/ws/ApolloGraphQLClientMessage.kt index 566cc0c7b83..76ac1177e65 100644 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/ws/ApolloGraphQLClientMessage.kt +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/ws/ApolloGraphQLClientMessage.kt @@ -1,9 +1,9 @@ -package com.apollographql.apollo.network.ws +package com.homer.apollographql.apollo.network.ws -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.internal.json.JsonWriter -import com.apollographql.apollo.api.internal.json.Utils.writeToJson -import com.apollographql.apollo.interceptor.ApolloRequest +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.api.internal.json.JsonWriter +import com.homer.apollographql.apollo.api.internal.json.Utils.writeToJson +import com.homer.apollographql.apollo.interceptor.ApolloRequest import com.benasher44.uuid.Uuid import okio.ByteString diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/ws/ApolloGraphQLServerMessage.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/ws/ApolloGraphQLServerMessage.kt similarity index 89% rename from apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/ws/ApolloGraphQLServerMessage.kt rename to apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/ws/ApolloGraphQLServerMessage.kt index 07a97e49434..4655bc7ac89 100644 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/ws/ApolloGraphQLServerMessage.kt +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/ws/ApolloGraphQLServerMessage.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.network.ws +package com.homer.apollographql.apollo.network.ws -import com.apollographql.apollo.ApolloWebSocketException -import com.apollographql.apollo.api.internal.json.BufferedSourceJsonReader -import com.apollographql.apollo.api.internal.json.ResponseJsonStreamReader +import com.homer.apollographql.apollo.ApolloWebSocketException +import com.homer.apollographql.apollo.api.internal.json.BufferedSourceJsonReader +import com.homer.apollographql.apollo.api.internal.json.ResponseJsonStreamReader import okio.Buffer import okio.ByteString diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/ws/ApolloWebSocketNetworkTransport.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/ws/ApolloWebSocketNetworkTransport.kt similarity index 89% rename from apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/ws/ApolloWebSocketNetworkTransport.kt rename to apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/ws/ApolloWebSocketNetworkTransport.kt index b000a04923f..a89208301d1 100644 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/ws/ApolloWebSocketNetworkTransport.kt +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/ws/ApolloWebSocketNetworkTransport.kt @@ -1,18 +1,18 @@ -package com.apollographql.apollo.network.ws - -import com.apollographql.apollo.ApolloParseException -import com.apollographql.apollo.ApolloWebSocketException -import com.apollographql.apollo.ApolloWebSocketServerException -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.internal.json.JsonWriter -import com.apollographql.apollo.api.internal.json.Utils -import com.apollographql.apollo.dispatcher.ApolloCoroutineDispatcherContext -import com.apollographql.apollo.interceptor.ApolloRequest -import com.apollographql.apollo.interceptor.ApolloResponse -import com.apollographql.apollo.network.NetworkTransport -import com.apollographql.apollo.network.ws.ApolloGraphQLServerMessage.Companion.parse +package com.homer.apollographql.apollo.network.ws + +import com.homer.apollographql.apollo.ApolloParseException +import com.homer.apollographql.apollo.ApolloWebSocketException +import com.homer.apollographql.apollo.ApolloWebSocketServerException +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.api.ExecutionContext +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.internal.json.JsonWriter +import com.homer.apollographql.apollo.api.internal.json.Utils +import com.homer.apollographql.apollo.dispatcher.ApolloCoroutineDispatcherContext +import com.homer.apollographql.apollo.interceptor.ApolloRequest +import com.homer.apollographql.apollo.interceptor.ApolloResponse +import com.homer.apollographql.apollo.network.NetworkTransport +import com.homer.apollographql.apollo.network.ws.ApolloGraphQLServerMessage.Companion.parse import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.ExperimentalCoroutinesApi diff --git a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/ws/WebSocket.kt b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/ws/WebSocket.kt similarity index 89% rename from apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/ws/WebSocket.kt rename to apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/ws/WebSocket.kt index 3a948d92b67..ed4620a2ac9 100644 --- a/apollo-runtime-kotlin/src/commonMain/kotlin/com/apollographql/apollo/network/ws/WebSocket.kt +++ b/apollo-runtime-kotlin/src/commonMain/kotlin/com/homer/apollographql/apollo/network/ws/WebSocket.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.network.ws +package com.homer.apollographql.apollo.network.ws import kotlinx.coroutines.channels.ReceiveChannel import okio.ByteString diff --git a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/ApolloClientTest.kt b/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/ApolloClientTest.kt deleted file mode 100644 index 6e280c76a9c..00000000000 --- a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/ApolloClientTest.kt +++ /dev/null @@ -1,78 +0,0 @@ -package com.apollographql.apollo - -import com.apollographql.apollo.mock.MockNetworkTransport -import com.apollographql.apollo.mock.MockQuery -import com.apollographql.apollo.mock.TestLoggerExecutor -import kotlinx.coroutines.flow.retryWhen -import kotlinx.coroutines.flow.single -import kotlin.test.BeforeTest -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertTrue - -@Suppress("EXPERIMENTAL_API_USAGE") -class ApolloClientTest { - private lateinit var networkTransport: MockNetworkTransport - private lateinit var apolloClient: ApolloClient - - @BeforeTest - fun setUp() { - networkTransport = MockNetworkTransport() - apolloClient = ApolloClient( - networkTransport = networkTransport, - interceptors = listOf(TestLoggerExecutor) - ) - } - - @Test - fun `when query and success network response, assert success`() { - networkTransport.offer("{\"data\":{\"name\":\"MockQuery\"}") - - val response = runBlocking { - apolloClient - .query(MockQuery()) - .execute() - .single() - } - - assertNotNull(response.data) - assertEquals(expected = MockQuery.Data("{\"data\":{\"name\":\"MockQuery\"}"), actual = response.data) - } - - @Test - fun `when query and malformed network response, assert parse error`() { - networkTransport.offer("") - - val result = runBlocking { - kotlin.runCatching { - apolloClient - .query(MockQuery()) - .execute() - .single() - } - } - - assertTrue(result.isFailure) - result.onFailure { e -> - assertTrue(e is ApolloParseException) - } - } - - @Test - fun `when query and malformed network response, assert success after retry`() { - networkTransport.offer("") - networkTransport.offer("{\"data\":{\"name\":\"MockQuery\"}}") - - val response = runBlocking { - apolloClient - .query(MockQuery()) - .execute() - .retryWhen { cause, attempt -> cause is ApolloException && attempt == 0L } - .single() - } - - assertNotNull(response.data) - assertEquals(expected = MockQuery.Data("{\"data\":{\"name\":\"MockQuery\"}}"), actual = response.data) - } -} diff --git a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/OauthInterceptorTest.kt b/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/OauthInterceptorTest.kt deleted file mode 100644 index ff4f5b30574..00000000000 --- a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/OauthInterceptorTest.kt +++ /dev/null @@ -1,111 +0,0 @@ -package com.apollographql.apollo - -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.interceptor.ApolloRequest -import com.apollographql.apollo.interceptor.ApolloResponse -import com.apollographql.apollo.interceptor.BearerTokenInterceptor -import com.apollographql.apollo.mock.MockQuery -import com.apollographql.apollo.mock.TestTokenProvider -import com.apollographql.apollo.network.HttpExecutionContext -import com.apollographql.apollo.network.NetworkTransport -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import kotlinx.coroutines.flow.single -import okio.ByteString.Companion.encodeUtf8 -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertNotNull -import kotlin.test.assertTrue - -@ExperimentalCoroutinesApi -@ApolloExperimental -class OauthInterceptorTest { - class AuthenticatedNetworkTransport : NetworkTransport { - companion object { - const val VALID_ACCESS_TOKEN1 = "VALID_ACCESS_TOKEN1" - const val VALID_ACCESS_TOKEN2 = "VALID_ACCESS_TOKEN2" - const val INVALID_ACCESS_TOKEN = "INVALID_ACCESS_TOKEN" - } - - override fun execute(request: ApolloRequest, executionContext: ExecutionContext): Flow> { - val authorization = executionContext[HttpExecutionContext.Request]?.headers?.get("Authorization") - - return flow { - when (authorization) { - "Bearer $VALID_ACCESS_TOKEN1", - "Bearer $VALID_ACCESS_TOKEN2" -> { - emit( - ApolloResponse( - requestUuid = request.requestUuid, - response = request.operation.parse("{\"data\":{\"name\":\"MockQuery\"}}".encodeUtf8()), - executionContext = ExecutionContext.Empty - ) - ) - } - else -> { - throw ApolloHttpException( - message = "Http request failed with status code `401`", - statusCode = 401, - headers = emptyMap() - ) - } - } - } - } - } - - - private fun apolloClient(currentAccessToken: String, newAccessToken: String): ApolloClient { - val networkTransport = AuthenticatedNetworkTransport() - return ApolloClient( - networkTransport = networkTransport, - interceptors = listOf(BearerTokenInterceptor(TestTokenProvider( - currentAccessToken, - newAccessToken - ))) - ) - } - - @Test - fun `valid access token succeeds`() { - val response = runBlocking { - apolloClient(AuthenticatedNetworkTransport.VALID_ACCESS_TOKEN1, - AuthenticatedNetworkTransport.VALID_ACCESS_TOKEN2) - .query(MockQuery()).execute().single() - } - - assertNotNull(response.data) - assertEquals(expected = MockQuery.Data("{\"data\":{\"name\":\"MockQuery\"}}"), actual = response.data) - } - - @Test - fun `invalid access token fails`() { - val result = runBlocking { - kotlin.runCatching { - apolloClient(AuthenticatedNetworkTransport.INVALID_ACCESS_TOKEN, - AuthenticatedNetworkTransport.INVALID_ACCESS_TOKEN) - .query(MockQuery()).execute().single() - } - } - - assertTrue(result.isFailure) - result.onFailure { e -> - assertTrue(e is ApolloException) - } - } - - @Test - fun `refresh access token succeeds`() { - val response = runBlocking { - apolloClient(AuthenticatedNetworkTransport.INVALID_ACCESS_TOKEN, - AuthenticatedNetworkTransport.VALID_ACCESS_TOKEN2) - .query(MockQuery()).execute().single() - } - - assertNotNull(response.data) - assertEquals(expected = MockQuery.Data("{\"data\":{\"name\":\"MockQuery\"}}"), actual = response.data) - } -} diff --git a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/TestUtils.kt b/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/TestUtils.kt deleted file mode 100644 index b39e8b96c01..00000000000 --- a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/TestUtils.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.apollographql.apollo - -import kotlinx.coroutines.CoroutineScope -import kotlin.coroutines.CoroutineContext -import kotlin.coroutines.EmptyCoroutineContext - -expect fun runBlocking(context: CoroutineContext = EmptyCoroutineContext, block: suspend CoroutineScope.() -> T): T diff --git a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/mock/MockNetworkTransport.kt b/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/mock/MockNetworkTransport.kt deleted file mode 100644 index 0d6b7a9b15a..00000000000 --- a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/mock/MockNetworkTransport.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.apollographql.apollo.mock - -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.interceptor.ApolloRequest -import com.apollographql.apollo.interceptor.ApolloResponse -import com.apollographql.apollo.network.NetworkTransport -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.channels.Channel -import kotlinx.coroutines.channels.SendChannel -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import okio.ByteString.Companion.encodeUtf8 - -@ApolloExperimental -@ExperimentalCoroutinesApi -internal class MockNetworkTransport( - private val mockResponseChannel: Channel = Channel(capacity = Channel.BUFFERED) -) : NetworkTransport, SendChannel by mockResponseChannel { - - override fun execute(request: ApolloRequest, executionContext: ExecutionContext): Flow> { - return flow { - emit( - ApolloResponse( - requestUuid = request.requestUuid, - response = request.operation.parse(mockResponseChannel.receive().encodeUtf8()), - executionContext = ExecutionContext.Empty - ) - ) - } - } -} diff --git a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/mock/MockQuery.kt b/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/mock/MockQuery.kt deleted file mode 100644 index 1889b1d9088..00000000000 --- a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/mock/MockQuery.kt +++ /dev/null @@ -1,89 +0,0 @@ -package com.apollographql.apollo.mock - -import com.apollographql.apollo.ApolloParseException -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import okio.BufferedSource -import okio.ByteString -import okio.ByteString.Companion.encodeUtf8 - -internal class MockQuery : Query { - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters - ): ByteString { - return composeRequestBody() - } - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString { - return composeRequestBody() - } - - override fun composeRequestBody(): ByteString { - return """ - { - "operationName": "MockQuery", - "query": "query MockQuery { name }", - "variables": "{"key": "value"}" - } - """.trimIndent().encodeUtf8() - } - - override fun queryDocument(): String = "query MockQuery { name }" - - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - - override fun responseFieldMapper(): ResponseFieldMapper { - throw UnsupportedOperationException("Unsupported") - } - - override fun wrapData(data: Data?): Data? = data - - override fun name(): OperationName = object : OperationName { - override fun name(): String = "MockQuery" - } - - override fun operationId(): String = "MockQuery".hashCode().toString() - - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response { - val data = source.readUtf8() - if (data.isEmpty()) throw ApolloParseException( - message = "Failed to parse mocked response" - ) - return Response( - operation = this, - data = Data(data) - ) - } - - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response { - if (byteString.size == 0) throw ApolloParseException( - message = "Failed to parse mocked response" - ) - return Response( - operation = this, - data = Data(byteString.utf8()) - ) - } - - override fun parse(source: BufferedSource): Response { - return parse(source, ScalarTypeAdapters.DEFAULT) - } - - override fun parse(byteString: ByteString): Response { - return parse(byteString, ScalarTypeAdapters.DEFAULT) - } - - data class Data(val rawResponse: String) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller { - throw UnsupportedOperationException("Unsupported") - } - } -} diff --git a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/mock/MockSubscription.kt b/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/mock/MockSubscription.kt deleted file mode 100644 index f96b4f47963..00000000000 --- a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/mock/MockSubscription.kt +++ /dev/null @@ -1,80 +0,0 @@ -package com.apollographql.apollo.mock - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.Subscription -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import okio.BufferedSource -import okio.ByteString -import okio.ByteString.Companion.encodeUtf8 - -internal class MockSubscription : Subscription { - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters): ByteString { - return composeRequestBody() - } - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString { - return composeRequestBody() - } - - override fun composeRequestBody(): ByteString { - return """ - { - "operationName": "MockSubscription", - "query": "subscription MockSubscription { name }", - "variables": "{"key": "value"}" - } - """.trimIndent().encodeUtf8() - } - - override fun queryDocument(): String = "subscription MockSubscription { name }" - - override fun variables(): Operation.Variables = Operation.EMPTY_VARIABLES - - override fun responseFieldMapper(): ResponseFieldMapper { - throw UnsupportedOperationException("Unsupported") - } - - override fun wrapData(data: Data?): Data? = data - - override fun name(): OperationName = object : OperationName { - override fun name(): String = "MockSubscription" - } - - override fun operationId(): String = "MockSubscription".hashCode().toString() - - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response { - return Response( - operation = this, - data = Data(source.readUtf8()) - ) - } - - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response { - return Response( - operation = this, - data = Data(byteString.toString()) - ) - } - - override fun parse(source: BufferedSource): Response { - return parse(source, ScalarTypeAdapters.DEFAULT) - } - - override fun parse(byteString: ByteString): Response { - return parse(byteString, ScalarTypeAdapters.DEFAULT) - } - - class Data(val rawResponse: String) : Operation.Data { - override fun marshaller(): ResponseFieldMarshaller { - throw UnsupportedOperationException("Unsupported") - } - } -} diff --git a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/mock/TestLoggerExecutor.kt b/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/mock/TestLoggerExecutor.kt deleted file mode 100644 index 18244f6ad89..00000000000 --- a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/mock/TestLoggerExecutor.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.apollographql.apollo.mock - -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.interceptor.ApolloInterceptorChain -import com.apollographql.apollo.interceptor.ApolloRequest -import com.apollographql.apollo.interceptor.ApolloRequestInterceptor -import com.apollographql.apollo.interceptor.ApolloResponse -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.catch -import kotlinx.coroutines.flow.onEach -import kotlinx.coroutines.flow.onStart - -@ApolloExperimental -@ExperimentalCoroutinesApi -object TestLoggerExecutor : ApolloRequestInterceptor { - - override fun intercept(request: ApolloRequest, chain: ApolloInterceptorChain): Flow> { - println("Preparing `${request.operation.name().name()}` GraphQL operation for execution ...") - return chain.proceed(request) - .onStart { println("Started `${request.operation.name().name()}` GraphQL operation execution ...") } - .onEach { response -> println("Finished `${request.operation.name().name()}` GraphQL operation execution, response: $response") } - .catch { e -> - println("Failed `${request.operation.name().name()}` GraphQL operation execution due to error: $e") - throw e - } - } -} diff --git a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/mock/TestTokenProvider.kt b/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/mock/TestTokenProvider.kt deleted file mode 100644 index 8072b252a10..00000000000 --- a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/mock/TestTokenProvider.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.apollographql.apollo.mock - -import com.apollographql.apollo.interceptor.TokenProvider - -class TestTokenProvider(currentAccessToken: String, - val newAccessToken: String) : TokenProvider { - var accessToken = currentAccessToken - override suspend fun currentToken(): String { - return accessToken - } - - override suspend fun refreshToken(previousToken: String): String { - accessToken = newAccessToken - return accessToken - } -} \ No newline at end of file diff --git a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/network/ws/ApolloWebSocketNetworkTransportTest.kt b/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/network/ws/ApolloWebSocketNetworkTransportTest.kt deleted file mode 100644 index b1d6a9f4b65..00000000000 --- a/apollo-runtime-kotlin/src/commonTest/kotlin/com/apollographql/apollo/network/ws/ApolloWebSocketNetworkTransportTest.kt +++ /dev/null @@ -1,253 +0,0 @@ -package com.apollographql.apollo.network.ws - -import com.apollographql.apollo.ApolloWebSocketException -import com.apollographql.apollo.ApolloWebSocketServerException -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.dispatcher.ApolloCoroutineDispatcherContext -import com.apollographql.apollo.interceptor.ApolloRequest -import com.apollographql.apollo.mock.MockSubscription -import com.apollographql.apollo.runBlocking -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.InternalCoroutinesApi -import kotlinx.coroutines.channels.Channel -import kotlinx.coroutines.channels.ReceiveChannel -import kotlinx.coroutines.flow.collect -import kotlinx.coroutines.flow.collectIndexed -import kotlinx.coroutines.flow.toList -import okio.ByteString -import okio.ByteString.Companion.encodeUtf8 -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertTrue - -@ApolloExperimental -@ExperimentalCoroutinesApi -@InternalCoroutinesApi -class ApolloWebSocketNetworkTransportTest { - - @Test - fun `when multiple responses, assert all delivered and completed`() { - runBlocking { - val expectedRequest = ApolloRequest( - operation = MockSubscription(), - scalarTypeAdapters = ScalarTypeAdapters.DEFAULT, - executionContext = ApolloCoroutineDispatcherContext(Dispatchers.Unconfined) - ) - val expectedResponses = listOf( - "{\"data\":{\"name\":\"MockQuery1\"}}", - "{\"data\":{\"name\":\"MockQuery2\"}}", - "{\"data\":{\"name\":\"MockQuery3\"}}" - ) - val webSocketConnection = WebSocketConnectionMock( - expectedRequest = expectedRequest, - expectedOnStartResponse = expectedResponses.first() - ) - - ApolloWebSocketNetworkTransport( - webSocketFactory = object : WebSocketFactory { - override suspend fun open(headers: Map): WebSocketConnection = webSocketConnection - }, - idleTimeoutMs = -1 - ).execute( - request = expectedRequest, - executionContext = ExecutionContext.Empty - ).collectIndexed { index, actualResponse -> - assertEquals(expectedResponses[index], actualResponse.response.data?.rawResponse) - if (index < expectedResponses.size - 1) { - webSocketConnection.enqueueResponse(expectedResponses[index + 1]) - } else { - webSocketConnection.enqueueComplete() - } - } - } - } - - @Test - fun `when connection ack timeout, assert completed with exception`() { - runBlocking { - val expectedRequest = ApolloRequest( - operation = MockSubscription(), - scalarTypeAdapters = ScalarTypeAdapters.DEFAULT, - executionContext = ApolloCoroutineDispatcherContext(Dispatchers.Unconfined) - ) - - val result = runCatching { - ApolloWebSocketNetworkTransport( - webSocketFactory = object : WebSocketFactory { - override suspend fun open(headers: Map): WebSocketConnection = FrozenWebSocketConnection() - }, - connectionAcknowledgeTimeoutMs = 1_000, - idleTimeoutMs = -1 - ).execute( - request = expectedRequest, - executionContext = ApolloCoroutineDispatcherContext(Dispatchers.Unconfined) - ).toList() - } - - assertTrue(result.isFailure) - assertTrue(result.exceptionOrNull() is ApolloWebSocketException) - } - } - - @Test - fun `when subscription error, assert completed with exception and payload`() { - val result = runBlocking { - val expectedRequest = ApolloRequest( - operation = MockSubscription(), - scalarTypeAdapters = ScalarTypeAdapters.DEFAULT, - executionContext = ApolloCoroutineDispatcherContext(Dispatchers.Unconfined) - ) - val expectedOnStartResponse = "{\"data\":{\"name\":\"MockQuery\"}}" - val webSocketConnection = WebSocketConnectionMock( - expectedRequest = expectedRequest, - expectedOnStartResponse = expectedOnStartResponse - ) - - runCatching { - ApolloWebSocketNetworkTransport( - webSocketFactory = object : WebSocketFactory { - override suspend fun open(headers: Map): WebSocketConnection = webSocketConnection - }, - idleTimeoutMs = -1 - ).execute( - request = expectedRequest, - executionContext = ExecutionContext.Empty - ).collect { actualResponse -> - assertEquals(expectedOnStartResponse, actualResponse.response.data?.rawResponse) - webSocketConnection.enqueueError("{\"key1\":\"value1\", \"key2\":\"value2\"}") - } - } - } - - assertTrue(result.isFailure) - assertTrue(result.exceptionOrNull() is ApolloWebSocketServerException) - assertEquals("value1", (result.exceptionOrNull() as ApolloWebSocketServerException).payload["key1"]) - assertEquals("value2", (result.exceptionOrNull() as ApolloWebSocketServerException).payload["key2"]) - } - - @Test - fun `when no active subscriptions, assert web socket connection closed`() { - runBlocking { - val expectedRequest = ApolloRequest( - operation = MockSubscription(), - scalarTypeAdapters = ScalarTypeAdapters.DEFAULT, - executionContext = ApolloCoroutineDispatcherContext(Dispatchers.Unconfined) - ) - val expectedOnStartResponse = "{\"data\":{\"name\":\"MockQuery\"}}" - val webSocketConnection = WebSocketConnectionMock( - expectedRequest = expectedRequest, - expectedOnStartResponse = expectedOnStartResponse - ) - - ApolloWebSocketNetworkTransport( - webSocketFactory = object : WebSocketFactory { - override suspend fun open(headers: Map): WebSocketConnection = webSocketConnection - }, - idleTimeoutMs = 1_000 - ).execute( - request = expectedRequest, - executionContext = ExecutionContext.Empty - ).collect { actualResponse -> - assertEquals(expectedOnStartResponse, actualResponse.response.data?.rawResponse) - webSocketConnection.enqueueComplete() - } - - webSocketConnection.isClosed.await() - } - } - - @Test - fun `when connection keep alive timeout, assert web socket connection closed`() { - runBlocking { - val expectedRequest = ApolloRequest( - operation = MockSubscription(), - scalarTypeAdapters = ScalarTypeAdapters.DEFAULT, - executionContext = ApolloCoroutineDispatcherContext(Dispatchers.Unconfined) - ) - val expectedOnStartResponse = "{\"data\":{\"name\":\"MockQuery\"}}" - val webSocketConnection = WebSocketConnectionMock( - expectedRequest = expectedRequest, - expectedOnStartResponse = expectedOnStartResponse - ) - - ApolloWebSocketNetworkTransport( - webSocketFactory = object : WebSocketFactory { - override suspend fun open(headers: Map): WebSocketConnection = webSocketConnection - }, - idleTimeoutMs = -1, - connectionKeepAliveTimeoutMs = 1_000 - ).execute( - request = expectedRequest, - executionContext = ExecutionContext.Empty - ).collect { actualResponse -> - assertEquals(expectedOnStartResponse, actualResponse.response.data?.rawResponse) - webSocketConnection.enqueueConnectionKeepAlive() - } - - webSocketConnection.isClosed.await() - } - } -} - -private class FrozenWebSocketConnection( - private val receivedMessageChannel: Channel = Channel() -) : WebSocketConnection, ReceiveChannel by receivedMessageChannel { - override fun send(data: ByteString) { - } - - override fun close() { - } -} - -private class WebSocketConnectionMock( - val expectedRequest: ApolloRequest, - val expectedOnStartResponse: String, - private val receivedMessageChannel: Channel = Channel(Channel.BUFFERED) -) : WebSocketConnection, ReceiveChannel by receivedMessageChannel { - val isClosed = CompletableDeferred() - - override fun send(data: ByteString) { - when (data.utf8()) { - ApolloGraphQLClientMessage.Init(emptyMap()).serialize().utf8() -> { - receivedMessageChannel.offer("{\"type\": \"connection_ack\"}".encodeUtf8()) - } - - ApolloGraphQLClientMessage.Start(expectedRequest).serialize().utf8() -> { - enqueueResponse(expectedOnStartResponse) - } - } - } - - override fun close() { - isClosed.complete(true) - receivedMessageChannel.close() - } - - fun enqueueResponse(payload: String) { - receivedMessageChannel.offer( - "{\"type\":\"data\", \"id\":\"${expectedRequest.requestUuid}\", \"payload\":$payload}".encodeUtf8() - ) - } - - fun enqueueError(payload: String) { - receivedMessageChannel.offer( - "{\"type\":\"error\", \"id\":\"${expectedRequest.requestUuid}\", \"payload\":$payload}".encodeUtf8() - ) - } - - fun enqueueConnectionKeepAlive() { - receivedMessageChannel.offer( - "{\"type\":\"ka\"}".encodeUtf8() - ) - } - - fun enqueueComplete() { - receivedMessageChannel.offer( - "{\"type\": \"complete\", \"id\":\"${expectedRequest.requestUuid}\"}".encodeUtf8() - ) - } -} diff --git a/apollo-runtime-kotlin/src/iosMain/kotlin/com/apollographql/apollo/network/IosPlatform.kt b/apollo-runtime-kotlin/src/iosMain/kotlin/com/apollographql/apollo/network/IosPlatform.kt deleted file mode 100644 index 32b664b2649..00000000000 --- a/apollo-runtime-kotlin/src/iosMain/kotlin/com/apollographql/apollo/network/IosPlatform.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.apollographql.apollo.network - -import kotlinx.cinterop.addressOf -import kotlinx.cinterop.convert -import kotlinx.cinterop.usePinned -import platform.Foundation.NSData -import platform.Foundation.NSMutableData -import platform.Foundation.appendBytes - -fun ByteArray.toNSData(): NSData = NSMutableData().apply { - if (isEmpty()) return@apply - this@toNSData.usePinned { - appendBytes(it.addressOf(0), size.convert()) - } -} diff --git a/apollo-runtime-kotlin/src/iosMain/kotlin/com/apollographql/apollo/network/http/ApolloHttpNetworkTransport.kt b/apollo-runtime-kotlin/src/iosMain/kotlin/com/apollographql/apollo/network/http/ApolloHttpNetworkTransport.kt deleted file mode 100644 index 295787d39be..00000000000 --- a/apollo-runtime-kotlin/src/iosMain/kotlin/com/apollographql/apollo/network/http/ApolloHttpNetworkTransport.kt +++ /dev/null @@ -1,281 +0,0 @@ -package com.apollographql.apollo.network.http - -import com.apollographql.apollo.ApolloException -import com.apollographql.apollo.ApolloHttpException -import com.apollographql.apollo.ApolloNetworkException -import com.apollographql.apollo.ApolloParseException -import com.apollographql.apollo.ApolloSerializationException -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.interceptor.ApolloRequest -import com.apollographql.apollo.interceptor.ApolloResponse -import com.apollographql.apollo.network.HttpExecutionContext -import com.apollographql.apollo.network.HttpMethod -import com.apollographql.apollo.network.NetworkTransport -import com.apollographql.apollo.network.toNSData -import kotlinx.cinterop.COpaquePointer -import kotlinx.cinterop.StableRef -import kotlinx.cinterop.asStableRef -import kotlinx.cinterop.staticCFunction -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import kotlinx.coroutines.suspendCancellableCoroutine -import okio.Buffer -import okio.IOException -import okio.toByteString -import platform.Foundation.NSData -import platform.Foundation.NSError -import platform.Foundation.NSHTTPURLResponse -import platform.Foundation.NSMutableURLRequest -import platform.Foundation.NSThread -import platform.Foundation.NSURL -import platform.Foundation.NSURLComponents -import platform.Foundation.NSURLQueryItem -import platform.Foundation.NSURLRequest -import platform.Foundation.NSURLRequestReloadIgnoringCacheData -import platform.Foundation.NSURLResponse -import platform.Foundation.NSURLSession -import platform.Foundation.NSURLSessionConfiguration -import platform.Foundation.NSURLSessionDataTask -import platform.Foundation.dataTaskWithRequest -import platform.Foundation.setHTTPBody -import platform.Foundation.setHTTPMethod -import platform.Foundation.setValue -import platform.darwin.dispatch_async_f -import platform.darwin.dispatch_get_main_queue -import kotlin.coroutines.Continuation -import kotlin.coroutines.resume -import kotlin.coroutines.resumeWithException -import kotlin.native.concurrent.freeze - -typealias UrlSessionDataTaskCompletionHandler = (NSData?, NSURLResponse?, NSError?) -> Unit - -fun interface DataTaskFactory { - fun dataTask(request: NSURLRequest, completionHandler: UrlSessionDataTaskCompletionHandler): NSURLSessionDataTask -} - -@ApolloExperimental -@ExperimentalCoroutinesApi -actual class ApolloHttpNetworkTransport( - private val serverUrl: NSURL, - private val headers: Map, - private val httpMethod: HttpMethod, - private val dataTaskFactory: DataTaskFactory, - private val connectTimeoutMillis: Long = 60_000, -) : NetworkTransport { - - actual constructor( - serverUrl: String, - headers: Map, - httpMethod: HttpMethod, - connectTimeoutMillis: Long, - readTimeoutMillis: Long, - ) : this( - serverUrl = NSURL(string = serverUrl), - headers = headers, - httpMethod = httpMethod, - dataTaskFactory = DefaultDataTaskFactory(readTimeoutMillis), - connectTimeoutMillis = connectTimeoutMillis, - ) - - private class DefaultDataTaskFactory(readTimeoutMillis: Long) : DataTaskFactory { - private val nsurlSession = NSURLSession.sessionWithConfiguration(NSURLSessionConfiguration.defaultSessionConfiguration().apply { - timeoutIntervalForRequest = readTimeoutMillis.toDouble()/1000 - }) - - override fun dataTask(request: NSURLRequest, completionHandler: UrlSessionDataTaskCompletionHandler): NSURLSessionDataTask { - return nsurlSession.dataTaskWithRequest(request, completionHandler) - } - - } - @Suppress("UNCHECKED_CAST") - override fun execute(request: ApolloRequest, executionContext: ExecutionContext): Flow> { - return flow { - assert(NSThread.isMainThread()) - - request.freeze() - - val result = suspendCancellableCoroutine { continuation -> - val continuationRef = StableRef.create(continuation).asCPointer() - val delegate = { httpData: NSData?, httpResponse: NSURLResponse?, error: NSError? -> - initRuntimeIfNeeded() - - parse( - request = request, - data = httpData, - httpResponse = httpResponse as? NSHTTPURLResponse, - error = error - ).dispatchOnMain(continuationRef) - } - - val httpRequest = try { - request.toHttpRequest(executionContext[HttpExecutionContext.Request]) - } catch (e: Exception) { - continuation.resumeWithException( - ApolloSerializationException( - message = "Failed to compose GraphQL network request", - cause = e - ) - ) - return@suspendCancellableCoroutine - } - - dataTaskFactory.dataTask(httpRequest.freeze(), delegate.freeze()) - .also { task -> - continuation.invokeOnCancellation { - task.cancel() - } - } - .resume() - } - - when (result) { - is Result.Success -> emit(result.response as ApolloResponse) - is Result.Failure -> throw result.cause - } - } - } - - private fun ApolloRequest<*>.toHttpRequest(httpExecutionContext: HttpExecutionContext.Request?): NSURLRequest { - return when (httpMethod) { - HttpMethod.Get -> toHttpGetRequest(httpExecutionContext) - HttpMethod.Post -> toHttpPostRequest(httpExecutionContext) - } - } - - private fun ApolloRequest<*>.toHttpGetRequest(httpExecutionContext: HttpExecutionContext.Request?): NSURLRequest { - val urlComponents = NSURLComponents(uRL = serverUrl, resolvingAgainstBaseURL = false) - urlComponents.queryItems = listOfNotNull( - NSURLQueryItem(name = "query", value = operation.queryDocument()), - NSURLQueryItem(name = "operationName", value = operation.name().name()), - operation.variables().marshal(scalarTypeAdapters).let { variables -> - if (variables.isNotEmpty()) NSURLQueryItem(name = "variables", value = variables) else null - } - ) - return NSMutableURLRequest.requestWithURL( - URL = urlComponents.URL!! - ).apply { - setHTTPMethod("GET") - setTimeoutInterval(connectTimeoutMillis.toDouble() / 1000) - headers - .plus(httpExecutionContext?.headers ?: emptyMap()) - .forEach { (key, value) -> setValue(value, forHTTPHeaderField = key) } - setCachePolicy(NSURLRequestReloadIgnoringCacheData) - } - } - - private fun ApolloRequest<*>.toHttpPostRequest(httpExecutionContext: HttpExecutionContext.Request?): NSURLRequest { - return NSMutableURLRequest.requestWithURL(serverUrl).apply { - val postBody = operation.composeRequestBody(scalarTypeAdapters).toByteArray().toNSData() - setHTTPMethod("POST") - headers - .plus("Content-Type" to "application/json; charset=utf-8") - .plus(httpExecutionContext?.headers ?: emptyMap()) - .forEach { (key, value) -> setValue(value, forHTTPHeaderField = key) } - setCachePolicy(NSURLRequestReloadIgnoringCacheData) - setHTTPBody(postBody) - } - } - - private fun parse( - request: ApolloRequest, - data: NSData?, - httpResponse: NSHTTPURLResponse?, - error: NSError? - ): Result { - if (error != null) return Result.Failure( - cause = ApolloNetworkException( - message = "Failed to execute GraphQL http network request", - cause = IOException(error.localizedDescription) - ) - ) - - if (httpResponse == null) return Result.Failure( - cause = ApolloNetworkException("Failed to parse GraphQL http network response: EOF") - ) - - val httpHeaders = httpResponse.allHeaderFields - .map { (key, value) -> key.toString() to value.toString() } - .toMap() - - val statusCode = httpResponse.statusCode.toInt() - if (statusCode !in 200..299) return Result.Failure( - cause = ApolloHttpException( - statusCode = httpResponse.statusCode.toInt(), - headers = httpHeaders, - message = "Http request failed with status code `$statusCode`" - ) - ) - - if (data == null) return Result.Failure( - cause = ApolloHttpException( - statusCode = httpResponse.statusCode.toInt(), - headers = httpHeaders, - message = "Failed to parse GraphQL http network response: EOF" - ) - ) - - return try { - val response = request.operation.parse( - source = Buffer().write(data.toByteString()).apply { flush() }, - scalarTypeAdapters = request.scalarTypeAdapters - ) - Result.Success( - ApolloResponse( - requestUuid = request.requestUuid, - response = response, - executionContext = request.executionContext + HttpExecutionContext.Response( - statusCode = httpResponse.statusCode.toInt(), - headers = httpHeaders - ) - ) - ) - } catch (e: Exception) { - Result.Failure( - cause = ApolloParseException( - message = "Failed to parse GraphQL network response", - cause = e - ) - ) - } - } - - sealed class Result { - class Success(val response: ApolloResponse<*>) : Result() - - class Failure(val cause: ApolloException) : Result() - } - - @Suppress("NAME_SHADOWING") - private fun Result.dispatchOnMain(continuationPtr: COpaquePointer) { - if (NSThread.isMainThread()) { - dispatch(continuationPtr) - } else { - val continuationWithResultRef = StableRef.create((continuationPtr to this).freeze()) - dispatch_async_f( - queue = dispatch_get_main_queue(), - context = continuationWithResultRef.asCPointer(), - work = staticCFunction { ptr -> - val continuationWithResultRef = ptr!!.asStableRef>() - val (continuationPtr, result) = continuationWithResultRef.get() - continuationWithResultRef.dispose() - - result.dispatch(continuationPtr) - } - ) - } - } -} - -@Suppress("NAME_SHADOWING") -@ApolloExperimental -@ExperimentalCoroutinesApi -internal fun ApolloHttpNetworkTransport.Result.dispatch(continuationPtr: COpaquePointer) { - val continuationRef = continuationPtr.asStableRef>() - val continuation = continuationRef.get() - continuationRef.dispose() - - continuation.resume(this) -} diff --git a/apollo-runtime-kotlin/src/iosMain/kotlin/com/apollographql/apollo/network/ws/ApolloWebSocket.kt b/apollo-runtime-kotlin/src/iosMain/kotlin/com/apollographql/apollo/network/ws/ApolloWebSocket.kt deleted file mode 100644 index b48d0ae6e40..00000000000 --- a/apollo-runtime-kotlin/src/iosMain/kotlin/com/apollographql/apollo/network/ws/ApolloWebSocket.kt +++ /dev/null @@ -1,258 +0,0 @@ -package com.apollographql.apollo.network.ws - -import com.apollographql.apollo.ApolloWebSocketException -import com.apollographql.apollo.network.toNSData -import kotlinx.cinterop.COpaquePointer -import kotlinx.cinterop.StableRef -import kotlinx.cinterop.asStableRef -import kotlinx.cinterop.staticCFunction -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.channels.Channel -import kotlinx.coroutines.channels.ReceiveChannel -import okio.ByteString -import okio.ByteString.Companion.toByteString -import okio.IOException -import okio.internal.commonAsUtf8ToByteArray -import okio.toByteString -import platform.Foundation.NSData -import platform.Foundation.NSError -import platform.Foundation.NSMutableURLRequest -import platform.Foundation.NSOperationQueue -import platform.Foundation.NSThread -import platform.Foundation.NSURL -import platform.Foundation.NSURLRequest -import platform.Foundation.NSURLSession -import platform.Foundation.NSURLSessionConfiguration -import platform.Foundation.NSURLSessionWebSocketCloseCode -import platform.Foundation.NSURLSessionWebSocketDelegateProtocol -import platform.Foundation.NSURLSessionWebSocketMessage -import platform.Foundation.NSURLSessionWebSocketMessageTypeData -import platform.Foundation.NSURLSessionWebSocketMessageTypeString -import platform.Foundation.NSURLSessionWebSocketTask -import platform.Foundation.setHTTPMethod -import platform.Foundation.setValue -import platform.darwin.NSObject -import platform.darwin.dispatch_async_f -import platform.darwin.dispatch_get_main_queue -import kotlin.native.concurrent.ensureNeverFrozen -import kotlin.native.concurrent.freeze - -interface WebSocketConnectionListener { - fun onOpen(webSocket: NSURLSessionWebSocketTask) - - fun onClose(webSocket: NSURLSessionWebSocketTask, code: NSURLSessionWebSocketCloseCode) -} - -typealias NSWebSocketFactory = (NSURLRequest, WebSocketConnectionListener) -> NSURLSessionWebSocketTask - -@ExperimentalCoroutinesApi -actual class ApolloWebSocketFactory( - private val serverUrl: NSURL, - private val headers: Map, - private val webSocketFactory: NSWebSocketFactory -) : WebSocketFactory { - - actual constructor( - serverUrl: String, - headers: Map - ) : this( - serverUrl = NSURL(string = serverUrl), - headers = headers, - webSocketFactory = { request, connectionListener -> - NSURLSession.sessionWithConfiguration( - configuration = NSURLSessionConfiguration.defaultSessionConfiguration, - delegate = NSURLSessionWebSocketDelegate(connectionListener), - delegateQueue = NSOperationQueue.mainQueue - ).webSocketTaskWithRequest(request) - } - ) - - override suspend fun open(headers: Map): WebSocketConnection { - assert(NSThread.isMainThread()) - - val request = NSMutableURLRequest.requestWithURL(serverUrl).apply { - this@ApolloWebSocketFactory.headers - .plus(headers) - .forEach { (key, value) -> setValue(value, forHTTPHeaderField = key) } - setHTTPMethod("GET") - } - - val messageChannel = Channel(Channel.BUFFERED) - val isOpen = CompletableDeferred() - - val connectionListener = object : WebSocketConnectionListener { - override fun onOpen(webSocket: NSURLSessionWebSocketTask) { - if (!isOpen.complete(true)) { - webSocket.cancel() - } - } - - override fun onClose(webSocket: NSURLSessionWebSocketTask, code: NSURLSessionWebSocketCloseCode) { - isOpen.cancel() - messageChannel.close() - } - } - - val webSocket = webSocketFactory(request, connectionListener) - .apply { resume() } - - try { - isOpen.await() - return WebSocketConnectionImpl( - webSocket = webSocket, - messageChannel = messageChannel.apply { ensureNeverFrozen() } - ) - } catch (e: Exception) { - webSocket.cancel() - throw e - } - } -} - -@ExperimentalCoroutinesApi -private class WebSocketConnectionImpl( - val webSocket: NSURLSessionWebSocketTask, - val messageChannel: Channel -) : WebSocketConnection, ReceiveChannel by messageChannel { - - init { - messageChannel.invokeOnClose { - webSocket.cancelWithCloseCode( - closeCode = 1001, - reason = null - ) - } - receiveNext() - } - - @Suppress("NAME_SHADOWING") - override fun send(data: ByteString) { - assert(NSThread.isMainThread()) - if (!messageChannel.isClosedForReceive) { - val message = NSURLSessionWebSocketMessage(data.toByteArray().toNSData()) - val webSocketConnectionPtr = StableRef.create(this).asCPointer() - val completionHandler = { error: NSError? -> - error?.dispatchOnMain(webSocketConnectionPtr) - Unit - }.freeze() - webSocket.sendMessage(message, completionHandler) - } - } - - override fun close() { - assert(NSThread.isMainThread()) - messageChannel.close() - } - - @Suppress("NAME_SHADOWING") - internal fun receiveNext() { - assert(NSThread.isMainThread()) - - val webSocketConnectionPtr = StableRef.create(this).asCPointer() - val completionHandler = { message: NSURLSessionWebSocketMessage?, error: NSError? -> - error?.dispatchOnMain(webSocketConnectionPtr) ?: message?.dispatchOnMainAndRequestNext(webSocketConnectionPtr) - Unit - } - webSocket.receiveMessageWithCompletionHandler(completionHandler) - } -} - -@Suppress("NAME_SHADOWING") -@ExperimentalCoroutinesApi -private fun NSError.dispatchOnMain(webSocketConnectionPtr: COpaquePointer) { - if (NSThread.isMainThread) { - dispatch(webSocketConnectionPtr) - } else { - dispatch_async_f( - queue = dispatch_get_main_queue(), - context = StableRef.create(freeze() to webSocketConnectionPtr).asCPointer(), - work = staticCFunction { ptr -> - val errorAndWebSocketConnectionRef = ptr!!.asStableRef>() - - val (error, webSocketConnectionPtr) = errorAndWebSocketConnectionRef.get() - errorAndWebSocketConnectionRef.dispose() - - error.dispatch(webSocketConnectionPtr) - } - ) - } -} - -@ExperimentalCoroutinesApi -private fun NSError.dispatch(webSocketConnectionPtr: COpaquePointer) { - val webSocketConnectionRef = webSocketConnectionPtr.asStableRef() - val webSocketConnection = webSocketConnectionRef.get() - webSocketConnectionRef.dispose() - - webSocketConnection.messageChannel.close( - ApolloWebSocketException( - message = "Web socket communication error", - cause = IOException(localizedDescription) - ) - ) - webSocketConnection.webSocket.cancel() -} - -@Suppress("NAME_SHADOWING") -@ExperimentalCoroutinesApi -private fun NSURLSessionWebSocketMessage.dispatchOnMainAndRequestNext(webSocketConnectionPtr: COpaquePointer) { - if (NSThread.isMainThread) { - dispatchAndRequestNext(webSocketConnectionPtr) - } else { - dispatch_async_f( - queue = dispatch_get_main_queue(), - context = StableRef.create(freeze() to webSocketConnectionPtr).asCPointer(), - work = staticCFunction { ptr -> - val messageAndWebSocketConnectionRef = ptr!!.asStableRef>() - - val (message, webSocketConnectionPtr) = messageAndWebSocketConnectionRef.get() - messageAndWebSocketConnectionRef.dispose() - - message.dispatchAndRequestNext(webSocketConnectionPtr) - } - ) - } -} - -@ExperimentalCoroutinesApi -private fun NSURLSessionWebSocketMessage.dispatchAndRequestNext(webSocketConnectionPtr: COpaquePointer) { - val webSocketConnectionRef = webSocketConnectionPtr.asStableRef() - val webSocketConnection = webSocketConnectionRef.get() - webSocketConnectionRef.dispose() - - val data = when (type) { - NSURLSessionWebSocketMessageTypeData -> { - data?.toByteString() - } - - NSURLSessionWebSocketMessageTypeString -> { - string?.commonAsUtf8ToByteArray()?.toByteString() - } - - else -> null - } - - try { - if (data != null) webSocketConnection.messageChannel.offer(data) - } catch (e: Exception) { - webSocketConnection.webSocket.cancel() - return - } - - webSocketConnection.receiveNext() -} - - -private class NSURLSessionWebSocketDelegate( - val webSocketConnectionListener: WebSocketConnectionListener -) : NSObject(), NSURLSessionWebSocketDelegateProtocol { - - override fun URLSession(session: NSURLSession, webSocketTask: NSURLSessionWebSocketTask, didOpenWithProtocol: String?) { - webSocketConnectionListener.onOpen(webSocketTask) - } - - override fun URLSession(session: NSURLSession, webSocketTask: NSURLSessionWebSocketTask, didCloseWithCode: NSURLSessionWebSocketCloseCode, reason: NSData?) { - webSocketConnectionListener.onClose(webSocket = webSocketTask, code = didCloseWithCode) - } -} diff --git a/apollo-runtime-kotlin/src/iosSimTest/kotlin/com/apollographql/apollo/IOSTestUtils.kt b/apollo-runtime-kotlin/src/iosSimTest/kotlin/com/apollographql/apollo/IOSTestUtils.kt deleted file mode 100644 index a5ad27cc963..00000000000 --- a/apollo-runtime-kotlin/src/iosSimTest/kotlin/com/apollographql/apollo/IOSTestUtils.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.apollographql.apollo - -import kotlinx.coroutines.CoroutineScope -import kotlin.coroutines.CoroutineContext - -actual fun runBlocking(context: CoroutineContext, block: suspend CoroutineScope.() -> T): T { - return kotlinx.coroutines.runBlocking(context, block) -} diff --git a/apollo-runtime-kotlin/src/iosSimTest/kotlin/com/apollographql/apollo/network/http/ApolloHttpNetworkTransportTest.kt b/apollo-runtime-kotlin/src/iosSimTest/kotlin/com/apollographql/apollo/network/http/ApolloHttpNetworkTransportTest.kt deleted file mode 100644 index 5e7ea0373d2..00000000000 --- a/apollo-runtime-kotlin/src/iosSimTest/kotlin/com/apollographql/apollo/network/http/ApolloHttpNetworkTransportTest.kt +++ /dev/null @@ -1,150 +0,0 @@ -package com.apollographql.apollo.network.http - -import com.apollographql.apollo.ApolloHttpException -import com.apollographql.apollo.ApolloNetworkException -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.interceptor.ApolloRequest -import com.apollographql.apollo.mock.MockQuery -import com.apollographql.apollo.network.HttpExecutionContext -import com.apollographql.apollo.network.HttpMethod -import com.apollographql.apollo.network.mock.MockHttpResponse -import com.apollographql.apollo.network.mock.MockSessionDataTask -import com.apollographql.apollo.network.toNSData -import com.apollographql.apollo.runBlocking -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.flow.single -import okio.ByteString.Companion.encodeUtf8 -import okio.toByteString -import platform.Foundation.HTTPBody -import platform.Foundation.NSError -import platform.Foundation.NSErrorDomain -import platform.Foundation.NSHTTPURLResponse -import platform.Foundation.NSURL -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertNotNull - -@ApolloExperimental -@ExperimentalCoroutinesApi -class ApolloHttpNetworkTransportTest { - - @Test - fun `when error, assert execute fails`() { - val networkTransport = mockApolloHttpNetworkTransport { _, completionHandler -> - MockSessionDataTask( - completionHandler = completionHandler, - mockResponse = MockHttpResponse( - error = NSError(domain = NSErrorDomain(), code = 100, userInfo = emptyMap()) - ) - ) - } - - try { - runBlocking { - networkTransport.execute(request = mockGraphQLRequest(), executionContext = ExecutionContext.Empty).single() - } - } catch (e: ApolloNetworkException) { - // expected - } - } - - @Test - fun `when http error, assert execute fails`() { - val networkTransport = mockApolloHttpNetworkTransport { _, completionHandler -> - MockSessionDataTask( - completionHandler = completionHandler, - mockResponse = MockHttpResponse( - httpResponse = NSHTTPURLResponse( - uRL = NSURL(string = "https://apollo.com"), - statusCode = 404, - HTTPVersion = null, - headerFields = mapOf( - "header1" to "header1Value", - "header2" to "header2Value" - ) - ) - ) - ) - } - - try { - runBlocking { - networkTransport.execute(request = mockGraphQLRequest(), executionContext = ExecutionContext.Empty).single() - } - } catch (e: ApolloHttpException) { - assertEquals(404, e.statusCode) - assertEquals("header1Value", e.headers["header1"]) - assertEquals("header2Value", e.headers["header2"]) - } - } - - @Test - fun `when http success, assert success`() { - val networkTransport = mockApolloHttpNetworkTransport { _, completionHandler -> - MockSessionDataTask( - completionHandler = completionHandler, - mockResponse = mockSuccessHttpResponse() - ) - } - - val response = runBlocking { - networkTransport.execute(request = mockGraphQLRequest(), executionContext = ExecutionContext.Empty).single() - } - - assertEquals("{\"data\":{\"name\":\"MockQuery\"}}", response.response.data?.rawResponse) - assertNotNull(response.executionContext[HttpExecutionContext.Response]) - assertEquals(200, response.executionContext[HttpExecutionContext.Response]?.statusCode) - assertEquals("header1Value", response.executionContext[HttpExecutionContext.Response]?.headers?.get("header1")) - assertEquals("header2Value", response.executionContext[HttpExecutionContext.Response]?.headers?.get("header2")) - } - - @Test - fun `when http post, assert request GraphQL request body`() { - val networkTransport = mockApolloHttpNetworkTransport { request, completionHandler -> - assertEquals("https://apollo.com", request.URL.toString()) - assertEquals(MockQuery().composeRequestBody().utf8(), request.HTTPBody!!.toByteString().utf8()) - MockSessionDataTask( - completionHandler = completionHandler, - mockResponse = mockSuccessHttpResponse() - ) - } - - runBlocking { - networkTransport.execute(request = mockGraphQLRequest(), executionContext = ExecutionContext.Empty).single() - } - } - - private fun mockApolloHttpNetworkTransport(dataTaskFactory: DataTaskFactory): ApolloHttpNetworkTransport { - return ApolloHttpNetworkTransport( - serverUrl = NSURL(string = "https://apollo.com"), - headers = emptyMap(), - httpMethod = HttpMethod.Post, - dataTaskFactory = dataTaskFactory, - ) - } - - private fun mockGraphQLRequest(): ApolloRequest { - return ApolloRequest( - operation = MockQuery(), - scalarTypeAdapters = ScalarTypeAdapters.DEFAULT, - executionContext = ExecutionContext.Empty - ) - } - - private fun mockSuccessHttpResponse(): MockHttpResponse { - return MockHttpResponse( - httpResponse = NSHTTPURLResponse( - uRL = NSURL(string = "https://apollo.com"), - statusCode = 200L, - HTTPVersion = null, - headerFields = mapOf( - "header1" to "header1Value", - "header2" to "header2Value" - ) - ), - httpData = "{\"data\":{\"name\":\"MockQuery\"}}".encodeUtf8().toByteArray().toNSData() - ) - } -} diff --git a/apollo-runtime-kotlin/src/iosSimTest/kotlin/com/apollographql/apollo/network/mock/MockHttpResponse.kt b/apollo-runtime-kotlin/src/iosSimTest/kotlin/com/apollographql/apollo/network/mock/MockHttpResponse.kt deleted file mode 100644 index 941a265150d..00000000000 --- a/apollo-runtime-kotlin/src/iosSimTest/kotlin/com/apollographql/apollo/network/mock/MockHttpResponse.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.apollographql.apollo.network.mock - -import platform.Foundation.NSData -import platform.Foundation.NSError -import platform.Foundation.NSHTTPURLResponse - -class MockHttpResponse( - val httpData: NSData? = null, - val httpResponse: NSHTTPURLResponse? = null, - val error: NSError? = null -) diff --git a/apollo-runtime-kotlin/src/iosSimTest/kotlin/com/apollographql/apollo/network/mock/MockSessionDataTask.kt b/apollo-runtime-kotlin/src/iosSimTest/kotlin/com/apollographql/apollo/network/mock/MockSessionDataTask.kt deleted file mode 100644 index a1b2599f917..00000000000 --- a/apollo-runtime-kotlin/src/iosSimTest/kotlin/com/apollographql/apollo/network/mock/MockSessionDataTask.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.apollographql.apollo.network.mock - -import com.apollographql.apollo.network.http.UrlSessionDataTaskCompletionHandler -import platform.Foundation.NSURLSessionDataTask - -class MockSessionDataTask( - private val completionHandler: UrlSessionDataTaskCompletionHandler, - private val mockResponse: MockHttpResponse -) : NSURLSessionDataTask() { - - override fun resume() { - with(mockResponse) { - completionHandler(httpData, httpResponse, error) - } - } -} diff --git a/apollo-runtime-kotlin/src/iosTest/kotlin/com/apollographql/apollo/IOSTestUtils.kt b/apollo-runtime-kotlin/src/iosTest/kotlin/com/apollographql/apollo/IOSTestUtils.kt deleted file mode 100644 index a5ad27cc963..00000000000 --- a/apollo-runtime-kotlin/src/iosTest/kotlin/com/apollographql/apollo/IOSTestUtils.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.apollographql.apollo - -import kotlinx.coroutines.CoroutineScope -import kotlin.coroutines.CoroutineContext - -actual fun runBlocking(context: CoroutineContext, block: suspend CoroutineScope.() -> T): T { - return kotlinx.coroutines.runBlocking(context, block) -} diff --git a/apollo-runtime-kotlin/src/jvmMain/kotlin/com/apollographql/apollo/network/http/ApolloHttpNetworkTransport.kt b/apollo-runtime-kotlin/src/jvmMain/kotlin/com/homer/apollographql/apollo/network/http/ApolloHttpNetworkTransport.kt similarity index 88% rename from apollo-runtime-kotlin/src/jvmMain/kotlin/com/apollographql/apollo/network/http/ApolloHttpNetworkTransport.kt rename to apollo-runtime-kotlin/src/jvmMain/kotlin/com/homer/apollographql/apollo/network/http/ApolloHttpNetworkTransport.kt index 5d448f83a1d..c3f5017a3bd 100644 --- a/apollo-runtime-kotlin/src/jvmMain/kotlin/com/apollographql/apollo/network/http/ApolloHttpNetworkTransport.kt +++ b/apollo-runtime-kotlin/src/jvmMain/kotlin/com/homer/apollographql/apollo/network/http/ApolloHttpNetworkTransport.kt @@ -1,18 +1,18 @@ -package com.apollographql.apollo.network.http +package com.homer.apollographql.apollo.network.http -import com.apollographql.apollo.ApolloException -import com.apollographql.apollo.ApolloHttpException -import com.apollographql.apollo.ApolloNetworkException -import com.apollographql.apollo.ApolloParseException -import com.apollographql.apollo.ApolloSerializationException -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.interceptor.ApolloRequest -import com.apollographql.apollo.interceptor.ApolloResponse -import com.apollographql.apollo.network.HttpExecutionContext -import com.apollographql.apollo.network.HttpMethod -import com.apollographql.apollo.network.NetworkTransport +import com.homer.apollographql.apollo.ApolloException +import com.homer.apollographql.apollo.ApolloHttpException +import com.homer.apollographql.apollo.ApolloNetworkException +import com.homer.apollographql.apollo.ApolloParseException +import com.homer.apollographql.apollo.ApolloSerializationException +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.api.ExecutionContext +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.interceptor.ApolloRequest +import com.homer.apollographql.apollo.interceptor.ApolloResponse +import com.homer.apollographql.apollo.network.HttpExecutionContext +import com.homer.apollographql.apollo.network.HttpMethod +import com.homer.apollographql.apollo.network.NetworkTransport import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow diff --git a/apollo-runtime-kotlin/src/jvmMain/kotlin/com/apollographql/apollo/network/ws/ApolloWebSocket.kt b/apollo-runtime-kotlin/src/jvmMain/kotlin/com/homer/apollographql/apollo/network/ws/ApolloWebSocket.kt similarity index 92% rename from apollo-runtime-kotlin/src/jvmMain/kotlin/com/apollographql/apollo/network/ws/ApolloWebSocket.kt rename to apollo-runtime-kotlin/src/jvmMain/kotlin/com/homer/apollographql/apollo/network/ws/ApolloWebSocket.kt index d962de85727..a539a84394d 100644 --- a/apollo-runtime-kotlin/src/jvmMain/kotlin/com/apollographql/apollo/network/ws/ApolloWebSocket.kt +++ b/apollo-runtime-kotlin/src/jvmMain/kotlin/com/homer/apollographql/apollo/network/ws/ApolloWebSocket.kt @@ -1,6 +1,6 @@ -package com.apollographql.apollo.network.ws +package com.homer.apollographql.apollo.network.ws -import com.apollographql.apollo.ApolloWebSocketException +import com.homer.apollographql.apollo.ApolloWebSocketException import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.channels.Channel @@ -51,7 +51,7 @@ actual class ApolloWebSocketFactory( override fun onMessage(webSocket: WebSocket, text: String) { try { - messageChannel.offer(text.commonAsUtf8ToByteArray().toByteString()) + messageChannel.trySend(text.commonAsUtf8ToByteArray().toByteString()) } catch (e: Exception) { webSocket.cancel() } @@ -59,7 +59,7 @@ actual class ApolloWebSocketFactory( override fun onMessage(webSocket: WebSocket, bytes: ByteString) { try { - messageChannel.offer(bytes) + messageChannel.trySend(bytes) } catch (e: Exception) { webSocket.cancel() } diff --git a/apollo-runtime-kotlin/src/jvmTest/kotlin/com/apollographql/apollo/JvmTestUtils.kt b/apollo-runtime-kotlin/src/jvmTest/kotlin/com/apollographql/apollo/JvmTestUtils.kt deleted file mode 100644 index a5ad27cc963..00000000000 --- a/apollo-runtime-kotlin/src/jvmTest/kotlin/com/apollographql/apollo/JvmTestUtils.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.apollographql.apollo - -import kotlinx.coroutines.CoroutineScope -import kotlin.coroutines.CoroutineContext - -actual fun runBlocking(context: CoroutineContext, block: suspend CoroutineScope.() -> T): T { - return kotlinx.coroutines.runBlocking(context, block) -} diff --git a/apollo-runtime/api.txt b/apollo-runtime/api.txt index e06ef985eda..61ab9c0c047 100644 --- a/apollo-runtime/api.txt +++ b/apollo-runtime/api.txt @@ -1,96 +1,96 @@ // Signature format: 3.0 -package com.apollographql.apollo { +package com.homer.apollographql.apollo { public interface ApolloCall { - method public com.apollographql.apollo.ApolloCall cacheHeaders(com.apollographql.apollo.cache.CacheHeaders); + method public com.homer.apollographql.apollo.ApolloCall cacheHeaders(com.homer.apollographql.apollo.cache.CacheHeaders); method public void cancel(); - method public com.apollographql.apollo.ApolloCall clone(); - method public void enqueue(com.apollographql.apollo.ApolloCall.Callback?); - method public com.apollographql.apollo.api.Operation operation(); - method public com.apollographql.apollo.ApolloCall.Builder toBuilder(); + method public com.homer.apollographql.apollo.ApolloCall clone(); + method public void enqueue(com.homer.apollographql.apollo.ApolloCall.Callback?); + method public com.homer.apollographql.apollo.api.Operation operation(); + method public com.homer.apollographql.apollo.ApolloCall.Builder toBuilder(); } public static interface ApolloCall.Builder { - method public com.apollographql.apollo.ApolloCall build(); - method public com.apollographql.apollo.ApolloCall.Builder cacheHeaders(com.apollographql.apollo.cache.CacheHeaders); + method public com.homer.apollographql.apollo.ApolloCall build(); + method public com.homer.apollographql.apollo.ApolloCall.Builder cacheHeaders(com.homer.apollographql.apollo.cache.CacheHeaders); } public abstract static class ApolloCall.Callback { ctor public ApolloCall.Callback(); - method public void onCanceledError(com.apollographql.apollo.exception.ApolloCanceledException); - method public abstract void onFailure(com.apollographql.apollo.exception.ApolloException); - method public void onHttpError(com.apollographql.apollo.exception.ApolloHttpException); - method public void onNetworkError(com.apollographql.apollo.exception.ApolloNetworkException); - method public void onParseError(com.apollographql.apollo.exception.ApolloParseException); - method public abstract void onResponse(com.apollographql.apollo.api.Response); - method public void onStatusEvent(com.apollographql.apollo.ApolloCall.StatusEvent); + method public void onCanceledError(com.homer.apollographql.apollo.exception.ApolloCanceledException); + method public abstract void onFailure(com.homer.apollographql.apollo.exception.ApolloException); + method public void onHttpError(com.homer.apollographql.apollo.exception.ApolloHttpException); + method public void onNetworkError(com.homer.apollographql.apollo.exception.ApolloNetworkException); + method public void onParseError(com.homer.apollographql.apollo.exception.ApolloParseException); + method public abstract void onResponse(com.homer.apollographql.apollo.api.Response); + method public void onStatusEvent(com.homer.apollographql.apollo.ApolloCall.StatusEvent); } public enum ApolloCall.StatusEvent { - enum_constant public static final com.apollographql.apollo.ApolloCall.StatusEvent COMPLETED; - enum_constant public static final com.apollographql.apollo.ApolloCall.StatusEvent FETCH_CACHE; - enum_constant public static final com.apollographql.apollo.ApolloCall.StatusEvent FETCH_NETWORK; - enum_constant public static final com.apollographql.apollo.ApolloCall.StatusEvent SCHEDULED; + enum_constant public static final com.homer.apollographql.apollo.ApolloCall.StatusEvent COMPLETED; + enum_constant public static final com.homer.apollographql.apollo.ApolloCall.StatusEvent FETCH_CACHE; + enum_constant public static final com.homer.apollographql.apollo.ApolloCall.StatusEvent FETCH_NETWORK; + enum_constant public static final com.homer.apollographql.apollo.ApolloCall.StatusEvent SCHEDULED; } - public final class ApolloClient implements com.apollographql.apollo.ApolloMutationCall.Factory com.apollographql.apollo.ApolloPrefetch.Factory com.apollographql.apollo.ApolloQueryCall.Factory com.apollographql.apollo.ApolloSubscriptionCall.Factory { + public final class ApolloClient implements com.homer.apollographql.apollo.ApolloMutationCall.Factory com.homer.apollographql.apollo.ApolloPrefetch.Factory com.homer.apollographql.apollo.ApolloQueryCall.Factory com.homer.apollographql.apollo.ApolloSubscriptionCall.Factory { method public int activeCallsCount(); - method public void addOnSubscriptionManagerStateChangeListener(com.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener); - method @Deprecated public com.apollographql.apollo.cache.normalized.ApolloStore! apolloStore(); - method public static com.apollographql.apollo.ApolloClient.Builder! builder(); + method public void addOnSubscriptionManagerStateChangeListener(com.homer.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener); + method @Deprecated public com.homer.apollographql.apollo.cache.normalized.ApolloStore! apolloStore(); + method public static com.homer.apollographql.apollo.ApolloClient.Builder! builder(); method public void clearHttpCache(); - method public void clearNormalizedCache(com.apollographql.apollo.cache.normalized.ApolloStoreOperation.Callback); + method public void clearNormalizedCache(com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation.Callback); method public boolean clearNormalizedCache(); - method @Deprecated public com.apollographql.apollo.cache.CacheHeaders! defaultCacheHeaders(); + method @Deprecated public com.homer.apollographql.apollo.cache.CacheHeaders! defaultCacheHeaders(); method public void disableSubscriptions(); method public void enableSubscriptions(); - method public com.apollographql.apollo.cache.normalized.ApolloStore! getApolloStore(); + method public com.homer.apollographql.apollo.cache.normalized.ApolloStore! getApolloStore(); method public List getApplicationInterceptorFactories(); method public List getApplicationInterceptors(); - method public com.apollographql.apollo.interceptor.ApolloInterceptorFactory! getAutoPersistedOperationsInterceptorFactory(); - method public com.apollographql.apollo.cache.CacheHeaders! getDefaultCacheHeaders(); + method public com.homer.apollographql.apollo.interceptor.ApolloInterceptorFactory! getAutoPersistedOperationsInterceptorFactory(); + method public com.homer.apollographql.apollo.cache.CacheHeaders! getDefaultCacheHeaders(); method public HttpCache getHttpCache(); - method public com.apollographql.apollo.api.ScalarTypeAdapters! getScalarTypeAdapters(); + method public com.homer.apollographql.apollo.api.ScalarTypeAdapters! getScalarTypeAdapters(); method public okhttp3.HttpUrl! getServerUrl(); - method public com.apollographql.apollo.internal.subscription.SubscriptionManager! getSubscriptionManager(); - method public com.apollographql.apollo.subscription.SubscriptionManagerState! getSubscriptionManagerState(); - method public void idleCallback(com.apollographql.apollo.IdleResourceCallback!); - method public com.apollographql.apollo.ApolloMutationCall! mutate(com.apollographql.apollo.api.Mutation); - method public com.apollographql.apollo.ApolloMutationCall! mutate(com.apollographql.apollo.api.Mutation, D); - method public com.apollographql.apollo.ApolloClient.Builder! newBuilder(); - method public com.apollographql.apollo.ApolloPrefetch! prefetch(com.apollographql.apollo.api.Operation); - method public com.apollographql.apollo.ApolloQueryCall! query(com.apollographql.apollo.api.Query); - method public void removeOnSubscriptionManagerStateChangeListener(com.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener); - method public com.apollographql.apollo.ApolloSubscriptionCall! subscribe(com.apollographql.apollo.api.Subscription); + method public com.homer.apollographql.apollo.internal.subscription.SubscriptionManager! getSubscriptionManager(); + method public com.homer.apollographql.apollo.subscription.SubscriptionManagerState! getSubscriptionManagerState(); + method public void idleCallback(com.homer.apollographql.apollo.IdleResourceCallback!); + method public com.homer.apollographql.apollo.ApolloMutationCall! mutate(com.homer.apollographql.apollo.api.Mutation); + method public com.homer.apollographql.apollo.ApolloMutationCall! mutate(com.homer.apollographql.apollo.api.Mutation, D); + method public com.homer.apollographql.apollo.ApolloClient.Builder! newBuilder(); + method public com.homer.apollographql.apollo.ApolloPrefetch! prefetch(com.homer.apollographql.apollo.api.Operation); + method public com.homer.apollographql.apollo.ApolloQueryCall! query(com.homer.apollographql.apollo.api.Query); + method public void removeOnSubscriptionManagerStateChangeListener(com.homer.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener); + method public com.homer.apollographql.apollo.ApolloSubscriptionCall! subscribe(com.homer.apollographql.apollo.api.Subscription); } public static class ApolloClient.Builder { - method public com.apollographql.apollo.ApolloClient.Builder! addApplicationInterceptor(com.apollographql.apollo.interceptor.ApolloInterceptor); - method public com.apollographql.apollo.ApolloClient.Builder! addApplicationInterceptorFactory(com.apollographql.apollo.interceptor.ApolloInterceptorFactory); - method public com.apollographql.apollo.ApolloClient.Builder! addCustomTypeAdapter(com.apollographql.apollo.api.ScalarType, com.apollographql.apollo.api.CustomTypeAdapter); - method public com.apollographql.apollo.ApolloClient! build(); - method public com.apollographql.apollo.ApolloClient.Builder! callFactory(okhttp3.Call.Factory); - method public com.apollographql.apollo.ApolloClient.Builder! defaultCacheHeaders(com.apollographql.apollo.cache.CacheHeaders); - method public com.apollographql.apollo.ApolloClient.Builder! defaultHttpCachePolicy(HttpCachePolicy.Policy); - method public com.apollographql.apollo.ApolloClient.Builder! defaultResponseFetcher(com.apollographql.apollo.fetcher.ResponseFetcher); - method public com.apollographql.apollo.ApolloClient.Builder! dispatcher(Executor); - method public com.apollographql.apollo.ApolloClient.Builder! enableAutoPersistedQueries(boolean); - method public com.apollographql.apollo.ApolloClient.Builder! enableAutoPersistedSubscriptions(boolean); - method public com.apollographql.apollo.ApolloClient.Builder! httpCache(HttpCache); - method public com.apollographql.apollo.ApolloClient.Builder! logger(com.apollographql.apollo.Logger?); - method public com.apollographql.apollo.ApolloClient.Builder! normalizedCache(com.apollographql.apollo.cache.normalized.NormalizedCacheFactory); - method public com.apollographql.apollo.ApolloClient.Builder! normalizedCache(com.apollographql.apollo.cache.normalized.NormalizedCacheFactory, com.apollographql.apollo.cache.normalized.CacheKeyResolver); - method public com.apollographql.apollo.ApolloClient.Builder! normalizedCache(com.apollographql.apollo.cache.normalized.NormalizedCacheFactory, com.apollographql.apollo.cache.normalized.CacheKeyResolver, boolean); - method public com.apollographql.apollo.ApolloClient.Builder! okHttpClient(okhttp3.OkHttpClient); - method public com.apollographql.apollo.ApolloClient.Builder! serverUrl(okhttp3.HttpUrl); - method public com.apollographql.apollo.ApolloClient.Builder! serverUrl(String); - method public com.apollographql.apollo.ApolloClient.Builder! setAutoPersistedOperationsInterceptorFactory(com.apollographql.apollo.interceptor.ApolloInterceptorFactory?); - method public com.apollographql.apollo.ApolloClient.Builder! subscriptionConnectionParams(com.apollographql.apollo.subscription.SubscriptionConnectionParams); - method public com.apollographql.apollo.ApolloClient.Builder! subscriptionConnectionParams(com.apollographql.apollo.subscription.SubscriptionConnectionParamsProvider); - method public com.apollographql.apollo.ApolloClient.Builder! subscriptionHeartbeatTimeout(long, TimeUnit); - method public com.apollographql.apollo.ApolloClient.Builder! subscriptionTransportFactory(com.apollographql.apollo.subscription.SubscriptionTransport.Factory); - method public com.apollographql.apollo.ApolloClient.Builder! useHttpGetMethodForPersistedQueries(boolean); - method public com.apollographql.apollo.ApolloClient.Builder! useHttpGetMethodForQueries(boolean); + method public com.homer.apollographql.apollo.ApolloClient.Builder! addApplicationInterceptor(com.homer.apollographql.apollo.interceptor.ApolloInterceptor); + method public com.homer.apollographql.apollo.ApolloClient.Builder! addApplicationInterceptorFactory(com.homer.apollographql.apollo.interceptor.ApolloInterceptorFactory); + method public com.homer.apollographql.apollo.ApolloClient.Builder! addCustomTypeAdapter(com.homer.apollographql.apollo.api.ScalarType, com.homer.apollographql.apollo.api.CustomTypeAdapter); + method public com.homer.apollographql.apollo.ApolloClient! build(); + method public com.homer.apollographql.apollo.ApolloClient.Builder! callFactory(okhttp3.Call.Factory); + method public com.homer.apollographql.apollo.ApolloClient.Builder! defaultCacheHeaders(com.homer.apollographql.apollo.cache.CacheHeaders); + method public com.homer.apollographql.apollo.ApolloClient.Builder! defaultHttpCachePolicy(HttpCachePolicy.Policy); + method public com.homer.apollographql.apollo.ApolloClient.Builder! defaultResponseFetcher(com.homer.apollographql.apollo.fetcher.ResponseFetcher); + method public com.homer.apollographql.apollo.ApolloClient.Builder! dispatcher(Executor); + method public com.homer.apollographql.apollo.ApolloClient.Builder! enableAutoPersistedQueries(boolean); + method public com.homer.apollographql.apollo.ApolloClient.Builder! enableAutoPersistedSubscriptions(boolean); + method public com.homer.apollographql.apollo.ApolloClient.Builder! httpCache(HttpCache); + method public com.homer.apollographql.apollo.ApolloClient.Builder! logger(com.homer.apollographql.apollo.Logger?); + method public com.homer.apollographql.apollo.ApolloClient.Builder! normalizedCache(com.homer.apollographql.apollo.cache.normalized.NormalizedCacheFactory); + method public com.homer.apollographql.apollo.ApolloClient.Builder! normalizedCache(com.homer.apollographql.apollo.cache.normalized.NormalizedCacheFactory, com.homer.apollographql.apollo.cache.normalized.CacheKeyResolver); + method public com.homer.apollographql.apollo.ApolloClient.Builder! normalizedCache(com.homer.apollographql.apollo.cache.normalized.NormalizedCacheFactory, com.homer.apollographql.apollo.cache.normalized.CacheKeyResolver, boolean); + method public com.homer.apollographql.apollo.ApolloClient.Builder! okHttpClient(okhttp3.OkHttpClient); + method public com.homer.apollographql.apollo.ApolloClient.Builder! serverUrl(okhttp3.HttpUrl); + method public com.homer.apollographql.apollo.ApolloClient.Builder! serverUrl(String); + method public com.homer.apollographql.apollo.ApolloClient.Builder! setAutoPersistedOperationsInterceptorFactory(com.homer.apollographql.apollo.interceptor.ApolloInterceptorFactory?); + method public com.homer.apollographql.apollo.ApolloClient.Builder! subscriptionConnectionParams(com.homer.apollographql.apollo.subscription.SubscriptionConnectionParams); + method public com.homer.apollographql.apollo.ApolloClient.Builder! subscriptionConnectionParams(com.homer.apollographql.apollo.subscription.SubscriptionConnectionParamsProvider); + method public com.homer.apollographql.apollo.ApolloClient.Builder! subscriptionHeartbeatTimeout(long, TimeUnit); + method public com.homer.apollographql.apollo.ApolloClient.Builder! subscriptionTransportFactory(com.homer.apollographql.apollo.subscription.SubscriptionTransport.Factory); + method public com.homer.apollographql.apollo.ApolloClient.Builder! useHttpGetMethodForPersistedQueries(boolean); + method public com.homer.apollographql.apollo.ApolloClient.Builder! useHttpGetMethodForQueries(boolean); } public final class ApolloClientAwarenessInterceptor implements okhttp3.Interceptor { @@ -100,101 +100,101 @@ package com.apollographql.apollo { method public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain); } - public interface ApolloMutationCall extends com.apollographql.apollo.ApolloCall { - method public com.apollographql.apollo.ApolloMutationCall cacheHeaders(com.apollographql.apollo.cache.CacheHeaders); - method public com.apollographql.apollo.ApolloMutationCall clone(); - method public com.apollographql.apollo.ApolloMutationCall refetchQueries(com.apollographql.apollo.api.OperationName!...); - method public com.apollographql.apollo.ApolloMutationCall refetchQueries(com.apollographql.apollo.api.Query!...); - method public com.apollographql.apollo.ApolloMutationCall requestHeaders(com.apollographql.apollo.request.RequestHeaders); - method public com.apollographql.apollo.ApolloMutationCall.Builder toBuilder(); + public interface ApolloMutationCall extends com.homer.apollographql.apollo.ApolloCall { + method public com.homer.apollographql.apollo.ApolloMutationCall cacheHeaders(com.homer.apollographql.apollo.cache.CacheHeaders); + method public com.homer.apollographql.apollo.ApolloMutationCall clone(); + method public com.homer.apollographql.apollo.ApolloMutationCall refetchQueries(com.homer.apollographql.apollo.api.OperationName!...); + method public com.homer.apollographql.apollo.ApolloMutationCall refetchQueries(com.homer.apollographql.apollo.api.Query!...); + method public com.homer.apollographql.apollo.ApolloMutationCall requestHeaders(com.homer.apollographql.apollo.request.RequestHeaders); + method public com.homer.apollographql.apollo.ApolloMutationCall.Builder toBuilder(); } - public static interface ApolloMutationCall.Builder extends com.apollographql.apollo.ApolloCall.Builder { - method public com.apollographql.apollo.ApolloMutationCall build(); - method public com.apollographql.apollo.ApolloMutationCall.Builder cacheHeaders(com.apollographql.apollo.cache.CacheHeaders); - method public com.apollographql.apollo.ApolloMutationCall.Builder refetchQueries(List); - method public com.apollographql.apollo.ApolloMutationCall.Builder refetchQueryNames(List); - method public com.apollographql.apollo.ApolloMutationCall.Builder requestHeaders(com.apollographql.apollo.request.RequestHeaders); + public static interface ApolloMutationCall.Builder extends com.homer.apollographql.apollo.ApolloCall.Builder { + method public com.homer.apollographql.apollo.ApolloMutationCall build(); + method public com.homer.apollographql.apollo.ApolloMutationCall.Builder cacheHeaders(com.homer.apollographql.apollo.cache.CacheHeaders); + method public com.homer.apollographql.apollo.ApolloMutationCall.Builder refetchQueries(List); + method public com.homer.apollographql.apollo.ApolloMutationCall.Builder refetchQueryNames(List); + method public com.homer.apollographql.apollo.ApolloMutationCall.Builder requestHeaders(com.homer.apollographql.apollo.request.RequestHeaders); } public static interface ApolloMutationCall.Factory { - method public com.apollographql.apollo.ApolloMutationCall! mutate(com.apollographql.apollo.api.Mutation); - method public com.apollographql.apollo.ApolloMutationCall! mutate(com.apollographql.apollo.api.Mutation, D); + method public com.homer.apollographql.apollo.ApolloMutationCall! mutate(com.homer.apollographql.apollo.api.Mutation); + method public com.homer.apollographql.apollo.ApolloMutationCall! mutate(com.homer.apollographql.apollo.api.Mutation, D); } public interface ApolloPrefetch { method public void cancel(); - method public com.apollographql.apollo.ApolloPrefetch! clone(); - method public void enqueue(com.apollographql.apollo.ApolloPrefetch.Callback?); - method public com.apollographql.apollo.api.Operation operation(); + method public com.homer.apollographql.apollo.ApolloPrefetch! clone(); + method public void enqueue(com.homer.apollographql.apollo.ApolloPrefetch.Callback?); + method public com.homer.apollographql.apollo.api.Operation operation(); } public abstract static class ApolloPrefetch.Callback { ctor public ApolloPrefetch.Callback(); - method public void onCanceledError(com.apollographql.apollo.exception.ApolloCanceledException); - method public abstract void onFailure(com.apollographql.apollo.exception.ApolloException); - method public void onHttpError(com.apollographql.apollo.exception.ApolloHttpException); - method public void onNetworkError(com.apollographql.apollo.exception.ApolloNetworkException); + method public void onCanceledError(com.homer.apollographql.apollo.exception.ApolloCanceledException); + method public abstract void onFailure(com.homer.apollographql.apollo.exception.ApolloException); + method public void onHttpError(com.homer.apollographql.apollo.exception.ApolloHttpException); + method public void onNetworkError(com.homer.apollographql.apollo.exception.ApolloNetworkException); method public abstract void onSuccess(); } public static interface ApolloPrefetch.Factory { - method public com.apollographql.apollo.ApolloPrefetch! prefetch(com.apollographql.apollo.api.Operation); + method public com.homer.apollographql.apollo.ApolloPrefetch! prefetch(com.homer.apollographql.apollo.api.Operation); } - public interface ApolloQueryCall extends com.apollographql.apollo.ApolloCall { - method public com.apollographql.apollo.ApolloQueryCall cacheHeaders(com.apollographql.apollo.cache.CacheHeaders); - method public com.apollographql.apollo.ApolloQueryCall clone(); - method public com.apollographql.apollo.ApolloQueryCall httpCachePolicy(HttpCachePolicy.Policy); - method public com.apollographql.apollo.ApolloQueryCall requestHeaders(com.apollographql.apollo.request.RequestHeaders); - method public com.apollographql.apollo.ApolloQueryCall responseFetcher(com.apollographql.apollo.fetcher.ResponseFetcher); - method public com.apollographql.apollo.ApolloQueryCall.Builder toBuilder(); - method public com.apollographql.apollo.ApolloQueryWatcher watcher(); + public interface ApolloQueryCall extends com.homer.apollographql.apollo.ApolloCall { + method public com.homer.apollographql.apollo.ApolloQueryCall cacheHeaders(com.homer.apollographql.apollo.cache.CacheHeaders); + method public com.homer.apollographql.apollo.ApolloQueryCall clone(); + method public com.homer.apollographql.apollo.ApolloQueryCall httpCachePolicy(HttpCachePolicy.Policy); + method public com.homer.apollographql.apollo.ApolloQueryCall requestHeaders(com.homer.apollographql.apollo.request.RequestHeaders); + method public com.homer.apollographql.apollo.ApolloQueryCall responseFetcher(com.homer.apollographql.apollo.fetcher.ResponseFetcher); + method public com.homer.apollographql.apollo.ApolloQueryCall.Builder toBuilder(); + method public com.homer.apollographql.apollo.ApolloQueryWatcher watcher(); } - public static interface ApolloQueryCall.Builder extends com.apollographql.apollo.ApolloCall.Builder { - method public com.apollographql.apollo.ApolloQueryCall build(); - method public com.apollographql.apollo.ApolloQueryCall.Builder cacheHeaders(com.apollographql.apollo.cache.CacheHeaders); - method public com.apollographql.apollo.ApolloQueryCall.Builder httpCachePolicy(HttpCachePolicy.Policy); - method public com.apollographql.apollo.ApolloQueryCall.Builder requestHeaders(com.apollographql.apollo.request.RequestHeaders); - method public com.apollographql.apollo.ApolloQueryCall.Builder responseFetcher(com.apollographql.apollo.fetcher.ResponseFetcher); + public static interface ApolloQueryCall.Builder extends com.homer.apollographql.apollo.ApolloCall.Builder { + method public com.homer.apollographql.apollo.ApolloQueryCall build(); + method public com.homer.apollographql.apollo.ApolloQueryCall.Builder cacheHeaders(com.homer.apollographql.apollo.cache.CacheHeaders); + method public com.homer.apollographql.apollo.ApolloQueryCall.Builder httpCachePolicy(HttpCachePolicy.Policy); + method public com.homer.apollographql.apollo.ApolloQueryCall.Builder requestHeaders(com.homer.apollographql.apollo.request.RequestHeaders); + method public com.homer.apollographql.apollo.ApolloQueryCall.Builder responseFetcher(com.homer.apollographql.apollo.fetcher.ResponseFetcher); } public static interface ApolloQueryCall.Factory { - method public com.apollographql.apollo.ApolloQueryCall! query(com.apollographql.apollo.api.Query); + method public com.homer.apollographql.apollo.ApolloQueryCall! query(com.homer.apollographql.apollo.api.Query); } public interface ApolloQueryWatcher { method public void cancel(); - method public com.apollographql.apollo.ApolloQueryWatcher clone(); - method public com.apollographql.apollo.ApolloQueryWatcher! enqueueAndWatch(com.apollographql.apollo.ApolloCall.Callback?); - method public com.apollographql.apollo.api.Operation operation(); + method public com.homer.apollographql.apollo.ApolloQueryWatcher clone(); + method public com.homer.apollographql.apollo.ApolloQueryWatcher! enqueueAndWatch(com.homer.apollographql.apollo.ApolloCall.Callback?); + method public com.homer.apollographql.apollo.api.Operation operation(); method public void refetch(); - method public com.apollographql.apollo.ApolloQueryWatcher refetchResponseFetcher(com.apollographql.apollo.fetcher.ResponseFetcher); + method public com.homer.apollographql.apollo.ApolloQueryWatcher refetchResponseFetcher(com.homer.apollographql.apollo.fetcher.ResponseFetcher); } public interface ApolloSubscriptionCall { - method public com.apollographql.apollo.ApolloSubscriptionCall cachePolicy(com.apollographql.apollo.ApolloSubscriptionCall.CachePolicy); - method public com.apollographql.apollo.ApolloSubscriptionCall! clone(); - method public void execute(com.apollographql.apollo.ApolloSubscriptionCall.Callback); + method public com.homer.apollographql.apollo.ApolloSubscriptionCall cachePolicy(com.homer.apollographql.apollo.ApolloSubscriptionCall.CachePolicy); + method public com.homer.apollographql.apollo.ApolloSubscriptionCall! clone(); + method public void execute(com.homer.apollographql.apollo.ApolloSubscriptionCall.Callback); } public enum ApolloSubscriptionCall.CachePolicy { - enum_constant public static final com.apollographql.apollo.ApolloSubscriptionCall.CachePolicy CACHE_AND_NETWORK; - enum_constant public static final com.apollographql.apollo.ApolloSubscriptionCall.CachePolicy NETWORK_ONLY; - enum_constant public static final com.apollographql.apollo.ApolloSubscriptionCall.CachePolicy NO_CACHE; + enum_constant public static final com.homer.apollographql.apollo.ApolloSubscriptionCall.CachePolicy CACHE_AND_NETWORK; + enum_constant public static final com.homer.apollographql.apollo.ApolloSubscriptionCall.CachePolicy NETWORK_ONLY; + enum_constant public static final com.homer.apollographql.apollo.ApolloSubscriptionCall.CachePolicy NO_CACHE; } public static interface ApolloSubscriptionCall.Callback { method public void onCompleted(); method public void onConnected(); - method public void onFailure(com.apollographql.apollo.exception.ApolloException); - method public void onResponse(com.apollographql.apollo.api.Response); + method public void onFailure(com.homer.apollographql.apollo.exception.ApolloException); + method public void onResponse(com.homer.apollographql.apollo.api.Response); method public void onTerminated(); } public static interface ApolloSubscriptionCall.Factory { - method public com.apollographql.apollo.ApolloSubscriptionCall! subscribe(com.apollographql.apollo.api.Subscription); + method public com.homer.apollographql.apollo.ApolloSubscriptionCall! subscribe(com.homer.apollographql.apollo.api.Subscription); } public interface IdleResourceCallback { @@ -203,189 +203,189 @@ package com.apollographql.apollo { } -package com.apollographql.apollo.exception { +package com.homer.apollographql.apollo.exception { - public final class ApolloCanceledException extends com.apollographql.apollo.exception.ApolloException { + public final class ApolloCanceledException extends com.homer.apollographql.apollo.exception.ApolloException { ctor public ApolloCanceledException(); ctor public ApolloCanceledException(String, Throwable); } - public final class ApolloHttpException extends com.apollographql.apollo.exception.ApolloException { + public final class ApolloHttpException extends com.homer.apollographql.apollo.exception.ApolloException { ctor public ApolloHttpException(okhttp3.Response?); method public int code(); method public String message(); method public okhttp3.Response? rawResponse(); } - public final class ApolloNetworkException extends com.apollographql.apollo.exception.ApolloException { + public final class ApolloNetworkException extends com.homer.apollographql.apollo.exception.ApolloException { ctor public ApolloNetworkException(String); ctor public ApolloNetworkException(String, Throwable); } - public final class ApolloParseException extends com.apollographql.apollo.exception.ApolloException { + public final class ApolloParseException extends com.homer.apollographql.apollo.exception.ApolloException { ctor public ApolloParseException(String); ctor public ApolloParseException(String, Throwable); } } -package com.apollographql.apollo.fetcher { +package com.homer.apollographql.apollo.fetcher { public final class ApolloResponseFetchers { ctor public ApolloResponseFetchers(); - field public static final com.apollographql.apollo.fetcher.ResponseFetcher! CACHE_AND_NETWORK; - field public static final com.apollographql.apollo.fetcher.ResponseFetcher! CACHE_FIRST; - field public static final com.apollographql.apollo.fetcher.ResponseFetcher! CACHE_ONLY; - field public static final com.apollographql.apollo.fetcher.ResponseFetcher! NETWORK_FIRST; - field public static final com.apollographql.apollo.fetcher.ResponseFetcher! NETWORK_ONLY; + field public static final com.homer.apollographql.apollo.fetcher.ResponseFetcher! CACHE_AND_NETWORK; + field public static final com.homer.apollographql.apollo.fetcher.ResponseFetcher! CACHE_FIRST; + field public static final com.homer.apollographql.apollo.fetcher.ResponseFetcher! CACHE_ONLY; + field public static final com.homer.apollographql.apollo.fetcher.ResponseFetcher! NETWORK_FIRST; + field public static final com.homer.apollographql.apollo.fetcher.ResponseFetcher! NETWORK_ONLY; } public interface ResponseFetcher { - method public com.apollographql.apollo.interceptor.ApolloInterceptor! provideInterceptor(com.apollographql.apollo.api.internal.ApolloLogger!); + method public com.homer.apollographql.apollo.interceptor.ApolloInterceptor! provideInterceptor(com.homer.apollographql.apollo.api.internal.ApolloLogger!); } } -package com.apollographql.apollo.http { +package com.homer.apollographql.apollo.http { - @com.apollographql.apollo.api.ApolloExperimental public final class OkHttpExecutionContext implements com.apollographql.apollo.api.ExecutionContext.Element { + @com.homer.apollographql.apollo.api.ApolloExperimental public final class OkHttpExecutionContext implements com.homer.apollographql.apollo.api.ExecutionContext.Element { ctor public OkHttpExecutionContext(okhttp3.Response response); - method public com.apollographql.apollo.api.ExecutionContext.Key getKey(); + method public com.homer.apollographql.apollo.api.ExecutionContext.Key getKey(); method public okhttp3.Response getResponse(); - property public com.apollographql.apollo.api.ExecutionContext.Key key; + property public com.homer.apollographql.apollo.api.ExecutionContext.Key key; property public final okhttp3.Response response; - field public static final com.apollographql.apollo.http.OkHttpExecutionContext.Key KEY; - field public static final com.apollographql.apollo.http.OkHttpExecutionContext.Key Key; + field public static final com.homer.apollographql.apollo.http.OkHttpExecutionContext.Key KEY; + field public static final com.homer.apollographql.apollo.http.OkHttpExecutionContext.Key Key; } - public static final class OkHttpExecutionContext.Key implements com.apollographql.apollo.api.ExecutionContext.Key { + public static final class OkHttpExecutionContext.Key implements com.homer.apollographql.apollo.api.ExecutionContext.Key { } } -package com.apollographql.apollo.interceptor { +package com.homer.apollographql.apollo.interceptor { - public class ApolloAutoPersistedOperationInterceptor implements com.apollographql.apollo.interceptor.ApolloInterceptor { - ctor public ApolloAutoPersistedOperationInterceptor(com.apollographql.apollo.api.internal.ApolloLogger, boolean); + public class ApolloAutoPersistedOperationInterceptor implements com.homer.apollographql.apollo.interceptor.ApolloInterceptor { + ctor public ApolloAutoPersistedOperationInterceptor(com.homer.apollographql.apollo.api.internal.ApolloLogger, boolean); method public void dispose(); - method public void interceptAsync(com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest, com.apollographql.apollo.interceptor.ApolloInterceptorChain, Executor, com.apollographql.apollo.interceptor.ApolloInterceptor.CallBack); + method public void interceptAsync(com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest, com.homer.apollographql.apollo.interceptor.ApolloInterceptorChain, Executor, com.homer.apollographql.apollo.interceptor.ApolloInterceptor.CallBack); } - public static class ApolloAutoPersistedOperationInterceptor.Factory implements com.apollographql.apollo.interceptor.ApolloInterceptorFactory { + public static class ApolloAutoPersistedOperationInterceptor.Factory implements com.homer.apollographql.apollo.interceptor.ApolloInterceptorFactory { ctor public ApolloAutoPersistedOperationInterceptor.Factory(boolean, boolean, boolean); ctor public ApolloAutoPersistedOperationInterceptor.Factory(); - method public com.apollographql.apollo.interceptor.ApolloInterceptor? newInterceptor(com.apollographql.apollo.api.internal.ApolloLogger, com.apollographql.apollo.api.Operation); + method public com.homer.apollographql.apollo.interceptor.ApolloInterceptor? newInterceptor(com.homer.apollographql.apollo.api.internal.ApolloLogger, com.homer.apollographql.apollo.api.Operation); } public interface ApolloInterceptor { method public void dispose(); - method public void interceptAsync(com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest, com.apollographql.apollo.interceptor.ApolloInterceptorChain, Executor, com.apollographql.apollo.interceptor.ApolloInterceptor.CallBack); + method public void interceptAsync(com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest, com.homer.apollographql.apollo.interceptor.ApolloInterceptorChain, Executor, com.homer.apollographql.apollo.interceptor.ApolloInterceptor.CallBack); } public static interface ApolloInterceptor.CallBack { method public void onCompleted(); - method public void onFailure(com.apollographql.apollo.exception.ApolloException); - method public void onFetch(com.apollographql.apollo.interceptor.ApolloInterceptor.FetchSourceType!); - method public void onResponse(com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorResponse); + method public void onFailure(com.homer.apollographql.apollo.exception.ApolloException); + method public void onFetch(com.homer.apollographql.apollo.interceptor.ApolloInterceptor.FetchSourceType!); + method public void onResponse(com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorResponse); } public enum ApolloInterceptor.FetchSourceType { - enum_constant public static final com.apollographql.apollo.interceptor.ApolloInterceptor.FetchSourceType CACHE; - enum_constant public static final com.apollographql.apollo.interceptor.ApolloInterceptor.FetchSourceType NETWORK; + enum_constant public static final com.homer.apollographql.apollo.interceptor.ApolloInterceptor.FetchSourceType CACHE; + enum_constant public static final com.homer.apollographql.apollo.interceptor.ApolloInterceptor.FetchSourceType NETWORK; } public static final class ApolloInterceptor.InterceptorRequest { - method public static com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! builder(com.apollographql.apollo.api.Operation); - method public com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! toBuilder(); + method public static com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! builder(com.homer.apollographql.apollo.api.Operation); + method public com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! toBuilder(); field public final boolean autoPersistQueries; - field public final com.apollographql.apollo.cache.CacheHeaders! cacheHeaders; + field public final com.homer.apollographql.apollo.cache.CacheHeaders! cacheHeaders; field public final boolean fetchFromCache; - field public final com.apollographql.apollo.api.Operation! operation; - field public final com.apollographql.apollo.api.internal.Optional! optimisticUpdates; - field public final com.apollographql.apollo.request.RequestHeaders! requestHeaders; + field public final com.homer.apollographql.apollo.api.Operation! operation; + field public final com.homer.apollographql.apollo.api.internal.Optional! optimisticUpdates; + field public final com.homer.apollographql.apollo.request.RequestHeaders! requestHeaders; field public final boolean sendQueryDocument; field public final UUID uniqueId; field public final boolean useHttpGetMethodForQueries; } public static final class ApolloInterceptor.InterceptorRequest.Builder { - method public com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! autoPersistQueries(boolean); - method public com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest! build(); - method public com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! cacheHeaders(com.apollographql.apollo.cache.CacheHeaders); - method public com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! fetchFromCache(boolean); - method public com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! optimisticUpdates(com.apollographql.apollo.api.Operation.Data!); - method public com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! optimisticUpdates(com.apollographql.apollo.api.internal.Optional); - method public com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! requestHeaders(com.apollographql.apollo.request.RequestHeaders); - method public com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! sendQueryDocument(boolean); - method public com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! useHttpGetMethodForQueries(boolean); + method public com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! autoPersistQueries(boolean); + method public com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest! build(); + method public com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! cacheHeaders(com.homer.apollographql.apollo.cache.CacheHeaders); + method public com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! fetchFromCache(boolean); + method public com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! optimisticUpdates(com.homer.apollographql.apollo.api.Operation.Data!); + method public com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! optimisticUpdates(com.homer.apollographql.apollo.api.internal.Optional); + method public com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! requestHeaders(com.homer.apollographql.apollo.request.RequestHeaders); + method public com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! sendQueryDocument(boolean); + method public com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest.Builder! useHttpGetMethodForQueries(boolean); } public static final class ApolloInterceptor.InterceptorResponse { ctor public ApolloInterceptor.InterceptorResponse(okhttp3.Response!); - ctor public ApolloInterceptor.InterceptorResponse(okhttp3.Response!, com.apollographql.apollo.api.Response!, Collection); - field public final com.apollographql.apollo.api.internal.Optional>! cacheRecords; - field public final com.apollographql.apollo.api.internal.Optional! httpResponse; - field public final com.apollographql.apollo.api.internal.Optional! parsedResponse; + ctor public ApolloInterceptor.InterceptorResponse(okhttp3.Response!, com.homer.apollographql.apollo.api.Response!, Collection); + field public final com.homer.apollographql.apollo.api.internal.Optional>! cacheRecords; + field public final com.homer.apollographql.apollo.api.internal.Optional! httpResponse; + field public final com.homer.apollographql.apollo.api.internal.Optional! parsedResponse; } public interface ApolloInterceptorChain { method public void dispose(); - method public void proceedAsync(com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest, Executor, com.apollographql.apollo.interceptor.ApolloInterceptor.CallBack); + method public void proceedAsync(com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest, Executor, com.homer.apollographql.apollo.interceptor.ApolloInterceptor.CallBack); } public interface ApolloInterceptorFactory { - method public com.apollographql.apollo.interceptor.ApolloInterceptor? newInterceptor(com.apollographql.apollo.api.internal.ApolloLogger logger, com.apollographql.apollo.api.Operation operation); + method public com.homer.apollographql.apollo.interceptor.ApolloInterceptor? newInterceptor(com.homer.apollographql.apollo.api.internal.ApolloLogger logger, com.homer.apollographql.apollo.api.Operation operation); } } -package com.apollographql.apollo.request { +package com.homer.apollographql.apollo.request { public final class RequestHeaders { - method public static com.apollographql.apollo.request.RequestHeaders.Builder! builder(); + method public static com.homer.apollographql.apollo.request.RequestHeaders.Builder! builder(); method public boolean hasHeader(String); method public String headerValue(String); method public Set headers(); - method public com.apollographql.apollo.request.RequestHeaders.Builder! toBuilder(); - field public static final com.apollographql.apollo.request.RequestHeaders! NONE; + method public com.homer.apollographql.apollo.request.RequestHeaders.Builder! toBuilder(); + field public static final com.homer.apollographql.apollo.request.RequestHeaders! NONE; } public static final class RequestHeaders.Builder { ctor public RequestHeaders.Builder(); - method public com.apollographql.apollo.request.RequestHeaders.Builder! addHeader(String, String); - method public com.apollographql.apollo.request.RequestHeaders.Builder! addHeaders(Map); - method public com.apollographql.apollo.request.RequestHeaders! build(); + method public com.homer.apollographql.apollo.request.RequestHeaders.Builder! addHeader(String, String); + method public com.homer.apollographql.apollo.request.RequestHeaders.Builder! addHeaders(Map); + method public com.homer.apollographql.apollo.request.RequestHeaders! build(); } } -package com.apollographql.apollo.response { +package com.homer.apollographql.apollo.response { - public final class OperationResponseParser { - ctor public OperationResponseParser(com.apollographql.apollo.api.Operation!, com.apollographql.apollo.api.internal.ResponseFieldMapper!, com.apollographql.apollo.api.ScalarTypeAdapters!); - ctor public OperationResponseParser(com.apollographql.apollo.api.Operation!, com.apollographql.apollo.api.internal.ResponseFieldMapper!, com.apollographql.apollo.api.ScalarTypeAdapters!, com.apollographql.apollo.cache.normalized.internal.ResponseNormalizer>!); - method public com.apollographql.apollo.api.Response! parse(Map); - method public com.apollographql.apollo.api.Response! parse(okio.BufferedSource!); - method public static com.apollographql.apollo.api.Error! parseError(Map); + public final class OperationResponseParser { + ctor public OperationResponseParser(com.homer.apollographql.apollo.api.Operation!, com.homer.apollographql.apollo.api.internal.ResponseFieldMapper!, com.homer.apollographql.apollo.api.ScalarTypeAdapters!); + ctor public OperationResponseParser(com.homer.apollographql.apollo.api.Operation!, com.homer.apollographql.apollo.api.internal.ResponseFieldMapper!, com.homer.apollographql.apollo.api.ScalarTypeAdapters!, com.homer.apollographql.apollo.cache.normalized.internal.ResponseNormalizer>!); + method public com.homer.apollographql.apollo.api.Response! parse(Map); + method public com.homer.apollographql.apollo.api.Response! parse(okio.BufferedSource!); + method public static com.homer.apollographql.apollo.api.Error! parseError(Map); } } -package com.apollographql.apollo.subscription { +package com.homer.apollographql.apollo.subscription { - public final class ApolloOperationMessageSerializer implements com.apollographql.apollo.subscription.OperationMessageSerializer { - method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public com.apollographql.apollo.subscription.OperationServerMessage readServerMessage(okio.BufferedSource source); - method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public void writeClientMessage(com.apollographql.apollo.subscription.OperationClientMessage message, okio.BufferedSink sink); - field public static final com.apollographql.apollo.subscription.ApolloOperationMessageSerializer INSTANCE; + public final class ApolloOperationMessageSerializer implements com.homer.apollographql.apollo.subscription.OperationMessageSerializer { + method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public com.homer.apollographql.apollo.subscription.OperationServerMessage readServerMessage(okio.BufferedSource source); + method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public void writeClientMessage(com.homer.apollographql.apollo.subscription.OperationClientMessage message, okio.BufferedSink sink); + field public static final com.homer.apollographql.apollo.subscription.ApolloOperationMessageSerializer INSTANCE; } - public final class AppSyncOperationMessageSerializer implements com.apollographql.apollo.subscription.OperationMessageSerializer { + public final class AppSyncOperationMessageSerializer implements com.homer.apollographql.apollo.subscription.OperationMessageSerializer { ctor public AppSyncOperationMessageSerializer(java.util.Map authorization); method public static String buildWebSocketUrl(String baseWebSocketUrl, java.util.Map authorization, java.util.Map payload = emptyMap()); method public static String buildWebSocketUrl(String baseWebSocketUrl, java.util.Map authorization); - method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public com.apollographql.apollo.subscription.OperationServerMessage readServerMessage(okio.BufferedSource source); - method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public void writeClientMessage(com.apollographql.apollo.subscription.OperationClientMessage message, okio.BufferedSink sink); - field public static final com.apollographql.apollo.subscription.AppSyncOperationMessageSerializer.Companion Companion; + method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public com.homer.apollographql.apollo.subscription.OperationServerMessage readServerMessage(okio.BufferedSource source); + method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public void writeClientMessage(com.homer.apollographql.apollo.subscription.OperationClientMessage message, okio.BufferedSink sink); + field public static final com.homer.apollographql.apollo.subscription.AppSyncOperationMessageSerializer.Companion Companion; } public static final class AppSyncOperationMessageSerializer.Companion { @@ -394,75 +394,75 @@ package com.apollographql.apollo.subscription { } public interface OnSubscriptionManagerStateChangeListener { - method public void onStateChange(com.apollographql.apollo.subscription.SubscriptionManagerState!, com.apollographql.apollo.subscription.SubscriptionManagerState!); + method public void onStateChange(com.homer.apollographql.apollo.subscription.SubscriptionManagerState!, com.homer.apollographql.apollo.subscription.SubscriptionManagerState!); } public abstract sealed class OperationClientMessage { method @Deprecated public final String toJsonString(); - method @Deprecated @kotlin.jvm.Throws(exceptionClasses=IOException::class) public final void writeToJson(com.apollographql.apollo.api.internal.json.JsonWriter writer); + method @Deprecated @kotlin.jvm.Throws(exceptionClasses=IOException::class) public final void writeToJson(com.homer.apollographql.apollo.api.internal.json.JsonWriter writer); } - public static final class OperationClientMessage.Init extends com.apollographql.apollo.subscription.OperationClientMessage { + public static final class OperationClientMessage.Init extends com.homer.apollographql.apollo.subscription.OperationClientMessage { ctor public OperationClientMessage.Init(java.util.Map connectionParams); - field public static final com.apollographql.apollo.subscription.OperationClientMessage.Init.Companion Companion; + field public static final com.homer.apollographql.apollo.subscription.OperationClientMessage.Init.Companion Companion; field public final java.util.Map connectionParams; } public static final class OperationClientMessage.Init.Companion { } - public static final class OperationClientMessage.Start extends com.apollographql.apollo.subscription.OperationClientMessage { - ctor public OperationClientMessage.Start(String subscriptionId, com.apollographql.apollo.api.Subscription subscription, com.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters, boolean autoPersistSubscription, boolean sendSubscriptionDocument); - field public static final com.apollographql.apollo.subscription.OperationClientMessage.Start.Companion Companion; + public static final class OperationClientMessage.Start extends com.homer.apollographql.apollo.subscription.OperationClientMessage { + ctor public OperationClientMessage.Start(String subscriptionId, com.homer.apollographql.apollo.api.Subscription subscription, com.homer.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters, boolean autoPersistSubscription, boolean sendSubscriptionDocument); + field public static final com.homer.apollographql.apollo.subscription.OperationClientMessage.Start.Companion Companion; field public final boolean autoPersistSubscription; - field public final com.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters; + field public final com.homer.apollographql.apollo.api.ScalarTypeAdapters scalarTypeAdapters; field public final boolean sendSubscriptionDocument; - field public final com.apollographql.apollo.api.Subscription subscription; + field public final com.homer.apollographql.apollo.api.Subscription subscription; field public final String subscriptionId; } public static final class OperationClientMessage.Start.Companion { } - public static final class OperationClientMessage.Stop extends com.apollographql.apollo.subscription.OperationClientMessage { + public static final class OperationClientMessage.Stop extends com.homer.apollographql.apollo.subscription.OperationClientMessage { ctor public OperationClientMessage.Stop(String subscriptionId); - field public static final com.apollographql.apollo.subscription.OperationClientMessage.Stop.Companion Companion; + field public static final com.homer.apollographql.apollo.subscription.OperationClientMessage.Stop.Companion Companion; field public final String subscriptionId; } public static final class OperationClientMessage.Stop.Companion { } - public static final class OperationClientMessage.Terminate extends com.apollographql.apollo.subscription.OperationClientMessage { + public static final class OperationClientMessage.Terminate extends com.homer.apollographql.apollo.subscription.OperationClientMessage { ctor public OperationClientMessage.Terminate(); - field public static final com.apollographql.apollo.subscription.OperationClientMessage.Terminate.Companion Companion; + field public static final com.homer.apollographql.apollo.subscription.OperationClientMessage.Terminate.Companion Companion; } public static final class OperationClientMessage.Terminate.Companion { } public interface OperationMessageSerializer { - method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public com.apollographql.apollo.subscription.OperationServerMessage readServerMessage(okio.BufferedSource source); - method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public void writeClientMessage(com.apollographql.apollo.subscription.OperationClientMessage message, okio.BufferedSink sink); + method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public com.homer.apollographql.apollo.subscription.OperationServerMessage readServerMessage(okio.BufferedSource source); + method @kotlin.jvm.Throws(exceptionClasses=IOException::class) public void writeClientMessage(com.homer.apollographql.apollo.subscription.OperationClientMessage message, okio.BufferedSink sink); } public abstract sealed class OperationServerMessage { - method @Deprecated public static final com.apollographql.apollo.subscription.OperationServerMessage fromJsonString(String json); - field public static final com.apollographql.apollo.subscription.OperationServerMessage.Companion Companion; + method @Deprecated public static final com.homer.apollographql.apollo.subscription.OperationServerMessage fromJsonString(String json); + field public static final com.homer.apollographql.apollo.subscription.OperationServerMessage.Companion Companion; field public static final String JSON_KEY_ID = "id"; field public static final String JSON_KEY_PAYLOAD = "payload"; field public static final String JSON_KEY_TYPE = "type"; } public static final class OperationServerMessage.Companion { - method @Deprecated public com.apollographql.apollo.subscription.OperationServerMessage fromJsonString(String json); + method @Deprecated public com.homer.apollographql.apollo.subscription.OperationServerMessage fromJsonString(String json); } - public static final class OperationServerMessage.Complete extends com.apollographql.apollo.subscription.OperationServerMessage { + public static final class OperationServerMessage.Complete extends com.homer.apollographql.apollo.subscription.OperationServerMessage { ctor public OperationServerMessage.Complete(String? id); method public boolean equals(Object? other); method public int hashCode(); - field public static final com.apollographql.apollo.subscription.OperationServerMessage.Complete.Companion Companion; + field public static final com.homer.apollographql.apollo.subscription.OperationServerMessage.Complete.Companion Companion; field public static final String TYPE = "complete"; field public final String? id; } @@ -470,22 +470,22 @@ package com.apollographql.apollo.subscription { public static final class OperationServerMessage.Complete.Companion { } - public static final class OperationServerMessage.ConnectionAcknowledge extends com.apollographql.apollo.subscription.OperationServerMessage { + public static final class OperationServerMessage.ConnectionAcknowledge extends com.homer.apollographql.apollo.subscription.OperationServerMessage { ctor public OperationServerMessage.ConnectionAcknowledge(); method public boolean equals(Object? other); method public int hashCode(); - field public static final com.apollographql.apollo.subscription.OperationServerMessage.ConnectionAcknowledge.Companion Companion; + field public static final com.homer.apollographql.apollo.subscription.OperationServerMessage.ConnectionAcknowledge.Companion Companion; field public static final String TYPE = "connection_ack"; } public static final class OperationServerMessage.ConnectionAcknowledge.Companion { } - public static final class OperationServerMessage.ConnectionError extends com.apollographql.apollo.subscription.OperationServerMessage { + public static final class OperationServerMessage.ConnectionError extends com.homer.apollographql.apollo.subscription.OperationServerMessage { ctor public OperationServerMessage.ConnectionError(java.util.Map payload); method public boolean equals(Object? other); method public int hashCode(); - field public static final com.apollographql.apollo.subscription.OperationServerMessage.ConnectionError.Companion Companion; + field public static final com.homer.apollographql.apollo.subscription.OperationServerMessage.ConnectionError.Companion Companion; field public static final String TYPE = "connection_error"; field public final java.util.Map payload; } @@ -493,22 +493,22 @@ package com.apollographql.apollo.subscription { public static final class OperationServerMessage.ConnectionError.Companion { } - public static final class OperationServerMessage.ConnectionKeepAlive extends com.apollographql.apollo.subscription.OperationServerMessage { + public static final class OperationServerMessage.ConnectionKeepAlive extends com.homer.apollographql.apollo.subscription.OperationServerMessage { ctor public OperationServerMessage.ConnectionKeepAlive(); method public boolean equals(Object? other); method public int hashCode(); - field public static final com.apollographql.apollo.subscription.OperationServerMessage.ConnectionKeepAlive.Companion Companion; + field public static final com.homer.apollographql.apollo.subscription.OperationServerMessage.ConnectionKeepAlive.Companion Companion; field public static final String TYPE = "ka"; } public static final class OperationServerMessage.ConnectionKeepAlive.Companion { } - public static final class OperationServerMessage.Data extends com.apollographql.apollo.subscription.OperationServerMessage { + public static final class OperationServerMessage.Data extends com.homer.apollographql.apollo.subscription.OperationServerMessage { ctor public OperationServerMessage.Data(String? id, java.util.Map payload); method public boolean equals(Object? other); method public int hashCode(); - field public static final com.apollographql.apollo.subscription.OperationServerMessage.Data.Companion Companion; + field public static final com.homer.apollographql.apollo.subscription.OperationServerMessage.Data.Companion Companion; field public static final String TYPE = "data"; field public final String? id; field public final java.util.Map payload; @@ -517,11 +517,11 @@ package com.apollographql.apollo.subscription { public static final class OperationServerMessage.Data.Companion { } - public static final class OperationServerMessage.Error extends com.apollographql.apollo.subscription.OperationServerMessage { + public static final class OperationServerMessage.Error extends com.homer.apollographql.apollo.subscription.OperationServerMessage { ctor public OperationServerMessage.Error(String? id, java.util.Map payload); method public boolean equals(Object? other); method public int hashCode(); - field public static final com.apollographql.apollo.subscription.OperationServerMessage.Error.Companion Companion; + field public static final com.homer.apollographql.apollo.subscription.OperationServerMessage.Error.Companion Companion; field public static final String TYPE = "error"; field public final String? id; field public final java.util.Map payload; @@ -530,7 +530,7 @@ package com.apollographql.apollo.subscription { public static final class OperationServerMessage.Error.Companion { } - public static final class OperationServerMessage.Unsupported extends com.apollographql.apollo.subscription.OperationServerMessage { + public static final class OperationServerMessage.Unsupported extends com.homer.apollographql.apollo.subscription.OperationServerMessage { ctor public OperationServerMessage.Unsupported(String rawMessage); method public boolean equals(Object? other); method public int hashCode(); @@ -543,52 +543,52 @@ package com.apollographql.apollo.subscription { } public interface SubscriptionConnectionParamsProvider { - method public com.apollographql.apollo.subscription.SubscriptionConnectionParams provide(); + method public com.homer.apollographql.apollo.subscription.SubscriptionConnectionParams provide(); } - public static class SubscriptionConnectionParamsProvider.Const implements com.apollographql.apollo.subscription.SubscriptionConnectionParamsProvider { - ctor public SubscriptionConnectionParamsProvider.Const(com.apollographql.apollo.subscription.SubscriptionConnectionParams); - method public com.apollographql.apollo.subscription.SubscriptionConnectionParams provide(); + public static class SubscriptionConnectionParamsProvider.Const implements com.homer.apollographql.apollo.subscription.SubscriptionConnectionParamsProvider { + ctor public SubscriptionConnectionParamsProvider.Const(com.homer.apollographql.apollo.subscription.SubscriptionConnectionParams); + method public com.homer.apollographql.apollo.subscription.SubscriptionConnectionParams provide(); } public enum SubscriptionManagerState { - enum_constant public static final com.apollographql.apollo.subscription.SubscriptionManagerState ACTIVE; - enum_constant public static final com.apollographql.apollo.subscription.SubscriptionManagerState CONNECTED; - enum_constant public static final com.apollographql.apollo.subscription.SubscriptionManagerState CONNECTING; - enum_constant public static final com.apollographql.apollo.subscription.SubscriptionManagerState DISCONNECTED; - enum_constant public static final com.apollographql.apollo.subscription.SubscriptionManagerState STOPPED; - enum_constant public static final com.apollographql.apollo.subscription.SubscriptionManagerState STOPPING; + enum_constant public static final com.homer.apollographql.apollo.subscription.SubscriptionManagerState ACTIVE; + enum_constant public static final com.homer.apollographql.apollo.subscription.SubscriptionManagerState CONNECTED; + enum_constant public static final com.homer.apollographql.apollo.subscription.SubscriptionManagerState CONNECTING; + enum_constant public static final com.homer.apollographql.apollo.subscription.SubscriptionManagerState DISCONNECTED; + enum_constant public static final com.homer.apollographql.apollo.subscription.SubscriptionManagerState STOPPED; + enum_constant public static final com.homer.apollographql.apollo.subscription.SubscriptionManagerState STOPPING; } public interface SubscriptionTransport { method public void connect(); - method public void disconnect(com.apollographql.apollo.subscription.OperationClientMessage!); - method public void send(com.apollographql.apollo.subscription.OperationClientMessage!); + method public void disconnect(com.homer.apollographql.apollo.subscription.OperationClientMessage!); + method public void send(com.homer.apollographql.apollo.subscription.OperationClientMessage!); } public static interface SubscriptionTransport.Callback { method public void onClosed(); method public void onConnected(); method public void onFailure(Throwable); - method public void onMessage(com.apollographql.apollo.subscription.OperationServerMessage!); + method public void onMessage(com.homer.apollographql.apollo.subscription.OperationServerMessage!); } public static interface SubscriptionTransport.Factory { - method public com.apollographql.apollo.subscription.SubscriptionTransport! create(com.apollographql.apollo.subscription.SubscriptionTransport.Callback); + method public com.homer.apollographql.apollo.subscription.SubscriptionTransport! create(com.homer.apollographql.apollo.subscription.SubscriptionTransport.Callback); } - public final class WebSocketSubscriptionTransport implements com.apollographql.apollo.subscription.SubscriptionTransport { - ctor public WebSocketSubscriptionTransport(okhttp3.Request webSocketRequest, okhttp3.WebSocket.Factory webSocketConnectionFactory, com.apollographql.apollo.subscription.SubscriptionTransport.Callback callback, com.apollographql.apollo.subscription.OperationMessageSerializer serializer); - ctor public WebSocketSubscriptionTransport(okhttp3.Request webSocketRequest, okhttp3.WebSocket.Factory webSocketConnectionFactory, com.apollographql.apollo.subscription.SubscriptionTransport.Callback callback); + public final class WebSocketSubscriptionTransport implements com.homer.apollographql.apollo.subscription.SubscriptionTransport { + ctor public WebSocketSubscriptionTransport(okhttp3.Request webSocketRequest, okhttp3.WebSocket.Factory webSocketConnectionFactory, com.homer.apollographql.apollo.subscription.SubscriptionTransport.Callback callback, com.homer.apollographql.apollo.subscription.OperationMessageSerializer serializer); + ctor public WebSocketSubscriptionTransport(okhttp3.Request webSocketRequest, okhttp3.WebSocket.Factory webSocketConnectionFactory, com.homer.apollographql.apollo.subscription.SubscriptionTransport.Callback callback); method public void connect(); - method public void disconnect(com.apollographql.apollo.subscription.OperationClientMessage message); - method public void send(com.apollographql.apollo.subscription.OperationClientMessage message); + method public void disconnect(com.homer.apollographql.apollo.subscription.OperationClientMessage message); + method public void send(com.homer.apollographql.apollo.subscription.OperationClientMessage message); } - public static final class WebSocketSubscriptionTransport.Factory implements com.apollographql.apollo.subscription.SubscriptionTransport.Factory { - ctor public WebSocketSubscriptionTransport.Factory(String webSocketUrl, okhttp3.WebSocket.Factory webSocketConnectionFactory, com.apollographql.apollo.subscription.OperationMessageSerializer serializer); + public static final class WebSocketSubscriptionTransport.Factory implements com.homer.apollographql.apollo.subscription.SubscriptionTransport.Factory { + ctor public WebSocketSubscriptionTransport.Factory(String webSocketUrl, okhttp3.WebSocket.Factory webSocketConnectionFactory, com.homer.apollographql.apollo.subscription.OperationMessageSerializer serializer); ctor public WebSocketSubscriptionTransport.Factory(String webSocketUrl, okhttp3.WebSocket.Factory webSocketConnectionFactory); - method public com.apollographql.apollo.subscription.SubscriptionTransport create(com.apollographql.apollo.subscription.SubscriptionTransport.Callback callback); + method public com.homer.apollographql.apollo.subscription.SubscriptionTransport create(com.homer.apollographql.apollo.subscription.SubscriptionTransport.Callback callback); } } diff --git a/apollo-runtime/build.gradle.kts b/apollo-runtime/build.gradle.kts index a064ce5ca36..0b87a711e3b 100644 --- a/apollo-runtime/build.gradle.kts +++ b/apollo-runtime/build.gradle.kts @@ -4,9 +4,11 @@ plugins { } metalava { - hiddenPackages += setOf("com.apollographql.apollo.internal") + hiddenPackages += setOf("com.homer.apollographql.apollo.internal") } +val testCompile by configurations.creating + dependencies { api(project(":apollo-api")) api(project(":apollo-normalized-cache")) @@ -18,7 +20,7 @@ dependencies { add("testImplementation", groovy.util.Eval.x(project, "x.dep.junit")) add("testImplementation", groovy.util.Eval.x(project, "x.dep.truth")) add("testImplementation", groovy.util.Eval.x(project, "x.dep.okHttp.mockWebServer")) - add("testImplementation", project(":apollo-rx2-support")) +// add("testImplementation", project(":apollo-rx2-support")) } tasks.withType { diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/NoOpSubscriptionManager.kt b/apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/NoOpSubscriptionManager.kt deleted file mode 100644 index f41bc32c552..00000000000 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/NoOpSubscriptionManager.kt +++ /dev/null @@ -1,40 +0,0 @@ -package com.apollographql.apollo.internal.subscription - -import com.apollographql.apollo.api.Subscription -import com.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener -import com.apollographql.apollo.subscription.SubscriptionManagerState - -class NoOpSubscriptionManager : SubscriptionManager { - val errorMessage = "No `SubscriptionTransport.Factory` found, please add one to your `ApolloClient` with `ApolloClient.Builder.subscriptionTransportFactory`" - - override fun subscribe(subscription: Subscription<*, T, *>, callback: SubscriptionManager.Callback) { - throw IllegalStateException(errorMessage) - } - - override fun unsubscribe(subscription: Subscription<*, *, *>) { - throw IllegalStateException(errorMessage) - } - - override fun start() { - throw IllegalStateException(errorMessage) - } - - override fun stop() { - throw IllegalStateException(errorMessage) - } - - override fun reconnect() { - } - - override fun getState(): SubscriptionManagerState { - return SubscriptionManagerState.DISCONNECTED - } - - override fun addOnStateChangeListener(onStateChangeListener: OnSubscriptionManagerStateChangeListener) { - throw IllegalStateException(errorMessage) - } - - override fun removeOnStateChangeListener(onStateChangeListener: OnSubscriptionManagerStateChangeListener) { - throw IllegalStateException(errorMessage) - } -} \ No newline at end of file diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloCall.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloCall.java similarity index 77% rename from apollo-runtime/src/main/java/com/apollographql/apollo/ApolloCall.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloCall.java index 01a94f42558..ca98f0e85bc 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloCall.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloCall.java @@ -1,17 +1,23 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.cache.ApolloCacheHeaders; -import com.apollographql.apollo.cache.CacheHeaders; -import com.apollographql.apollo.exception.ApolloCanceledException; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.exception.ApolloHttpException; -import com.apollographql.apollo.exception.ApolloNetworkException; -import com.apollographql.apollo.exception.ApolloParseException; -import com.apollographql.apollo.fetcher.ResponseFetcher; -import com.apollographql.apollo.internal.util.Cancelable; - +package com.homer.apollographql.apollo; + +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.cache.ApolloCacheHeaders; +import com.homer.apollographql.apollo.cache.CacheHeaders; +import com.homer.apollographql.apollo.exception.ApolloCanceledException; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.exception.ApolloHttpException; +import com.homer.apollographql.apollo.exception.ApolloNetworkException; +import com.homer.apollographql.apollo.exception.ApolloParseException; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.internal.util.Cancelable; + +import com.homer.apollographql.apollo.exception.ApolloCanceledException; +import com.homer.apollographql.apollo.exception.ApolloHttpException; +import com.homer.apollographql.apollo.exception.ApolloNetworkException; +import com.homer.apollographql.apollo.exception.ApolloParseException; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.internal.util.Cancelable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -32,13 +38,13 @@ public interface ApolloCall extends Cancelable { void enqueue(@Nullable Callback callback); /** - * Sets the {@link CacheHeaders} to use for this call. {@link com.apollographql.apollo.interceptor.FetchOptions} will + * Sets the {@link CacheHeaders} to use for this call. {@link com.homer.apollographql.apollo.interceptor.FetchOptions} will * be configured with this headers, and will be accessible from the {@link ResponseFetcher} used for this call. * * Deprecated, use {@link #toBuilder()} to mutate the ApolloCall * * @param cacheHeaders the {@link CacheHeaders} that will be passed with records generated from this request to {@link - * com.apollographql.apollo.cache.normalized.NormalizedCache}. Standardized cache headers are + * com.homer.apollographql.apollo.cache.normalized.NormalizedCache}. Standardized cache headers are * defined in {@link ApolloCacheHeaders}. * @return The ApolloCall object with the provided {@link CacheHeaders}. */ @@ -62,7 +68,7 @@ public interface ApolloCall extends Cancelable { /** * Cancels this {@link ApolloCall}. If the call was started with {@link #enqueue(Callback)}, the - * {@link com.apollographql.apollo.ApolloCall.Callback} will be disposed, and will receive no more events. + * {@link ApolloCall.Callback} will be disposed, and will receive no more events. * The call will attempt to abort and release resources, if possible. */ @Override void cancel(); @@ -73,11 +79,11 @@ interface Builder { @NotNull ApolloCall build(); /** - * Sets the {@link CacheHeaders} to use for this call. {@link com.apollographql.apollo.interceptor.FetchOptions} will + * Sets the {@link CacheHeaders} to use for this call. {@link com.homer.apollographql.apollo.interceptor.FetchOptions} will * be configured with this headers, and will be accessible from the {@link ResponseFetcher} used for this call. * * @param cacheHeaders the {@link CacheHeaders} that will be passed with records generated from this request to {@link - * com.apollographql.apollo.cache.normalized.NormalizedCache}. Standardized cache headers are + * com.homer.apollographql.apollo.cache.normalized.NormalizedCache}. Standardized cache headers are * defined in {@link ApolloCacheHeaders}. * @return The builder */ diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloClient.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloClient.java similarity index 89% rename from apollo-runtime/src/main/java/com/apollographql/apollo/ApolloClient.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloClient.java index ee3a6cbeb05..56221f087cc 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloClient.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloClient.java @@ -1,43 +1,57 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.CustomTypeAdapter; -import com.apollographql.apollo.api.Mutation; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.ScalarType; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.Subscription; -import com.apollographql.apollo.api.cache.http.HttpCache; -import com.apollographql.apollo.api.cache.http.HttpCachePolicy; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.cache.CacheHeaders; -import com.apollographql.apollo.cache.normalized.ApolloStore; -import com.apollographql.apollo.cache.normalized.ApolloStoreOperation; -import com.apollographql.apollo.cache.normalized.CacheKeyResolver; -import com.apollographql.apollo.cache.normalized.NormalizedCache; -import com.apollographql.apollo.cache.normalized.NormalizedCacheFactory; -import com.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter; -import com.apollographql.apollo.fetcher.ApolloResponseFetchers; -import com.apollographql.apollo.fetcher.ResponseFetcher; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptorFactory; -import com.apollographql.apollo.internal.ApolloCallTracker; -import com.apollographql.apollo.internal.RealApolloCall; -import com.apollographql.apollo.internal.RealApolloPrefetch; -import com.apollographql.apollo.internal.RealApolloSubscriptionCall; -import com.apollographql.apollo.internal.ResponseFieldMapperFactory; -import com.apollographql.apollo.internal.RealApolloStore; -import com.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; -import com.apollographql.apollo.internal.subscription.NoOpSubscriptionManager; -import com.apollographql.apollo.internal.subscription.RealSubscriptionManager; -import com.apollographql.apollo.internal.subscription.SubscriptionManager; -import com.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener; -import com.apollographql.apollo.subscription.SubscriptionConnectionParams; -import com.apollographql.apollo.subscription.SubscriptionConnectionParamsProvider; -import com.apollographql.apollo.subscription.SubscriptionManagerState; -import com.apollographql.apollo.subscription.SubscriptionTransport; +package com.homer.apollographql.apollo; + +import com.homer.apollographql.apollo.api.CustomTypeAdapter; +import com.homer.apollographql.apollo.api.Mutation; +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.api.OperationName; +import com.homer.apollographql.apollo.api.Query; +import com.homer.apollographql.apollo.api.ScalarType; +import com.homer.apollographql.apollo.api.ScalarTypeAdapters; +import com.homer.apollographql.apollo.api.Subscription; +import com.homer.apollographql.apollo.api.cache.http.HttpCache; +import com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.api.internal.Optional; +import com.homer.apollographql.apollo.cache.CacheHeaders; +import com.homer.apollographql.apollo.cache.normalized.ApolloStore; +import com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation; +import com.homer.apollographql.apollo.cache.normalized.CacheKeyResolver; +import com.homer.apollographql.apollo.cache.normalized.NormalizedCache; +import com.homer.apollographql.apollo.cache.normalized.NormalizedCacheFactory; +import com.homer.apollographql.apollo.cache.normalized.RecordFieldJsonAdapter; +import com.homer.apollographql.apollo.fetcher.ApolloResponseFetchers; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptorFactory; +import com.homer.apollographql.apollo.internal.ApolloCallTracker; +import com.homer.apollographql.apollo.internal.RealApolloCall; +import com.homer.apollographql.apollo.internal.RealApolloPrefetch; +import com.homer.apollographql.apollo.internal.RealApolloSubscriptionCall; +import com.homer.apollographql.apollo.internal.ResponseFieldMapperFactory; +import com.homer.apollographql.apollo.internal.RealApolloStore; +import com.homer.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; +import com.homer.apollographql.apollo.internal.subscription.NoOpSubscriptionManager; +import com.homer.apollographql.apollo.internal.subscription.RealSubscriptionManager; +import com.homer.apollographql.apollo.internal.subscription.SubscriptionManager; +import com.homer.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener; +import com.homer.apollographql.apollo.subscription.SubscriptionConnectionParams; +import com.homer.apollographql.apollo.subscription.SubscriptionConnectionParamsProvider; +import com.homer.apollographql.apollo.subscription.SubscriptionManagerState; +import com.homer.apollographql.apollo.subscription.SubscriptionTransport; +import com.homer.apollographql.apollo.fetcher.ApolloResponseFetchers; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptorFactory; +import com.homer.apollographql.apollo.internal.ApolloCallTracker; +import com.homer.apollographql.apollo.internal.RealApolloCall; +import com.homer.apollographql.apollo.internal.RealApolloPrefetch; +import com.homer.apollographql.apollo.internal.RealApolloStore; +import com.homer.apollographql.apollo.internal.RealApolloSubscriptionCall; +import com.homer.apollographql.apollo.internal.ResponseFieldMapperFactory; +import com.homer.apollographql.apollo.internal.subscription.NoOpSubscriptionManager; +import com.homer.apollographql.apollo.internal.subscription.RealSubscriptionManager; +import com.homer.apollographql.apollo.internal.subscription.SubscriptionManager; +import com.homer.apollographql.apollo.subscription.WebSocketSubscriptionTransport; import kotlin.jvm.functions.Function0; import okhttp3.Call; import okhttp3.HttpUrl; @@ -59,7 +73,7 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; /** * ApolloClient class represents the abstraction for the graphQL client that will be used to execute queries and read the responses back. @@ -571,7 +585,7 @@ public Builder defaultHttpCachePolicy(@NotNull HttpCachePolicy.Policy cachePolic } /** - * Set the default {@link CacheHeaders} strategy that will be passed to the {@link com.apollographql.apollo.interceptor.FetchOptions} + * Set the default {@link CacheHeaders} strategy that will be passed to the {@link com.homer.apollographql.apollo.interceptor.FetchOptions} * used in each new {@link ApolloCall}. * * @return The {@link Builder} object to be used for chaining method calls @@ -656,7 +670,7 @@ public Builder enableAutoPersistedQueries(boolean enableAutoPersistedQueries) { /** *

Sets up subscription transport factory to be used for subscription server communication.

See also: {@link - * com.apollographql.apollo.subscription.WebSocketSubscriptionTransport} + * WebSocketSubscriptionTransport} * * @param subscriptionTransportFactory transport layer to be used for subscriptions. * @return The {@link Builder} object to be used for chaining method calls diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloClientAwarenessInterceptor.kt b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloClientAwarenessInterceptor.kt similarity index 94% rename from apollo-runtime/src/main/java/com/apollographql/apollo/ApolloClientAwarenessInterceptor.kt rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloClientAwarenessInterceptor.kt index f8125e4e11a..591878cf05d 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloClientAwarenessInterceptor.kt +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloClientAwarenessInterceptor.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo +package com.homer.apollographql.apollo import okhttp3.Interceptor import okhttp3.Response diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloMutationCall.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloMutationCall.java similarity index 84% rename from apollo-runtime/src/main/java/com/apollographql/apollo/ApolloMutationCall.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloMutationCall.java index b5eb5d125c1..993c12404bd 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloMutationCall.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloMutationCall.java @@ -1,11 +1,13 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.Mutation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.cache.CacheHeaders; -import com.apollographql.apollo.fetcher.ResponseFetcher; -import com.apollographql.apollo.request.RequestHeaders; +package com.homer.apollographql.apollo; + +import com.homer.apollographql.apollo.api.Mutation; +import com.homer.apollographql.apollo.api.OperationName; +import com.homer.apollographql.apollo.api.Query; +import com.homer.apollographql.apollo.cache.CacheHeaders; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.request.RequestHeaders; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.request.RequestHeaders; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -16,14 +18,14 @@ public interface ApolloMutationCall extends ApolloCall { /** - * Sets the {@link CacheHeaders} to use for this call. {@link com.apollographql.apollo.interceptor.FetchOptions} will + * Sets the {@link CacheHeaders} to use for this call. {@link com.homer.apollographql.apollo.interceptor.FetchOptions} will * be configured with this headers, and will be accessible from the {@link ResponseFetcher} used for this call. * * Deprecated, use {@link #toBuilder()} to mutate the ApolloCall * * @param cacheHeaders the {@link CacheHeaders} that will be passed with records generated from this request to {@link - * com.apollographql.apollo.cache.normalized.NormalizedCache}. Standardized cache headers are - * defined in {@link com.apollographql.apollo.cache.ApolloCacheHeaders}. + * com.homer.apollographql.apollo.cache.normalized.NormalizedCache}. Standardized cache headers are + * defined in {@link com.homer.apollographql.apollo.cache.ApolloCacheHeaders}. * @return The ApolloCall object with the provided {@link CacheHeaders}. */ @Deprecated @NotNull @Override ApolloMutationCall cacheHeaders(@NotNull CacheHeaders cacheHeaders); @@ -106,7 +108,7 @@ ApolloMutationCall /** *

Creates and prepares a new {@link ApolloMutationCall} call with optimistic updates.

* - * Provided optimistic updates will be stored in {@link com.apollographql.apollo.cache.normalized.ApolloStore} + * Provided optimistic updates will be stored in {@link com.homer.apollographql.apollo.cache.normalized.ApolloStore} * immediately before mutation execution. Any {@link ApolloQueryWatcher} dependent on the changed cache records will * be re-fetched. * diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloPrefetch.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloPrefetch.java similarity index 81% rename from apollo-runtime/src/main/java/com/apollographql/apollo/ApolloPrefetch.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloPrefetch.java index cf15834fbf9..b7b8fbee2f1 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloPrefetch.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloPrefetch.java @@ -1,12 +1,16 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.exception.ApolloCanceledException; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.exception.ApolloHttpException; -import com.apollographql.apollo.exception.ApolloNetworkException; -import com.apollographql.apollo.internal.util.Cancelable; - +package com.homer.apollographql.apollo; + +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.exception.ApolloCanceledException; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.exception.ApolloHttpException; +import com.homer.apollographql.apollo.exception.ApolloNetworkException; +import com.homer.apollographql.apollo.internal.util.Cancelable; + +import com.homer.apollographql.apollo.exception.ApolloCanceledException; +import com.homer.apollographql.apollo.exception.ApolloHttpException; +import com.homer.apollographql.apollo.exception.ApolloNetworkException; +import com.homer.apollographql.apollo.internal.util.Cancelable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -54,7 +58,7 @@ public interface ApolloPrefetch extends Cancelable { * Cancels this {@link ApolloPrefetch}. If the call has already completed, nothing will happen. * If the call is outgoing, an {@link ApolloCanceledException} will be thrown if the call was started * with {@link #execute()}. If the call was started with {@link #enqueue(Callback)} - * the {@link com.apollographql.apollo.ApolloPrefetch.Callback} will be disposed, and will receive no more events. + * the {@link ApolloPrefetch.Callback} will be disposed, and will receive no more events. * The call will attempt to abort and release resources, if possible. */ @Override void cancel(); diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloQueryCall.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloQueryCall.java similarity index 81% rename from apollo-runtime/src/main/java/com/apollographql/apollo/ApolloQueryCall.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloQueryCall.java index e3a6e474a0f..d713914750c 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloQueryCall.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloQueryCall.java @@ -1,11 +1,13 @@ -package com.apollographql.apollo; +package com.homer.apollographql.apollo; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.cache.http.HttpCachePolicy; -import com.apollographql.apollo.cache.CacheHeaders; -import com.apollographql.apollo.fetcher.ResponseFetcher; -import com.apollographql.apollo.request.RequestHeaders; +import com.homer.apollographql.apollo.api.OperationName; +import com.homer.apollographql.apollo.api.Query; +import com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy; +import com.homer.apollographql.apollo.cache.CacheHeaders; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.request.RequestHeaders; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.request.RequestHeaders; import org.jetbrains.annotations.NotNull; /** @@ -31,14 +33,14 @@ public interface ApolloQueryCall extends ApolloCall { @Deprecated @NotNull ApolloQueryCall httpCachePolicy(@NotNull HttpCachePolicy.Policy httpCachePolicy); /** - * Sets the {@link CacheHeaders} to use for this call. {@link com.apollographql.apollo.interceptor.FetchOptions} will + * Sets the {@link CacheHeaders} to use for this call. {@link com.homer.apollographql.apollo.interceptor.FetchOptions} will * be configured with this headers, and will be accessible from the {@link ResponseFetcher} used for this call. * * Deprecated, use {@link #toBuilder()} to mutate the ApolloCall * * @param cacheHeaders the {@link CacheHeaders} that will be passed with records generated from this request to {@link - * com.apollographql.apollo.cache.normalized.NormalizedCache}. Standardized cache headers are - * defined in {@link com.apollographql.apollo.cache.ApolloCacheHeaders}. + * com.homer.apollographql.apollo.cache.normalized.NormalizedCache}. Standardized cache headers are + * defined in {@link com.homer.apollographql.apollo.cache.ApolloCacheHeaders}. * @return The ApolloCall object with the provided {@link CacheHeaders}. */ @Deprecated @NotNull @Override ApolloQueryCall cacheHeaders(@NotNull CacheHeaders cacheHeaders); @@ -73,12 +75,12 @@ interface Builder extends ApolloCall.Builder { @NotNull @Override ApolloQueryCall build(); /** - * Sets the {@link CacheHeaders} to use for this call. {@link com.apollographql.apollo.interceptor.FetchOptions} will + * Sets the {@link CacheHeaders} to use for this call. {@link com.homer.apollographql.apollo.interceptor.FetchOptions} will * be configured with this headers, and will be accessible from the {@link ResponseFetcher} used for this call. * * @param cacheHeaders the {@link CacheHeaders} that will be passed with records generated from this request to {@link - * com.apollographql.apollo.cache.normalized.NormalizedCache}. Standardized cache headers are - * defined in {@link com.apollographql.apollo.cache.ApolloCacheHeaders}. + * com.homer.apollographql.apollo.cache.normalized.NormalizedCache}. Standardized cache headers are + * defined in {@link com.homer.apollographql.apollo.cache.ApolloCacheHeaders}. * @return The ApolloCall object with the provided {@link CacheHeaders}. */ @NotNull @Override Builder cacheHeaders(@NotNull CacheHeaders cacheHeaders); diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloQueryWatcher.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloQueryWatcher.java similarity index 71% rename from apollo-runtime/src/main/java/com/apollographql/apollo/ApolloQueryWatcher.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloQueryWatcher.java index caa33cb8c56..e3410d265a8 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloQueryWatcher.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloQueryWatcher.java @@ -1,9 +1,11 @@ -package com.apollographql.apollo; +package com.homer.apollographql.apollo; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.fetcher.ResponseFetcher; -import com.apollographql.apollo.internal.util.Cancelable; +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.internal.util.Cancelable; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.internal.util.Cancelable; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,7 +32,7 @@ public interface ApolloQueryWatcher extends Cancelable { void refetch(); /** - * Cancels this {@link ApolloQueryWatcher}. The {@link com.apollographql.apollo.ApolloCall.Callback} + * Cancels this {@link ApolloQueryWatcher}. The {@link ApolloCall.Callback} * will be disposed, and will receive no more events. Any active operations will attempt to abort and * release resources, if possible. */ diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloSubscriptionCall.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloSubscriptionCall.java similarity index 88% rename from apollo-runtime/src/main/java/com/apollographql/apollo/ApolloSubscriptionCall.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloSubscriptionCall.java index fc2d989c817..228cdedb6a4 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/ApolloSubscriptionCall.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/ApolloSubscriptionCall.java @@ -1,11 +1,13 @@ -package com.apollographql.apollo; +package com.homer.apollographql.apollo; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.Subscription; -import com.apollographql.apollo.exception.ApolloCanceledException; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.internal.util.Cancelable; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.api.Subscription; +import com.homer.apollographql.apollo.exception.ApolloCanceledException; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.internal.util.Cancelable; +import com.homer.apollographql.apollo.exception.ApolloCanceledException; +import com.homer.apollographql.apollo.internal.util.Cancelable; import org.jetbrains.annotations.NotNull; /** diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/IdleResourceCallback.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/IdleResourceCallback.java similarity index 86% rename from apollo-runtime/src/main/java/com/apollographql/apollo/IdleResourceCallback.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/IdleResourceCallback.java index 2b8b6d8d065..67661df0935 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/IdleResourceCallback.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/IdleResourceCallback.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo; +package com.homer.apollographql.apollo; /** * Callback which gets invoked when the resource transitions diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/exception/ApolloCanceledException.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/exception/ApolloCanceledException.java similarity index 83% rename from apollo-runtime/src/main/java/com/apollographql/apollo/exception/ApolloCanceledException.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/exception/ApolloCanceledException.java index 86d0612ccd9..873e88c2b05 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/exception/ApolloCanceledException.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/exception/ApolloCanceledException.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.exception; +package com.homer.apollographql.apollo.exception; public final class ApolloCanceledException extends ApolloException { diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/exception/ApolloHttpException.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/exception/ApolloHttpException.java similarity index 94% rename from apollo-runtime/src/main/java/com/apollographql/apollo/exception/ApolloHttpException.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/exception/ApolloHttpException.java index 1a9a081c280..f7620b816f1 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/exception/ApolloHttpException.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/exception/ApolloHttpException.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.exception; +package com.homer.apollographql.apollo.exception; import org.jetbrains.annotations.Nullable; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/exception/ApolloNetworkException.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/exception/ApolloNetworkException.java similarity index 82% rename from apollo-runtime/src/main/java/com/apollographql/apollo/exception/ApolloNetworkException.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/exception/ApolloNetworkException.java index d3769bb708e..39d3d9142b7 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/exception/ApolloNetworkException.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/exception/ApolloNetworkException.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.exception; +package com.homer.apollographql.apollo.exception; public final class ApolloNetworkException extends ApolloException { public ApolloNetworkException(String message) { diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/exception/ApolloParseException.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/exception/ApolloParseException.java similarity index 82% rename from apollo-runtime/src/main/java/com/apollographql/apollo/exception/ApolloParseException.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/exception/ApolloParseException.java index 9bdc36fbb84..ffbbf9a3fca 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/exception/ApolloParseException.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/exception/ApolloParseException.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.exception; +package com.homer.apollographql.apollo.exception; public final class ApolloParseException extends ApolloException { diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/fetcher/ApolloResponseFetchers.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/fetcher/ApolloResponseFetchers.java similarity index 68% rename from apollo-runtime/src/main/java/com/apollographql/apollo/fetcher/ApolloResponseFetchers.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/fetcher/ApolloResponseFetchers.java index cbb6a551fff..cf47f3c527e 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/fetcher/ApolloResponseFetchers.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/fetcher/ApolloResponseFetchers.java @@ -1,17 +1,22 @@ -package com.apollographql.apollo.fetcher; +package com.homer.apollographql.apollo.fetcher; -import com.apollographql.apollo.internal.fetcher.CacheFirstFetcher; -import com.apollographql.apollo.internal.fetcher.CacheOnlyFetcher; -import com.apollographql.apollo.internal.fetcher.CacheAndNetworkFetcher; -import com.apollographql.apollo.internal.fetcher.NetworkFirstFetcher; -import com.apollographql.apollo.internal.fetcher.NetworkOnlyFetcher; +import com.homer.apollographql.apollo.internal.fetcher.CacheFirstFetcher; +import com.homer.apollographql.apollo.internal.fetcher.CacheOnlyFetcher; +import com.homer.apollographql.apollo.internal.fetcher.CacheAndNetworkFetcher; +import com.homer.apollographql.apollo.internal.fetcher.NetworkFirstFetcher; +import com.homer.apollographql.apollo.internal.fetcher.NetworkOnlyFetcher; +import com.homer.apollographql.apollo.internal.fetcher.CacheAndNetworkFetcher; +import com.homer.apollographql.apollo.internal.fetcher.CacheFirstFetcher; +import com.homer.apollographql.apollo.internal.fetcher.CacheOnlyFetcher; +import com.homer.apollographql.apollo.internal.fetcher.NetworkFirstFetcher; +import com.homer.apollographql.apollo.internal.fetcher.NetworkOnlyFetcher; public final class ApolloResponseFetchers { /** * Signals the apollo client to only fetch the data from the normalized cache. If it's not present in * the normalized cache or if an exception occurs while trying to fetch it from the normalized cache, an empty {@link - * com.apollographql.apollo.api.Response} is sent back with the {@link com.apollographql.apollo.api.Operation} info + * com.homer.apollographql.apollo.api.Response} is sent back with the {@link com.homer.apollographql.apollo.api.Operation} info * wrapped inside. */ public static final ResponseFetcher CACHE_ONLY = new CacheOnlyFetcher(); diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/fetcher/ResponseFetcher.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/fetcher/ResponseFetcher.java similarity index 62% rename from apollo-runtime/src/main/java/com/apollographql/apollo/fetcher/ResponseFetcher.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/fetcher/ResponseFetcher.java index 93e6d3d432a..06a2d07196b 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/fetcher/ResponseFetcher.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/fetcher/ResponseFetcher.java @@ -1,11 +1,12 @@ -package com.apollographql.apollo.fetcher; +package com.homer.apollographql.apollo.fetcher; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.interceptor.ApolloInterceptor; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor; /** * A ResponseFetcher is an {@link ApolloInterceptor} inserted at the beginning of a request chain. - * It can control how a request is fetched by configuring {@link com.apollographql.apollo.interceptor.FetchOptions}. + * It can control how a request is fetched by configuring {@link com.homer.apollographql.apollo.interceptor.FetchOptions}. * * See {@link ApolloResponseFetchers} for a basic set of fetchers. */ diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/http/OkHttpExecutionContext.kt b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/http/OkHttpExecutionContext.kt similarity index 84% rename from apollo-runtime/src/main/java/com/apollographql/apollo/http/OkHttpExecutionContext.kt rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/http/OkHttpExecutionContext.kt index a1ba9660ea1..71f0519508d 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/http/OkHttpExecutionContext.kt +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/http/OkHttpExecutionContext.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.http +package com.homer.apollographql.apollo.http -import com.apollographql.apollo.api.ApolloExperimental -import com.apollographql.apollo.api.ExecutionContext +import com.homer.apollographql.apollo.api.ApolloExperimental +import com.homer.apollographql.apollo.api.ExecutionContext import okhttp3.Response /** diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/interceptor/ApolloAutoPersistedOperationInterceptor.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/interceptor/ApolloAutoPersistedOperationInterceptor.java similarity index 89% rename from apollo-runtime/src/main/java/com/apollographql/apollo/interceptor/ApolloAutoPersistedOperationInterceptor.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/interceptor/ApolloAutoPersistedOperationInterceptor.java index 594a64f54f8..e62b3734c93 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/interceptor/ApolloAutoPersistedOperationInterceptor.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/interceptor/ApolloAutoPersistedOperationInterceptor.java @@ -1,14 +1,14 @@ -package com.apollographql.apollo.interceptor; - -import com.apollographql.apollo.api.Error; -import com.apollographql.apollo.api.Mutation; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.api.internal.Function; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.exception.ApolloException; +package com.homer.apollographql.apollo.interceptor; + +import com.homer.apollographql.apollo.api.Error; +import com.homer.apollographql.apollo.api.Mutation; +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.api.Query; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.api.internal.Function; +import com.homer.apollographql.apollo.api.internal.Optional; +import com.homer.apollographql.apollo.exception.ApolloException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/interceptor/ApolloInterceptor.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/interceptor/ApolloInterceptor.java similarity index 91% rename from apollo-runtime/src/main/java/com/apollographql/apollo/interceptor/ApolloInterceptor.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/interceptor/ApolloInterceptor.java index 597d498b871..5bbd6866055 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/interceptor/ApolloInterceptor.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/interceptor/ApolloInterceptor.java @@ -1,20 +1,22 @@ -package com.apollographql.apollo.interceptor; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.cache.CacheHeaders; -import com.apollographql.apollo.cache.normalized.Record; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.request.RequestHeaders; - +package com.homer.apollographql.apollo.interceptor; + +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.api.internal.Optional; +import com.homer.apollographql.apollo.cache.CacheHeaders; +import com.homer.apollographql.apollo.cache.normalized.Record; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.ApolloCall; +import com.homer.apollographql.apollo.request.RequestHeaders; + +import com.homer.apollographql.apollo.request.RequestHeaders; import java.util.Collection; import java.util.UUID; import java.util.concurrent.Executor; import org.jetbrains.annotations.NotNull; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; /** * ApolloInterceptor is responsible for observing and modifying the requests going out and the corresponding responses @@ -37,7 +39,7 @@ void interceptAsync(@NotNull InterceptorRequest request, @NotNull ApolloIntercep /** * Disposes of the resources which are no longer required. * - *

A use case for this method call would be when an {@link com.apollographql.apollo.ApolloCall} needs to be + *

A use case for this method call would be when an {@link ApolloCall} needs to be * cancelled and resources need to be disposed of.

*/ void dispose(); diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/interceptor/ApolloInterceptorChain.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/interceptor/ApolloInterceptorChain.java similarity index 94% rename from apollo-runtime/src/main/java/com/apollographql/apollo/interceptor/ApolloInterceptorChain.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/interceptor/ApolloInterceptorChain.java index 85149a5e411..aab22babe47 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/interceptor/ApolloInterceptorChain.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/interceptor/ApolloInterceptorChain.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.interceptor; +package com.homer.apollographql.apollo.interceptor; import java.util.concurrent.Executor; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/interceptor/ApolloInterceptorFactory.kt b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/interceptor/ApolloInterceptorFactory.kt similarity index 59% rename from apollo-runtime/src/main/java/com/apollographql/apollo/interceptor/ApolloInterceptorFactory.kt rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/interceptor/ApolloInterceptorFactory.kt index 96a53b32a3a..fcec6b5dc14 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/interceptor/ApolloInterceptorFactory.kt +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/interceptor/ApolloInterceptorFactory.kt @@ -1,7 +1,7 @@ -package com.apollographql.apollo.interceptor +package com.homer.apollographql.apollo.interceptor -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.internal.ApolloLogger +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.internal.ApolloLogger interface ApolloInterceptorFactory { /** @@ -12,5 +12,5 @@ interface ApolloInterceptorFactory { * * @return the interceptor or null if no interceptor is needed for this operation */ - fun newInterceptor(logger: ApolloLogger, operation: Operation<*, *, *>): ApolloInterceptor? + fun newInterceptor(logger: ApolloLogger, operation: Operation<*, *, *>): com.homer.apollographql.apollo.interceptor.ApolloInterceptor? } \ No newline at end of file diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/ApolloCallTracker.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/ApolloCallTracker.java similarity index 94% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/ApolloCallTracker.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/ApolloCallTracker.java index 9d28321fb65..2d3e4909bfb 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/ApolloCallTracker.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/ApolloCallTracker.java @@ -1,15 +1,15 @@ -package com.apollographql.apollo.internal; +package com.homer.apollographql.apollo.internal; -import com.apollographql.apollo.ApolloCall; -import com.apollographql.apollo.ApolloMutationCall; -import com.apollographql.apollo.ApolloPrefetch; -import com.apollographql.apollo.ApolloQueryCall; -import com.apollographql.apollo.ApolloQueryWatcher; -import com.apollographql.apollo.IdleResourceCallback; -import com.apollographql.apollo.api.Mutation; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; +import com.homer.apollographql.apollo.ApolloCall; +import com.homer.apollographql.apollo.ApolloMutationCall; +import com.homer.apollographql.apollo.ApolloPrefetch; +import com.homer.apollographql.apollo.ApolloQueryCall; +import com.homer.apollographql.apollo.ApolloQueryWatcher; +import com.homer.apollographql.apollo.IdleResourceCallback; +import com.homer.apollographql.apollo.api.Mutation; +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.api.OperationName; +import com.homer.apollographql.apollo.api.Query; import org.jetbrains.annotations.NotNull; import java.util.Collections; @@ -19,7 +19,7 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; /** * ApolloCallTracker is responsible for keeping track of running {@link ApolloPrefetch} & {@link ApolloQueryCall} diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/CallState.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/CallState.java similarity index 93% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/CallState.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/CallState.java index d74936991f7..284b5e8cd69 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/CallState.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/CallState.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.internal; +package com.homer.apollographql.apollo.internal; enum CallState { IDLE, ACTIVE, TERMINATED, CANCELED; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/QueryReFetcher.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/QueryReFetcher.java similarity index 86% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/QueryReFetcher.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/QueryReFetcher.java index 26819eb03cc..be8896ba04a 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/QueryReFetcher.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/QueryReFetcher.java @@ -1,19 +1,19 @@ -package com.apollographql.apollo.internal; - -import com.apollographql.apollo.ApolloCall; -import com.apollographql.apollo.ApolloQueryWatcher; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.cache.http.HttpCachePolicy; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.cache.CacheHeaders; -import com.apollographql.apollo.cache.normalized.ApolloStore; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.fetcher.ApolloResponseFetchers; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptorFactory; +package com.homer.apollographql.apollo.internal; + +import com.homer.apollographql.apollo.ApolloCall; +import com.homer.apollographql.apollo.ApolloQueryWatcher; +import com.homer.apollographql.apollo.api.OperationName; +import com.homer.apollographql.apollo.api.Query; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.api.ScalarTypeAdapters; +import com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.cache.CacheHeaders; +import com.homer.apollographql.apollo.cache.normalized.ApolloStore; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.fetcher.ApolloResponseFetchers; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptorFactory; import okhttp3.Call; import okhttp3.HttpUrl; import org.jetbrains.annotations.NotNull; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloCall.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/RealApolloCall.java similarity index 89% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloCall.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/RealApolloCall.java index 5e12a88f656..3cb91d133f8 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloCall.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/RealApolloCall.java @@ -1,36 +1,36 @@ -package com.apollographql.apollo.internal; - -import com.apollographql.apollo.ApolloMutationCall; -import com.apollographql.apollo.ApolloQueryCall; -import com.apollographql.apollo.api.Mutation; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.cache.http.HttpCache; -import com.apollographql.apollo.api.cache.http.HttpCachePolicy; -import com.apollographql.apollo.api.internal.Action; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.cache.CacheHeaders; -import com.apollographql.apollo.cache.normalized.ApolloStore; -import com.apollographql.apollo.exception.ApolloCanceledException; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.exception.ApolloHttpException; -import com.apollographql.apollo.exception.ApolloNetworkException; -import com.apollographql.apollo.exception.ApolloParseException; -import com.apollographql.apollo.fetcher.ApolloResponseFetchers; -import com.apollographql.apollo.fetcher.ResponseFetcher; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptorChain; -import com.apollographql.apollo.interceptor.ApolloInterceptorFactory; -import com.apollographql.apollo.interceptor.ApolloAutoPersistedOperationInterceptor; -import com.apollographql.apollo.internal.interceptor.ApolloCacheInterceptor; -import com.apollographql.apollo.internal.interceptor.ApolloParseInterceptor; -import com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor; -import com.apollographql.apollo.internal.interceptor.RealApolloInterceptorChain; -import com.apollographql.apollo.request.RequestHeaders; +package com.homer.apollographql.apollo.internal; + +import com.homer.apollographql.apollo.ApolloMutationCall; +import com.homer.apollographql.apollo.ApolloQueryCall; +import com.homer.apollographql.apollo.api.Mutation; +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.api.OperationName; +import com.homer.apollographql.apollo.api.Query; +import com.homer.apollographql.apollo.api.ScalarTypeAdapters; +import com.homer.apollographql.apollo.api.cache.http.HttpCache; +import com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy; +import com.homer.apollographql.apollo.api.internal.Action; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.api.internal.Optional; +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper; +import com.homer.apollographql.apollo.cache.CacheHeaders; +import com.homer.apollographql.apollo.cache.normalized.ApolloStore; +import com.homer.apollographql.apollo.exception.ApolloCanceledException; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.exception.ApolloHttpException; +import com.homer.apollographql.apollo.exception.ApolloNetworkException; +import com.homer.apollographql.apollo.exception.ApolloParseException; +import com.homer.apollographql.apollo.fetcher.ApolloResponseFetchers; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptorChain; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptorFactory; +import com.homer.apollographql.apollo.interceptor.ApolloAutoPersistedOperationInterceptor; +import com.homer.apollographql.apollo.internal.interceptor.ApolloCacheInterceptor; +import com.homer.apollographql.apollo.internal.interceptor.ApolloParseInterceptor; +import com.homer.apollographql.apollo.internal.interceptor.ApolloServerInterceptor; +import com.homer.apollographql.apollo.internal.interceptor.RealApolloInterceptorChain; +import com.homer.apollographql.apollo.request.RequestHeaders; import okhttp3.Call; import okhttp3.HttpUrl; import org.jetbrains.annotations.NotNull; @@ -42,11 +42,11 @@ import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicReference; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; -import static com.apollographql.apollo.internal.CallState.ACTIVE; -import static com.apollographql.apollo.internal.CallState.CANCELED; -import static com.apollographql.apollo.internal.CallState.IDLE; -import static com.apollographql.apollo.internal.CallState.TERMINATED; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.internal.CallState.ACTIVE; +import static com.homer.apollographql.apollo.internal.CallState.CANCELED; +import static com.homer.apollographql.apollo.internal.CallState.IDLE; +import static com.homer.apollographql.apollo.internal.CallState.TERMINATED; import static java.util.Collections.emptyList; @SuppressWarnings("WeakerAccess") diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloPrefetch.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/RealApolloPrefetch.java similarity index 81% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloPrefetch.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/RealApolloPrefetch.java index 1d0cd326738..b3a6f7e1f80 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloPrefetch.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/RealApolloPrefetch.java @@ -1,19 +1,19 @@ -package com.apollographql.apollo.internal; - -import com.apollographql.apollo.ApolloPrefetch; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.cache.http.HttpCachePolicy; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.exception.ApolloCanceledException; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.exception.ApolloHttpException; -import com.apollographql.apollo.exception.ApolloNetworkException; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptorChain; -import com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor; -import com.apollographql.apollo.internal.interceptor.RealApolloInterceptorChain; +package com.homer.apollographql.apollo.internal; + +import com.homer.apollographql.apollo.ApolloPrefetch; +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.api.ScalarTypeAdapters; +import com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.api.internal.Optional; +import com.homer.apollographql.apollo.exception.ApolloCanceledException; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.exception.ApolloHttpException; +import com.homer.apollographql.apollo.exception.ApolloNetworkException; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptorChain; +import com.homer.apollographql.apollo.internal.interceptor.ApolloServerInterceptor; +import com.homer.apollographql.apollo.internal.interceptor.RealApolloInterceptorChain; import okhttp3.Call; import okhttp3.HttpUrl; import okhttp3.Response; @@ -24,10 +24,10 @@ import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicReference; -import static com.apollographql.apollo.internal.CallState.ACTIVE; -import static com.apollographql.apollo.internal.CallState.CANCELED; -import static com.apollographql.apollo.internal.CallState.IDLE; -import static com.apollographql.apollo.internal.CallState.TERMINATED; +import static com.homer.apollographql.apollo.internal.CallState.ACTIVE; +import static com.homer.apollographql.apollo.internal.CallState.CANCELED; +import static com.homer.apollographql.apollo.internal.CallState.IDLE; +import static com.homer.apollographql.apollo.internal.CallState.TERMINATED; @SuppressWarnings("WeakerAccess") public final class RealApolloPrefetch implements ApolloPrefetch { final Operation operation; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloQueryWatcher.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/RealApolloQueryWatcher.java similarity index 79% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloQueryWatcher.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/RealApolloQueryWatcher.java index a08e7994c32..9ef27caa30f 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloQueryWatcher.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/RealApolloQueryWatcher.java @@ -1,18 +1,22 @@ -package com.apollographql.apollo.internal; - -import com.apollographql.apollo.ApolloCall; -import com.apollographql.apollo.ApolloQueryWatcher; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.cache.normalized.ApolloStore; -import com.apollographql.apollo.exception.ApolloCanceledException; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.exception.ApolloHttpException; -import com.apollographql.apollo.exception.ApolloNetworkException; -import com.apollographql.apollo.exception.ApolloParseException; -import com.apollographql.apollo.fetcher.ResponseFetcher; +package com.homer.apollographql.apollo.internal; + +import com.homer.apollographql.apollo.ApolloCall; +import com.homer.apollographql.apollo.ApolloQueryWatcher; +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.api.internal.Optional; +import com.homer.apollographql.apollo.cache.normalized.ApolloStore; +import com.homer.apollographql.apollo.exception.ApolloCanceledException; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.exception.ApolloHttpException; +import com.homer.apollographql.apollo.exception.ApolloNetworkException; +import com.homer.apollographql.apollo.exception.ApolloParseException; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.exception.ApolloCanceledException; +import com.homer.apollographql.apollo.exception.ApolloHttpException; +import com.homer.apollographql.apollo.exception.ApolloNetworkException; +import com.homer.apollographql.apollo.exception.ApolloParseException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -20,11 +24,11 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicReference; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; -import static com.apollographql.apollo.internal.CallState.ACTIVE; -import static com.apollographql.apollo.internal.CallState.CANCELED; -import static com.apollographql.apollo.internal.CallState.IDLE; -import static com.apollographql.apollo.internal.CallState.TERMINATED; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.internal.CallState.ACTIVE; +import static com.homer.apollographql.apollo.internal.CallState.CANCELED; +import static com.homer.apollographql.apollo.internal.CallState.IDLE; +import static com.homer.apollographql.apollo.internal.CallState.TERMINATED; final class RealApolloQueryWatcher implements ApolloQueryWatcher { private RealApolloCall activeCall; @@ -40,7 +44,7 @@ final class RealApolloQueryWatcher implements ApolloQueryWatcher { } } }; - private final AtomicReference state = new AtomicReference<>(IDLE); + private final AtomicReference state = new AtomicReference<>(CallState.IDLE); private final AtomicReference> originalCallback = new AtomicReference<>(); RealApolloQueryWatcher( @@ -74,7 +78,7 @@ final class RealApolloQueryWatcher implements ApolloQueryWatcher { @NotNull @Override public synchronized RealApolloQueryWatcher refetchResponseFetcher(@NotNull ResponseFetcher fetcher) { - if (state.get() != IDLE) throw new IllegalStateException("Already Executed"); + if (state.get() != CallState.IDLE) throw new IllegalStateException("Already Executed"); checkNotNull(fetcher, "responseFetcher == null"); this.refetchResponseFetcher = fetcher; return this; @@ -89,11 +93,11 @@ final class RealApolloQueryWatcher implements ApolloQueryWatcher { } finally { tracker.unregisterQueryWatcher(this); originalCallback.set(null); - state.set(CANCELED); + state.set(CallState.CANCELED); } break; case IDLE: - state.set(CANCELED); + state.set(CallState.CANCELED); break; case CANCELED: case TERMINATED: @@ -105,7 +109,7 @@ final class RealApolloQueryWatcher implements ApolloQueryWatcher { } @Override public boolean isCanceled() { - return state.get() == CANCELED; + return state.get() == CallState.CANCELED; } @NotNull @Override public Operation operation() { @@ -191,7 +195,7 @@ private synchronized void activate(Optional> callback) th default: throw new IllegalStateException("Unknown state"); } - state.set(ACTIVE); + state.set(CallState.ACTIVE); } synchronized Optional> responseCallback() { @@ -202,7 +206,7 @@ synchronized Optional> responseCallback() { case IDLE: case TERMINATED: throw new IllegalStateException( - CallState.IllegalStateMessage.forCurrentState(state.get()).expected(ACTIVE, CANCELED)); + CallState.IllegalStateMessage.forCurrentState(state.get()).expected(CallState.ACTIVE, CallState.CANCELED)); default: throw new IllegalStateException("Unknown state"); } @@ -212,14 +216,14 @@ synchronized Optional> terminate() { switch (state.get()) { case ACTIVE: tracker.unregisterQueryWatcher(this); - state.set(TERMINATED); + state.set(CallState.TERMINATED); return Optional.fromNullable(originalCallback.getAndSet(null)); case CANCELED: return Optional.fromNullable(originalCallback.getAndSet(null)); case IDLE: case TERMINATED: throw new IllegalStateException( - CallState.IllegalStateMessage.forCurrentState(state.get()).expected(ACTIVE, CANCELED)); + CallState.IllegalStateMessage.forCurrentState(state.get()).expected(CallState.ACTIVE, CallState.CANCELED)); default: throw new IllegalStateException("Unknown state"); } diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloStore.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/RealApolloStore.java similarity index 90% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloStore.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/RealApolloStore.java index 687e3acdb71..5cf3ca5cd27 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloStore.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/RealApolloStore.java @@ -1,30 +1,30 @@ -package com.apollographql.apollo.internal; - -import com.apollographql.apollo.api.GraphqlFragment; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.api.internal.ResolveDelegate; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.cache.CacheHeaders; -import com.apollographql.apollo.cache.normalized.ApolloStore; -import com.apollographql.apollo.cache.normalized.ApolloStoreOperation; -import com.apollographql.apollo.cache.normalized.CacheKey; -import com.apollographql.apollo.cache.normalized.CacheKeyResolver; -import com.apollographql.apollo.cache.normalized.NormalizedCache; -import com.apollographql.apollo.cache.normalized.OptimisticNormalizedCache; -import com.apollographql.apollo.cache.normalized.Record; -import com.apollographql.apollo.cache.normalized.internal.CacheFieldValueResolver; -import com.apollographql.apollo.cache.normalized.internal.CacheKeyBuilder; -import com.apollographql.apollo.cache.normalized.internal.ReadableStore; -import com.apollographql.apollo.cache.normalized.internal.RealCacheKeyBuilder; -import com.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; -import com.apollographql.apollo.cache.normalized.internal.Transaction; -import com.apollographql.apollo.cache.normalized.internal.WriteableStore; -import com.apollographql.apollo.internal.response.RealResponseReader; -import com.apollographql.apollo.internal.response.RealResponseWriter; +package com.homer.apollographql.apollo.internal; + +import com.homer.apollographql.apollo.api.GraphqlFragment; +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.api.ResponseField; +import com.homer.apollographql.apollo.api.ScalarTypeAdapters; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.api.internal.ResolveDelegate; +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper; +import com.homer.apollographql.apollo.cache.CacheHeaders; +import com.homer.apollographql.apollo.cache.normalized.ApolloStore; +import com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation; +import com.homer.apollographql.apollo.cache.normalized.CacheKey; +import com.homer.apollographql.apollo.cache.normalized.CacheKeyResolver; +import com.homer.apollographql.apollo.cache.normalized.NormalizedCache; +import com.homer.apollographql.apollo.cache.normalized.OptimisticNormalizedCache; +import com.homer.apollographql.apollo.cache.normalized.Record; +import com.homer.apollographql.apollo.cache.normalized.internal.CacheFieldValueResolver; +import com.homer.apollographql.apollo.cache.normalized.internal.CacheKeyBuilder; +import com.homer.apollographql.apollo.cache.normalized.internal.ReadableStore; +import com.homer.apollographql.apollo.cache.normalized.internal.RealCacheKeyBuilder; +import com.homer.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; +import com.homer.apollographql.apollo.cache.normalized.internal.Transaction; +import com.homer.apollographql.apollo.cache.normalized.internal.WriteableStore; +import com.homer.apollographql.apollo.internal.response.RealResponseReader; +import com.homer.apollographql.apollo.internal.response.RealResponseWriter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -41,7 +41,7 @@ import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; public final class RealApolloStore implements ApolloStore, ReadableStore, WriteableStore { final OptimisticNormalizedCache optimisticCache; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloSubscriptionCall.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/RealApolloSubscriptionCall.java similarity index 78% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloSubscriptionCall.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/RealApolloSubscriptionCall.java index e1ab9c4d7d0..33667b5105c 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/RealApolloSubscriptionCall.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/RealApolloSubscriptionCall.java @@ -1,22 +1,25 @@ -package com.apollographql.apollo.internal; - -import com.apollographql.apollo.ApolloSubscriptionCall; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.Subscription; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.cache.CacheHeaders; -import com.apollographql.apollo.cache.normalized.ApolloStore; -import com.apollographql.apollo.cache.normalized.ApolloStoreOperation; -import com.apollographql.apollo.cache.normalized.Record; -import com.apollographql.apollo.exception.ApolloCanceledException; -import com.apollographql.apollo.exception.ApolloNetworkException; -import com.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; -import com.apollographql.apollo.cache.normalized.internal.Transaction; -import com.apollographql.apollo.cache.normalized.internal.WriteableStore; -import com.apollographql.apollo.internal.subscription.ApolloSubscriptionException; -import com.apollographql.apollo.internal.subscription.SubscriptionManager; -import com.apollographql.apollo.internal.subscription.SubscriptionResponse; +package com.homer.apollographql.apollo.internal; + +import com.homer.apollographql.apollo.ApolloSubscriptionCall; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.api.Subscription; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper; +import com.homer.apollographql.apollo.cache.CacheHeaders; +import com.homer.apollographql.apollo.cache.normalized.ApolloStore; +import com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation; +import com.homer.apollographql.apollo.cache.normalized.Record; +import com.homer.apollographql.apollo.exception.ApolloCanceledException; +import com.homer.apollographql.apollo.exception.ApolloNetworkException; +import com.homer.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; +import com.homer.apollographql.apollo.cache.normalized.internal.Transaction; +import com.homer.apollographql.apollo.cache.normalized.internal.WriteableStore; +import com.homer.apollographql.apollo.internal.subscription.ApolloSubscriptionException; +import com.homer.apollographql.apollo.internal.subscription.SubscriptionManager; +import com.homer.apollographql.apollo.internal.subscription.SubscriptionResponse; +import com.homer.apollographql.apollo.internal.subscription.ApolloSubscriptionException; +import com.homer.apollographql.apollo.internal.subscription.SubscriptionManager; +import com.homer.apollographql.apollo.internal.subscription.SubscriptionResponse; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -24,11 +27,11 @@ import java.util.concurrent.Executor; import java.util.concurrent.atomic.AtomicReference; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; -import static com.apollographql.apollo.internal.CallState.ACTIVE; -import static com.apollographql.apollo.internal.CallState.CANCELED; -import static com.apollographql.apollo.internal.CallState.IDLE; -import static com.apollographql.apollo.internal.CallState.TERMINATED; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.internal.CallState.ACTIVE; +import static com.homer.apollographql.apollo.internal.CallState.CANCELED; +import static com.homer.apollographql.apollo.internal.CallState.IDLE; +import static com.homer.apollographql.apollo.internal.CallState.TERMINATED; public class RealApolloSubscriptionCall implements ApolloSubscriptionCall { private final Subscription subscription; @@ -38,7 +41,7 @@ public class RealApolloSubscriptionCall implements ApolloSubscriptionCall private final Executor dispatcher; private final ResponseFieldMapperFactory responseFieldMapperFactory; private final ApolloLogger logger; - private final AtomicReference state = new AtomicReference<>(IDLE); + private final AtomicReference state = new AtomicReference<>(CallState.IDLE); private SubscriptionManagerCallback subscriptionCallback; public RealApolloSubscriptionCall(@NotNull Subscription subscription, @NotNull SubscriptionManager subscriptionManager, @@ -59,7 +62,7 @@ public void execute(@NotNull final Callback callback) throws ApolloCanceledEx synchronized (this) { switch (state.get()) { case IDLE: { - state.set(ACTIVE); + state.set(CallState.ACTIVE); if (cachePolicy == CachePolicy.CACHE_AND_NETWORK) { dispatcher.execute(new Runnable() { @@ -95,7 +98,7 @@ public void cancel() { synchronized (this) { switch (state.get()) { case IDLE: { - state.set(CANCELED); + state.set(CallState.CANCELED); break; } @@ -103,7 +106,7 @@ public void cancel() { try { subscriptionManager.unsubscribe(subscription); } finally { - state.set(CANCELED); + state.set(CallState.CANCELED); subscriptionCallback.release(); } break; @@ -128,7 +131,7 @@ public ApolloSubscriptionCall clone() { } @Override public boolean isCanceled() { - return state.get() == CANCELED; + return state.get() == CallState.CANCELED; } @NotNull @Override public ApolloSubscriptionCall cachePolicy(@NotNull CachePolicy cachePolicy) { @@ -141,7 +144,7 @@ private void terminate() { synchronized (this) { switch (state.get()) { case ACTIVE: { - state.set(TERMINATED); + state.set(CallState.TERMINATED); subscriptionCallback.release(); break; } @@ -152,7 +155,7 @@ private void terminate() { case IDLE: case TERMINATED: throw new IllegalStateException( - CallState.IllegalStateMessage.forCurrentState(state.get()).expected(ACTIVE, CANCELED)); + CallState.IllegalStateMessage.forCurrentState(state.get()).expected(CallState.ACTIVE, CallState.CANCELED)); default: throw new IllegalStateException("Unknown state"); diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/ResponseFieldMapperFactory.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/ResponseFieldMapperFactory.java similarity index 71% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/ResponseFieldMapperFactory.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/ResponseFieldMapperFactory.java index 19b0a5b2a97..91bf7995fab 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/ResponseFieldMapperFactory.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/ResponseFieldMapperFactory.java @@ -1,12 +1,12 @@ -package com.apollographql.apollo.internal; +package com.homer.apollographql.apollo.internal; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper; import org.jetbrains.annotations.NotNull; import java.util.concurrent.ConcurrentHashMap; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; public final class ResponseFieldMapperFactory { private final ConcurrentHashMap pool = new ConcurrentHashMap<>(); diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/fetcher/CacheAndNetworkFetcher.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/fetcher/CacheAndNetworkFetcher.java similarity index 90% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/fetcher/CacheAndNetworkFetcher.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/fetcher/CacheAndNetworkFetcher.java index 094c99eebd5..9e7439cd43a 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/fetcher/CacheAndNetworkFetcher.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/fetcher/CacheAndNetworkFetcher.java @@ -1,11 +1,11 @@ -package com.apollographql.apollo.internal.fetcher; - -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.fetcher.ResponseFetcher; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptorChain; +package com.homer.apollographql.apollo.internal.fetcher; + +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.api.internal.Optional; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptorChain; import org.jetbrains.annotations.NotNull; import java.util.concurrent.Executor; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/fetcher/CacheFirstFetcher.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/fetcher/CacheFirstFetcher.java similarity index 81% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/fetcher/CacheFirstFetcher.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/fetcher/CacheFirstFetcher.java index fe6f1e08799..e1c5338e46d 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/fetcher/CacheFirstFetcher.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/fetcher/CacheFirstFetcher.java @@ -1,10 +1,10 @@ -package com.apollographql.apollo.internal.fetcher; +package com.homer.apollographql.apollo.internal.fetcher; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.fetcher.ResponseFetcher; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptorChain; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptorChain; import org.jetbrains.annotations.NotNull; import java.util.concurrent.Executor; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/fetcher/CacheOnlyFetcher.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/fetcher/CacheOnlyFetcher.java similarity index 74% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/fetcher/CacheOnlyFetcher.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/fetcher/CacheOnlyFetcher.java index b16c3b8e5a3..597fe95f4e1 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/fetcher/CacheOnlyFetcher.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/fetcher/CacheOnlyFetcher.java @@ -1,12 +1,12 @@ -package com.apollographql.apollo.internal.fetcher; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.fetcher.ResponseFetcher; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptorChain; +package com.homer.apollographql.apollo.internal.fetcher; + +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptorChain; import org.jetbrains.annotations.NotNull; import java.util.concurrent.Executor; @@ -14,7 +14,7 @@ /** * Signals the apollo client to only fetch the data from the normalized cache. If it's not present in the * normalized cache or if an exception occurs while trying to fetch it from the normalized cache, an empty {@link - * com.apollographql.apollo.api.Response} is sent back with the {@link com.apollographql.apollo.api.Operation} info + * com.homer.apollographql.apollo.api.Response} is sent back with the {@link com.homer.apollographql.apollo.api.Operation} info * wrapped inside. */ public final class CacheOnlyFetcher implements ResponseFetcher { diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/fetcher/NetworkFirstFetcher.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/fetcher/NetworkFirstFetcher.java similarity index 87% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/fetcher/NetworkFirstFetcher.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/fetcher/NetworkFirstFetcher.java index 93700344674..5904ef68d18 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/fetcher/NetworkFirstFetcher.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/fetcher/NetworkFirstFetcher.java @@ -1,10 +1,10 @@ -package com.apollographql.apollo.internal.fetcher; +package com.homer.apollographql.apollo.internal.fetcher; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.fetcher.ResponseFetcher; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptorChain; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptorChain; import org.jetbrains.annotations.NotNull; import java.util.concurrent.Executor; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/fetcher/NetworkOnlyFetcher.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/fetcher/NetworkOnlyFetcher.java similarity index 73% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/fetcher/NetworkOnlyFetcher.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/fetcher/NetworkOnlyFetcher.java index 2de7f9af6e8..ec59ca2a6cf 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/fetcher/NetworkOnlyFetcher.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/fetcher/NetworkOnlyFetcher.java @@ -1,9 +1,9 @@ -package com.apollographql.apollo.internal.fetcher; +package com.homer.apollographql.apollo.internal.fetcher; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.fetcher.ResponseFetcher; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptorChain; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptorChain; import org.jetbrains.annotations.NotNull; import java.util.concurrent.Executor; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/field/MapFieldValueResolver.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/field/MapFieldValueResolver.java similarity index 63% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/field/MapFieldValueResolver.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/field/MapFieldValueResolver.java index 6c4d35d2e58..ae32770b14d 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/field/MapFieldValueResolver.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/field/MapFieldValueResolver.java @@ -1,7 +1,7 @@ -package com.apollographql.apollo.internal.field; +package com.homer.apollographql.apollo.internal.field; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.api.internal.FieldValueResolver; +import com.homer.apollographql.apollo.api.ResponseField; +import com.homer.apollographql.apollo.api.internal.FieldValueResolver; import java.util.Map; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/interceptor/ApolloCacheInterceptor.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/interceptor/ApolloCacheInterceptor.java similarity index 86% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/interceptor/ApolloCacheInterceptor.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/interceptor/ApolloCacheInterceptor.java index 5b6d5bc7e50..6ec6fa7f1d2 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/interceptor/ApolloCacheInterceptor.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/interceptor/ApolloCacheInterceptor.java @@ -1,21 +1,21 @@ -package com.apollographql.apollo.internal.interceptor; - -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.api.internal.Function; -import com.apollographql.apollo.api.internal.Optional; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.cache.ApolloCacheHeaders; -import com.apollographql.apollo.cache.normalized.ApolloStore; -import com.apollographql.apollo.cache.normalized.ApolloStoreOperation; -import com.apollographql.apollo.cache.normalized.Record; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptorChain; -import com.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; -import com.apollographql.apollo.cache.normalized.internal.Transaction; -import com.apollographql.apollo.cache.normalized.internal.WriteableStore; +package com.homer.apollographql.apollo.internal.interceptor; + +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.api.internal.Function; +import com.homer.apollographql.apollo.api.internal.Optional; +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper; +import com.homer.apollographql.apollo.cache.ApolloCacheHeaders; +import com.homer.apollographql.apollo.cache.normalized.ApolloStore; +import com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation; +import com.homer.apollographql.apollo.cache.normalized.Record; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptorChain; +import com.homer.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; +import com.homer.apollographql.apollo.cache.normalized.internal.Transaction; +import com.homer.apollographql.apollo.cache.normalized.internal.WriteableStore; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -27,7 +27,7 @@ import java.util.Set; import java.util.concurrent.Executor; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; /** * ApolloCacheInterceptor is a concrete {@link ApolloInterceptor} responsible for serving requests from the normalized diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/interceptor/ApolloParseInterceptor.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/interceptor/ApolloParseInterceptor.java similarity index 80% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/interceptor/ApolloParseInterceptor.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/interceptor/ApolloParseInterceptor.java index 1428fdb7803..ca189f9bdc3 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/interceptor/ApolloParseInterceptor.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/interceptor/ApolloParseInterceptor.java @@ -1,19 +1,19 @@ -package com.apollographql.apollo.internal.interceptor; +package com.homer.apollographql.apollo.internal.interceptor; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.cache.http.HttpCache; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.exception.ApolloHttpException; -import com.apollographql.apollo.exception.ApolloParseException; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptorChain; -import com.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; -import com.apollographql.apollo.http.OkHttpExecutionContext; -import com.apollographql.apollo.response.OperationResponseParser; +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.api.ScalarTypeAdapters; +import com.homer.apollographql.apollo.api.cache.http.HttpCache; +import com.homer.apollographql.apollo.api.internal.ApolloLogger; +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.exception.ApolloHttpException; +import com.homer.apollographql.apollo.exception.ApolloParseException; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptorChain; +import com.homer.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; +import com.homer.apollographql.apollo.http.OkHttpExecutionContext; +import com.homer.apollographql.apollo.response.OperationResponseParser; import org.jetbrains.annotations.NotNull; import java.io.Closeable; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/interceptor/ApolloServerInterceptor.kt b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/interceptor/ApolloServerInterceptor.kt old mode 100755 new mode 100644 similarity index 84% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/interceptor/ApolloServerInterceptor.kt rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/interceptor/ApolloServerInterceptor.kt index 8879665f719..331c20a1720 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/interceptor/ApolloServerInterceptor.kt +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/interceptor/ApolloServerInterceptor.kt @@ -1,28 +1,28 @@ -package com.apollographql.apollo.internal.interceptor +package com.homer.apollographql.apollo.internal.interceptor -import com.apollographql.apollo.api.FileUpload -import com.apollographql.apollo.api.Input -import com.apollographql.apollo.api.InputType -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.cache.http.HttpCache -import com.apollographql.apollo.api.cache.http.HttpCachePolicy -import com.apollographql.apollo.api.internal.ApolloLogger -import com.apollographql.apollo.api.internal.Optional -import com.apollographql.apollo.api.internal.Utils.__checkNotNull -import com.apollographql.apollo.api.internal.json.InputFieldJsonWriter -import com.apollographql.apollo.api.internal.json.JsonWriter.Companion.of -import com.apollographql.apollo.cache.ApolloCacheHeaders -import com.apollographql.apollo.cache.CacheHeaders -import com.apollographql.apollo.exception.ApolloNetworkException -import com.apollographql.apollo.interceptor.ApolloInterceptor -import com.apollographql.apollo.interceptor.ApolloInterceptor.CallBack -import com.apollographql.apollo.interceptor.ApolloInterceptor.FetchSourceType -import com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest -import com.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorResponse -import com.apollographql.apollo.interceptor.ApolloInterceptorChain -import com.apollographql.apollo.request.RequestHeaders +import com.homer.apollographql.apollo.api.FileUpload +import com.homer.apollographql.apollo.api.Input +import com.homer.apollographql.apollo.api.InputType +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.Query +import com.homer.apollographql.apollo.api.ScalarTypeAdapters +import com.homer.apollographql.apollo.api.cache.http.HttpCache +import com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy +import com.homer.apollographql.apollo.api.internal.ApolloLogger +import com.homer.apollographql.apollo.api.internal.Optional +import com.homer.apollographql.apollo.api.internal.Utils.__checkNotNull +import com.homer.apollographql.apollo.api.internal.json.InputFieldJsonWriter +import com.homer.apollographql.apollo.api.internal.json.JsonWriter.Companion.of +import com.homer.apollographql.apollo.cache.ApolloCacheHeaders +import com.homer.apollographql.apollo.cache.CacheHeaders +import com.homer.apollographql.apollo.exception.ApolloNetworkException +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor.CallBack +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor.FetchSourceType +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorRequest +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor.InterceptorResponse +import com.homer.apollographql.apollo.interceptor.ApolloInterceptorChain +import com.homer.apollographql.apollo.request.RequestHeaders import okhttp3.Call import okhttp3.Callback import okhttp3.HttpUrl @@ -48,7 +48,8 @@ import java.util.concurrent.atomic.AtomicReference */ class ApolloServerInterceptor(serverUrl: HttpUrl, httpCallFactory: Call.Factory, cachePolicy: HttpCachePolicy.Policy?, prefetch: Boolean, - scalarTypeAdapters: ScalarTypeAdapters, logger: ApolloLogger) : ApolloInterceptor { + scalarTypeAdapters: ScalarTypeAdapters, logger: ApolloLogger) : + com.homer.apollographql.apollo.interceptor.ApolloInterceptor { val serverUrl: HttpUrl val httpCallFactory: Call.Factory val cachePolicy: Optional @@ -60,7 +61,7 @@ class ApolloServerInterceptor(serverUrl: HttpUrl, httpCallFactory: Call.Factory, @Volatile var disposed = false - override fun interceptAsync(request: InterceptorRequest, chain: ApolloInterceptorChain, + override fun interceptAsync(request: InterceptorRequest, chain: com.homer.apollographql.apollo.interceptor.ApolloInterceptorChain, dispatcher: Executor, callBack: CallBack) { dispatcher.execute { executeHttpCall(request, callBack) } } @@ -85,7 +86,11 @@ class ApolloServerInterceptor(serverUrl: HttpUrl, httpCallFactory: Call.Factory, } } catch (e: IOException) { logger.e(e, "Failed to prepare http call for operation %s", request.operation.name().name()) - callBack.onFailure(ApolloNetworkException("Failed to prepare http call", e)) + callBack.onFailure( + com.homer.apollographql.apollo.exception.ApolloNetworkException( + "Failed to prepare http call", e + ) + ) return } val previousCall = httpCallRef.getAndSet(httpCall) @@ -99,7 +104,11 @@ class ApolloServerInterceptor(serverUrl: HttpUrl, httpCallFactory: Call.Factory, if (disposed) return if (httpCallRef.compareAndSet(httpCall, null)) { logger.e(e, "Failed to execute http call for operation %s", request.operation.name().name()) - callBack.onFailure(ApolloNetworkException("Failed to execute http call", e)) + callBack.onFailure( + com.homer.apollographql.apollo.exception.ApolloNetworkException( + "Failed to execute http call", e + ) + ) } } @@ -114,7 +123,7 @@ class ApolloServerInterceptor(serverUrl: HttpUrl, httpCallFactory: Call.Factory, } @Throws(IOException::class) - fun httpGetCall(operation: Operation<*, *, *>, cacheHeaders: CacheHeaders, requestHeaders: RequestHeaders, + fun httpGetCall(operation: Operation<*, *, *>, cacheHeaders: CacheHeaders, requestHeaders: com.homer.apollographql.apollo.request.RequestHeaders, writeQueryDocument: Boolean, autoPersistQueries: Boolean): Call { val requestBuilder = Request.Builder() .url(httpGetUrl(serverUrl, operation, scalarTypeAdapters, writeQueryDocument, autoPersistQueries)) @@ -124,7 +133,7 @@ class ApolloServerInterceptor(serverUrl: HttpUrl, httpCallFactory: Call.Factory, } @Throws(IOException::class) - fun httpPostCall(operation: Operation<*, *, *>, cacheHeaders: CacheHeaders, requestHeaders: RequestHeaders, + fun httpPostCall(operation: Operation<*, *, *>, cacheHeaders: CacheHeaders, requestHeaders: com.homer.apollographql.apollo.request.RequestHeaders, writeQueryDocument: Boolean, autoPersistQueries: Boolean): Call { var requestBody = RequestBody.create(MEDIA_TYPE, httpPostRequestBody(operation, scalarTypeAdapters, writeQueryDocument, autoPersistQueries)) @@ -139,7 +148,8 @@ class ApolloServerInterceptor(serverUrl: HttpUrl, httpCallFactory: Call.Factory, @Throws(IOException::class) fun decorateRequest(requestBuilder: Request.Builder, operation: Operation<*, *, *>, cacheHeaders: CacheHeaders, - requestHeaders: RequestHeaders) { + requestHeaders: com.homer.apollographql.apollo.request.RequestHeaders + ) { requestBuilder .header(HEADER_ACCEPT_TYPE, ACCEPT_TYPE) .header(HEADER_APOLLO_OPERATION_ID, operation.operationId()) diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/interceptor/RealApolloInterceptorChain.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/interceptor/RealApolloInterceptorChain.java similarity index 85% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/interceptor/RealApolloInterceptorChain.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/interceptor/RealApolloInterceptorChain.java index 87bf56b351e..275562e6d75 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/interceptor/RealApolloInterceptorChain.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/interceptor/RealApolloInterceptorChain.java @@ -1,7 +1,7 @@ -package com.apollographql.apollo.internal.interceptor; +package com.homer.apollographql.apollo.internal.interceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptorChain; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptor; +import com.homer.apollographql.apollo.interceptor.ApolloInterceptorChain; import java.util.ArrayList; import java.util.List; @@ -9,7 +9,7 @@ import org.jetbrains.annotations.NotNull; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; /** * RealApolloInterceptorChain is responsible for building the entire interceptor chain. Based on the task at hand, the diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/response/RealResponseReader.kt b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/response/RealResponseReader.kt similarity index 92% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/response/RealResponseReader.kt rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/response/RealResponseReader.kt index 29294aafc58..e7deb8b7d35 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/response/RealResponseReader.kt +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/response/RealResponseReader.kt @@ -1,15 +1,15 @@ -package com.apollographql.apollo.internal.response +package com.homer.apollographql.apollo.internal.response -import com.apollographql.apollo.api.BigDecimal -import com.apollographql.apollo.api.CustomTypeAdapter -import com.apollographql.apollo.api.CustomTypeValue.Companion.fromRawValue -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarType -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.internal.FieldValueResolver -import com.apollographql.apollo.api.internal.ResolveDelegate -import com.apollographql.apollo.api.internal.ResponseReader +import com.homer.apollographql.apollo.api.BigDecimal +import com.homer.apollographql.apollo.api.CustomTypeAdapter +import com.homer.apollographql.apollo.api.CustomTypeValue.Companion.fromRawValue +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.ResponseField +import com.homer.apollographql.apollo.api.ScalarType +import com.homer.apollographql.apollo.api.ScalarTypeAdapters +import com.homer.apollographql.apollo.api.internal.FieldValueResolver +import com.homer.apollographql.apollo.api.internal.ResolveDelegate +import com.homer.apollographql.apollo.api.internal.ResponseReader import java.util.Collections class RealResponseReader( diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/response/RealResponseWriter.kt b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/response/RealResponseWriter.kt similarity index 93% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/response/RealResponseWriter.kt rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/response/RealResponseWriter.kt index 09c08c7adef..2d1b0cf7cde 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/response/RealResponseWriter.kt +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/response/RealResponseWriter.kt @@ -1,13 +1,13 @@ -package com.apollographql.apollo.internal.response - -import com.apollographql.apollo.api.CustomTypeAdapter -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.ResponseField -import com.apollographql.apollo.api.ScalarType -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.internal.ResolveDelegate -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseWriter +package com.homer.apollographql.apollo.internal.response + +import com.homer.apollographql.apollo.api.CustomTypeAdapter +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.ResponseField +import com.homer.apollographql.apollo.api.ScalarType +import com.homer.apollographql.apollo.api.ScalarTypeAdapters +import com.homer.apollographql.apollo.api.internal.ResolveDelegate +import com.homer.apollographql.apollo.api.internal.ResponseFieldMarshaller +import com.homer.apollographql.apollo.api.internal.ResponseWriter import java.math.BigDecimal import java.util.ArrayList import java.util.LinkedHashMap diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/ApolloSubscriptionException.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/ApolloSubscriptionException.java similarity index 69% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/ApolloSubscriptionException.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/ApolloSubscriptionException.java index 408c585284d..86a55d89e1d 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/ApolloSubscriptionException.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/ApolloSubscriptionException.java @@ -1,6 +1,6 @@ -package com.apollographql.apollo.internal.subscription; +package com.homer.apollographql.apollo.internal.subscription; -import com.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.exception.ApolloException; @SuppressWarnings("WeakerAccess") public class ApolloSubscriptionException extends ApolloException { diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/ApolloSubscriptionServerException.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/ApolloSubscriptionServerException.java similarity index 78% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/ApolloSubscriptionServerException.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/ApolloSubscriptionServerException.java index 41846f60730..37c5b4db846 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/ApolloSubscriptionServerException.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/ApolloSubscriptionServerException.java @@ -1,10 +1,10 @@ -package com.apollographql.apollo.internal.subscription; +package com.homer.apollographql.apollo.internal.subscription; import java.util.Map; import org.jetbrains.annotations.NotNull; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; import static java.util.Collections.unmodifiableMap; @SuppressWarnings("WeakerAccess") diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/ApolloSubscriptionTerminatedException.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/ApolloSubscriptionTerminatedException.java similarity index 69% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/ApolloSubscriptionTerminatedException.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/ApolloSubscriptionTerminatedException.java index 48d31feb0d8..7bd989c64c2 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/ApolloSubscriptionTerminatedException.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/ApolloSubscriptionTerminatedException.java @@ -1,6 +1,6 @@ -package com.apollographql.apollo.internal.subscription; +package com.homer.apollographql.apollo.internal.subscription; -import com.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.exception.ApolloException; public class ApolloSubscriptionTerminatedException extends ApolloException { diff --git a/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/NoOpSubscriptionManager.kt b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/NoOpSubscriptionManager.kt new file mode 100644 index 00000000000..040d704da51 --- /dev/null +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/NoOpSubscriptionManager.kt @@ -0,0 +1,40 @@ +package com.homer.apollographql.apollo.internal.subscription + +import com.homer.apollographql.apollo.api.Subscription +import com.homer.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener +import com.homer.apollographql.apollo.subscription.SubscriptionManagerState + +class NoOpSubscriptionManager : com.homer.apollographql.apollo.internal.subscription.SubscriptionManager { + val errorMessage = "No `SubscriptionTransport.Factory` found, please add one to your `ApolloClient` with `ApolloClient.Builder.subscriptionTransportFactory`" + + override fun subscribe(subscription: Subscription<*, T, *>, callback: com.homer.apollographql.apollo.internal.subscription.SubscriptionManager.Callback) { + throw IllegalStateException(errorMessage) + } + + override fun unsubscribe(subscription: Subscription<*, *, *>) { + throw IllegalStateException(errorMessage) + } + + override fun start() { + throw IllegalStateException(errorMessage) + } + + override fun stop() { + throw IllegalStateException(errorMessage) + } + + override fun reconnect() { + } + + override fun getState(): com.homer.apollographql.apollo.subscription.SubscriptionManagerState { + return com.homer.apollographql.apollo.subscription.SubscriptionManagerState.DISCONNECTED + } + + override fun addOnStateChangeListener(onStateChangeListener: com.homer.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener) { + throw IllegalStateException(errorMessage) + } + + override fun removeOnStateChangeListener(onStateChangeListener: com.homer.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener) { + throw IllegalStateException(errorMessage) + } +} \ No newline at end of file diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/RealSubscriptionManager.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/RealSubscriptionManager.java similarity index 94% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/RealSubscriptionManager.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/RealSubscriptionManager.java index 8a6f4a39303..8faf0a64463 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/RealSubscriptionManager.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/RealSubscriptionManager.java @@ -1,21 +1,21 @@ -package com.apollographql.apollo.internal.subscription; - -import com.apollographql.apollo.api.Error; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.Subscription; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.cache.normalized.Record; -import com.apollographql.apollo.exception.ApolloNetworkException; -import com.apollographql.apollo.internal.ResponseFieldMapperFactory; -import com.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; -import com.apollographql.apollo.response.OperationResponseParser; -import com.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener; -import com.apollographql.apollo.subscription.OperationClientMessage; -import com.apollographql.apollo.subscription.OperationServerMessage; -import com.apollographql.apollo.subscription.SubscriptionConnectionParamsProvider; -import com.apollographql.apollo.subscription.SubscriptionManagerState; -import com.apollographql.apollo.subscription.SubscriptionTransport; +package com.homer.apollographql.apollo.internal.subscription; + +import com.homer.apollographql.apollo.api.Error; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.api.ScalarTypeAdapters; +import com.homer.apollographql.apollo.api.Subscription; +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper; +import com.homer.apollographql.apollo.cache.normalized.Record; +import com.homer.apollographql.apollo.exception.ApolloNetworkException; +import com.homer.apollographql.apollo.internal.ResponseFieldMapperFactory; +import com.homer.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; +import com.homer.apollographql.apollo.response.OperationResponseParser; +import com.homer.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener; +import com.homer.apollographql.apollo.subscription.OperationClientMessage; +import com.homer.apollographql.apollo.subscription.OperationServerMessage; +import com.homer.apollographql.apollo.subscription.SubscriptionConnectionParamsProvider; +import com.homer.apollographql.apollo.subscription.SubscriptionManagerState; +import com.homer.apollographql.apollo.subscription.SubscriptionTransport; import kotlin.jvm.functions.Function0; import org.jetbrains.annotations.NotNull; @@ -31,7 +31,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; @SuppressWarnings("WeakerAccess") public final class RealSubscriptionManager implements SubscriptionManager { diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/SubscriptionManager.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/SubscriptionManager.java similarity index 87% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/SubscriptionManager.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/SubscriptionManager.java index 4a5af4f3f57..8724fc559a1 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/SubscriptionManager.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/SubscriptionManager.java @@ -1,8 +1,8 @@ -package com.apollographql.apollo.internal.subscription; +package com.homer.apollographql.apollo.internal.subscription; -import com.apollographql.apollo.api.Subscription; -import com.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener; -import com.apollographql.apollo.subscription.SubscriptionManagerState; +import com.homer.apollographql.apollo.api.Subscription; +import com.homer.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener; +import com.homer.apollographql.apollo.subscription.SubscriptionManagerState; import org.jetbrains.annotations.NotNull; public interface SubscriptionManager { diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/SubscriptionResponse.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/SubscriptionResponse.java similarity index 70% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/SubscriptionResponse.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/SubscriptionResponse.java index d762c7af1a6..9df9af354c6 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/subscription/SubscriptionResponse.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/subscription/SubscriptionResponse.java @@ -1,8 +1,8 @@ -package com.apollographql.apollo.internal.subscription; +package com.homer.apollographql.apollo.internal.subscription; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.Subscription; -import com.apollographql.apollo.cache.normalized.Record; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.api.Subscription; +import com.homer.apollographql.apollo.cache.normalized.Record; import org.jetbrains.annotations.NotNull; import java.util.Collection; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/util/Cancelable.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/util/Cancelable.java similarity index 85% rename from apollo-runtime/src/main/java/com/apollographql/apollo/internal/util/Cancelable.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/util/Cancelable.java index 5044ee61745..9186ad8c860 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/internal/util/Cancelable.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/internal/util/Cancelable.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.internal.util; +package com.homer.apollographql.apollo.internal.util; /** * Represents an operation which can be canceled. diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/request/RequestHeaders.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/request/RequestHeaders.java similarity index 97% rename from apollo-runtime/src/main/java/com/apollographql/apollo/request/RequestHeaders.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/request/RequestHeaders.java index a1ce6f2989a..154f8ed1afc 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/request/RequestHeaders.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/request/RequestHeaders.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.request; +package com.homer.apollographql.apollo.request; import java.util.Collections; import java.util.LinkedHashMap; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/response/OperationResponseParser.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/response/OperationResponseParser.java similarity index 87% rename from apollo-runtime/src/main/java/com/apollographql/apollo/response/OperationResponseParser.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/response/OperationResponseParser.java index bedb9a40579..1753d76492d 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/response/OperationResponseParser.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/response/OperationResponseParser.java @@ -1,15 +1,17 @@ -package com.apollographql.apollo.response; - -import com.apollographql.apollo.api.Error; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.json.BufferedSourceJsonReader; -import com.apollographql.apollo.api.internal.json.ResponseJsonStreamReader; -import com.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; -import com.apollographql.apollo.internal.field.MapFieldValueResolver; -import com.apollographql.apollo.internal.response.RealResponseReader; +package com.homer.apollographql.apollo.response; + +import com.homer.apollographql.apollo.api.Error; +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.api.ScalarTypeAdapters; +import com.homer.apollographql.apollo.api.internal.ResponseFieldMapper; +import com.homer.apollographql.apollo.api.internal.json.BufferedSourceJsonReader; +import com.homer.apollographql.apollo.api.internal.json.ResponseJsonStreamReader; +import com.homer.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; +import com.homer.apollographql.apollo.internal.field.MapFieldValueResolver; +import com.homer.apollographql.apollo.internal.response.RealResponseReader; +import com.homer.apollographql.apollo.internal.field.MapFieldValueResolver; +import com.homer.apollographql.apollo.internal.response.RealResponseReader; import okio.BufferedSource; import org.jetbrains.annotations.NotNull; @@ -19,7 +21,7 @@ import java.util.List; import java.util.Map; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; @SuppressWarnings("WeakerAccess") public final class OperationResponseParser { diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/ApolloOperationMessageSerializer.kt b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/ApolloOperationMessageSerializer.kt similarity index 90% rename from apollo-runtime/src/main/java/com/apollographql/apollo/subscription/ApolloOperationMessageSerializer.kt rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/ApolloOperationMessageSerializer.kt index e5eadef7f51..03665825a4f 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/ApolloOperationMessageSerializer.kt +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/ApolloOperationMessageSerializer.kt @@ -1,12 +1,12 @@ -package com.apollographql.apollo.subscription +package com.homer.apollographql.apollo.subscription -import com.apollographql.apollo.api.internal.json.BufferedSourceJsonReader -import com.apollographql.apollo.api.internal.json.JsonEncodingException -import com.apollographql.apollo.api.internal.json.JsonReader -import com.apollographql.apollo.api.internal.json.JsonWriter -import com.apollographql.apollo.api.internal.json.ResponseJsonStreamReader -import com.apollographql.apollo.api.internal.json.Utils -import com.apollographql.apollo.api.internal.json.writeObject +import com.homer.apollographql.apollo.api.internal.json.BufferedSourceJsonReader +import com.homer.apollographql.apollo.api.internal.json.JsonEncodingException +import com.homer.apollographql.apollo.api.internal.json.JsonReader +import com.homer.apollographql.apollo.api.internal.json.JsonWriter +import com.homer.apollographql.apollo.api.internal.json.ResponseJsonStreamReader +import com.homer.apollographql.apollo.api.internal.json.Utils +import com.homer.apollographql.apollo.api.internal.json.writeObject import okio.BufferedSink import okio.BufferedSource import java.io.IOException diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/AppSyncOperationMessageSerializer.kt b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/AppSyncOperationMessageSerializer.kt similarity index 92% rename from apollo-runtime/src/main/java/com/apollographql/apollo/subscription/AppSyncOperationMessageSerializer.kt rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/AppSyncOperationMessageSerializer.kt index cf8f8fca70f..6b1717f27d9 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/AppSyncOperationMessageSerializer.kt +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/AppSyncOperationMessageSerializer.kt @@ -1,9 +1,9 @@ -package com.apollographql.apollo.subscription +package com.homer.apollographql.apollo.subscription -import com.apollographql.apollo.api.internal.json.JsonWriter -import com.apollographql.apollo.api.internal.json.Utils -import com.apollographql.apollo.api.internal.json.writeObject -import com.apollographql.apollo.subscription.ApolloOperationMessageSerializer.writePayloadContentsTo +import com.homer.apollographql.apollo.api.internal.json.JsonWriter +import com.homer.apollographql.apollo.api.internal.json.Utils +import com.homer.apollographql.apollo.api.internal.json.writeObject +import com.homer.apollographql.apollo.subscription.ApolloOperationMessageSerializer.writePayloadContentsTo import okhttp3.HttpUrl import okio.Buffer import okio.BufferedSink diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/OnSubscriptionManagerStateChangeListener.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/OnSubscriptionManagerStateChangeListener.java similarity index 88% rename from apollo-runtime/src/main/java/com/apollographql/apollo/subscription/OnSubscriptionManagerStateChangeListener.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/OnSubscriptionManagerStateChangeListener.java index 29ff275dc03..2aed406145f 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/OnSubscriptionManagerStateChangeListener.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/OnSubscriptionManagerStateChangeListener.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.subscription; +package com.homer.apollographql.apollo.subscription; /** * Represents a callback for subscription manager state changes. diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/OperationClientMessage.kt b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/OperationClientMessage.kt similarity index 87% rename from apollo-runtime/src/main/java/com/apollographql/apollo/subscription/OperationClientMessage.kt rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/OperationClientMessage.kt index 40efa9f4661..76ba418d99f 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/OperationClientMessage.kt +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/OperationClientMessage.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.subscription +package com.homer.apollographql.apollo.subscription -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.Subscription -import com.apollographql.apollo.api.internal.json.JsonWriter +import com.homer.apollographql.apollo.api.ScalarTypeAdapters +import com.homer.apollographql.apollo.api.Subscription +import com.homer.apollographql.apollo.api.internal.json.JsonWriter import okio.Buffer import java.io.IOException diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/OperationMessageSerializer.kt b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/OperationMessageSerializer.kt similarity index 95% rename from apollo-runtime/src/main/java/com/apollographql/apollo/subscription/OperationMessageSerializer.kt rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/OperationMessageSerializer.kt index 3abe549cd1c..860274b0f7a 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/OperationMessageSerializer.kt +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/OperationMessageSerializer.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.subscription +package com.homer.apollographql.apollo.subscription import okio.BufferedSink import okio.BufferedSource diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/OperationServerMessage.kt b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/OperationServerMessage.kt similarity index 98% rename from apollo-runtime/src/main/java/com/apollographql/apollo/subscription/OperationServerMessage.kt rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/OperationServerMessage.kt index 3a21fb02466..5d4ea179e08 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/OperationServerMessage.kt +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/OperationServerMessage.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.subscription +package com.homer.apollographql.apollo.subscription import okio.Buffer diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/SubscriptionConnectionParams.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/SubscriptionConnectionParams.java similarity index 89% rename from apollo-runtime/src/main/java/com/apollographql/apollo/subscription/SubscriptionConnectionParams.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/SubscriptionConnectionParams.java index 1b9c13096c0..41dcef7a6df 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/SubscriptionConnectionParams.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/SubscriptionConnectionParams.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.subscription; +package com.homer.apollographql.apollo.subscription; import java.util.HashMap; import java.util.Map; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/SubscriptionConnectionParamsProvider.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/SubscriptionConnectionParamsProvider.java similarity index 92% rename from apollo-runtime/src/main/java/com/apollographql/apollo/subscription/SubscriptionConnectionParamsProvider.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/SubscriptionConnectionParamsProvider.java index ff5389eb74d..6728676ae43 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/SubscriptionConnectionParamsProvider.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/SubscriptionConnectionParamsProvider.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.subscription; +package com.homer.apollographql.apollo.subscription; import org.jetbrains.annotations.NotNull; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/SubscriptionManagerState.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/SubscriptionManagerState.java similarity index 94% rename from apollo-runtime/src/main/java/com/apollographql/apollo/subscription/SubscriptionManagerState.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/SubscriptionManagerState.java index cbe7923a5e3..a6382fbba02 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/SubscriptionManagerState.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/SubscriptionManagerState.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.subscription; +package com.homer.apollographql.apollo.subscription; /** * Subscription manager state. diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/SubscriptionTransport.java b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/SubscriptionTransport.java similarity index 97% rename from apollo-runtime/src/main/java/com/apollographql/apollo/subscription/SubscriptionTransport.java rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/SubscriptionTransport.java index 63596bed3bb..28b36bfe0c0 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/SubscriptionTransport.java +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/SubscriptionTransport.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.subscription; +package com.homer.apollographql.apollo.subscription; import org.jetbrains.annotations.NotNull; diff --git a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/WebSocketSubscriptionTransport.kt b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/WebSocketSubscriptionTransport.kt similarity index 88% rename from apollo-runtime/src/main/java/com/apollographql/apollo/subscription/WebSocketSubscriptionTransport.kt rename to apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/WebSocketSubscriptionTransport.kt index b9036da8550..471fdb5611f 100644 --- a/apollo-runtime/src/main/java/com/apollographql/apollo/subscription/WebSocketSubscriptionTransport.kt +++ b/apollo-runtime/src/main/java/com/homer/apollographql/apollo/subscription/WebSocketSubscriptionTransport.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.subscription +package com.homer.apollographql.apollo.subscription import okhttp3.Request import okhttp3.Response @@ -13,9 +13,9 @@ import java.util.concurrent.atomic.AtomicReference class WebSocketSubscriptionTransport @JvmOverloads constructor( private val webSocketRequest: Request, private val webSocketConnectionFactory: WebSocket.Factory, - private val callback: SubscriptionTransport.Callback, + private val callback: com.homer.apollographql.apollo.subscription.SubscriptionTransport.Callback, private val serializer: OperationMessageSerializer = ApolloOperationMessageSerializer -) : SubscriptionTransport { +) : com.homer.apollographql.apollo.subscription.SubscriptionTransport { internal val webSocket = AtomicReference() internal val webSocketListener = AtomicReference() @@ -114,14 +114,14 @@ class WebSocketSubscriptionTransport @JvmOverloads constructor( webSocketUrl: String, private val webSocketConnectionFactory: WebSocket.Factory, private val serializer: OperationMessageSerializer = ApolloOperationMessageSerializer - ) : SubscriptionTransport.Factory { + ) : com.homer.apollographql.apollo.subscription.SubscriptionTransport.Factory { private val webSocketRequest: Request = Request.Builder() .url(webSocketUrl) .addHeader("Sec-WebSocket-Protocol", "graphql-ws") .addHeader("Cookie", "") .build() - override fun create(callback: SubscriptionTransport.Callback): SubscriptionTransport = + override fun create(callback: com.homer.apollographql.apollo.subscription.SubscriptionTransport.Callback): com.homer.apollographql.apollo.subscription.SubscriptionTransport = WebSocketSubscriptionTransport(webSocketRequest, webSocketConnectionFactory, callback, serializer) } } \ No newline at end of file diff --git a/apollo-runtime/src/test/java/com/apollographql/apollo/ApolloClientTest.java b/apollo-runtime/src/test/java/com/apollographql/apollo/ApolloClientTest.java deleted file mode 100644 index 0019260ea8e..00000000000 --- a/apollo-runtime/src/test/java/com/apollographql/apollo/ApolloClientTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import org.junit.Test; - -import static com.google.common.truth.Truth.assertThat; -import static org.mockito.Mockito.mock; - -public class ApolloClientTest { - - private final ApolloClient apolloClient = ApolloClient.builder().serverUrl("https://example.com").build(); - - @Test public void clonedInterceptorsListsAreIndependent() { - ApolloInterceptor interceptor = mock(ApolloInterceptor.class); - apolloClient.newBuilder() - .addApplicationInterceptor(interceptor) - .build(); - assertThat(apolloClient.getApplicationInterceptors().size()).isEqualTo(0); - } - - /** - * When copying the client, stateful things like the connection pool are shared across all - * clients. - */ - @Test public void cloneSharesInstances() { - ApolloClient copy = apolloClient.newBuilder().build(); - - assertThat(apolloClient.getApolloStore()).isSameAs(copy.getApolloStore()); - assertThat(apolloClient.getSubscriptionManager()).isSameAs(copy.getSubscriptionManager()); - assertThat(apolloClient.getHttpCache()).isSameAs(copy.getHttpCache()); - } -} diff --git a/apollo-runtime/src/test/java/com/apollographql/apollo/ApolloExceptionTest.java b/apollo-runtime/src/test/java/com/apollographql/apollo/ApolloExceptionTest.java deleted file mode 100644 index 330402c37ae..00000000000 --- a/apollo-runtime/src/test/java/com/apollographql/apollo/ApolloExceptionTest.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.apollographql.apollo; - -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.json.JsonEncodingException; -import com.apollographql.apollo.exception.ApolloHttpException; -import com.apollographql.apollo.exception.ApolloNetworkException; -import com.apollographql.apollo.exception.ApolloParseException; -import com.apollographql.apollo.rx2.Rx2Apollo; -import io.reactivex.functions.Consumer; -import io.reactivex.functions.Predicate; -import okhttp3.OkHttpClient; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.net.SocketTimeoutException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicReference; - -import static com.google.common.truth.Truth.assertThat; - -@SuppressWarnings("unchecked") public class ApolloExceptionTest { - private static long timeoutSeconds = 2; - - @Rule public final MockWebServer server = new MockWebServer(); - private ApolloClient apolloClient; - private Query emptyQuery; - - @Before public void setUp() { - apolloClient = ApolloClient.builder() - .serverUrl(server.url("/")) - .okHttpClient(new OkHttpClient.Builder() - .connectTimeout(timeoutSeconds, TimeUnit.SECONDS) - .readTimeout(timeoutSeconds, TimeUnit.SECONDS) - .build()) - .build(); - - emptyQuery = new Query() { - OperationName operationName = new OperationName() { - @Override public String name() { - return "emptyQuery"; - } - }; - - @Override public String queryDocument() { - return ""; - } - - @Override public Variables variables() { - return EMPTY_VARIABLES; - } - - @Override public ResponseFieldMapper responseFieldMapper() { - return new ResponseFieldMapper() { - @Override public Data map(ResponseReader responseReader) { - return null; - } - }; - } - - @NotNull @Override public OperationName name() { - return operationName; - } - - @NotNull @Override public String operationId() { - return ""; - } - - @Override public Object wrapData(Data data) { - return data; - } - - @NotNull @Override public Response parse(@NotNull BufferedSource source) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull BufferedSource source, @NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull ByteString byteString) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull ByteString byteString, @NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public ByteString composeRequestBody( - boolean autoPersistQueries, - boolean withQueryDocument, - @NotNull ScalarTypeAdapters scalarTypeAdapters - ) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - @NotNull @Override public ByteString composeRequestBody(@NotNull ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull @Override public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - }; - } - - @Test public void httpException() throws Exception { - server.enqueue(new MockResponse().setResponseCode(401).setBody("Unauthorized request!")); - - final AtomicReference errorRef = new AtomicReference<>(); - final AtomicReference errorResponse = new AtomicReference<>(); - Rx2Apollo - .from(apolloClient.query(emptyQuery)) - .doOnError(new Consumer() { - @Override public void accept(Throwable throwable) throws Exception { - errorRef.set(throwable); - errorResponse.set(((ApolloHttpException) throwable).rawResponse().body().string()); - } - }) - .test() - .awaitDone(timeoutSeconds, TimeUnit.SECONDS) - .assertError(ApolloHttpException.class); - - ApolloHttpException e = (ApolloHttpException) errorRef.get(); - assertThat(e.code()).isEqualTo(401); - assertThat(e.message()).isEqualTo("Client Error"); - assertThat(errorResponse.get()).isEqualTo("Unauthorized request!"); - assertThat(e.getMessage()).isEqualTo("HTTP 401 Client Error"); - } - - @Test public void httpExceptionPrefetch() throws Exception { - server.enqueue(new MockResponse().setResponseCode(401).setBody("Unauthorized request!")); - Rx2Apollo - .from(apolloClient.prefetch(emptyQuery)) - .test() - .awaitDone(timeoutSeconds, TimeUnit.SECONDS) - .assertNoValues() - .assertError(ApolloHttpException.class); - } - - @Test public void testTimeoutException() throws Exception { - Rx2Apollo - .from(apolloClient.query(emptyQuery)) - .test() - .awaitDone(timeoutSeconds * 2, TimeUnit.SECONDS) - .assertNoValues() - .assertError(new Predicate() { - @Override public boolean test(Throwable throwable) throws Exception { - ApolloNetworkException e = (ApolloNetworkException) throwable; - assertThat(e.getMessage()).isEqualTo("Failed to execute http call"); - assertThat(e.getCause().getClass()).isEqualTo(SocketTimeoutException.class); - return true; - } - }); - } - - @Test public void testTimeoutExceptionPrefetch() throws Exception { - Rx2Apollo - .from(apolloClient.prefetch(emptyQuery)) - .test() - .awaitDone(timeoutSeconds * 2, TimeUnit.SECONDS) - .assertNoValues() - .assertError(new Predicate() { - @Override public boolean test(Throwable throwable) throws Exception { - ApolloNetworkException e = (ApolloNetworkException) throwable; - assertThat(e.getMessage()).isEqualTo("Failed to execute http call"); - assertThat(e.getCause().getClass()).isEqualTo(SocketTimeoutException.class); - return true; - } - }); - } - - @Test public void testParseException() throws Exception { - server.enqueue(new MockResponse().setBody("Noise")); - Rx2Apollo - .from(apolloClient.query(emptyQuery)) - .test() - .awaitDone(timeoutSeconds, TimeUnit.SECONDS) - .assertNoValues() - .assertError(new Predicate() { - @Override public boolean test(Throwable throwable) throws Exception { - ApolloParseException e = (ApolloParseException) throwable; - assertThat(e.getMessage()).isEqualTo("Failed to parse http response"); - assertThat(e.getCause().getClass()).isEqualTo(JsonEncodingException.class); - return true; - } - }); - } -} diff --git a/apollo-runtime/src/test/java/com/apollographql/apollo/internal/ResponseFetcherTest.java b/apollo-runtime/src/test/java/com/apollographql/apollo/internal/ResponseFetcherTest.java deleted file mode 100644 index a1129cfaa15..00000000000 --- a/apollo-runtime/src/test/java/com/apollographql/apollo/internal/ResponseFetcherTest.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.apollographql.apollo.internal; - -import com.apollographql.apollo.ApolloClient; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.cache.http.HttpCachePolicy; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseReader; -import okhttp3.OkHttpClient; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.junit.Before; -import org.junit.Test; - -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.CACHE_FIRST; -import static com.apollographql.apollo.fetcher.ApolloResponseFetchers.NETWORK_ONLY; -import static com.google.common.truth.Truth.assertThat; - -public class ResponseFetcherTest { - private OkHttpClient okHttpClient; - private Query emptyQuery; - - @Before public void setUp() { - okHttpClient = new OkHttpClient.Builder().build(); - - emptyQuery = new Query() { - OperationName operationName = new OperationName() { - @Override public String name() { - return "emptyQuery"; - } - }; - @Override public String queryDocument() { - return ""; - } - - @Override public Variables variables() { - return EMPTY_VARIABLES; - } - - @Override public ResponseFieldMapper responseFieldMapper() { - return new ResponseFieldMapper() { - @Override public Data map(ResponseReader responseReader) { - return null; - } - }; - } - - @NotNull @Override public OperationName name() { - return operationName; - } - - @NotNull @Override public String operationId() { - return ""; - } - - @Override public Object wrapData(Data data) { - return data; - } - - @NotNull @Override public Response parse(@NotNull BufferedSource source) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull BufferedSource source, @NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull ByteString byteString) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull ByteString byteString, @NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public ByteString composeRequestBody( - boolean autoPersistQueries, - boolean withQueryDocument, - @NotNull ScalarTypeAdapters scalarTypeAdapters - ) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - @NotNull @Override public ByteString composeRequestBody(@NotNull ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull @Override public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - }; - } - - @Test public void setDefaultCachePolicy() { - ApolloClient apolloClient = ApolloClient.builder() - .serverUrl("http://google.com") - .okHttpClient(okHttpClient) - .defaultHttpCachePolicy(HttpCachePolicy.CACHE_ONLY) - .defaultResponseFetcher(NETWORK_ONLY) - .build(); - - RealApolloCall realApolloCall = (RealApolloCall) apolloClient.query(emptyQuery); - assertThat(realApolloCall.httpCachePolicy.fetchStrategy).isEqualTo(HttpCachePolicy.FetchStrategy.CACHE_ONLY); - assertThat(realApolloCall.responseFetcher).isEqualTo(NETWORK_ONLY); - } - - @Test public void defaultCacheControl() { - ApolloClient apolloClient = ApolloClient.builder() - .serverUrl("http://google.com") - .okHttpClient(okHttpClient) - .build(); - - RealApolloCall realApolloCall = (RealApolloCall) apolloClient.query(emptyQuery); - assertThat(realApolloCall.httpCachePolicy.fetchStrategy).isEqualTo(HttpCachePolicy.FetchStrategy.NETWORK_ONLY); - assertThat(realApolloCall.responseFetcher).isEqualTo(CACHE_FIRST); - } -} diff --git a/apollo-runtime/src/test/java/com/apollographql/apollo/internal/interceptor/ApolloAutoPersistedOperationInterceptorTest.java b/apollo-runtime/src/test/java/com/apollographql/apollo/internal/interceptor/ApolloAutoPersistedOperationInterceptorTest.java deleted file mode 100644 index 8a545cbb903..00000000000 --- a/apollo-runtime/src/test/java/com/apollographql/apollo/internal/interceptor/ApolloAutoPersistedOperationInterceptorTest.java +++ /dev/null @@ -1,388 +0,0 @@ -package com.apollographql.apollo.internal.interceptor; - -import com.apollographql.apollo.api.Error; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.cache.normalized.Record; -import com.apollographql.apollo.interceptor.ApolloAutoPersistedOperationInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import com.apollographql.apollo.interceptor.ApolloInterceptorChain; -import okhttp3.MediaType; -import okhttp3.Protocol; -import okhttp3.Request; -import okhttp3.Response; -import okhttp3.ResponseBody; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -import java.util.Collections; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.AbstractExecutorService; -import java.util.concurrent.Executor; -import java.util.concurrent.TimeUnit; - -import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -public class ApolloAutoPersistedOperationInterceptorTest { - private ApolloAutoPersistedOperationInterceptor interceptor = - new ApolloAutoPersistedOperationInterceptor(new ApolloLogger(null), false); - - private ApolloAutoPersistedOperationInterceptor interceptorWithGetMethod = - new ApolloAutoPersistedOperationInterceptor(new ApolloLogger(null), true); - - private ApolloInterceptor.InterceptorRequest request = ApolloInterceptor.InterceptorRequest.builder(new MockOperation()) - .autoPersistQueries(true) - .build(); - - @Test - public void initialRequestWithoutQueryDocument() { - ApolloInterceptorChain chain = mock(ApolloInterceptorChain.class); - - interceptor.interceptAsync(request, chain, new TrampolineExecutor(), mock(ApolloInterceptor.CallBack.class)); - - ArgumentCaptor requestArgumentCaptor = - ArgumentCaptor.forClass(ApolloInterceptor.InterceptorRequest.class); - verify(chain).proceedAsync(requestArgumentCaptor.capture(), any(Executor.class), - any(ApolloInterceptor.CallBack.class)); - - assertThat(requestArgumentCaptor.getValue().sendQueryDocument).isFalse(); - assertThat(requestArgumentCaptor.getValue().useHttpGetMethodForQueries).isFalse(); - assertThat(requestArgumentCaptor.getValue().autoPersistQueries).isTrue(); - } - - @Test - public void initialRequestWithGetMethodForPersistedQueries() { - ApolloInterceptorChain chain = mock(ApolloInterceptorChain.class); - - interceptorWithGetMethod.interceptAsync(request, chain, new TrampolineExecutor(), mock(ApolloInterceptor.CallBack.class)); - - ArgumentCaptor requestArgumentCaptor = - ArgumentCaptor.forClass(ApolloInterceptor.InterceptorRequest.class); - verify(chain).proceedAsync(requestArgumentCaptor.capture(), any(Executor.class), - any(ApolloInterceptor.CallBack.class)); - - assertThat(requestArgumentCaptor.getValue().sendQueryDocument).isFalse(); - assertThat(requestArgumentCaptor.getValue().useHttpGetMethodForQueries).isTrue(); - assertThat(requestArgumentCaptor.getValue().autoPersistQueries).isTrue(); - } - - @Test - public void onPersistedQueryNotFoundErrorRequestWithQueryDocument() { - ApolloInterceptorChainAdapter chain = new ApolloInterceptorChainAdapter() { - @Override - public void proceedAsync(@NotNull ApolloInterceptor.InterceptorRequest request, @NotNull Executor dispatcher, - @NotNull ApolloInterceptor.CallBack callBack) { - super.proceedAsync(request, dispatcher, callBack); - if (proceedAsyncInvocationCount == 1) { - assertThat(request.sendQueryDocument).isFalse(); - assertThat(request.autoPersistQueries).isTrue(); - callBack.onResponse( - new ApolloInterceptor.InterceptorResponse( - mockHttpResponse(), - com.apollographql.apollo.api.Response.builder(new MockOperation()) - .errors( - Collections.singletonList( - new Error("PersistedQueryNotFound", Collections.emptyList(), Collections.emptyMap()) - ) - ) - .build(), - Collections.emptyList() - ) - ); - } else if (proceedAsyncInvocationCount == 2) { - assertThat(request.sendQueryDocument).isTrue(); - assertThat(request.autoPersistQueries).isTrue(); - callBack.onResponse( - new ApolloInterceptor.InterceptorResponse( - mockHttpResponse(), - com.apollographql.apollo.api.Response.builder(new MockOperation()) - .data(new MockOperation.Data()) - .build(), - Collections.emptyList() - ) - ); - } else { - fail("expected only 2 invocation first without query document, second with it"); - } - } - }; - ApolloInterceptor.CallBack interceptorCallBack = mock(ApolloInterceptor.CallBack.class); - - interceptor.interceptAsync(request, chain, new TrampolineExecutor(), interceptorCallBack); - - assertThat(chain.proceedAsyncInvocationCount).isEqualTo(2); - - ArgumentCaptor interceptorResponseArgumentCaptor = - ArgumentCaptor.forClass(ApolloInterceptor.InterceptorResponse.class); - verify(interceptorCallBack).onResponse(interceptorResponseArgumentCaptor.capture()); - assertThat(interceptorResponseArgumentCaptor.getValue().parsedResponse.get().hasErrors()).isFalse(); - assertThat(interceptorResponseArgumentCaptor.getValue().parsedResponse.get().getData()).isNotNull(); - } - - @Test - public void onPersistedQueryNotSupportedErrorRequestWithQueryDocument() { - ApolloInterceptorChainAdapter chain = new ApolloInterceptorChainAdapter() { - @Override - public void proceedAsync(@NotNull ApolloInterceptor.InterceptorRequest request, @NotNull Executor dispatcher, - @NotNull ApolloInterceptor.CallBack callBack) { - super.proceedAsync(request, dispatcher, callBack); - if (proceedAsyncInvocationCount == 1) { - assertThat(request.sendQueryDocument).isFalse(); - assertThat(request.autoPersistQueries).isTrue(); - callBack.onResponse( - new ApolloInterceptor.InterceptorResponse( - mockHttpResponse(), - com.apollographql.apollo.api.Response.builder(new MockOperation()) - .errors( - Collections.singletonList( - new Error("PersistedQueryNotSupported", Collections.emptyList(), Collections.emptyMap()) - ) - ) - .build(), - Collections.emptyList() - ) - ); - } else if (proceedAsyncInvocationCount == 2) { - assertThat(request.sendQueryDocument).isTrue(); - assertThat(request.autoPersistQueries).isTrue(); - callBack.onResponse( - new ApolloInterceptor.InterceptorResponse( - mockHttpResponse(), - com.apollographql.apollo.api.Response.builder(new MockOperation()) - .data(new MockOperation.Data()) - .build(), - Collections.emptyList() - ) - ); - } else { - fail("expected only 2 invocation first without query document, second with it"); - } - } - }; - ApolloInterceptor.CallBack interceptorCallBack = mock(ApolloInterceptor.CallBack.class); - - interceptor.interceptAsync(request, chain, new TrampolineExecutor(), interceptorCallBack); - - assertThat(chain.proceedAsyncInvocationCount).isEqualTo(2); - - ArgumentCaptor interceptorResponseArgumentCaptor = - ArgumentCaptor.forClass(ApolloInterceptor.InterceptorResponse.class); - verify(interceptorCallBack).onResponse(interceptorResponseArgumentCaptor.capture()); - assertThat(interceptorResponseArgumentCaptor.getValue().parsedResponse.get().hasErrors()).isFalse(); - assertThat(interceptorResponseArgumentCaptor.getValue().parsedResponse.get().getData()).isNotNull(); - } - - @Test - public void onNonPersistedQueryErrorOriginalCallbackCalled() { - ApolloInterceptorChain chain = mock(ApolloInterceptorChain.class); - doAnswer(new Answer() { - @Override public Object answer(InvocationOnMock invocation) throws Throwable { - ((ApolloInterceptor.CallBack) invocation.getArguments()[2]).onResponse( - new ApolloInterceptor.InterceptorResponse( - mockHttpResponse(), - com.apollographql.apollo.api.Response.builder(new MockOperation()) - .errors( - Collections.singletonList( - new Error("SomeOtherError", Collections.emptyList(), Collections.emptyMap()) - ) - ) - .build(), - Collections.emptyList() - ) - ); - return null; - } - }).when(chain).proceedAsync( - any(ApolloInterceptor.InterceptorRequest.class), - any(Executor.class), - any(ApolloInterceptor.CallBack.class) - ); - - ApolloInterceptor.CallBack interceptorCallBack = mock(ApolloInterceptor.CallBack.class); - - interceptor.interceptAsync(request, chain, new TrampolineExecutor(), interceptorCallBack); - - verify(chain).proceedAsync(any(ApolloInterceptor.InterceptorRequest.class), any(Executor.class), - any(ApolloInterceptor.CallBack.class)); - - ArgumentCaptor interceptorResponseArgumentCaptor = - ArgumentCaptor.forClass(ApolloInterceptor.InterceptorResponse.class); - verify(interceptorCallBack).onResponse(interceptorResponseArgumentCaptor.capture()); - assertThat(interceptorResponseArgumentCaptor.getValue().parsedResponse.get().hasErrors()).isTrue(); - } - - @Test - public void onPersistedQueryFoundCallbackCalled() { - ApolloInterceptorChain chain = mock(ApolloInterceptorChain.class); - doAnswer(new Answer() { - @Override public Object answer(InvocationOnMock invocation) throws Throwable { - ((ApolloInterceptor.CallBack) invocation.getArguments()[2]).onResponse( - new ApolloInterceptor.InterceptorResponse( - mockHttpResponse(), - com.apollographql.apollo.api.Response.builder(new MockOperation()) - .data(new MockOperation.Data()) - .build(), - Collections.emptyList() - ) - ); - return null; - } - }).when(chain).proceedAsync( - any(ApolloInterceptor.InterceptorRequest.class), - any(Executor.class), - any(ApolloInterceptor.CallBack.class) - ); - - ApolloInterceptor.CallBack interceptorCallBack = mock(ApolloInterceptor.CallBack.class); - - interceptor.interceptAsync(request, chain, new TrampolineExecutor(), interceptorCallBack); - - verify(chain).proceedAsync(any(ApolloInterceptor.InterceptorRequest.class), any(Executor.class), - any(ApolloInterceptor.CallBack.class)); - - ArgumentCaptor interceptorResponseArgumentCaptor = - ArgumentCaptor.forClass(ApolloInterceptor.InterceptorResponse.class); - verify(interceptorCallBack).onResponse(interceptorResponseArgumentCaptor.capture()); - assertThat(interceptorResponseArgumentCaptor.getValue().parsedResponse.get().getData()).isNotNull(); - assertThat(interceptorResponseArgumentCaptor.getValue().parsedResponse.get().hasErrors()).isFalse(); - } - - private Response mockHttpResponse() { - return new okhttp3.Response.Builder() - .request(new Request.Builder() - .url("https://localhost/") - .build()) - .protocol(Protocol.HTTP_2) - .code(200) - .message("Intercepted") - .body(ResponseBody.create(MediaType.parse("text/plain; charset=utf-8"), "fakeResponse")) - .build(); - } - - static class MockOperation implements Operation { - - @Override public String queryDocument() { - throw new UnsupportedOperationException(); - } - - @Override public Variables variables() { - throw new UnsupportedOperationException(); - } - - @Override public ResponseFieldMapper responseFieldMapper() { - throw new UnsupportedOperationException(); - } - - @Override public Data wrapData(Data data) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public OperationName name() { - return new OperationName() { - @Override public String name() { - return "MockOperation"; - } - }; - } - - @NotNull @Override public String operationId() { - return UUID.randomUUID().toString(); - } - - static class Data implements Operation.Data { - @Override public ResponseFieldMarshaller marshaller() { - throw new UnsupportedOperationException(); - } - } - - @NotNull @Override public com.apollographql.apollo.api.Response parse(@NotNull BufferedSource source) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public com.apollographql.apollo.api.Response parse( - @NotNull BufferedSource source, - @NotNull ScalarTypeAdapters scalarTypeAdapters - ) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public com.apollographql.apollo.api.Response parse(@NotNull ByteString byteString) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public com.apollographql.apollo.api.Response parse( - @NotNull ByteString byteString, - @NotNull ScalarTypeAdapters scalarTypeAdapters - ) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public ByteString composeRequestBody( - boolean autoPersistQueries, - boolean withQueryDocument, - @NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public ByteString composeRequestBody(@NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public ByteString composeRequestBody() { - throw new UnsupportedOperationException(); - } - } - - static class TrampolineExecutor extends AbstractExecutorService { - @Override public void shutdown() { - } - - @Override public List shutdownNow() { - return null; - } - - @Override public boolean isShutdown() { - return false; - } - - @Override public boolean isTerminated() { - return false; - } - - @Override public boolean awaitTermination(long l, TimeUnit timeUnit) { - return false; - } - - @Override public void execute(Runnable runnable) { - runnable.run(); - } - } - - static class ApolloInterceptorChainAdapter implements ApolloInterceptorChain { - int proceedAsyncInvocationCount; - - @Override - public void proceedAsync(@NotNull ApolloInterceptor.InterceptorRequest request, @NotNull Executor dispatcher, - @NotNull ApolloInterceptor.CallBack callBack) { - proceedAsyncInvocationCount++; - } - - @Override public void dispose() { - } - } -} diff --git a/apollo-runtime/src/test/java/com/apollographql/apollo/internal/interceptor/ApolloCacheInterceptorTest.java b/apollo-runtime/src/test/java/com/apollographql/apollo/internal/interceptor/ApolloCacheInterceptorTest.java deleted file mode 100644 index 20d7e69ee2a..00000000000 --- a/apollo-runtime/src/test/java/com/apollographql/apollo/internal/interceptor/ApolloCacheInterceptorTest.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.apollographql.apollo.internal.interceptor; - -import com.apollographql.apollo.Logger; -import com.apollographql.apollo.api.Error; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.internal.ApolloLogger; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.cache.ApolloCacheHeaders; -import com.apollographql.apollo.cache.CacheHeaders; -import com.apollographql.apollo.cache.normalized.ApolloStore; -import com.apollographql.apollo.cache.normalized.Record; -import com.apollographql.apollo.interceptor.ApolloInterceptor; -import okhttp3.MediaType; -import okhttp3.Protocol; -import okhttp3.Request; -import okhttp3.ResponseBody; -import okhttp3.mockwebserver.MockWebServer; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Set; -import java.util.concurrent.Executor; - -import static com.google.common.truth.Truth.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyZeroInteractions; -import static org.mockito.Mockito.when; - -public class ApolloCacheInterceptorTest { - private ApolloCacheInterceptor interceptor; - private ApolloStore apolloStore; - private Logger logger; - private okhttp3.Response okHttpResponse; - - @Rule public final MockWebServer server = new MockWebServer(); - - @Before - public void setUp() { - apolloStore = mock(ApolloStore.class); - logger = mock(Logger.class); - okHttpResponse = new okhttp3.Response.Builder() - .request(new Request.Builder().url(server.url("/")).build()) - .protocol(Protocol.HTTP_2) - .code(200) - .message("Intercepted") - .body(ResponseBody.create(MediaType.parse("text/plain; charset=utf-8"), "fakeResponse")) - .build(); - - interceptor = new ApolloCacheInterceptor( - apolloStore, - mock(ResponseFieldMapper.class), - mock(Executor.class), - new ApolloLogger(logger), - false - ); - } - - @Test - public void testDoesNotCacheErrorResponse() { - Operation operation = mock(Operation.class); - Error error = new Error("Error", Collections.emptyList(), Collections.emptyMap()); - ApolloInterceptor.InterceptorResponse networkResponse = new ApolloInterceptor.InterceptorResponse( - okHttpResponse, - com.apollographql.apollo.api.Response.builder(operation).errors(Collections.singletonList(error)).build(), - new ArrayList() - ); - ApolloInterceptor.InterceptorRequest request = ApolloInterceptor.InterceptorRequest.builder(operation).build(); - - Set cachedKeys = interceptor.cacheResponse(networkResponse, request); - - assertThat(cachedKeys).isEmpty(); - verifyZeroInteractions(apolloStore, logger); - } - - @Test - public void testCachesErrorResponseWhenStorePartialResponsesCacheHeaderPresent() { - Operation operation = mock(Operation.class); - Error error = new Error("Error", Collections.emptyList(), Collections.emptyMap()); - ApolloInterceptor.InterceptorResponse networkResponse = new ApolloInterceptor.InterceptorResponse( - okHttpResponse, - com.apollographql.apollo.api.Response.builder(operation).errors(Collections.singletonList(error)).build(), - new ArrayList() - ); - ApolloInterceptor.InterceptorRequest request = ApolloInterceptor.InterceptorRequest.builder(operation).cacheHeaders( - CacheHeaders.builder() - .addHeader(ApolloCacheHeaders.STORE_PARTIAL_RESPONSES, "true") - .build() - ).build(); - Set expectedCachedKeys = Collections.singleton("cacheKey"); - - when(apolloStore.writeTransaction(any())).thenReturn(expectedCachedKeys); - - Set cachedKeys = interceptor.cacheResponse(networkResponse, request); - - assertThat(cachedKeys).isEqualTo(expectedCachedKeys); - verify(apolloStore).writeTransaction(any()); - verifyZeroInteractions(logger); - } - - @Test - public void testDoesCachesNonErrorResponse() { - Operation operation = mock(Operation.class); - ApolloInterceptor.InterceptorResponse networkResponse = new ApolloInterceptor.InterceptorResponse( - okHttpResponse, - com.apollographql.apollo.api.Response.builder(operation).build(), - new ArrayList() - ); - ApolloInterceptor.InterceptorRequest request = ApolloInterceptor.InterceptorRequest.builder(operation).build(); - Set expectedCachedKeys = Collections.singleton("cacheKey"); - - when(apolloStore.writeTransaction(any())).thenReturn(expectedCachedKeys); - - Set cachedKeys = interceptor.cacheResponse(networkResponse, request); - - assertThat(cachedKeys).isEqualTo(expectedCachedKeys); - verify(apolloStore).writeTransaction(any()); - verifyZeroInteractions(logger); - } -} diff --git a/apollo-runtime/src/test/java/com/apollographql/apollo/internal/reader/ApolloCallTrackerTest.java b/apollo-runtime/src/test/java/com/apollographql/apollo/internal/reader/ApolloCallTrackerTest.java deleted file mode 100644 index 652a3c158b3..00000000000 --- a/apollo-runtime/src/test/java/com/apollographql/apollo/internal/reader/ApolloCallTrackerTest.java +++ /dev/null @@ -1,201 +0,0 @@ -package com.apollographql.apollo.internal.reader; - -import com.apollographql.apollo.ApolloClient; -import com.apollographql.apollo.IdleResourceCallback; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Query; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.OperationRequestBodyComposer; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.rx2.Rx2Apollo; -import okhttp3.Interceptor; -import okhttp3.OkHttpClient; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; -import java.util.concurrent.atomic.AtomicBoolean; - -import static com.google.common.truth.Truth.assertThat; - -public class ApolloCallTrackerTest { - private static final String SERVER_URL = "http://localhost:1234"; - private static final int TIMEOUT_SECONDS = 2; - private static final Query EMPTY_QUERY = new Query() { - - OperationName operationName = new OperationName() { - @Override public String name() { - return "EmptyQuery"; - } - }; - - @Override public String queryDocument() { - return ""; - } - - @Override public Variables variables() { - return EMPTY_VARIABLES; - } - - @Override public ResponseFieldMapper responseFieldMapper() { - return new ResponseFieldMapper() { - @Override public Data map(ResponseReader responseReader) { - return null; - } - }; - } - - @Override public Object wrapData(Data data) { - return data; - } - - @NotNull @Override public OperationName name() { - return operationName; - } - - @NotNull @Override public String operationId() { - return ""; - } - - @NotNull @Override public Response parse(@NotNull BufferedSource source) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull BufferedSource source, @NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull ByteString byteString) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull ByteString byteString, @NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public ByteString composeRequestBody( - boolean autoPersistQueries, - boolean withQueryDocument, - @NotNull ScalarTypeAdapters scalarTypeAdapters - ) { - return OperationRequestBodyComposer.compose(this, autoPersistQueries, withQueryDocument, scalarTypeAdapters); - } - - @NotNull @Override public ByteString composeRequestBody(@NotNull ScalarTypeAdapters scalarTypeAdapters) { - return OperationRequestBodyComposer.compose(this, false, true, scalarTypeAdapters); - } - - @NotNull @Override public ByteString composeRequestBody() { - return OperationRequestBodyComposer.compose(this, false, true, ScalarTypeAdapters.DEFAULT); - } - }; - - @Rule public final MockWebServer server = new MockWebServer(); - private List activeCallCounts; - private ApolloClient apolloClient; - - @Before - public void setUp() throws Exception { - activeCallCounts = new ArrayList<>(); - Interceptor interceptor = new Interceptor() { - @Override public okhttp3.Response intercept(Chain chain) throws IOException { - activeCallCounts.add(apolloClient.activeCallsCount()); - return chain.proceed(chain.request()); - } - }; - - OkHttpClient okHttpClient = new OkHttpClient.Builder() - .addInterceptor(interceptor) - .build(); - - apolloClient = ApolloClient.builder() - .serverUrl(SERVER_URL) - .okHttpClient(okHttpClient) - .build(); - } - - @Test - public void testRunningCallsCountWhenSyncPrefetchCallIsMade() throws InterruptedException { - assertThat(apolloClient.activeCallsCount()).isEqualTo(0); - Rx2Apollo - .from(apolloClient.prefetch(EMPTY_QUERY)) - .test() - .awaitDone(TIMEOUT_SECONDS, TimeUnit.SECONDS); - assertThat(activeCallCounts).isEqualTo(Collections.singletonList(1)); - assertThat(apolloClient.activeCallsCount()).isEqualTo(0); - } - - @Test - public void testRunningCallsCountWhenAsyncPrefetchCallIsMade() throws InterruptedException { - assertThat(apolloClient.activeCallsCount()).isEqualTo(0); - server.enqueue(createMockResponse()); - Rx2Apollo - .from(apolloClient.prefetch(EMPTY_QUERY)) - .test() - .awaitDone(TIMEOUT_SECONDS, TimeUnit.SECONDS); - assertThat(activeCallCounts).isEqualTo(Collections.singletonList(1)); - assertThat(apolloClient.activeCallsCount()).isEqualTo(0); - } - - @Test - public void testRunningCallsCountWhenAsyncApolloCallIsMade() throws InterruptedException { - assertThat(apolloClient.activeCallsCount()).isEqualTo(0); - server.enqueue(createMockResponse()); - Rx2Apollo - .from(apolloClient.query(EMPTY_QUERY)) - .test() - .awaitDone(TIMEOUT_SECONDS, TimeUnit.SECONDS); - assertThat(activeCallCounts).isEqualTo(Collections.singletonList(1)); - assertThat(apolloClient.activeCallsCount()).isEqualTo(0); - } - - @Test - public void testIdleCallBackIsInvokedWhenApolloClientBecomesIdle() throws InterruptedException, TimeoutException { - server.enqueue(createMockResponse()); - final AtomicBoolean idle = new AtomicBoolean(); - IdleResourceCallback idleResourceCallback = new IdleResourceCallback() { - @Override public void onIdle() { - idle.set(true); - } - }; - apolloClient.idleCallback(idleResourceCallback); - - assertThat(idle.get()).isFalse(); - Rx2Apollo - .from(apolloClient.query(EMPTY_QUERY)) - .test() - .awaitDone(TIMEOUT_SECONDS, TimeUnit.SECONDS); - assertThat(idle.get()).isTrue(); - } - - private MockResponse createMockResponse() { - return new MockResponse().setResponseCode(200).setBody(new StringBuilder() - .append("{") - .append(" \"errors\": [") - .append(" {") - .append(" \"message\": \"Cannot query field \\\"names\\\" on type \\\"Species\\\".\",") - .append(" \"locations\": [") - .append(" {") - .append(" \"line\": 3,") - .append(" \"column\": 5") - .append(" }") - .append(" ]") - .append(" }") - .append(" ]") - .append("}") - .toString()); - } -} diff --git a/apollo-runtime/src/test/java/com/apollographql/apollo/internal/subscription/SubscriptionAutoPersistTest.java b/apollo-runtime/src/test/java/com/apollographql/apollo/internal/subscription/SubscriptionAutoPersistTest.java deleted file mode 100644 index 1e98eb1d433..00000000000 --- a/apollo-runtime/src/test/java/com/apollographql/apollo/internal/subscription/SubscriptionAutoPersistTest.java +++ /dev/null @@ -1,273 +0,0 @@ -package com.apollographql.apollo.internal.subscription; - -import com.apollographql.apollo.api.CustomTypeAdapter; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ScalarType; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.Subscription; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.cache.normalized.ApolloStore; -import com.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; -import com.apollographql.apollo.subscription.OperationClientMessage; -import com.apollographql.apollo.subscription.OperationServerMessage; -import com.apollographql.apollo.subscription.SubscriptionConnectionParams; -import com.apollographql.apollo.subscription.SubscriptionConnectionParamsProvider; -import com.apollographql.apollo.subscription.SubscriptionManagerState; -import com.apollographql.apollo.subscription.SubscriptionTransport; -import kotlin.jvm.functions.Function0; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.junit.Before; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.Executor; - -import static com.google.common.truth.Truth.assertThat; - -public class SubscriptionAutoPersistTest { - private MockSubscriptionTransportFactory subscriptionTransportFactory; - private RealSubscriptionManager subscriptionManager; - private MockSubscription subscription = new MockSubscription("MockSubscription"); - private SubscriptionManagerCallbackAdapter callbackAdapter; - - @Before public void setUp() { - subscriptionTransportFactory = new MockSubscriptionTransportFactory(); - subscriptionManager = new RealSubscriptionManager(new ScalarTypeAdapters(Collections.>emptyMap()), - subscriptionTransportFactory, new SubscriptionConnectionParamsProvider.Const(new SubscriptionConnectionParams()), - new MockExecutor(), -1, new Function0>>() { - @Override public ResponseNormalizer> invoke() { - return ApolloStore.NO_APOLLO_STORE.networkResponseNormalizer(); - } - }, true); - assertThat(subscriptionTransportFactory.subscriptionTransport).isNotNull(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.DISCONNECTED); - - callbackAdapter = new SubscriptionManagerCallbackAdapter<>(); - subscriptionManager.subscribe(subscription, callbackAdapter); - subscriptionTransportFactory.callback.onConnected(); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionAcknowledge()); - assertStartMessage(false); - } - - @Test public void success() { - final UUID subscriptionId = new ArrayList<>(subscriptionManager.subscriptions.keySet()).get(0); - subscriptionTransportFactory.callback.onMessage( - new OperationServerMessage.Data(subscriptionId.toString(), Collections.emptyMap()) - ); - assertThat(callbackAdapter.response).isNotNull(); - } - - @Test public void protocolNegotiationErrorNotFound() { - final UUID subscriptionId = new ArrayList<>(subscriptionManager.subscriptions.keySet()).get(0); - subscriptionTransportFactory.callback.onMessage( - new OperationServerMessage.Error( - subscriptionId.toString(), - new UnmodifiableMapBuilder() - .put("message", RealSubscriptionManager.PROTOCOL_NEGOTIATION_ERROR_NOT_FOUND) - .build() - ) - ); - assertStartMessage(true); - } - - @Test public void protocolNegotiationErrorNotSupported() { - final UUID subscriptionId = new ArrayList<>(subscriptionManager.subscriptions.keySet()).get(0); - subscriptionTransportFactory.callback.onMessage( - new OperationServerMessage.Error( - subscriptionId.toString(), - new UnmodifiableMapBuilder() - .put("message", RealSubscriptionManager.PROTOCOL_NEGOTIATION_ERROR_NOT_SUPPORTED) - .build() - ) - ); - assertStartMessage(true); - } - - @Test public void unknownError() { - final UUID subscriptionId = new ArrayList<>(subscriptionManager.subscriptions.keySet()).get(0); - subscriptionTransportFactory.callback.onMessage( - new OperationServerMessage.Error( - subscriptionId.toString(), - new UnmodifiableMapBuilder() - .put("meh", "¯\\_(ツ)_/¯") - .build() - ) - ); - assertThat(callbackAdapter.error).isInstanceOf(ApolloSubscriptionServerException.class); - assertThat(((ApolloSubscriptionServerException) callbackAdapter.error).errorPayload).containsEntry("meh", "¯\\_(ツ)_/¯"); - } - - private void assertStartMessage(boolean isWriteDocument) { - final UUID subscriptionId = new ArrayList<>(subscriptionManager.subscriptions.keySet()).get(0); - if (isWriteDocument) { - assertThat(subscriptionTransportFactory.subscriptionTransport.lastSentMessage.toJsonString()).isEqualTo( - "" - + "{\"id\":\"" + subscriptionId.toString() + "\"," - + "\"type\":\"start\"," - + "\"payload\":{" - + "\"variables\":{}," - + "\"operationName\":\"SomeSubscription\"," - + "\"query\":\"subscription{\\ncommentAdded(repoFullName:\\\"repo\\\"){\\n__typename\\nid\\ncontent\\n}\\n}\"," - + "\"extensions\":{\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"MockSubscription\"}}}}" - ); - } else { - assertThat(subscriptionTransportFactory.subscriptionTransport.lastSentMessage.toJsonString()).isEqualTo( - "" - + "{\"id\":\"" + subscriptionId.toString() + "\"," - + "\"type\":\"start\"," - + "\"payload\":{" - + "\"variables\":{}," - + "\"operationName\":\"SomeSubscription\"," - + "\"extensions\":{\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"MockSubscription\"}}}}" - ); - } - } - - private static final class MockSubscriptionTransportFactory implements SubscriptionTransport.Factory { - MockSubscriptionTransport subscriptionTransport; - SubscriptionTransport.Callback callback; - - @Override public SubscriptionTransport create(@NotNull SubscriptionTransport.Callback callback) { - this.callback = callback; - return subscriptionTransport = new MockSubscriptionTransport(); - } - } - - private static final class MockSubscriptionTransport implements SubscriptionTransport { - volatile OperationClientMessage lastSentMessage; - - @Override public void connect() { - } - - @Override public void disconnect(OperationClientMessage message) { - } - - @Override public void send(OperationClientMessage message) { - lastSentMessage = message; - } - } - - private static final class MockExecutor implements Executor { - @Override public void execute(@NotNull Runnable command) { - command.run(); - } - } - - private static final class MockSubscription implements Subscription { - final String operationId; - - MockSubscription(String operationId) { - this.operationId = operationId; - } - - @Override public String queryDocument() { - return "subscription{\ncommentAdded(repoFullName:\"repo\"){\n__typename\nid\ncontent\n}\n}"; - } - - @Override public Variables variables() { - return EMPTY_VARIABLES; - } - - @Override public ResponseFieldMapper responseFieldMapper() { - return new ResponseFieldMapper() { - @Override public Data map(ResponseReader responseReader) { - return new Data() { - @Override public ResponseFieldMarshaller marshaller() { - throw new UnsupportedOperationException(); - } - }; - } - }; - } - - @Override public Data wrapData(Data data) { - return data; - } - - @NotNull @Override public OperationName name() { - return new OperationName() { - @Override public String name() { - return "SomeSubscription"; - } - }; - } - - @NotNull @Override public String operationId() { - return operationId; - } - - @NotNull @Override public Response parse(@NotNull BufferedSource source) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull BufferedSource source, @NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull ByteString byteString) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull ByteString byteString, @NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public ByteString composeRequestBody( - boolean autoPersistQueries, - boolean withQueryDocument, - @NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public ByteString composeRequestBody(@NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public ByteString composeRequestBody() { - throw new UnsupportedOperationException(); - } - } - - private static class SubscriptionManagerCallbackAdapter implements SubscriptionManager.Callback { - volatile SubscriptionResponse response; - volatile ApolloSubscriptionException error; - volatile Throwable networkError; - volatile boolean completed; - volatile boolean terminated; - volatile boolean connected; - - @Override public void onResponse(@NotNull SubscriptionResponse response) { - this.response = response; - } - - @Override public void onError(@NotNull ApolloSubscriptionException error) { - this.error = error; - } - - @Override public void onNetworkError(@NotNull Throwable t) { - networkError = t; - } - - @Override public void onCompleted() { - completed = true; - } - - @Override public void onTerminated() { - terminated = true; - } - - @Override public void onConnected() { - connected = true; - } - } -} diff --git a/apollo-runtime/src/test/java/com/apollographql/apollo/internal/subscription/SubscriptionManagerTest.java b/apollo-runtime/src/test/java/com/apollographql/apollo/internal/subscription/SubscriptionManagerTest.java deleted file mode 100644 index 52cf631cd1e..00000000000 --- a/apollo-runtime/src/test/java/com/apollographql/apollo/internal/subscription/SubscriptionManagerTest.java +++ /dev/null @@ -1,511 +0,0 @@ -package com.apollographql.apollo.internal.subscription; - -import com.apollographql.apollo.api.CustomTypeAdapter; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.OperationName; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.api.ScalarType; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.Subscription; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import com.apollographql.apollo.api.internal.ResponseFieldMarshaller; -import com.apollographql.apollo.api.internal.ResponseReader; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import com.apollographql.apollo.cache.normalized.ApolloStore; -import com.apollographql.apollo.cache.normalized.internal.ResponseNormalizer; -import com.apollographql.apollo.subscription.OnSubscriptionManagerStateChangeListener; -import com.apollographql.apollo.subscription.OperationClientMessage; -import com.apollographql.apollo.subscription.OperationServerMessage; -import com.apollographql.apollo.subscription.SubscriptionConnectionParams; -import com.apollographql.apollo.subscription.SubscriptionConnectionParamsProvider; -import com.apollographql.apollo.subscription.SubscriptionManagerState; -import com.apollographql.apollo.subscription.SubscriptionTransport; -import kotlin.jvm.functions.Function0; -import okio.BufferedSource; -import okio.ByteString; -import org.jetbrains.annotations.NotNull; -import org.junit.Before; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.Executor; -import java.util.concurrent.TimeUnit; - -import static com.google.common.truth.Truth.assertThat; - -public class SubscriptionManagerTest { - private final long connectionHeartbeatTimeoutMs = TimeUnit.SECONDS.toMillis(1); - private MockSubscriptionTransportFactory subscriptionTransportFactory; - private RealSubscriptionManager subscriptionManager; - private MockSubscription subscription1 = new MockSubscription("MockSubscription1"); - private MockSubscription subscription2 = new MockSubscription("MockSubscription2"); - private SubscriptionManagerOnStateChangeListener onStateChangeListener = new SubscriptionManagerOnStateChangeListener(); - - @Before public void setUp() { - subscriptionTransportFactory = new MockSubscriptionTransportFactory(); - subscriptionManager = new RealSubscriptionManager(new ScalarTypeAdapters(Collections.>emptyMap()), - subscriptionTransportFactory, new SubscriptionConnectionParamsProvider.Const(new SubscriptionConnectionParams()), - new MockExecutor(), connectionHeartbeatTimeoutMs, new Function0>>() { - @Override public ResponseNormalizer> invoke() { - return ApolloStore.NO_APOLLO_STORE.networkResponseNormalizer(); - } - }, false); - subscriptionManager.addOnStateChangeListener(onStateChangeListener); - assertThat(subscriptionTransportFactory.subscriptionTransport).isNotNull(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.DISCONNECTED); - } - - @Test public void connecting() { - subscriptionManager.subscribe(subscription1, new SubscriptionManagerCallbackAdapter()); - - assertThat(subscriptionTransportFactory.subscriptionTransport).isNotNull(); - assertThat(subscriptionTransportFactory.subscriptionTransport.connected).isTrue(); - assertThat(subscriptionTransportFactory.subscriptionTransport.lastSentMessage).isNull(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.CONNECTING); - - subscriptionManager.subscribe(subscription2, new SubscriptionManagerCallbackAdapter()); - assertThat(subscriptionTransportFactory.subscriptionTransport.connected).isTrue(); - assertThat(subscriptionTransportFactory.subscriptionTransport.lastSentMessage).isNull(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.CONNECTING); - - assertThat(subscriptionManager.subscriptions).hasSize(2); - - assertThat(subscriptionManager.timer.tasks).isEmpty(); - } - - @Test public void connected() { - subscriptionManager.subscribe(subscription1, new SubscriptionManagerCallbackAdapter()); - subscriptionTransportFactory.callback.onConnected(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.CONNECTED); - assertThat(subscriptionTransportFactory.subscriptionTransport.lastSentMessage).isInstanceOf(OperationClientMessage.Init.class); - assertThat(subscriptionManager.timer.tasks).containsKey(RealSubscriptionManager.CONNECTION_ACKNOWLEDGE_TIMEOUT_TIMER_TASK_ID); - } - - @Test public void active() { - subscriptionManager.subscribe(subscription1, new SubscriptionManagerCallbackAdapter()); - subscriptionTransportFactory.callback.onConnected(); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionAcknowledge()); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.ACTIVE); - assertThat(subscriptionTransportFactory.subscriptionTransport.lastSentMessage).isInstanceOf(OperationClientMessage.Start.class); - assertThat(subscriptionManager.timer.tasks).isEmpty(); - } - - @Test public void disconnected() throws Exception { - subscriptionManager.subscribe(subscription1, new SubscriptionManagerCallbackAdapter()); - subscriptionTransportFactory.callback.onConnected(); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionAcknowledge()); - subscriptionManager.unsubscribe(subscription1); - - assertThat(subscriptionManager.subscriptions).isEmpty(); - assertThat(subscriptionTransportFactory.subscriptionTransport.lastSentMessage).isInstanceOf(OperationClientMessage.Stop.class); - - assertThat(subscriptionManager.timer.tasks).containsKey(RealSubscriptionManager.INACTIVITY_TIMEOUT_TIMER_TASK_ID); - - onStateChangeListener.awaitState(SubscriptionManagerState.DISCONNECTED, RealSubscriptionManager - .INACTIVITY_TIMEOUT + 800, TimeUnit.MILLISECONDS); - - assertThat(subscriptionTransportFactory.subscriptionTransport.disconnectMessage).isInstanceOf(OperationClientMessage.Terminate.class); - assertThat(subscriptionManager.timer.tasks).isEmpty(); - } - - @Test public void reconnect() throws Exception { - subscriptionManager.subscribe(subscription1, new SubscriptionManagerCallbackAdapter()); - subscriptionTransportFactory.callback.onConnected(); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionAcknowledge()); - subscriptionManager.unsubscribe(subscription1); - - onStateChangeListener.awaitState(SubscriptionManagerState.DISCONNECTED, RealSubscriptionManager - .INACTIVITY_TIMEOUT + 800, TimeUnit.MILLISECONDS); - - subscriptionManager.subscribe(subscription2, new SubscriptionManagerCallbackAdapter()); - subscriptionTransportFactory.callback.onConnected(); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionAcknowledge()); - - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.ACTIVE); - assertThat(subscriptionTransportFactory.subscriptionTransport.lastSentMessage).isInstanceOf(OperationClientMessage.Start.class); - assertThat(subscriptionManager.timer.tasks).isEmpty(); - } - - @Test public void disconnectedOnConnectionAcknowledgeTimeout() throws Exception { - subscriptionManager.subscribe(subscription1, new SubscriptionManagerCallbackAdapter()); - subscriptionTransportFactory.callback.onConnected(); - - assertThat(subscriptionManager.timer.tasks).containsKey(RealSubscriptionManager.CONNECTION_ACKNOWLEDGE_TIMEOUT_TIMER_TASK_ID); - - onStateChangeListener.awaitState(SubscriptionManagerState.DISCONNECTED, RealSubscriptionManager - .CONNECTION_ACKNOWLEDGE_TIMEOUT + 800, TimeUnit.MILLISECONDS); - - assertThat(subscriptionTransportFactory.subscriptionTransport.disconnectMessage).isInstanceOf(OperationClientMessage.Terminate.class); - assertThat(subscriptionManager.timer.tasks).isEmpty(); - assertThat(subscriptionManager.subscriptions).isEmpty(); - } - - @Test public void disconnectedOnTransportFailure() { - SubscriptionManagerCallbackAdapter subscriptionManagerCallback1 = new SubscriptionManagerCallbackAdapter<>(); - subscriptionManager.subscribe(subscription1, subscriptionManagerCallback1); - SubscriptionManagerCallbackAdapter subscriptionManagerCallback2 = new SubscriptionManagerCallbackAdapter<>(); - subscriptionManager.subscribe(subscription2, subscriptionManagerCallback2); - subscriptionTransportFactory.callback.onConnected(); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionAcknowledge()); - subscriptionTransportFactory.callback.onFailure(new UnsupportedOperationException()); - assertThat(subscriptionManagerCallback1.networkError).isInstanceOf(UnsupportedOperationException.class); - assertThat(subscriptionManagerCallback2.networkError).isInstanceOf(UnsupportedOperationException.class); - assertThat(subscriptionTransportFactory.subscriptionTransport.disconnectMessage).isInstanceOf(OperationClientMessage.Terminate.class); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.DISCONNECTED); - assertThat(subscriptionManager.timer.tasks).isEmpty(); - assertThat(subscriptionManager.subscriptions).isEmpty(); - } - - @Test public void unsubscribeOnComplete() { - SubscriptionManagerCallbackAdapter subscriptionManagerCallback1 = new SubscriptionManagerCallbackAdapter<>(); - subscriptionManager.subscribe(subscription1, subscriptionManagerCallback1); - SubscriptionManagerCallbackAdapter subscriptionManagerCallback2 = new SubscriptionManagerCallbackAdapter<>(); - subscriptionManager.subscribe(subscription2, subscriptionManagerCallback2); - - final List subscriptionIds = new ArrayList<>(subscriptionManager.subscriptions.keySet()); - - subscriptionTransportFactory.callback.onConnected(); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionAcknowledge()); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.Complete(subscriptionIds.get(0).toString())); - assertThat(subscriptionManagerCallback1.completed).isTrue(); - - assertThat(subscriptionManager.subscriptions).hasSize(1); - assertThat(subscriptionManagerCallback2.completed).isFalse(); - } - - @Test public void unsubscribeOnError() { - SubscriptionManagerCallbackAdapter subscriptionManagerCallback1 = new SubscriptionManagerCallbackAdapter<>(); - subscriptionManager.subscribe(subscription1, subscriptionManagerCallback1); - SubscriptionManagerCallbackAdapter subscriptionManagerCallback2 = new SubscriptionManagerCallbackAdapter<>(); - subscriptionManager.subscribe(subscription2, subscriptionManagerCallback2); - - final List subscriptionIds = new ArrayList<>(subscriptionManager.subscriptions.keySet()); - - subscriptionTransportFactory.callback.onConnected(); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionAcknowledge()); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.Error(subscriptionIds.get(0).toString(), - new UnmodifiableMapBuilder().put("key1", "value1").put("key2", "value2").build())); - - assertThat(subscriptionManagerCallback1.error).isInstanceOf(ApolloSubscriptionServerException.class); - assertThat(((ApolloSubscriptionServerException) subscriptionManagerCallback1.error).errorPayload).containsEntry("key1", "value1"); - assertThat(((ApolloSubscriptionServerException) subscriptionManagerCallback1.error).errorPayload).containsEntry("key2", "value2"); - - assertThat(subscriptionManager.subscriptions).hasSize(1); - assertThat(subscriptionManagerCallback2.completed).isFalse(); - } - - @Test public void notifyOnData() { - SubscriptionManagerCallbackAdapter subscriptionManagerCallback1 = new SubscriptionManagerCallbackAdapter<>(); - subscriptionManager.subscribe(subscription1, subscriptionManagerCallback1); - - final List subscriptionIds = new ArrayList<>(subscriptionManager.subscriptions.keySet()); - - subscriptionTransportFactory.callback.onConnected(); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionAcknowledge()); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.Data(subscriptionIds.get(0).toString(), - Collections.emptyMap())); - - assertThat(subscriptionManagerCallback1.response).isNotNull(); - } - - @Test public void notifyOnConnected() { - SubscriptionManagerCallbackAdapter subscriptionManagerCallback1 = new SubscriptionManagerCallbackAdapter<>(); - subscriptionManager.subscribe(subscription1, subscriptionManagerCallback1); - - subscriptionTransportFactory.callback.onConnected(); - assertThat(subscriptionManagerCallback1.connected).isTrue(); - } - - @Test public void duplicateSubscriptions() { - SubscriptionManagerCallbackAdapter subscriptionManagerCallback1 = new SubscriptionManagerCallbackAdapter<>(); - subscriptionManager.subscribe(subscription1, subscriptionManagerCallback1); - SubscriptionManagerCallbackAdapter subscriptionManagerCallback2 = new SubscriptionManagerCallbackAdapter<>(); - subscriptionManager.subscribe(subscription1, subscriptionManagerCallback2); - - assertThat(subscriptionManagerCallback2.error).isNull(); - } - - @Test public void reconnectingAfterHeartbeatTimeout() throws Exception { - subscriptionManager.subscribe(subscription1, new SubscriptionManagerCallbackAdapter()); - - subscriptionTransportFactory.callback.onConnected(); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionAcknowledge()); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionKeepAlive()); - - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.ACTIVE); - assertThat(subscriptionManager.timer.tasks).containsKey(RealSubscriptionManager.CONNECTION_KEEP_ALIVE_TIMEOUT_TIMER_TASK_ID); - - onStateChangeListener.awaitState(SubscriptionManagerState.DISCONNECTED, connectionHeartbeatTimeoutMs + 800, TimeUnit.MILLISECONDS); - onStateChangeListener.awaitState(SubscriptionManagerState.CONNECTING, 800, TimeUnit.MILLISECONDS); - } - - @Test public void startWhenDisconnected() { - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.DISCONNECTED); - - subscriptionManager.start(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.DISCONNECTED); - } - - @Test public void startWhenConnected() { - subscriptionManager.subscribe(subscription1, new SubscriptionManagerCallbackAdapter()); - subscriptionTransportFactory.callback.onConnected(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.CONNECTED); - - subscriptionManager.start(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.CONNECTED); - } - - @Test public void startWhenActive() { - subscriptionManager.subscribe(subscription1, new SubscriptionManagerCallbackAdapter()); - subscriptionTransportFactory.callback.onConnected(); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionAcknowledge()); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.ACTIVE); - - subscriptionManager.start(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.ACTIVE); - } - - @Test public void startWhenStopped() { - subscriptionManager.subscribe(subscription1, new SubscriptionManagerCallbackAdapter()); - subscriptionTransportFactory.callback.onConnected(); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionAcknowledge()); - subscriptionManager.stop(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.STOPPED); - - subscriptionManager.start(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.DISCONNECTED); - } - - @Test public void stopWhenDisconnected() { - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.DISCONNECTED); - subscriptionManager.stop(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.STOPPED); - } - - @Test public void stopWhenConnected() { - subscriptionManager.subscribe(subscription1, new SubscriptionManagerCallbackAdapter()); - subscriptionManager.subscribe(subscription2, new SubscriptionManagerCallbackAdapter()); - subscriptionTransportFactory.callback.onConnected(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.CONNECTED); - - subscriptionManager.stop(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.STOPPED); - } - - @Test public void stopWhenActive() { - subscriptionManager.subscribe(subscription1, new SubscriptionManagerCallbackAdapter()); - subscriptionTransportFactory.callback.onConnected(); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionAcknowledge()); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.ACTIVE); - - subscriptionManager.stop(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.STOPPED); - } - - @Test public void stopWhenStopped() { - subscriptionManager.subscribe(subscription1, new SubscriptionManagerCallbackAdapter()); - subscriptionTransportFactory.callback.onConnected(); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionAcknowledge()); - subscriptionManager.stop(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.STOPPED); - - subscriptionManager.stop(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.STOPPED); - } - - @Test public void subscriptionWhenStopped() { - subscriptionManager.stop(); - SubscriptionManagerCallbackAdapter subscriptionManagerCallback = new SubscriptionManagerCallbackAdapter<>(); - subscriptionManager.subscribe(subscription1, subscriptionManagerCallback); - - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.STOPPED); - assertThat(subscriptionManagerCallback.error).isInstanceOf(ApolloSubscriptionException.class); - assertThat(subscriptionManagerCallback.error.getMessage()).startsWith("Illegal state: STOPPED"); - } - - @Test public void connectionTerminated() { - SubscriptionManagerCallbackAdapter subscriptionManagerCallback = new SubscriptionManagerCallbackAdapter<>(); - subscriptionManager.subscribe(subscription1, subscriptionManagerCallback); - - subscriptionTransportFactory.callback.onConnected(); - subscriptionTransportFactory.callback.onMessage(new OperationServerMessage.ConnectionAcknowledge()); - - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.ACTIVE); - - subscriptionTransportFactory.callback.onClosed(); - assertThat(subscriptionManager.state).isEqualTo(SubscriptionManagerState.DISCONNECTED); - assertThat(subscriptionManagerCallback.terminated).isTrue(); - } - - private static final class MockSubscriptionTransportFactory implements SubscriptionTransport.Factory { - MockSubscriptionTransport subscriptionTransport; - SubscriptionTransport.Callback callback; - - @Override public SubscriptionTransport create(@NotNull SubscriptionTransport.Callback callback) { - this.callback = callback; - return subscriptionTransport = new MockSubscriptionTransport(); - } - } - - private static final class MockSubscriptionTransport implements SubscriptionTransport { - volatile OperationClientMessage lastSentMessage; - volatile boolean connected; - volatile OperationClientMessage disconnectMessage; - - @Override public void connect() { - connected = true; - } - - @Override public void disconnect(OperationClientMessage message) { - connected = false; - disconnectMessage = message; - } - - @Override public void send(OperationClientMessage message) { - lastSentMessage = message; - } - } - - private static class SubscriptionManagerOnStateChangeListener implements OnSubscriptionManagerStateChangeListener { - private final List stateNotifications = new ArrayList<>(); - - @Override - public void onStateChange(SubscriptionManagerState fromState, SubscriptionManagerState toState) { - synchronized (stateNotifications) { - stateNotifications.add(toState); - stateNotifications.notify(); - } - } - - void awaitState(SubscriptionManagerState state, long timeout, TimeUnit timeUnit) throws InterruptedException { - synchronized (stateNotifications) { - if (stateNotifications.contains(state)) { - return; - } - - stateNotifications.clear(); - stateNotifications.wait(timeUnit.toMillis(timeout)); - - assertThat(stateNotifications).contains(state); - } - } - } - - private static final class MockExecutor implements Executor { - @Override public void execute(@NotNull Runnable command) { - command.run(); - } - } - - private static final class MockSubscription implements Subscription { - final String operationId; - - MockSubscription(String operationId) { - this.operationId = operationId; - } - - @Override public String queryDocument() { - return "subscription {\n commentAdded(repoFullName: \"repo\") {\n __typename\n id\n content\n }\n}"; - } - - @Override public Variables variables() { - return EMPTY_VARIABLES; - } - - @Override public ResponseFieldMapper responseFieldMapper() { - return new ResponseFieldMapper() { - @Override public Data map(ResponseReader responseReader) { - return new Operation.Data() { - @Override public ResponseFieldMarshaller marshaller() { - throw new UnsupportedOperationException(); - } - }; - } - }; - } - - @Override public Operation.Data wrapData(Data data) { - return data; - } - - @NotNull @Override public OperationName name() { - return new OperationName() { - @Override public String name() { - return "SomeSubscription"; - } - }; - } - - @NotNull @Override public String operationId() { - return operationId; - } - - @NotNull @Override public Response parse(@NotNull BufferedSource source) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull BufferedSource source, @NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull ByteString byteString) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public Response parse(@NotNull ByteString byteString, @NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public ByteString composeRequestBody( - boolean autoPersistQueries, - boolean withQueryDocument, - @NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public ByteString composeRequestBody(@NotNull ScalarTypeAdapters scalarTypeAdapters) { - throw new UnsupportedOperationException(); - } - - @NotNull @Override public ByteString composeRequestBody() { - throw new UnsupportedOperationException(); - } - } - - private static class SubscriptionManagerCallbackAdapter implements SubscriptionManager.Callback { - volatile SubscriptionResponse response; - volatile ApolloSubscriptionException error; - volatile Throwable networkError; - volatile boolean completed; - volatile boolean terminated; - volatile boolean connected; - - @Override public void onResponse(@NotNull SubscriptionResponse response) { - this.response = response; - } - - @Override public void onError(@NotNull ApolloSubscriptionException error) { - this.error = error; - } - - @Override public void onNetworkError(@NotNull Throwable t) { - networkError = t; - } - - @Override public void onCompleted() { - completed = true; - } - - @Override public void onTerminated() { - terminated = true; - } - - @Override public void onConnected() { - connected = true; - } - } -} diff --git a/apollo-runtime/src/test/java/com/apollographql/apollo/response/OperationResponseParserTest.java b/apollo-runtime/src/test/java/com/apollographql/apollo/response/OperationResponseParserTest.java deleted file mode 100644 index 8eefe884dd0..00000000000 --- a/apollo-runtime/src/test/java/com/apollographql/apollo/response/OperationResponseParserTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.apollographql.apollo.response; - -import com.apollographql.apollo.api.CustomTypeAdapter; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.ScalarType; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.ResponseFieldMapper; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - -import static org.mockito.Mockito.mock; - -public class OperationResponseParserTest { - - abstract static class TestOperation implements Operation { - } - - @Test - public void validateNullDataFieldInPayload() { - OperationResponseParser parser = new OperationResponseParser<>( - mock(TestOperation.class), - mock(ResponseFieldMapper.class), - new ScalarTypeAdapters(new HashMap>()) - ); - - Map payload = new HashMap<>(); - parser.parse(payload); - - payload.put("data", null); - parser.parse(payload); - } -} diff --git a/apollo-runtime/src/test/java/com/apollographql/apollo/response/ScalarTypeAdaptersTest.java b/apollo-runtime/src/test/java/com/apollographql/apollo/response/ScalarTypeAdaptersTest.java deleted file mode 100644 index b417ffce890..00000000000 --- a/apollo-runtime/src/test/java/com/apollographql/apollo/response/ScalarTypeAdaptersTest.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.apollographql.apollo.response; - -import com.apollographql.apollo.api.CustomTypeAdapter; -import com.apollographql.apollo.api.CustomTypeValue; -import com.apollographql.apollo.api.ScalarType; -import com.apollographql.apollo.api.ScalarTypeAdapters; -import com.apollographql.apollo.api.internal.UnmodifiableMapBuilder; -import org.junit.Test; -import org.mockito.Mockito; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static com.google.common.truth.Truth.assertThat; - -public class ScalarTypeAdaptersTest { - - @Test - public void customAdapterTakePrecedentOverDefault() { - final Map> customTypeAdapters = new HashMap<>(); - final CustomTypeAdapter expectedAdapter = Mockito.mock(CustomTypeAdapter.class); - customTypeAdapters.put(new ScalarType() { - @Override - public String typeName() { - return "String"; - } - - @Override - public String className() { - return String.class.getName(); - } - }, expectedAdapter); - - final CustomTypeAdapter actualAdapter = new ScalarTypeAdapters(customTypeAdapters).adapterFor(new ScalarType() { - @Override - public String typeName() { - return "String"; - } - - @Override - public String className() { - return String.class.getName(); - } - }); - - assertThat(actualAdapter).isEqualTo(expectedAdapter); - } - - @Test(expected = IllegalArgumentException.class) - public void missingAdapter() { - new ScalarTypeAdapters(Collections.>emptyMap()) - .adapterFor( - new ScalarType() { - @Override - public String typeName() { - return "RuntimeException"; - } - - @Override - public String className() { - return RuntimeException.class.getName(); - } - } - ); - } - - @Test - public void defaultStringAdapter() { - final CustomTypeAdapter adapter = defaultAdapter(String.class); - assertThat(adapter.decode(CustomTypeValue.fromRawValue("string"))).isEqualTo("string"); - assertThat(adapter.encode("string").value).isEqualTo("string"); - } - - @Test - public void defaultBooleanAdapter() { - final CustomTypeAdapter adapter = defaultAdapter(Boolean.class); - assertThat(adapter.decode(CustomTypeValue.fromRawValue(true))).isEqualTo(true); - assertThat(adapter.encode(true).value).isEqualTo(true); - } - - @Test - public void defaultIntegerAdapter() { - final CustomTypeAdapter adapter = defaultAdapter(Integer.class); - assertThat(adapter.decode(CustomTypeValue.fromRawValue(100))).isEqualTo(100); - assertThat(adapter.encode(100).value).isEqualTo(100); - } - - @Test - public void defaultLongAdapter() { - final CustomTypeAdapter adapter = defaultAdapter(Long.class); - assertThat(adapter.decode(CustomTypeValue.fromRawValue(100L))).isEqualTo(100L); - assertThat(adapter.encode(100L).value).isEqualTo(100L); - } - - @Test - public void defaultFloatAdapter() { - final CustomTypeAdapter adapter = defaultAdapter(Float.class); - assertThat(adapter.decode(CustomTypeValue.fromRawValue(10.10f))).isWithin(0.0f).of(10.10f); - assertThat(adapter.encode(10.10f).value).isEqualTo(10.10f); - } - - @Test - public void defaultDoubleAdapter() { - final CustomTypeAdapter adapter = defaultAdapter(Double.class); - assertThat(adapter.decode(CustomTypeValue.fromRawValue(10.10d))).isWithin(0.0d).of(10.10d); - assertThat(adapter.encode(10.10d).value).isEqualTo(10.10d); - } - - @Test - public void defaultObjectAdapter() { - final CustomTypeAdapter adapter = defaultAdapter(Object.class); - assertThat(adapter.decode(CustomTypeValue.fromRawValue(RuntimeException.class))).isEqualTo("class java.lang.RuntimeException"); - assertThat(adapter.encode(RuntimeException.class).value).isEqualTo("class java.lang.RuntimeException"); - } - - @Test - public void defaultMapAdapter() { - final Map value = new UnmodifiableMapBuilder() - .put("key1", "value1") - .put("key2", "value2") - .build(); - - final CustomTypeAdapter adapter = defaultAdapter(Map.class); - assertThat(adapter.decode(CustomTypeValue.fromRawValue(value))).isEqualTo(value); - assertThat(adapter.encode(value).value).isEqualTo(value); - } - - @Test - public void defaultListAdapter() { - final List value = Arrays.asList("item 1", "item 2"); - final CustomTypeAdapter adapter = defaultAdapter(List.class); - assertThat(adapter.decode(CustomTypeValue.fromRawValue(value))).isEqualTo(value); - assertThat(adapter.encode(value).value).isEqualTo(value); - } - - @Test - public void defaultJsonString() { - final CustomTypeValue.GraphQLJsonObject actualObject = new CustomTypeValue.GraphQLJsonObject( - new UnmodifiableMapBuilder() - .put("key", "scalar") - .put("object", new UnmodifiableMapBuilder() - .put("nestedKey", "nestedScalar") - .build() - ) - .put("list", Arrays.asList("1", "2", "3")) - .build() - ); - final String expectedJsonString = "{\"key\":\"scalar\",\"object\":{\"nestedKey\":\"nestedScalar\"},\"list\":[\"1\",\"2\",\"3\"]}"; - - final CustomTypeAdapter adapter = defaultAdapter(String.class); - assertThat(adapter.decode(actualObject)).isEqualTo(expectedJsonString); - } - - private CustomTypeAdapter defaultAdapter(final Class clazz) { - return new ScalarTypeAdapters(Collections.>emptyMap()).adapterFor( - new ScalarType() { - @Override - public String typeName() { - return clazz.getSimpleName(); - } - - @Override - public String className() { - return clazz.getName(); - } - } - ); - } -} diff --git a/apollo-runtime/src/test/java/com/apollographql/apollo/subscription/ApolloOperationMessageSerializerTest.kt b/apollo-runtime/src/test/java/com/apollographql/apollo/subscription/ApolloOperationMessageSerializerTest.kt deleted file mode 100644 index 96b2c107524..00000000000 --- a/apollo-runtime/src/test/java/com/apollographql/apollo/subscription/ApolloOperationMessageSerializerTest.kt +++ /dev/null @@ -1,178 +0,0 @@ -package com.apollographql.apollo.subscription - -import com.apollographql.apollo.api.BigDecimal -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.internal.json.BufferedSourceJsonReader -import com.apollographql.apollo.api.internal.json.ResponseJsonStreamReader -import com.google.common.truth.Truth.assertThat -import okio.Buffer -import org.junit.Test - -class ApolloOperationMessageSerializerTest { - private val serializer = ApolloOperationMessageSerializer - - @Test - fun writeClientMessage_init() { - val message = OperationClientMessage.Init(mapOf( - "param1" to "value1", - "param2" to "value2" - )) - assertThat(parseJson(serializer.writeClientMessage(message))).isEqualTo(mapOf( - "type" to "connection_init", - "payload" to message.connectionParams - )) - } - - @Test - fun writeClientMessage_start() { - val subscription = MockSubscription( - variables = mapOf("variable" to "value"), - queryDocument = "subscription{commentAdded{id name}", - name = "SomeSubscription" - ) - val regularQuery = OperationClientMessage.Start( - subscriptionId = "subscription-id", - subscription = subscription, - scalarTypeAdapters = ScalarTypeAdapters.DEFAULT, - autoPersistSubscription = false, - sendSubscriptionDocument = true - ) - val persistedQueryWithoutDocument = OperationClientMessage.Start( - subscriptionId = "subscription-id", - subscription = subscription, - scalarTypeAdapters = ScalarTypeAdapters.DEFAULT, - autoPersistSubscription = true, - sendSubscriptionDocument = false - ) - val persistedQueryWithDocument = OperationClientMessage.Start( - subscriptionId = "subscription-id", - subscription = subscription, - scalarTypeAdapters = ScalarTypeAdapters.DEFAULT, - autoPersistSubscription = true, - sendSubscriptionDocument = true - ) - assertThat(parseJson(serializer.writeClientMessage(regularQuery))).isEqualTo(mapOf( - "id" to regularQuery.subscriptionId, - "type" to "start", - "payload" to mapOf( - "variables" to subscription.variables().valueMap(), - "operationName" to subscription.name().name(), - "query" to subscription.queryDocument() - ) - )) - assertThat(parseJson(serializer.writeClientMessage(persistedQueryWithoutDocument))).isEqualTo(mapOf( - "id" to persistedQueryWithoutDocument.subscriptionId, - "type" to "start", - "payload" to mapOf( - "variables" to subscription.variables().valueMap(), - "operationName" to subscription.name().name(), - "extensions" to mapOf( - "persistedQuery" to mapOf( - "version" to BigDecimal(1), - "sha256Hash" to subscription.operationId() - ) - ) - ) - )) - assertThat(parseJson(serializer.writeClientMessage(persistedQueryWithDocument))).isEqualTo(mapOf( - "id" to persistedQueryWithDocument.subscriptionId, - "type" to "start", - "payload" to mapOf( - "variables" to subscription.variables().valueMap(), - "operationName" to subscription.name().name(), - "query" to subscription.queryDocument(), - "extensions" to mapOf( - "persistedQuery" to mapOf( - "version" to BigDecimal(1), - "sha256Hash" to subscription.operationId() - ) - ) - ) - )) - } - - @Test - fun writeClientMessage_stop() { - val message = OperationClientMessage.Stop("subscription-id") - assertThat(parseJson(serializer.writeClientMessage(message))).isEqualTo(mapOf( - "type" to "stop", - "id" to "subscription-id" - )) - } - - @Test - fun writeClientMessage_terminate() { - val message = OperationClientMessage.Terminate() - assertThat(parseJson(serializer.writeClientMessage(message))).isEqualTo(mapOf( - "type" to "connection_terminate" - )) - } - - @Test - fun readServerMessage_connectionAcknowledge() { - assertThat(serializer.readServerMessage("""{"type":"connection_ack"}""")) - .isEqualTo(OperationServerMessage.ConnectionAcknowledge()) - } - - @Test - fun readServerMessage_data() { - assertThat(serializer.readServerMessage("""{"type":"data","id":"some-id","payload":{"key":"value"}}""")).isEqualTo(OperationServerMessage.Data( - id = "some-id", - payload = mapOf("key" to "value") - )) - } - - @Test - fun readServerMessage_keepAlive() { - assertThat(serializer.readServerMessage("""{"type":"ka"}""")).isEqualTo(OperationServerMessage.ConnectionKeepAlive()) - } - - @Test - fun readServerMessage_error() { - assertThat(serializer.readServerMessage("""{"type":"error","id":"some-id","payload":{"key":"value"}}""")).isEqualTo(OperationServerMessage.Error( - id = "some-id", - payload = mapOf("key" to "value") - )) - } - - @Test - fun readServerMessage_connectionError() { - assertThat(serializer.readServerMessage("""{"type":"connection_error","payload":{"key":"value"}}""")).isEqualTo(OperationServerMessage.ConnectionError( - payload = mapOf("key" to "value") - )) - } - - @Test - fun readServerMessage_complete() { - assertThat(serializer.readServerMessage("""{"type":"complete","id":"some-id"}""")).isEqualTo(OperationServerMessage.Complete( - id = "some-id" - )) - } - - @Test - fun readServerMessage_unknown() { - assertThat(serializer.readServerMessage("invalid json")) - .isEqualTo(OperationServerMessage.Unsupported("invalid json")) - assertThat(serializer.readServerMessage("{}")) - .isEqualTo(OperationServerMessage.Unsupported("{}")) - assertThat(serializer.readServerMessage("""{"type":"unknown"}""")) - .isEqualTo(OperationServerMessage.Unsupported("""{"type":"unknown"}""")) - } - - private fun OperationMessageSerializer.writeClientMessage(message: OperationClientMessage): String = - Buffer() - .also { writeClientMessage(message, it) } - .readUtf8() - - private fun OperationMessageSerializer.readServerMessage(json: String): OperationServerMessage = - Buffer() - .writeUtf8(json) - .let { readServerMessage(it) } - - private fun parseJson(json: String): Map? = - Buffer() - .writeUtf8(json) - .let(::BufferedSourceJsonReader) - .let(::ResponseJsonStreamReader) - .toMap() -} \ No newline at end of file diff --git a/apollo-runtime/src/test/java/com/apollographql/apollo/subscription/AppSyncOperationMessageSerializerTest.kt b/apollo-runtime/src/test/java/com/apollographql/apollo/subscription/AppSyncOperationMessageSerializerTest.kt deleted file mode 100644 index 350ad186475..00000000000 --- a/apollo-runtime/src/test/java/com/apollographql/apollo/subscription/AppSyncOperationMessageSerializerTest.kt +++ /dev/null @@ -1,142 +0,0 @@ -package com.apollographql.apollo.subscription - -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.internal.json.BufferedSourceJsonReader -import com.apollographql.apollo.api.internal.json.ResponseJsonStreamReader -import com.google.common.truth.Truth.assertThat -import okio.Buffer -import org.junit.Test - -class AppSyncOperationMessageSerializerTest { - private val authorization = mapOf( - "host" to "example1234567890000.appsync-api.us-east-1.amazonaws.com", - "x-api-key" to "da2-12345678901234567890123456" - ) - private val serializer = AppSyncOperationMessageSerializer(authorization) - - @Test - fun writeClientMessage_init() { - val message = OperationClientMessage.Init(mapOf( - "param1" to "value1", - "param2" to "value2" - )) - assertThat(serializer.writeClientMessage(message)).isEqualTo(ApolloOperationMessageSerializer.writeClientMessage(message)) - } - - @Test - fun writeClientMessage_start() { - val message = OperationClientMessage.Start( - subscriptionId = "subscription-id", - subscription = MockSubscription( - variables = mapOf("variable" to "value"), - queryDocument = "subscription{commentAdded{id name}", - name = "SomeSubscription" - ), - scalarTypeAdapters = ScalarTypeAdapters.DEFAULT, - autoPersistSubscription = false, - sendSubscriptionDocument = true - ) - ApolloOperationMessageSerializer.JSON_KEY_VARIABLES - ApolloOperationMessageSerializer.JSON_KEY_OPERATION_NAME - ApolloOperationMessageSerializer.JSON_KEY_QUERY - assertThat(parseJson(serializer.writeClientMessage(message))).isEqualTo(mapOf( - "id" to message.subscriptionId, - "type" to "start", - "payload" to mapOf( - "data" to """{"variables":{"variable":"value"},"operationName":"SomeSubscription","query":"subscription{commentAdded{id name}"}""", - "extensions" to mapOf( - "authorization" to authorization - ) - ) - )) - } - - @Test - fun writeClientMessage_stop() { - val message = OperationClientMessage.Stop("subscription-id") - assertThat(serializer.writeClientMessage(message)).isEqualTo(ApolloOperationMessageSerializer.writeClientMessage(message)) - } - - @Test - fun writeClientMessage_terminate() { - val message = OperationClientMessage.Terminate() - assertThat(serializer.writeClientMessage(message)).isEqualTo(ApolloOperationMessageSerializer.writeClientMessage(message)) - } - - @Test - fun readServerMessage_connectionAcknowledge() { - assertThat(serializer.readServerMessage("""{"type":"connection_ack","payload":{"connectionTimeoutMs":300000}}""")) - .isEqualTo(OperationServerMessage.ConnectionAcknowledge()) - } - - @Test - fun readServerMessage_data() { - assertThat(serializer.readServerMessage("""{"type":"data","id":"some-id","payload":{"key":"value"}}""")).isEqualTo(OperationServerMessage.Data( - id = "some-id", - payload = mapOf("key" to "value") - )) - } - - @Test - fun readServerMessage_keepAlive() { - assertThat(serializer.readServerMessage("""{"type":"ka"}""")).isEqualTo(OperationServerMessage.ConnectionKeepAlive()) - } - - @Test - fun readServerMessage_error() { - assertThat(serializer.readServerMessage("""{"type":"error","id":"some-id","payload":{"key":"value"}}""")).isEqualTo(OperationServerMessage.Error( - id = "some-id", - payload = mapOf("key" to "value") - )) - } - - @Test - fun readServerMessage_connectionError() { - assertThat(serializer.readServerMessage("""{"type":"connection_error","payload":{"key":"value"}}""")).isEqualTo(OperationServerMessage.ConnectionError( - payload = mapOf("key" to "value") - )) - } - - @Test - fun readServerMessage_complete() { - assertThat(serializer.readServerMessage("""{"type":"complete","id":"some-id"}""")).isEqualTo(OperationServerMessage.Complete( - id = "some-id" - )) - } - - @Test - fun readServerMessage_unknown() { - assertThat(serializer.readServerMessage("invalid json")) - .isEqualTo(OperationServerMessage.Unsupported("invalid json")) - assertThat(serializer.readServerMessage("{}")) - .isEqualTo(OperationServerMessage.Unsupported("{}")) - assertThat(serializer.readServerMessage("""{"type":"unknown"}""")) - .isEqualTo(OperationServerMessage.Unsupported("""{"type":"unknown"}""")) - } - - @Test - fun buildWebSocketUrl() { - val url = AppSyncOperationMessageSerializer.buildWebSocketUrl( - baseWebSocketUrl = "wss://example1234567890000.appsync-realtime-api.us-east-1.amazonaws.com/graphql", - authorization = authorization - ) - assertThat(url).isEqualTo("wss://example1234567890000.appsync-realtime-api.us-east-1.amazonaws.com/graphql?header=eyJob3N0IjoiZXhhbXBsZTEyMzQ1Njc4OTAwMDAuYXBwc3luYy1hcGkudXMtZWFzdC0xLmFtYXpvbmF3cy5jb20iLCJ4LWFwaS1rZXkiOiJkYTItMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTYifQ%3D%3D&payload=e30%3D") - } - - private fun OperationMessageSerializer.writeClientMessage(message: OperationClientMessage): String = - Buffer() - .also { writeClientMessage(message, it) } - .readUtf8() - - private fun OperationMessageSerializer.readServerMessage(json: String): OperationServerMessage = - Buffer() - .writeUtf8(json) - .let { readServerMessage(it) } - - private fun parseJson(json: String): Map? = - Buffer() - .writeUtf8(json) - .let(::BufferedSourceJsonReader) - .let(::ResponseJsonStreamReader) - .toMap() -} \ No newline at end of file diff --git a/apollo-runtime/src/test/java/com/apollographql/apollo/subscription/MockSubscription.kt b/apollo-runtime/src/test/java/com/apollographql/apollo/subscription/MockSubscription.kt deleted file mode 100644 index c2acc9639eb..00000000000 --- a/apollo-runtime/src/test/java/com/apollographql/apollo/subscription/MockSubscription.kt +++ /dev/null @@ -1,68 +0,0 @@ -package com.apollographql.apollo.subscription - -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.OperationName -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.apollographql.apollo.api.Subscription -import com.apollographql.apollo.api.internal.InputFieldMarshaller -import com.apollographql.apollo.api.internal.ResponseFieldMapper -import okio.BufferedSource -import okio.ByteString -import java.io.IOException - -class MockSubscription( - private val queryDocument: String = "subscription{commentAdded{id name}", - private val variables: Map = emptyMap(), - private val name: String = "SomeSubscription", - private val operationId: String = "someId" -) : Subscription { - override fun queryDocument(): String = queryDocument - - override fun variables(): Operation.Variables = object : Operation.Variables() { - override fun valueMap(): Map = variables - - override fun marshaller(): InputFieldMarshaller = - InputFieldMarshaller { writer -> - for ((name, value) in variables.entries) { - when (value) { - is Number -> writer.writeNumber(name, value) - is Boolean -> writer.writeBoolean(name, value) - else -> writer.writeString(name, value.toString()) - } - } - } - } - - override fun responseFieldMapper(): ResponseFieldMapper = throw UnsupportedOperationException() - - override fun wrapData(data: Operation.Data?): Operation.Data? = data - - override fun name(): OperationName = - object : OperationName { - override fun name(): String = name - } - - override fun operationId(): String = operationId - - @kotlin.jvm.Throws(IOException::class) - override fun parse(source: BufferedSource): Response = throw UnsupportedOperationException() - - override fun parse(source: BufferedSource, scalarTypeAdapters: ScalarTypeAdapters): Response = - throw UnsupportedOperationException() - - override fun parse(byteString: ByteString): Response = - throw UnsupportedOperationException() - - override fun parse(byteString: ByteString, scalarTypeAdapters: ScalarTypeAdapters): Response = - throw UnsupportedOperationException() - - override fun composeRequestBody( - autoPersistQueries: Boolean, - withQueryDocument: Boolean, - scalarTypeAdapters: ScalarTypeAdapters): ByteString = throw UnsupportedOperationException() - - override fun composeRequestBody(scalarTypeAdapters: ScalarTypeAdapters): ByteString = throw UnsupportedOperationException() - - override fun composeRequestBody(): ByteString = throw UnsupportedOperationException() -} \ No newline at end of file diff --git a/apollo-runtime/src/test/java/com/apollographql/apollo/subscription/WebSocketSubscriptionTransportMessageTest.kt b/apollo-runtime/src/test/java/com/apollographql/apollo/subscription/WebSocketSubscriptionTransportMessageTest.kt deleted file mode 100644 index be3ebe16afe..00000000000 --- a/apollo-runtime/src/test/java/com/apollographql/apollo/subscription/WebSocketSubscriptionTransportMessageTest.kt +++ /dev/null @@ -1,191 +0,0 @@ -package com.apollographql.apollo.subscription - -import com.apollographql.apollo.api.ScalarTypeAdapters -import com.google.common.truth.Truth.assertThat -import okhttp3.Protocol -import okhttp3.Request -import okhttp3.Response -import okhttp3.WebSocket -import okhttp3.WebSocketListener -import okio.ByteString -import org.junit.Before -import org.junit.Test -import java.math.BigDecimal - -class WebSocketSubscriptionTransportMessageTest { - private lateinit var webSocketFactory: MockWebSocketFactory - private lateinit var subscriptionTransport: WebSocketSubscriptionTransport - private lateinit var transportCallback: MockSubscriptionTransportCallback - - @Before - fun setUp() { - webSocketFactory = MockWebSocketFactory() - transportCallback = MockSubscriptionTransportCallback() - val factory = WebSocketSubscriptionTransport.Factory("wss://localhost/", webSocketFactory) - subscriptionTransport = factory.create(transportCallback) as WebSocketSubscriptionTransport - subscriptionTransport.connect() - assertThat(webSocketFactory.webSocket).isNotNull() - } - - @Test - fun connectionInit() { - subscriptionTransport.send(OperationClientMessage.Init(emptyMap())) - assertThat(webSocketFactory.webSocket.lastSentMessage).isEqualTo("""{"type":"connection_init"}""") - subscriptionTransport.send(OperationClientMessage.Init(mapOf("param1" to true, "param2" to "value"))) - assertThat(webSocketFactory.webSocket.lastSentMessage) - .isEqualTo("""{"type":"connection_init","payload":{"param1":true,"param2":"value"}}""") - } - - @Test - fun startSubscriptionAutoPersistSubscriptionDisabled() { - subscriptionTransport.send(OperationClientMessage.Start(subscriptionId = "subscriptionId", - subscription = MockSubscription(), - scalarTypeAdapters = ScalarTypeAdapters(emptyMap()), - autoPersistSubscription = false, - sendSubscriptionDocument = false)) - val expected = """{"id":"subscriptionId","type":"start","payload":{"variables":{},"operationName":"SomeSubscription","query":"subscription{commentAdded{id name}"}}""" - assertThat(webSocketFactory.webSocket.lastSentMessage).isEqualTo(expected) - } - - @Test - fun startSubscriptionAutoPersistSubscriptionEnabledSendDocumentEnabled() { - subscriptionTransport.send(OperationClientMessage.Start("subscriptionId", MockSubscription(), - ScalarTypeAdapters(emptyMap()), autoPersistSubscription = true, sendSubscriptionDocument = true)) - val expected = """{"id":"subscriptionId","type":"start","payload":{"variables":{},"operationName":"SomeSubscription","query":"subscription{commentAdded{id name}","extensions":{"persistedQuery":{"version":1,"sha256Hash":"someId"}}}}""" - assertThat(webSocketFactory.webSocket.lastSentMessage).isEqualTo(expected) - } - - @Test - fun startSubscriptionAutoPersistSubscriptionEnabledSendDocumentDisabled() { - subscriptionTransport.send(OperationClientMessage.Start("subscriptionId", MockSubscription(), - ScalarTypeAdapters(emptyMap()), autoPersistSubscription = true, sendSubscriptionDocument = false)) - val expected = """{"id":"subscriptionId","type":"start","payload":{"variables":{},"operationName":"SomeSubscription","extensions":{"persistedQuery":{"version":1,"sha256Hash":"someId"}}}}""" - assertThat(webSocketFactory.webSocket.lastSentMessage).isEqualTo(expected) - } - - @Test - fun stopSubscription() { - subscriptionTransport.send(OperationClientMessage.Stop("subscriptionId")) - assertThat(webSocketFactory.webSocket.lastSentMessage).isEqualTo("""{"id":"subscriptionId","type":"stop"}""") - } - - @Test - fun terminateSubscription() { - subscriptionTransport.send(OperationClientMessage.Terminate()) - assertThat(webSocketFactory.webSocket.lastSentMessage).isEqualTo("""{"type":"connection_terminate"}""") - } - - @Test - fun connectionAcknowledge() { - webSocketFactory.webSocket.listener.onMessage(webSocketFactory.webSocket, """{"type":"connection_ack"}""") - assertThat(transportCallback.lastMessage).isInstanceOf(OperationServerMessage.ConnectionAcknowledge::class.java) - } - - @Test - fun data() { - webSocketFactory.webSocket.listener.onMessage( - webSocketFactory.webSocket, - """{"type":"data","id":"subscriptionId","payload":{"data":{"commentAdded":{"__typename":"Comment","id":10,"content":"test10"}}}}""" - ) - assertThat(transportCallback.lastMessage).isEqualTo(OperationServerMessage.Data( - id = "subscriptionId", - payload = mapOf( - "data" to mapOf( - "commentAdded" to mapOf( - "__typename" to "Comment", - "id" to BigDecimal.valueOf(10), - "content" to "test10" - ) - ) - ) - )) - } - - @Test - fun connectionError() { - webSocketFactory.webSocket.listener.onMessage( - webSocketFactory.webSocket, - """{"type":"connection_error","payload":{"message":"Connection Error"}}""" - ) - assertThat(transportCallback.lastMessage) - .isEqualTo(OperationServerMessage.ConnectionError(mapOf("message" to "Connection Error"))) - } - - @Test - fun error() { - webSocketFactory.webSocket.listener.onMessage( - webSocketFactory.webSocket, - """{"type":"error", "id":"subscriptionId", "payload":{"message":"Error"}}""" - ) - assertThat(transportCallback.lastMessage).isEqualTo(OperationServerMessage.Error( - id = "subscriptionId", - payload = mapOf("message" to "Error") - )) - } - - @Test - fun complete() { - webSocketFactory.webSocket.listener.onMessage(webSocketFactory.webSocket, """{"type":"complete", "id":"subscriptionId"}""") - assertThat(transportCallback.lastMessage).isEqualTo(OperationServerMessage.Complete("subscriptionId")) - } - - @Test - fun unsupported() { - webSocketFactory.webSocket.listener.onMessage(webSocketFactory.webSocket, """{"type":"unsupported"}""") - assertThat(transportCallback.lastMessage).isEqualTo(OperationServerMessage.Unsupported("""{"type":"unsupported"}""")) - webSocketFactory.webSocket.listener.onMessage(webSocketFactory.webSocket, """{"type":"unsupported""") - assertThat(transportCallback.lastMessage).isEqualTo(OperationServerMessage.Unsupported("""{"type":"unsupported""")) - } - - private class MockWebSocketFactory : WebSocket.Factory { - lateinit var webSocket: MockWebSocket - - override fun newWebSocket(request: Request, listener: WebSocketListener): WebSocket { - check(!::webSocket.isInitialized) { "already initialized" } - return MockWebSocket(request, listener).also { webSocket = it } - } - } - - private class MockWebSocket(val request: Request, val listener: WebSocketListener) : WebSocket { - var lastSentMessage: String? = null - - init { - listener.onOpen(this, Response.Builder() - .request(request) - .protocol(Protocol.HTTP_1_0) - .code(200) - .message("Ok") - .build() - ) - } - - override fun request(): Request = request - - override fun queueSize(): Long = throw UnsupportedOperationException() - - override fun send(text: String): Boolean { - lastSentMessage = text - return true - } - - override fun send(bytes: ByteString): Boolean = throw UnsupportedOperationException() - - override fun close(code: Int, reason: String?): Boolean = throw UnsupportedOperationException() - - override fun cancel() { - throw UnsupportedOperationException() - } - } - - private class MockSubscriptionTransportCallback : SubscriptionTransport.Callback { - var lastMessage: OperationServerMessage? = null - - override fun onConnected() {} - override fun onFailure(t: Throwable) {} - override fun onMessage(message: OperationServerMessage) { - lastMessage = message - } - - override fun onClosed() {} - } -} \ No newline at end of file diff --git a/apollo-runtime/src/test/java/com/apollographql/apollo/subscription/WebSocketSubscriptionTransportTest.kt b/apollo-runtime/src/test/java/com/apollographql/apollo/subscription/WebSocketSubscriptionTransportTest.kt deleted file mode 100644 index e4709a410bc..00000000000 --- a/apollo-runtime/src/test/java/com/apollographql/apollo/subscription/WebSocketSubscriptionTransportTest.kt +++ /dev/null @@ -1,178 +0,0 @@ -package com.apollographql.apollo.subscription - -import com.google.common.truth.Truth.assertThat -import okhttp3.Protocol -import okhttp3.Request -import okhttp3.Response -import okhttp3.WebSocket -import okhttp3.WebSocketListener -import okio.ByteString -import org.junit.Before -import org.junit.Test -import java.util.concurrent.atomic.AtomicBoolean -import java.util.concurrent.atomic.AtomicReference - -class WebSocketSubscriptionTransportTest { - private lateinit var webSocketRequest: Request - private lateinit var webSocketFactory: MockWebSocketFactory - private lateinit var subscriptionTransport: WebSocketSubscriptionTransport - - @Before - @Throws(Exception::class) - fun setUp() { - webSocketRequest = Request.Builder().url("wss://localhost").build() - webSocketFactory = MockWebSocketFactory() - val factory = WebSocketSubscriptionTransport.Factory("wss://localhost/", webSocketFactory) - subscriptionTransport = factory.create(object : SubscriptionTransport.Callback { - override fun onConnected() {} - override fun onFailure(t: Throwable) {} - override fun onMessage(message: OperationServerMessage) {} - override fun onClosed() {} - }) as WebSocketSubscriptionTransport - } - - @Test - fun connect() { - assertThat(subscriptionTransport.webSocket.get()).isNull() - assertThat(subscriptionTransport.webSocketListener.get()).isNull() - subscriptionTransport.connect() - assertThat(subscriptionTransport.webSocket.get()).isNotNull() - assertThat(subscriptionTransport.webSocketListener.get()).isNotNull() - assertThat(webSocketFactory.request.header("Sec-WebSocket-Protocol")).isEqualTo("graphql-ws") - assertThat(webSocketFactory.request.header("Cookie")).isEqualTo("") - } - - @Test - fun disconnect() { - subscriptionTransport.connect() - assertThat(subscriptionTransport.webSocket.get()).isNotNull() - assertThat(subscriptionTransport.webSocketListener.get()).isNotNull() - subscriptionTransport.disconnect(OperationClientMessage.Terminate()) - assertThat(subscriptionTransport.webSocket.get()).isNull() - assertThat(subscriptionTransport.webSocketListener.get()).isNull() - } - - @Test - fun send() { - val callbackFailure = AtomicReference() - subscriptionTransport = WebSocketSubscriptionTransport(webSocketRequest, webSocketFactory, object : SubscriptionTransport.Callback { - override fun onConnected() {} - override fun onFailure(t: Throwable) { - callbackFailure.set(t) - } - - override fun onMessage(message: OperationServerMessage) {} - override fun onClosed() {} - }) - subscriptionTransport.send(OperationClientMessage.Init(emptyMap())) - assertThat(callbackFailure.get()).isInstanceOf(IllegalStateException::class.java) - callbackFailure.set(null) - subscriptionTransport.connect() - subscriptionTransport.send(OperationClientMessage.Init(emptyMap())) - assertThat(callbackFailure.get()).isNull() - subscriptionTransport.disconnect(OperationClientMessage.Terminate()) - subscriptionTransport.send(OperationClientMessage.Init(emptyMap())) - assertThat(callbackFailure.get()).isInstanceOf(IllegalStateException::class.java) - } - - @Test - fun subscriptionTransportCallback() { - val callbackConnected = AtomicBoolean() - val callbackFailure = AtomicReference() - val callbackMessage = AtomicReference() - subscriptionTransport = WebSocketSubscriptionTransport(webSocketRequest, webSocketFactory, object : SubscriptionTransport.Callback { - override fun onConnected() { - callbackConnected.set(true) - } - - override fun onFailure(t: Throwable) { - callbackFailure.set(t) - } - - override fun onMessage(message: OperationServerMessage) { - callbackMessage.set(message) - } - - override fun onClosed() {} - }) - subscriptionTransport.connect() - webSocketFactory.webSocket.listener.onMessage(webSocketFactory.webSocket, "{\"type\":\"connection_ack\"}") - webSocketFactory.webSocket.listener.onFailure(webSocketFactory.webSocket, UnsupportedOperationException(), null) - assertThat(callbackConnected.get()).isTrue() - assertThat(callbackMessage.get()).isInstanceOf(OperationServerMessage.ConnectionAcknowledge::class.java) - assertThat(callbackFailure.get()).isInstanceOf(UnsupportedOperationException::class.java) - } - - @Test - fun subscriptionTransportClosedCallback() { - val callbackConnected = AtomicBoolean() - val callbackClosed = AtomicBoolean() - subscriptionTransport = WebSocketSubscriptionTransport(webSocketRequest, webSocketFactory, object : SubscriptionTransport.Callback { - override fun onConnected() { - callbackConnected.set(true) - } - - override fun onFailure(t: Throwable) { - throw UnsupportedOperationException("Unexpected") - } - - override fun onMessage(message: OperationServerMessage) {} - override fun onClosed() { - callbackClosed.set(true) - } - }) - subscriptionTransport.connect() - webSocketFactory.webSocket.listener.onClosed(webSocketFactory.webSocket, 1001, "") - assertThat(callbackConnected.get()).isTrue() - assertThat(callbackClosed.get()).isTrue() - } - - private class MockWebSocketFactory : WebSocket.Factory { - lateinit var request: Request - lateinit var webSocket: MockWebSocket - - override fun newWebSocket(request: Request, listener: WebSocketListener): WebSocket { - this.request = request - return MockWebSocket(request, listener).also { webSocket = it } - } - } - - private class MockWebSocket(val request: Request, val listener: WebSocketListener) : WebSocket { - var lastSentMessage: String? = null - var closed = false - - override fun request(): Request { - return request - } - - override fun queueSize(): Long = throw UnsupportedOperationException() - - override fun send(text: String): Boolean { - lastSentMessage = text - return true - } - - override fun send(bytes: ByteString): Boolean { - throw UnsupportedOperationException() - } - - override fun close(code: Int, reason: String?): Boolean { - closed = true - return true - } - - override fun cancel() { - throw UnsupportedOperationException() - } - - init { - listener.onOpen(this, Response.Builder() - .request(request) - .protocol(Protocol.HTTP_1_0) - .code(200) - .message("Ok") - .build() - ) - } - } -} \ No newline at end of file diff --git a/apollo-rx2-support/api.txt b/apollo-rx2-support/api.txt index 3f1e26905b2..af519e00cd5 100644 --- a/apollo-rx2-support/api.txt +++ b/apollo-rx2-support/api.txt @@ -1,16 +1,16 @@ // Signature format: 3.0 -package com.apollographql.apollo.rx2 { +package com.homer.apollographql.apollo.rx2 { public final class KotlinExtensions { } public class Rx2Apollo { - method @io.reactivex.annotations.CheckReturnValue public static io.reactivex.Observable!> from(com.apollographql.apollo.ApolloQueryWatcher); - method @io.reactivex.annotations.CheckReturnValue public static io.reactivex.Observable!> from(com.apollographql.apollo.ApolloCall); - method @io.reactivex.annotations.CheckReturnValue public static io.reactivex.Completable from(com.apollographql.apollo.ApolloPrefetch); - method @io.reactivex.annotations.CheckReturnValue public static io.reactivex.Flowable!> from(com.apollographql.apollo.ApolloSubscriptionCall); - method @io.reactivex.annotations.CheckReturnValue public static io.reactivex.Flowable!> from(com.apollographql.apollo.ApolloSubscriptionCall, io.reactivex.BackpressureStrategy); - method @io.reactivex.annotations.CheckReturnValue public static io.reactivex.Single from(com.apollographql.apollo.cache.normalized.ApolloStoreOperation); + method @io.reactivex.annotations.CheckReturnValue public static io.reactivex.Observable!> from(com.homer.apollographql.apollo.ApolloQueryWatcher); + method @io.reactivex.annotations.CheckReturnValue public static io.reactivex.Observable!> from(com.homer.apollographql.apollo.ApolloCall); + method @io.reactivex.annotations.CheckReturnValue public static io.reactivex.Completable from(com.homer.apollographql.apollo.ApolloPrefetch); + method @io.reactivex.annotations.CheckReturnValue public static io.reactivex.Flowable!> from(com.homer.apollographql.apollo.ApolloSubscriptionCall); + method @io.reactivex.annotations.CheckReturnValue public static io.reactivex.Flowable!> from(com.homer.apollographql.apollo.ApolloSubscriptionCall, io.reactivex.BackpressureStrategy); + method @io.reactivex.annotations.CheckReturnValue public static io.reactivex.Single from(com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation); } } diff --git a/apollo-rx2-support/src/main/java/com/apollographql/apollo/rx2/RxJavaExtensions.kt b/apollo-rx2-support/src/main/java/com/apollographql/apollo/rx2/RxJavaExtensions.kt deleted file mode 100644 index fa5ef1e1cec..00000000000 --- a/apollo-rx2-support/src/main/java/com/apollographql/apollo/rx2/RxJavaExtensions.kt +++ /dev/null @@ -1,109 +0,0 @@ -@file:Suppress("NOTHING_TO_INLINE") -@file:JvmName("KotlinExtensions") - -package com.apollographql.apollo.rx2 - -import com.apollographql.apollo.ApolloCall -import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.ApolloMutationCall -import com.apollographql.apollo.ApolloPrefetch -import com.apollographql.apollo.ApolloQueryCall -import com.apollographql.apollo.ApolloQueryWatcher -import com.apollographql.apollo.ApolloSubscriptionCall -import com.apollographql.apollo.api.Mutation -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.Subscription -import com.apollographql.apollo.cache.normalized.ApolloStoreOperation -import io.reactivex.BackpressureStrategy -import io.reactivex.Completable -import io.reactivex.Flowable -import io.reactivex.Observable -import io.reactivex.Single -import io.reactivex.annotations.CheckReturnValue - -@JvmSynthetic -@CheckReturnValue -inline fun ApolloPrefetch.rx(): Completable = - Rx2Apollo.from(this) - -@JvmSynthetic -@CheckReturnValue -inline fun ApolloStoreOperation.rx(): Single = - Rx2Apollo.from(this) - -@JvmSynthetic -@CheckReturnValue -inline fun ApolloQueryWatcher.rx(): Observable> = - Rx2Apollo.from(this) - -@JvmSynthetic -@CheckReturnValue -inline fun ApolloCall.rx(): Observable> = - Rx2Apollo.from(this) - -@JvmSynthetic -@CheckReturnValue -inline fun ApolloSubscriptionCall.rx( - backpressureStrategy: BackpressureStrategy = BackpressureStrategy.LATEST -): Flowable> = Rx2Apollo.from(this, backpressureStrategy) - -/** - * Creates a new [ApolloQueryCall] call and then converts it to an [Observable]. - * - * The number of emissions this Observable will have is based on the - * [com.apollographql.apollo.fetcher.ResponseFetcher] used with the call. - */ -@JvmSynthetic -@CheckReturnValue -inline fun ApolloClient.rxQuery( - query: Query, - configure: ApolloQueryCall.() -> ApolloQueryCall = { this } -): Observable> = query(query).configure().rx() - -/** - * Creates a new [ApolloMutationCall] call and then converts it to a [Single]. - */ -@JvmSynthetic -@CheckReturnValue -inline fun ApolloClient.rxMutate( - mutation: Mutation, - configure: ApolloMutationCall.() -> ApolloMutationCall = { this } -): Single> = mutate(mutation).configure().rx().singleOrError() - -/** - * Creates a new [ApolloMutationCall] call and then converts it to a [Single]. - * - * Provided optimistic updates will be stored in [com.apollographql.apollo.cache.normalized.ApolloStore] - * immediately before mutation execution. Any [ApolloQueryWatcher] dependent on the changed cache records will - * be re-fetched. - */ -@JvmSynthetic -@CheckReturnValue -inline fun ApolloClient.rxMutate( - mutation: Mutation, - withOptimisticUpdates: D, - configure: ApolloMutationCall.() -> ApolloMutationCall = { this } -): Single> = mutate(mutation, withOptimisticUpdates).configure().rx().singleOrError() - -/** - * Creates the [ApolloPrefetch] by wrapping the operation object inside and then converts it to a [Completable]. - */ -@JvmSynthetic -@CheckReturnValue -inline fun ApolloClient.rxPrefetch( - operation: Operation -): Completable = prefetch(operation).rx() - -/** - * Creates a new [ApolloSubscriptionCall] call and then converts it to a [Flowable]. - * - * Back-pressure strategy can be provided via [backpressureStrategy] parameter. The default value is [BackpressureStrategy.LATEST] - */ -@JvmSynthetic -@CheckReturnValue -inline fun ApolloClient.rxSubscribe( - subscription: Subscription, - backpressureStrategy: BackpressureStrategy = BackpressureStrategy.LATEST -): Flowable> = subscribe(subscription).rx(backpressureStrategy) diff --git a/apollo-rx2-support/src/main/java/com/apollographql/apollo/rx2/Rx2Apollo.java b/apollo-rx2-support/src/main/java/com/homer/apollographql/apollo/rx2/Rx2Apollo.java similarity index 87% rename from apollo-rx2-support/src/main/java/com/apollographql/apollo/rx2/Rx2Apollo.java rename to apollo-rx2-support/src/main/java/com/homer/apollographql/apollo/rx2/Rx2Apollo.java index 9d77f9ba967..89091ad0e82 100644 --- a/apollo-rx2-support/src/main/java/com/apollographql/apollo/rx2/Rx2Apollo.java +++ b/apollo-rx2-support/src/main/java/com/homer/apollographql/apollo/rx2/Rx2Apollo.java @@ -1,14 +1,21 @@ -package com.apollographql.apollo.rx2; +package com.homer.apollographql.apollo.rx2; -import com.apollographql.apollo.ApolloCall; -import com.apollographql.apollo.ApolloPrefetch; -import com.apollographql.apollo.ApolloQueryWatcher; -import com.apollographql.apollo.ApolloSubscriptionCall; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.cache.normalized.ApolloStoreOperation; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.internal.subscription.ApolloSubscriptionTerminatedException; -import com.apollographql.apollo.internal.util.Cancelable; +import com.homer.apollographql.apollo.ApolloCall; +import com.homer.apollographql.apollo.ApolloPrefetch; +import com.homer.apollographql.apollo.ApolloQueryWatcher; +import com.homer.apollographql.apollo.ApolloSubscriptionCall; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.internal.subscription.ApolloSubscriptionTerminatedException; +import com.homer.apollographql.apollo.internal.util.Cancelable; +import com.homer.apollographql.apollo.ApolloCall; +import com.homer.apollographql.apollo.ApolloPrefetch; +import com.homer.apollographql.apollo.ApolloQueryWatcher; +import com.homer.apollographql.apollo.ApolloSubscriptionCall; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.internal.subscription.ApolloSubscriptionTerminatedException; +import com.homer.apollographql.apollo.internal.util.Cancelable; import io.reactivex.BackpressureStrategy; import io.reactivex.Completable; import io.reactivex.CompletableEmitter; @@ -27,7 +34,7 @@ import io.reactivex.exceptions.Exceptions; import org.jetbrains.annotations.NotNull; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; /** * The Rx2Apollo class provides methods for converting ApolloCall, ApolloPrefetch and ApolloWatcher types to RxJava 2 @@ -76,7 +83,7 @@ public static Observable> from(@NotNull final ApolloQueryWatcher /** * Converts an {@link ApolloCall} to an {@link Observable}. The number of emissions this Observable will have is based - * on the {@link com.apollographql.apollo.fetcher.ResponseFetcher} used with the call. + * on the {@link ResponseFetcher} used with the call. * * @param call the ApolloCall to convert * @param the value type. diff --git a/apollo-rx2-support/src/main/java/com/homer/apollographql/apollo/rx2/RxJavaExtensions.kt b/apollo-rx2-support/src/main/java/com/homer/apollographql/apollo/rx2/RxJavaExtensions.kt new file mode 100644 index 00000000000..97e953ad5e6 --- /dev/null +++ b/apollo-rx2-support/src/main/java/com/homer/apollographql/apollo/rx2/RxJavaExtensions.kt @@ -0,0 +1,109 @@ +@file:Suppress("NOTHING_TO_INLINE") +@file:JvmName("KotlinExtensions") + +package com.homer.apollographql.apollo.rx2 + +import com.homer.apollographql.apollo.ApolloCall +import com.homer.apollographql.apollo.ApolloClient +import com.homer.apollographql.apollo.ApolloMutationCall +import com.homer.apollographql.apollo.ApolloPrefetch +import com.homer.apollographql.apollo.ApolloQueryCall +import com.homer.apollographql.apollo.ApolloQueryWatcher +import com.homer.apollographql.apollo.ApolloSubscriptionCall +import com.homer.apollographql.apollo.api.Mutation +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.Query +import com.homer.apollographql.apollo.api.Response +import com.homer.apollographql.apollo.api.Subscription +import com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation +import io.reactivex.BackpressureStrategy +import io.reactivex.Completable +import io.reactivex.Flowable +import io.reactivex.Observable +import io.reactivex.Single +import io.reactivex.annotations.CheckReturnValue + +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloPrefetch.rx(): Completable = + com.homer.apollographql.apollo.rx2.Rx2Apollo.from(this) + +@JvmSynthetic +@CheckReturnValue +inline fun ApolloStoreOperation.rx(): Single = + Rx2Apollo.from(this) + +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloQueryWatcher.rx(): Observable> = + com.homer.apollographql.apollo.rx2.Rx2Apollo.from(this) + +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloCall.rx(): Observable> = + com.homer.apollographql.apollo.rx2.Rx2Apollo.from(this) + +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloSubscriptionCall.rx( + backpressureStrategy: BackpressureStrategy = BackpressureStrategy.LATEST +): Flowable> = com.homer.apollographql.apollo.rx2.Rx2Apollo.from(this, backpressureStrategy) + +/** + * Creates a new [ApolloQueryCall] call and then converts it to an [Observable]. + * + * The number of emissions this Observable will have is based on the + * [com.homer.apollographql.apollo.fetcher.ResponseFetcher] used with the call. + */ +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloClient.rxQuery( + query: Query, + configure: com.homer.apollographql.apollo.ApolloQueryCall.() -> com.homer.apollographql.apollo.ApolloQueryCall = { this } +): Observable> = query(query).configure().rx() + +/** + * Creates a new [ApolloMutationCall] call and then converts it to a [Single]. + */ +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloClient.rxMutate( + mutation: Mutation, + configure: com.homer.apollographql.apollo.ApolloMutationCall.() -> com.homer.apollographql.apollo.ApolloMutationCall = { this } +): Single> = mutate(mutation).configure().rx().singleOrError() + +/** + * Creates a new [ApolloMutationCall] call and then converts it to a [Single]. + * + * Provided optimistic updates will be stored in [com.homer.apollographql.apollo.cache.normalized.ApolloStore] + * immediately before mutation execution. Any [ApolloQueryWatcher] dependent on the changed cache records will + * be re-fetched. + */ +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloClient.rxMutate( + mutation: Mutation, + withOptimisticUpdates: D, + configure: com.homer.apollographql.apollo.ApolloMutationCall.() -> com.homer.apollographql.apollo.ApolloMutationCall = { this } +): Single> = mutate(mutation, withOptimisticUpdates).configure().rx().singleOrError() + +/** + * Creates the [ApolloPrefetch] by wrapping the operation object inside and then converts it to a [Completable]. + */ +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloClient.rxPrefetch( + operation: Operation +): Completable = prefetch(operation).rx() + +/** + * Creates a new [ApolloSubscriptionCall] call and then converts it to a [Flowable]. + * + * Back-pressure strategy can be provided via [backpressureStrategy] parameter. The default value is [BackpressureStrategy.LATEST] + */ +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloClient.rxSubscribe( + subscription: Subscription, + backpressureStrategy: BackpressureStrategy = BackpressureStrategy.LATEST +): Flowable> = subscribe(subscription).rx(backpressureStrategy) diff --git a/apollo-rx3-support/api.txt b/apollo-rx3-support/api.txt index 616520646fd..4bb90fa9b6f 100644 --- a/apollo-rx3-support/api.txt +++ b/apollo-rx3-support/api.txt @@ -1,16 +1,16 @@ // Signature format: 3.0 -package com.apollographql.apollo.rx3 { +package com.homer.apollographql.apollo.rx3 { public final class KotlinExtensions { } public class Rx3Apollo { - method @io.reactivex.rxjava3.annotations.CheckReturnValue public static io.reactivex.rxjava3.core.Observable!> from(com.apollographql.apollo.ApolloQueryWatcher); - method @io.reactivex.rxjava3.annotations.CheckReturnValue public static io.reactivex.rxjava3.core.Observable!> from(com.apollographql.apollo.ApolloCall); - method @io.reactivex.rxjava3.annotations.CheckReturnValue public static io.reactivex.rxjava3.core.Completable from(com.apollographql.apollo.ApolloPrefetch); - method @io.reactivex.rxjava3.annotations.CheckReturnValue public static io.reactivex.rxjava3.core.Flowable!> from(com.apollographql.apollo.ApolloSubscriptionCall); - method @io.reactivex.rxjava3.annotations.CheckReturnValue public static io.reactivex.rxjava3.core.Flowable!> from(com.apollographql.apollo.ApolloSubscriptionCall, io.reactivex.rxjava3.core.BackpressureStrategy); - method @io.reactivex.rxjava3.annotations.CheckReturnValue public static io.reactivex.rxjava3.core.Single from(com.apollographql.apollo.cache.normalized.ApolloStoreOperation); + method @io.reactivex.rxjava3.annotations.CheckReturnValue public static io.reactivex.rxjava3.core.Observable!> from(com.homer.apollographql.apollo.ApolloQueryWatcher); + method @io.reactivex.rxjava3.annotations.CheckReturnValue public static io.reactivex.rxjava3.core.Observable!> from(com.homer.apollographql.apollo.ApolloCall); + method @io.reactivex.rxjava3.annotations.CheckReturnValue public static io.reactivex.rxjava3.core.Completable from(com.homer.apollographql.apollo.ApolloPrefetch); + method @io.reactivex.rxjava3.annotations.CheckReturnValue public static io.reactivex.rxjava3.core.Flowable!> from(com.homer.apollographql.apollo.ApolloSubscriptionCall); + method @io.reactivex.rxjava3.annotations.CheckReturnValue public static io.reactivex.rxjava3.core.Flowable!> from(com.homer.apollographql.apollo.ApolloSubscriptionCall, io.reactivex.rxjava3.core.BackpressureStrategy); + method @io.reactivex.rxjava3.annotations.CheckReturnValue public static io.reactivex.rxjava3.core.Single from(com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation); } } diff --git a/apollo-rx3-support/src/main/java/com/apollographql/apollo/rx3/RxJavaExtensions.kt b/apollo-rx3-support/src/main/java/com/apollographql/apollo/rx3/RxJavaExtensions.kt deleted file mode 100644 index c7d58d29ea6..00000000000 --- a/apollo-rx3-support/src/main/java/com/apollographql/apollo/rx3/RxJavaExtensions.kt +++ /dev/null @@ -1,109 +0,0 @@ -@file:Suppress("NOTHING_TO_INLINE") -@file:JvmName("KotlinExtensions") - -package com.apollographql.apollo.rx3 - -import com.apollographql.apollo.ApolloCall -import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.ApolloMutationCall -import com.apollographql.apollo.ApolloPrefetch -import com.apollographql.apollo.ApolloQueryCall -import com.apollographql.apollo.ApolloQueryWatcher -import com.apollographql.apollo.ApolloSubscriptionCall -import com.apollographql.apollo.api.Mutation -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.Query -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.Subscription -import com.apollographql.apollo.cache.normalized.ApolloStoreOperation -import io.reactivex.rxjava3.annotations.CheckReturnValue -import io.reactivex.rxjava3.core.BackpressureStrategy -import io.reactivex.rxjava3.core.Completable -import io.reactivex.rxjava3.core.Flowable -import io.reactivex.rxjava3.core.Observable -import io.reactivex.rxjava3.core.Single - -@JvmSynthetic -@CheckReturnValue -inline fun ApolloPrefetch.rx(): Completable = - Rx3Apollo.from(this) - -@JvmSynthetic -@CheckReturnValue -inline fun ApolloStoreOperation.rx(): Single = - Rx3Apollo.from(this) - -@JvmSynthetic -@CheckReturnValue -inline fun ApolloQueryWatcher.rx(): Observable> = - Rx3Apollo.from(this) - -@JvmSynthetic -@CheckReturnValue -inline fun ApolloCall.rx(): Observable> = - Rx3Apollo.from(this) - -@JvmSynthetic -@CheckReturnValue -inline fun ApolloSubscriptionCall.rx( - backpressureStrategy: BackpressureStrategy = BackpressureStrategy.LATEST -): Flowable> = Rx3Apollo.from(this, backpressureStrategy) - -/** - * Creates a new [ApolloQueryCall] call and then converts it to an [Observable]. - * - * The number of emissions this Observable will have is based on the - * [com.apollographql.apollo.fetcher.ResponseFetcher] used with the call. - */ -@JvmSynthetic -@CheckReturnValue -inline fun ApolloClient.rxQuery( - query: Query, - configure: ApolloQueryCall.() -> ApolloQueryCall = { this } -): Observable> = query(query).configure().rx() - -/** - * Creates a new [ApolloMutationCall] call and then converts it to a [Single]. - */ -@JvmSynthetic -@CheckReturnValue -inline fun ApolloClient.rxMutate( - mutation: Mutation, - configure: ApolloMutationCall.() -> ApolloMutationCall = { this } -): Single> = mutate(mutation).configure().rx().singleOrError() - -/** - * Creates a new [ApolloMutationCall] call and then converts it to a [Single]. - * - * Provided optimistic updates will be stored in [com.apollographql.apollo.cache.normalized.ApolloStore] - * immediately before mutation execution. Any [ApolloQueryWatcher] dependent on the changed cache records will - * be re-fetched. - */ -@JvmSynthetic -@CheckReturnValue -inline fun ApolloClient.rxMutate( - mutation: Mutation, - withOptimisticUpdates: D, - configure: ApolloMutationCall.() -> ApolloMutationCall = { this } -): Single> = mutate(mutation, withOptimisticUpdates).configure().rx().singleOrError() - -/** - * Creates the [ApolloPrefetch] by wrapping the operation object inside and then converts it to a [Completable]. - */ -@JvmSynthetic -@CheckReturnValue -inline fun ApolloClient.rxPrefetch( - operation: Operation -): Completable = prefetch(operation).rx() - -/** - * Creates a new [ApolloSubscriptionCall] call and then converts it to a [Flowable]. - * - * Back-pressure strategy can be provided via [backpressureStrategy] parameter. The default value is [BackpressureStrategy.LATEST] - */ -@JvmSynthetic -@CheckReturnValue -inline fun ApolloClient.rxSubscribe( - subscription: Subscription, - backpressureStrategy: BackpressureStrategy = BackpressureStrategy.LATEST -): Flowable> = subscribe(subscription).rx(backpressureStrategy) diff --git a/apollo-rx3-support/src/main/java/com/apollographql/apollo/rx3/Rx3Apollo.java b/apollo-rx3-support/src/main/java/com/homer/apollographql/apollo/rx3/Rx3Apollo.java similarity index 87% rename from apollo-rx3-support/src/main/java/com/apollographql/apollo/rx3/Rx3Apollo.java rename to apollo-rx3-support/src/main/java/com/homer/apollographql/apollo/rx3/Rx3Apollo.java index 00b77e9ae95..f08caa56304 100644 --- a/apollo-rx3-support/src/main/java/com/apollographql/apollo/rx3/Rx3Apollo.java +++ b/apollo-rx3-support/src/main/java/com/homer/apollographql/apollo/rx3/Rx3Apollo.java @@ -1,14 +1,21 @@ -package com.apollographql.apollo.rx3; +package com.homer.apollographql.apollo.rx3; -import com.apollographql.apollo.ApolloCall; -import com.apollographql.apollo.ApolloPrefetch; -import com.apollographql.apollo.ApolloQueryWatcher; -import com.apollographql.apollo.ApolloSubscriptionCall; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.cache.normalized.ApolloStoreOperation; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.internal.subscription.ApolloSubscriptionTerminatedException; -import com.apollographql.apollo.internal.util.Cancelable; +import com.homer.apollographql.apollo.ApolloCall; +import com.homer.apollographql.apollo.ApolloPrefetch; +import com.homer.apollographql.apollo.ApolloQueryWatcher; +import com.homer.apollographql.apollo.ApolloSubscriptionCall; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.internal.subscription.ApolloSubscriptionTerminatedException; +import com.homer.apollographql.apollo.internal.util.Cancelable; +import com.homer.apollographql.apollo.ApolloCall; +import com.homer.apollographql.apollo.ApolloPrefetch; +import com.homer.apollographql.apollo.ApolloQueryWatcher; +import com.homer.apollographql.apollo.ApolloSubscriptionCall; +import com.homer.apollographql.apollo.fetcher.ResponseFetcher; +import com.homer.apollographql.apollo.internal.subscription.ApolloSubscriptionTerminatedException; +import com.homer.apollographql.apollo.internal.util.Cancelable; import org.jetbrains.annotations.NotNull; import io.reactivex.rxjava3.annotations.CheckReturnValue; import io.reactivex.rxjava3.core.BackpressureStrategy; @@ -26,7 +33,7 @@ import io.reactivex.rxjava3.core.SingleOnSubscribe; import io.reactivex.rxjava3.disposables.Disposable; import io.reactivex.rxjava3.exceptions.Exceptions; -import static com.apollographql.apollo.api.internal.Utils.checkNotNull; +import static com.homer.apollographql.apollo.api.internal.Utils.checkNotNull; /** * The Rx3Apollo class provides methods for converting ApolloCall, ApolloPrefetch and ApolloWatcher types to RxJava 3 @@ -75,7 +82,7 @@ public static Observable> from(@NotNull final ApolloQueryWatcher /** * Converts an {@link ApolloCall} to an {@link Observable}. The number of emissions this Observable will have is based - * on the {@link com.apollographql.apollo.fetcher.ResponseFetcher} used with the call. + * on the {@link ResponseFetcher} used with the call. * * @param call the ApolloCall to convert * @param the value type. diff --git a/apollo-rx3-support/src/main/java/com/homer/apollographql/apollo/rx3/RxJavaExtensions.kt b/apollo-rx3-support/src/main/java/com/homer/apollographql/apollo/rx3/RxJavaExtensions.kt new file mode 100644 index 00000000000..82e8171fdb4 --- /dev/null +++ b/apollo-rx3-support/src/main/java/com/homer/apollographql/apollo/rx3/RxJavaExtensions.kt @@ -0,0 +1,109 @@ +@file:Suppress("NOTHING_TO_INLINE") +@file:JvmName("KotlinExtensions") + +package com.homer.apollographql.apollo.rx3 + +import com.homer.apollographql.apollo.ApolloCall +import com.homer.apollographql.apollo.ApolloClient +import com.homer.apollographql.apollo.ApolloMutationCall +import com.homer.apollographql.apollo.ApolloPrefetch +import com.homer.apollographql.apollo.ApolloQueryCall +import com.homer.apollographql.apollo.ApolloQueryWatcher +import com.homer.apollographql.apollo.ApolloSubscriptionCall +import com.homer.apollographql.apollo.api.Mutation +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.Query +import com.homer.apollographql.apollo.api.Response +import com.homer.apollographql.apollo.api.Subscription +import com.homer.apollographql.apollo.cache.normalized.ApolloStoreOperation +import io.reactivex.rxjava3.annotations.CheckReturnValue +import io.reactivex.rxjava3.core.BackpressureStrategy +import io.reactivex.rxjava3.core.Completable +import io.reactivex.rxjava3.core.Flowable +import io.reactivex.rxjava3.core.Observable +import io.reactivex.rxjava3.core.Single + +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloPrefetch.rx(): Completable = + com.homer.apollographql.apollo.rx3.Rx3Apollo.from(this) + +@JvmSynthetic +@CheckReturnValue +inline fun ApolloStoreOperation.rx(): Single = + Rx3Apollo.from(this) + +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloQueryWatcher.rx(): Observable> = + com.homer.apollographql.apollo.rx3.Rx3Apollo.from(this) + +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloCall.rx(): Observable> = + com.homer.apollographql.apollo.rx3.Rx3Apollo.from(this) + +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloSubscriptionCall.rx( + backpressureStrategy: BackpressureStrategy = BackpressureStrategy.LATEST +): Flowable> = com.homer.apollographql.apollo.rx3.Rx3Apollo.from(this, backpressureStrategy) + +/** + * Creates a new [ApolloQueryCall] call and then converts it to an [Observable]. + * + * The number of emissions this Observable will have is based on the + * [com.homer.apollographql.apollo.fetcher.ResponseFetcher] used with the call. + */ +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloClient.rxQuery( + query: Query, + configure: com.homer.apollographql.apollo.ApolloQueryCall.() -> com.homer.apollographql.apollo.ApolloQueryCall = { this } +): Observable> = query(query).configure().rx() + +/** + * Creates a new [ApolloMutationCall] call and then converts it to a [Single]. + */ +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloClient.rxMutate( + mutation: Mutation, + configure: com.homer.apollographql.apollo.ApolloMutationCall.() -> com.homer.apollographql.apollo.ApolloMutationCall = { this } +): Single> = mutate(mutation).configure().rx().singleOrError() + +/** + * Creates a new [ApolloMutationCall] call and then converts it to a [Single]. + * + * Provided optimistic updates will be stored in [com.homer.apollographql.apollo.cache.normalized.ApolloStore] + * immediately before mutation execution. Any [ApolloQueryWatcher] dependent on the changed cache records will + * be re-fetched. + */ +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloClient.rxMutate( + mutation: Mutation, + withOptimisticUpdates: D, + configure: com.homer.apollographql.apollo.ApolloMutationCall.() -> com.homer.apollographql.apollo.ApolloMutationCall = { this } +): Single> = mutate(mutation, withOptimisticUpdates).configure().rx().singleOrError() + +/** + * Creates the [ApolloPrefetch] by wrapping the operation object inside and then converts it to a [Completable]. + */ +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloClient.rxPrefetch( + operation: Operation +): Completable = prefetch(operation).rx() + +/** + * Creates a new [ApolloSubscriptionCall] call and then converts it to a [Flowable]. + * + * Back-pressure strategy can be provided via [backpressureStrategy] parameter. The default value is [BackpressureStrategy.LATEST] + */ +@JvmSynthetic +@CheckReturnValue +inline fun com.homer.apollographql.apollo.ApolloClient.rxSubscribe( + subscription: Subscription, + backpressureStrategy: BackpressureStrategy = BackpressureStrategy.LATEST +): Flowable> = subscribe(subscription).rx(backpressureStrategy) diff --git a/build.gradle.kts b/build.gradle.kts index 32e63d71588..48d37c210ef 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,6 +14,8 @@ buildscript { ApiCompatibility.configure(rootProject) subprojects { + setJitPackFields() + apply { from(rootProject.file("gradle/dependencies.gradle")) } @@ -64,25 +66,6 @@ subprojects { group = property("GROUP")!! version = property("VERSION_NAME")!! - apply(plugin = "checkstyle") - - extensions.findByType(CheckstyleExtension::class.java)!!.apply { - configFile = rootProject.file("checkstyle.xml") - configProperties = mapOf( - "checkstyle.cache.file" to rootProject.file("build/checkstyle.cache") - ) - } - - tasks.register("checkstyle", Checkstyle::class.java) { - source("src/main/java") - include("**/*.java") - classpath = files() - } - - afterEvaluate { - tasks.findByName("check")?.dependsOn("checkstyle") - } - tasks.withType().configureEach { systemProperty("updateTestFixtures", System.getProperty("updateTestFixtures")) } @@ -99,23 +82,7 @@ fun Project.configurePublishing() { * Javadoc */ var javadocTask = tasks.findByName("javadoc") as Javadoc? - var javadocJarTaskProvider: TaskProvider? = null - - if (javadocTask == null && android != null) { - // create the Android javadoc if needed - javadocTask = tasks.create("javadoc", Javadoc::class.java) { - source = android.sourceSets["main"].java.sourceFiles - classpath += project.files(android.bootClasspath.joinToString(File.pathSeparator)) - - (android as? com.android.build.gradle.LibraryExtension)?.libraryVariants?.configureEach { - if (name != "release") { - return@configureEach - } - classpath += getCompileClasspath(null) - } - } - } - + var javadocJarTaskProvider: TaskProvider? javadocJarTaskProvider = tasks.register("javadocJar", org.gradle.jvm.tasks.Jar::class.java) { archiveClassifier.set("javadoc") if (javadocTask != null) { @@ -124,19 +91,6 @@ fun Project.configurePublishing() { } } - val javaPluginConvention = project.convention.findPlugin(JavaPluginConvention::class.java) - val sourcesJarTaskProvider = tasks.register("sourcesJar", org.gradle.jvm.tasks.Jar::class.java) { - archiveClassifier.set("sources") - when { - javaPluginConvention != null && android == null -> { - from(javaPluginConvention.sourceSets.get("main").allSource) - } - android != null -> { - from(android.sourceSets["main"].java.sourceFiles) - } - } - } - tasks.withType(Javadoc::class.java) { // TODO: fix the javadoc warnings (options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet") @@ -161,7 +115,6 @@ fun Project.configurePublishing() { artifact(javadocJarTaskProvider.get()) if (name == "kotlinMultiplatform") { // sources are added for each platform but not for the common module - artifact(sourcesJarTaskProvider.get()) } } } @@ -169,7 +122,6 @@ fun Project.configurePublishing() { // java-gradle-plugin doesn't add javadoc/sources by default so add it here withType { artifact(javadocJarTaskProvider.get()) - artifact(sourcesJarTaskProvider.get()) } } else -> { @@ -184,7 +136,6 @@ fun Project.configurePublishing() { } artifact(javadocJarTaskProvider.get()) - artifact(sourcesJarTaskProvider.get()) pom { artifactId = findProperty("POM_ARTIFACT_ID") as String? @@ -348,7 +299,7 @@ tasks.register("sonatypeCloseAndReleaseRepository") { username = System.getenv("SONATYPE_NEXUS_USERNAME"), password = System.getenv("SONATYPE_NEXUS_PASSWORD"), baseUrl = "https://oss.sonatype.org/service/local/", - groupId = "com.apollographql" + groupId = "com.homer.apollographql" ).closeAndReleaseRepository() } } @@ -381,3 +332,11 @@ tasks.register("bintrayPublish") { } } +/* Jit pack configuration */ +fun Project.setJitPackFields() { + val android = extensions.findByType(com.android.build.gradle.BaseExtension::class.java) + if ( android as? com.android.build.gradle.LibraryExtension != null) { + apply(plugin = "com.github.dcendents.android-maven") + } +} + diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index a9d8aa24aa7..ba00f654dad 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,5 +1,6 @@ plugins { - id("org.jetbrains.kotlin.jvm").version("1.4.10") + // Match the gradle wrapper version as close as possible to avoid classpath mismatches + id("org.jetbrains.kotlin.jvm").version("1.5.31") } project.apply { @@ -23,4 +24,6 @@ dependencies { implementation(groovy.util.Eval.x(project, "x.dep.gradlePublishPlugin")) // this plugin is added to the classpath but never applied, it is only used for the closeAndRelease code implementation(groovy.util.Eval.x(project, "x.dep.vanniktechPlugin")) + // this plugin was added to publish the artifacts to jit pack + implementation(groovy.util.Eval.x(project, "x.dep.mavenGradlePlugin")) } \ No newline at end of file diff --git a/composite/build.gradle.kts b/composite/build.gradle.kts index 4da66fe6afb..7c64bcd2969 100644 --- a/composite/build.gradle.kts +++ b/composite/build.gradle.kts @@ -12,7 +12,7 @@ buildscript { dependencies { classpath(groovy.util.Eval.x(project, "x.dep.android.plugin")) classpath(groovy.util.Eval.x(project, "x.dep.kotlin.plugin")) - classpath("com.apollographql.apollo:apollo-gradle-plugin") + classpath("com.homer.apollographql.apollo:apollo-gradle-plugin") } } diff --git a/composite/gradle/wrapper b/composite/gradle/wrapper deleted file mode 120000 index cbfd2e1d394..00000000000 --- a/composite/gradle/wrapper +++ /dev/null @@ -1 +0,0 @@ -../../gradle/wrapper/ \ No newline at end of file diff --git a/composite/gradle/wrapper/gradle-wrapper.jar b/composite/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000000..f3d88b1c2fa Binary files /dev/null and b/composite/gradle/wrapper/gradle-wrapper.jar differ diff --git a/composite/gradle/wrapper/gradle-wrapper.properties b/composite/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000000..1b16c34a71c --- /dev/null +++ b/composite/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/composite/gradlew b/composite/gradlew deleted file mode 120000 index 502f5a2d3ec..00000000000 --- a/composite/gradlew +++ /dev/null @@ -1 +0,0 @@ -../gradlew \ No newline at end of file diff --git a/composite/gradlew b/composite/gradlew new file mode 100644 index 00000000000..2fe81a7d95e --- /dev/null +++ b/composite/gradlew @@ -0,0 +1,183 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/composite/gradlew.bat b/composite/gradlew.bat deleted file mode 120000 index 28401328871..00000000000 --- a/composite/gradlew.bat +++ /dev/null @@ -1 +0,0 @@ -../gradlew.bat \ No newline at end of file diff --git a/composite/gradlew.bat b/composite/gradlew.bat new file mode 100644 index 00000000000..9618d8d9607 --- /dev/null +++ b/composite/gradlew.bat @@ -0,0 +1,100 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/composite/settings.gradle.kts b/composite/settings.gradle.kts index 90bcbddbdce..0476e132716 100644 --- a/composite/settings.gradle.kts +++ b/composite/settings.gradle.kts @@ -5,14 +5,14 @@ include(":multiplatform") project(":multiplatform").projectDir = file("../samples/multiplatform") include(":multiplatform:kmp-lib-sample") project(":multiplatform:kmp-lib-sample").projectDir = file("../samples/multiplatform/kmp-lib-sample") -if (System.getProperty("idea.sync.active") == null) { +//if (System.getProperty("idea.sync.active") == null) { include(":java-sample") project(":java-sample").projectDir = file("../samples/java-sample") include(":kotlin-sample") project(":kotlin-sample").projectDir = file("../samples/kotlin-sample") include(":multiplatform:kmp-android-app") project(":multiplatform:kmp-android-app").projectDir = file("../samples/multiplatform/kmp-android-app") -} +//} // Integration Tests include(":apollo-integration") diff --git a/docs/source/advanced/coroutines.mdx b/docs/source/advanced/coroutines.mdx index 55f313cc6d9..93ac0df8464 100644 --- a/docs/source/advanced/coroutines.mdx +++ b/docs/source/advanced/coroutines.mdx @@ -18,5 +18,5 @@ fun ApolloPrefetch.toJob(): Job Add the following `dependency`: ```groovy -implementation 'com.apollographql.apollo:apollo-coroutines-support:x.y.z' +implementation 'com.homer.apollographql.apollo:apollo-coroutines-support:x.y.z' ``` diff --git a/docs/source/advanced/multi-modules.mdx b/docs/source/advanced/multi-modules.mdx index 688da1d9f64..fb24877cbb5 100644 --- a/docs/source/advanced/multi-modules.mdx +++ b/docs/source/advanced/multi-modules.mdx @@ -23,7 +23,7 @@ And declare your parent module as a dependency of your feature module: ```kotlin // feature/build.gradle.kts dependencies { - implementation("com.apollographql.apollo:apollo-runtime:xyz") + implementation("com.homer.apollographql.apollo:apollo-runtime:xyz") // more regular dependencies // Apollo dependencies diff --git a/docs/source/advanced/no-runtime.mdx b/docs/source/advanced/no-runtime.mdx index b8f8fceeb42..0923c138627 100644 --- a/docs/source/advanced/no-runtime.mdx +++ b/docs/source/advanced/no-runtime.mdx @@ -7,10 +7,10 @@ import {MultiCodeBlock} from 'gatsby-theme-apollo-docs'; `apollo-runtime` and `ApolloClient` provides support for doing the network requests and interacting with the cache but you can use the generated queries without the runtime if you want. -For this, remove the `com.apollographql.apollo:apollo-runtime`dependency and replace it with: +For this, remove the `com.homer.apollographql.apollo:apollo-runtime`dependency and replace it with: ```kotlin:title=build.gradle -implementation("com.apollographql.apollo:apollo-api:x.y.z") +implementation("com.homer.apollographql.apollo:apollo-api:x.y.z") ``` ## Composing HTTP request body @@ -36,7 +36,7 @@ okhttp3.RequestBody requestBody = RequestBody.create(mediaType, payload); If GraphQL operation defines any variable with custom scalar type, you must provide properly configured instance of -`com.apollographql.apollo.response.ScalarTypeAdapters`: +`com.homer.apollographql.apollo.response.ScalarTypeAdapters`: ```java ScalarTypeAdapters scalarTypeAdapters = new ScalarTypeAdapters(); @@ -72,7 +72,7 @@ okhttp3.Response httpResponse = ...; Response response = new Query().parse(httpResponse.body().source()); ``` -If you do have custom GraphQL scalar types, pass properly configured instance of `com.apollographql.apollo.response.ScalarTypeAdapters`: +If you do have custom GraphQL scalar types, pass properly configured instance of `com.homer.apollographql.apollo.response.ScalarTypeAdapters`: ```java okhttp3.Response httpResponse = ...; diff --git a/docs/source/advanced/persisted-queries.mdx b/docs/source/advanced/persisted-queries.mdx index 1dc38c98601..cd173b62ad6 100644 --- a/docs/source/advanced/persisted-queries.mdx +++ b/docs/source/advanced/persisted-queries.mdx @@ -41,7 +41,7 @@ apollo { ## Custom ID for Persisted Queries -By default, Apollo uses `Sha256` hashing algorithm to generate an ID for the query. To provide custom ID generation logic, use the option - `operationIdGenerator` which accepts an `instance` that implements the `OperationIdGenerator` interface (`com.apollographql.apollo.compiler.OperationIdGenerator`) as the input. This option can be used to either specify a different hashing algorithm or to fetch the persisted query ID from a different place - e.g. a service or a CLI. +By default, Apollo uses `Sha256` hashing algorithm to generate an ID for the query. To provide custom ID generation logic, use the option - `operationIdGenerator` which accepts an `instance` that implements the `OperationIdGenerator` interface (`com.homer.apollographql.apollo.compiler.OperationIdGenerator`) as the input. This option can be used to either specify a different hashing algorithm or to fetch the persisted query ID from a different place - e.g. a service or a CLI. Example Md5 hash generator: @@ -49,7 +49,7 @@ Example Md5 hash generator: ```kotlin apollo { - operationIdGenerator.set(object: com.apollographql.apollo.compiler.OperationIdGenerator { + operationIdGenerator.set(object: com.homer.apollographql.apollo.compiler.OperationIdGenerator { override val version = "my-md5-version1" override fun apply(operationDocument: String, operationFilepath: String): String { @@ -60,7 +60,7 @@ apollo { ``` ```groovy -import com.apollographql.apollo.compiler.OperationIdGenerator +import com.homer.apollographql.apollo.compiler.OperationIdGenerator apollo { operationIdGenerator = new OperationIdGenerator() { diff --git a/docs/source/advanced/rxjava2.mdx b/docs/source/advanced/rxjava2.mdx index 04d96a7c737..2fa82237833 100644 --- a/docs/source/advanced/rxjava2.mdx +++ b/docs/source/advanced/rxjava2.mdx @@ -22,7 +22,7 @@ Add the following `dependency`: ```groovy // RxJava2 support -implementation 'com.apollographql.apollo:apollo-rx2-support:x.y.z' +implementation 'com.homer.apollographql.apollo:apollo-rx2-support:x.y.z' ``` ## Usage examples diff --git a/docs/source/advanced/rxjava3.mdx b/docs/source/advanced/rxjava3.mdx index a67d7cfbc66..53df77db200 100644 --- a/docs/source/advanced/rxjava3.mdx +++ b/docs/source/advanced/rxjava3.mdx @@ -22,7 +22,7 @@ Add the following `dependency`: ```groovy // RxJava3 support -implementation 'com.apollographql.apollo:apollo-rx3-support:x.y.z' +implementation 'com.homer.apollographql.apollo:apollo-rx3-support:x.y.z' ``` ## Usage examples diff --git a/docs/source/advanced/ui-tests.mdx b/docs/source/advanced/ui-tests.mdx index 0b0433a6459..0af3e7c39ac 100644 --- a/docs/source/advanced/ui-tests.mdx +++ b/docs/source/advanced/ui-tests.mdx @@ -10,7 +10,7 @@ Add the following `dependency`: [ ![apollo-idling-resource](https://img.shields.io/bintray/v/apollographql/android/apollo-idling-resource.svg?label=apollo-idling-resource) ](https://bintray.com/apollographql/android/apollo-idling-resource/_latestVersion) ```groovy -implementation("com.apollographql.apollo:apollo-idling-resource:x.y.z") +implementation("com.homer.apollographql.apollo:apollo-idling-resource:x.y.z") ``` If you have multiple `ApolloClients` you need to create and register multiple `ApolloIdlingResource` with different names. Registering several IdlingResources with the same name will crash. diff --git a/docs/source/essentials/get-started-java.mdx b/docs/source/essentials/get-started-java.mdx index dc4f3f7a861..76f08b801d8 100644 --- a/docs/source/essentials/get-started-java.mdx +++ b/docs/source/essentials/get-started-java.mdx @@ -9,7 +9,7 @@ import AddQuery from "../shared/add-query.mdx" ## Add the Gradle plugin -In your app Gradle file, apply the `com.apollographql.apollo` plugin: +In your app Gradle file, apply the `com.homer.apollographql.apollo` plugin: Using the [plugins DSL](https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block): @@ -18,14 +18,14 @@ Using the [plugins DSL](https://docs.gradle.org/current/userguide/plugins.html#s ```groovy plugins { // ... - id("com.apollographql.apollo").version("x.y.z") + id("com.homer.apollographql.apollo").version("x.y.z") } ``` ```kotlin plugins { // ... - id("com.apollographql.apollo").version("x.y.z") + id("com.homer.apollographql.apollo").version("x.y.z") } ``` @@ -38,19 +38,19 @@ Or using the [legacy syntax](https://docs.gradle.org/current/userguide/plugins.h ```groovy buildscript { // ... - classpath("com.apollographql.apollo:apollo-gradle-plugin:x.y.z") + classpath("com.homer.apollographql.apollo:apollo-gradle-plugin:x.y.z") } -apply plugin: "com.apollographql.apollo" +apply plugin: "com.homer.apollographql.apollo" ``` ```kotlin buildscript { // ... - classpath("com.apollographql.apollo:apollo-gradle-plugin:x.y.z") + classpath("com.homer.apollographql.apollo:apollo-gradle-plugin:x.y.z") } -apply(plugin = "com.apollographql.apollo") +apply(plugin = "com.homer.apollographql.apollo") ``` @@ -60,7 +60,7 @@ The plugin is hosted on the Gradle plugin portal, Jcenter and Maven Central. ```kotlin dependencies { - implementation("com.apollographql.apollo:apollo-runtime:x.y.z") + implementation("com.homer.apollographql.apollo:apollo-runtime:x.y.z") } ``` diff --git a/docs/source/essentials/get-started-kotlin.mdx b/docs/source/essentials/get-started-kotlin.mdx index 480fc90d0fc..f6727fd28bb 100644 --- a/docs/source/essentials/get-started-kotlin.mdx +++ b/docs/source/essentials/get-started-kotlin.mdx @@ -38,9 +38,9 @@ apollo { ```kotlin dependencies { // The core runtime dependencies - implementation("com.apollographql.apollo:apollo-runtime:x.y.z") + implementation("com.homer.apollographql.apollo:apollo-runtime:x.y.z") // Coroutines extensions for easier asynchronicity handling - implementation("com.apollographql.apollo:apollo-coroutines-support:x.y.z") + implementation("com.homer.apollographql.apollo:apollo-coroutines-support:x.y.z") } ``` diff --git a/docs/source/essentials/get-started-multiplatform.mdx b/docs/source/essentials/get-started-multiplatform.mdx index 3136f2efd6e..f00e0215f07 100644 --- a/docs/source/essentials/get-started-multiplatform.mdx +++ b/docs/source/essentials/get-started-multiplatform.mdx @@ -29,7 +29,7 @@ kotlin { commonMain { dependencies { // - implementation("com.apollographql.apollo:apollo-runtime-kotlin:x.y.z") + implementation("com.homer.apollographql.apollo:apollo-runtime-kotlin:x.y.z") } } } diff --git a/docs/source/essentials/http-cache.mdx b/docs/source/essentials/http-cache.mdx index 12c68aac016..13129e21dc4 100644 --- a/docs/source/essentials/http-cache.mdx +++ b/docs/source/essentials/http-cache.mdx @@ -9,11 +9,11 @@ Apollo Android provides two different kinds of caches: an HTTP cache and a norma ## HTTP cache To enable HTTP cache support, add the dependency to your project's `build.gradle file. The latest version is -[![Maven Central](https://img.shields.io/maven-central/v/com.apollographql.apollo/apollo-api)](https://repo1.maven.org/maven2/com/apollographql/apollo/) +[![Maven Central](https://img.shields.io/maven-central/v/com.homer.apollographql.apollo/apollo-api)](https://repo1.maven.org/maven2/com/apollographql/apollo/) ```kotlin:title=build.gradle dependencies { - implementation("com.apollographql.apollo:apollo-http-cache:x.y.z") + implementation("com.homer.apollographql.apollo:apollo-http-cache:x.y.z") } ``` diff --git a/docs/source/essentials/migration.mdx b/docs/source/essentials/migration.mdx index de40998f6af..ac6390d576a 100644 --- a/docs/source/essentials/migration.mdx +++ b/docs/source/essentials/migration.mdx @@ -36,7 +36,7 @@ If you explicitly depend okio, it is recommended to do a major version upgrade b ### New Normalized Cache Modules For in-memory `LruNormalizedCache` users, no change required since `apollo-runtime` brings it as transitive dependency. It is still -recommended adding the following dependency explicitly: `implementation("com.apollographql.apollo:apollo-normalized-cache:x.y.z")` +recommended adding the following dependency explicitly: `implementation("com.homer.apollographql.apollo:apollo-normalized-cache:x.y.z")` > Apollo normalized cache module ([#2142](https://github.com/apollographql/apollo-android/pull/2142)) @@ -44,10 +44,10 @@ recommended adding the following dependency explicitly: `implementation("com.apo ```kotlin:title=build.gradle // Replace: -implementation("com.apollographql.apollo:apollo-android-support:x.y.z") +implementation("com.homer.apollographql.apollo:apollo-android-support:x.y.z") // With: -implementation("com.apollographql.apollo:apollo-normalized-cache-sqlite:x.y.z") // highlight-line +implementation("com.homer.apollographql.apollo:apollo-normalized-cache-sqlite:x.y.z") // highlight-line ``` `ApolloSqlHelper` is deprecated. Instantiate `SqlNormalizedCacheFactory` with same arguments instead. @@ -95,25 +95,25 @@ different options. #### New plugin ID -The plugin ID has been changed from `com.apollographql.android` to `com.apollographql.apollo` to make it clear that the plugin works also -for non-Android projects. `com.apollographql.android` will be removed in a future revision. +The plugin ID has been changed from `com.homer.apollographql.android` to `com.homer.apollographql.apollo` to make it clear that the plugin works also +for non-Android projects. `com.homer.apollographql.android` will be removed in a future revision. ```kotlin // Replace: -apply(plugin = "com.apollographql.android") +apply(plugin = "com.homer.apollographql.android") // With: -apply(plugin = "com.apollographql.apollo") // highlight-line +apply(plugin = "com.homer.apollographql.apollo") // highlight-line ``` ```groovy // Replace: -apply plugin: 'com.apollographql.android' +apply plugin: 'com.homer.apollographql.android' // With: -apply plugin: 'com.apollographql.apollo' // highlight-line +apply plugin: 'com.homer.apollographql.apollo' // highlight-line ``` @@ -205,10 +205,10 @@ one. If you were relying on fully qualified class names from your `build.gradle. ```kotlin // Replace: -import com.apollographql.apollo.gradle.ApolloExtension +import com.homer.apollographql.apollo.gradle.ApolloExtension // With: -import com.apollographql.apollo.gradle.api.ApolloExtension // highlight-line +import com.homer.apollographql.apollo.gradle.api.ApolloExtension // highlight-line ``` ### Breaking changes in generated Kotlin models with inline fragments: @@ -320,8 +320,8 @@ The artifact is also renamed to make its intention more obvious. Documentation f ```groovy:title=build.gradle // Replace: - androidTestImplementation("com.apollographql.apollo:apollo-espresso-support:x.y.z") + androidTestImplementation("com.homer.apollographql.apollo:apollo-espresso-support:x.y.z") // With: - androidTestImplementation("com.apollographql.apollo:apollo-idling-resource:x.y.z") // highlight-line + androidTestImplementation("com.homer.apollographql.apollo:apollo-idling-resource:x.y.z") // highlight-line ``` diff --git a/docs/source/essentials/mutations.mdx b/docs/source/essentials/mutations.mdx index 9c188ca33fc..dbfbdf06bec 100644 --- a/docs/source/essentials/mutations.mdx +++ b/docs/source/essentials/mutations.mdx @@ -173,7 +173,7 @@ You need to define this mapping in your build.gradle file. ```groovy apollo { customTypeMapping = [ - "Upload" : "com.apollographql.apollo.api.FileUpload" + "Upload" : "com.homer.apollographql.apollo.api.FileUpload" ] } ``` @@ -183,7 +183,7 @@ apollo { **Note2** While Apollo Android doesn't use reflection for regular operations, file upload is. If you're using Proguard/R8, you need to keep everything inheriting from `InputType`: ```proguard:title=proguard-rules.pro --keep class * implements com.apollographql.apollo.api.InputType { *; } +-keep class * implements com.homer.apollographql.apollo.api.InputType { *; } ``` In this example, the GraphQL schema uses custom scalar type named `Upload` for file upload. diff --git a/docs/source/essentials/normalized-cache.mdx b/docs/source/essentials/normalized-cache.mdx index 686daada85d..576ce9344cb 100644 --- a/docs/source/essentials/normalized-cache.mdx +++ b/docs/source/essentials/normalized-cache.mdx @@ -71,7 +71,7 @@ If the amount of data you store becomes too big to fit in memory or if you want ```kotlin:title=build.gradle.kts dependencies { - implementation("com.apollographql.apollo:apollo-normalized-cache-sqlite:x.y.z") + implementation("com.homer.apollographql.apollo:apollo-normalized-cache-sqlite:x.y.z") } ``` diff --git a/docs/source/essentials/plugin-configuration.mdx b/docs/source/essentials/plugin-configuration.mdx index 492711b234b..af63ac1f17b 100644 --- a/docs/source/essentials/plugin-configuration.mdx +++ b/docs/source/essentials/plugin-configuration.mdx @@ -79,7 +79,7 @@ The up-to-date list of options can be found in [CompilerParams](https://github.c * * Example Md5 hash generator: * - * import com.apollographql.apollo.compiler.OperationIdGenerator + * import com.homer.apollographql.apollo.compiler.OperationIdGenerator * * apollo { * operationIdGenerator = new OperationIdGenerator() { diff --git a/docs/source/shared/add-plugin.mdx b/docs/source/shared/add-plugin.mdx index fe2e3166f5e..620a6b6513a 100644 --- a/docs/source/shared/add-plugin.mdx +++ b/docs/source/shared/add-plugin.mdx @@ -1,6 +1,6 @@ import {MultiCodeBlock} from 'gatsby-theme-apollo-docs'; -In your app Gradle file, apply the `com.apollographql.apollo` plugin: +In your app Gradle file, apply the `com.homer.apollographql.apollo` plugin: Using the [plugins DSL](https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block): @@ -9,14 +9,14 @@ Using the [plugins DSL](https://docs.gradle.org/current/userguide/plugins.html#s ```kotlin plugins { // ... - id("com.apollographql.apollo").version("x.y.z") + id("com.homer.apollographql.apollo").version("x.y.z") } ``` ```groovy plugins { // ... - id("com.apollographql.apollo").version("x.y.z") + id("com.homer.apollographql.apollo").version("x.y.z") } ``` @@ -29,19 +29,19 @@ Or using the [legacy syntax](https://docs.gradle.org/current/userguide/plugins.h ```kotlin buildscript { // ... - classpath("com.apollographql.apollo:apollo-gradle-plugin:x.y.z") + classpath("com.homer.apollographql.apollo:apollo-gradle-plugin:x.y.z") } -apply(plugin = "com.apollographql.apollo") +apply(plugin = "com.homer.apollographql.apollo") ``` ```groovy buildscript { // ... - classpath("com.apollographql.apollo:apollo-gradle-plugin:x.y.z") + classpath("com.homer.apollographql.apollo:apollo-gradle-plugin:x.y.z") } -apply plugin: "com.apollographql.apollo" +apply plugin: "com.homer.apollographql.apollo" ``` diff --git a/docs/source/tutorial/01-configure-project.mdx b/docs/source/tutorial/01-configure-project.mdx index 9586f15be9b..5e08215b2c1 100644 --- a/docs/source/tutorial/01-configure-project.mdx +++ b/docs/source/tutorial/01-configure-project.mdx @@ -36,13 +36,13 @@ This tutorial uses `2.2.0` because it is the latest version at the time of writi ## Apply the plugin -Apply the Apollo plugin in `app/build.gradle.kts`. There are two `build.gradle.kts` in the project. Make sure to use the one in the `app` directory this time. The Apollo plugin ID is `com.apollographql.apollo`. +Apply the Apollo plugin in `app/build.gradle.kts`. There are two `build.gradle.kts` in the project. Make sure to use the one in the `app` directory this time. The Apollo plugin ID is `com.homer.apollographql.apollo`. ```kotlin:title=app/build.gradle.kts plugins { id("com.android.application") // ... - id("com.apollographql.apollo").version("2.2.0") + id("com.homer.apollographql.apollo").version("2.2.0") } ``` @@ -66,8 +66,8 @@ Now add `apollo-runtime` and `apollo-coroutines-support` to the list of dependen dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" // ... - implementation 'com.apollographql.apollo:apollo-runtime:2.2.0' - implementation 'com.apollographql.apollo:apollo-coroutines-support:2.2.0' + implementation 'com.homer.apollographql.apollo:apollo-runtime:2.2.0' + implementation 'com.homer.apollographql.apollo:apollo-coroutines-support:2.2.0' // ... } ``` diff --git a/gradle.properties b/gradle.properties index a7e8ddb4348..77691b7150a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ -GROUP=com.apollographql.apollo -VERSION_NAME=2.5.3-SNAPSHOT +GROUP=com.homer.apollographql.apollo +VERSION_NAME=2.5.4-SNAPSHOT POM_URL=https://github.com/apollographql/apollo-android/ POM_SCM_URL=https://github.com/apollographql/apollo-android/ diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index e666146772f..7c8589a5945 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -1,34 +1,31 @@ def versions = [ minAndroidPlugin : '3.4.2', - androidPlugin : '3.6.2', + androidPlugin : '7.4.1', androidxSqlite : '2.1.0', apollo : '2.5.3-SNAPSHOT', // This should only be used by apollo-gradle-plugin-incubating:test to get the artifacts locally - antlr4 : '4.5.3', + antlr4 : '4.9.3', cache : '2.0.2', compiletesting : '0.15', espressoIdlingResource: '3.2.0', guava : '28.0-jre', - javaPoet : '1.9.0', - jetbrainsAnnotations : '13.0', + javaPoet : '1.13.0', + jetbrainsAnnotations : '32.0.0', junit : '4.13.1', - kotlin : '1.4.10', - kotlinCoroutines : '1.3.9', - kotlinPoet : '1.6.0', + kotlin : '1.6.21', + kotlinCoroutines : '1.6.4', + kotlinPoet : '1.12.0', mockito : '1.9.5', - moshi : '1.11.0', + moshi : '1.13.0', okHttp4 : '4.9.0', okHttp : '3.12.11', // Keep this to keep supporting older Android devices okio : '2.9.0', rxjava : '2.2.20', rxjava3 : '3.0.7', rxandroid : '2.0.1', - sqldelight : '1.4.4', + sqldelight : '1.5.5', testRunner : '0.5', truth : '0.30' ] - -ext.isCi = "true" == System.getenv('CI') - ext.dep = [ android : [ plugin : "com.android.tools.build:gradle:$versions.androidPlugin", @@ -47,9 +44,9 @@ ext.dep = [ runtime: "org.antlr:antlr4-runtime:$versions.antlr4", ], apollo : [ - plugin : "com.apollographql.apollo:apollo-gradle-plugin:$versions.apollo", - runtime: "com.apollographql.apollo:apollo-runtime:$versions.apollo", - api : "com.apollographql.apollo:apollo-api:$versions.apollo", + plugin : "com.homer.apollographql.apollo:apollo-gradle-plugin:$versions.apollo", + runtime: "com.homer.apollographql.apollo:apollo-runtime:$versions.apollo", + api : "com.homer.apollographql.apollo:apollo-api:$versions.apollo", ], compiletesting : "com.google.testing.compile:compile-testing:$versions.compiletesting", kotlinCompileTesting : "com.github.tschuchortdev:kotlin-compile-testing:1.2.10", @@ -57,6 +54,7 @@ ext.dep = [ gradleJapiCmpPlugin : "me.champeau.gradle:japicmp-gradle-plugin:0.2.8", gradleMetalavaPlugin : "me.tylerbwong.gradle:metalava-gradle:0.1.5", vanniktechPlugin : "com.vanniktech:gradle-maven-publish-plugin:0.11.1", + mavenGradlePlugin : "com.github.dcendents:android-maven-gradle-plugin:2.1", gradlePublishPlugin : "com.gradle.publish:plugin-publish-plugin:0.12.0", guavaJre : "com.google.guava:guava:$versions.guava", jetbrainsAnnotations : "org.jetbrains:annotations:$versions.jetbrainsAnnotations", @@ -100,8 +98,11 @@ ext.dep = [ truth : "com.google.truth:truth:$versions.truth", uuid : "com.benasher44:uuid:0.2.0", ] + +ext.isCi = "true" == System.getenv('CI') + ext.androidConfig = [ - compileSdkVersion: 28, + compileSdkVersion: 34, minSdkVersion : 15, - targetSdkVersion : 28 + targetSdkVersion : 34 ] diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index da9702f9e70..00e33edef69 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/samples/java-sample/build.gradle.kts b/samples/java-sample/build.gradle.kts index f5438e93ed4..1cf329d820c 100644 --- a/samples/java-sample/build.gradle.kts +++ b/samples/java-sample/build.gradle.kts @@ -1,6 +1,6 @@ import com.android.build.gradle.BaseExtension apply(plugin = "com.android.application") -apply(plugin = "com.apollographql.apollo") +apply(plugin = "com.homer.apollographql.apollo") extensions.findByType(BaseExtension::class.java)!!.apply { compileSdkVersion(groovy.util.Eval.x(project, "x.androidConfig.compileSdkVersion").toString().toInt()) @@ -37,9 +37,9 @@ extensions.findByType(BaseExtension::class.java)!!.apply { dependencies { add("compileOnly", groovy.util.Eval.x(project, "x.dep.jetbrainsAnnotations")) - add("implementation", "com.apollographql.apollo:apollo-runtime") - add("implementation", "com.apollographql.apollo:apollo-android-support") - add("implementation", "com.apollographql.apollo:apollo-rx2-support") + add("implementation", "com.homer.apollographql.apollo:apollo-runtime") + add("implementation", "com.homer.apollographql.apollo:apollo-android-support") + add("implementation", "com.homer.apollographql.apollo:apollo-rx2-support") add("implementation", groovy.util.Eval.x(project, "x.dep.androidx.appcompat")) add("implementation", groovy.util.Eval.x(project, "x.dep.androidx.recyclerView")) add("implementation", groovy.util.Eval.x(project, "x.dep.rx.java")) diff --git a/samples/java-sample/src/main/AndroidManifest.xml b/samples/java-sample/src/main/AndroidManifest.xml index b40f59b1820..b9b2adec86a 100644 --- a/samples/java-sample/src/main/AndroidManifest.xml +++ b/samples/java-sample/src/main/AndroidManifest.xml @@ -1,18 +1,18 @@ + package="com.homer.apollographql.apollo.sample"> - + @@ -20,7 +20,7 @@ - + \ No newline at end of file diff --git a/samples/java-sample/src/main/graphql/com/apollographql/apollo/sample/GihuntRepositoryDetailQuery.graphql b/samples/java-sample/src/main/graphql/com/homer/apollographql/apollo/sample/GihuntRepositoryDetailQuery.graphql similarity index 100% rename from samples/java-sample/src/main/graphql/com/apollographql/apollo/sample/GihuntRepositoryDetailQuery.graphql rename to samples/java-sample/src/main/graphql/com/homer/apollographql/apollo/sample/GihuntRepositoryDetailQuery.graphql diff --git a/samples/java-sample/src/main/graphql/com/apollographql/apollo/sample/GithuntFeedQuery.graphql b/samples/java-sample/src/main/graphql/com/homer/apollographql/apollo/sample/GithuntFeedQuery.graphql similarity index 100% rename from samples/java-sample/src/main/graphql/com/apollographql/apollo/sample/GithuntFeedQuery.graphql rename to samples/java-sample/src/main/graphql/com/homer/apollographql/apollo/sample/GithuntFeedQuery.graphql diff --git a/samples/java-sample/src/main/graphql/com/apollographql/apollo/sample/RepoCommentAddedSubscription.graphql b/samples/java-sample/src/main/graphql/com/homer/apollographql/apollo/sample/RepoCommentAddedSubscription.graphql similarity index 100% rename from samples/java-sample/src/main/graphql/com/apollographql/apollo/sample/RepoCommentAddedSubscription.graphql rename to samples/java-sample/src/main/graphql/com/homer/apollographql/apollo/sample/RepoCommentAddedSubscription.graphql diff --git a/samples/java-sample/src/main/graphql/com/apollographql/apollo/sample/schema.json b/samples/java-sample/src/main/graphql/com/homer/apollographql/apollo/sample/schema.json similarity index 100% rename from samples/java-sample/src/main/graphql/com/apollographql/apollo/sample/schema.json rename to samples/java-sample/src/main/graphql/com/homer/apollographql/apollo/sample/schema.json diff --git a/samples/java-sample/src/main/java/com/apollographql/apollo/sample/GitHuntApplication.java b/samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/GitHuntApplication.java similarity index 76% rename from samples/java-sample/src/main/java/com/apollographql/apollo/sample/GitHuntApplication.java rename to samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/GitHuntApplication.java index 389703a8f14..9ea219112fc 100644 --- a/samples/java-sample/src/main/java/com/apollographql/apollo/sample/GitHuntApplication.java +++ b/samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/GitHuntApplication.java @@ -1,16 +1,16 @@ -package com.apollographql.apollo.sample; +package com.homer.apollographql.apollo.sample; import android.app.Application; -import com.apollographql.apollo.ApolloClient; -import com.apollographql.apollo.api.Operation; -import com.apollographql.apollo.api.ResponseField; -import com.apollographql.apollo.cache.normalized.CacheKey; -import com.apollographql.apollo.cache.normalized.CacheKeyResolver; -import com.apollographql.apollo.cache.normalized.NormalizedCacheFactory; -import com.apollographql.apollo.cache.normalized.lru.EvictionPolicy; -import com.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory; -import com.apollographql.apollo.cache.normalized.sql.SqlNormalizedCacheFactory; -import com.apollographql.apollo.subscription.WebSocketSubscriptionTransport; +import com.homer.apollographql.apollo.ApolloClient; +import com.homer.apollographql.apollo.api.Operation; +import com.homer.apollographql.apollo.api.ResponseField; +import com.homer.apollographql.apollo.cache.normalized.CacheKey; +import com.homer.apollographql.apollo.cache.normalized.CacheKeyResolver; +import com.homer.apollographql.apollo.cache.normalized.NormalizedCacheFactory; +import com.homer.apollographql.apollo.cache.normalized.lru.EvictionPolicy; +import com.homer.apollographql.apollo.cache.normalized.lru.LruNormalizedCacheFactory; +import com.homer.apollographql.apollo.cache.normalized.sql.SqlNormalizedCacheFactory; +import com.homer.apollographql.apollo.subscription.WebSocketSubscriptionTransport; import okhttp3.OkHttpClient; import org.jetbrains.annotations.NotNull; diff --git a/samples/java-sample/src/main/java/com/apollographql/apollo/sample/detail/CommentsRecyclerViewAdapter.java b/samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/detail/CommentsRecyclerViewAdapter.java similarity index 93% rename from samples/java-sample/src/main/java/com/apollographql/apollo/sample/detail/CommentsRecyclerViewAdapter.java rename to samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/detail/CommentsRecyclerViewAdapter.java index 9bc7a28c425..0d7d70744b4 100644 --- a/samples/java-sample/src/main/java/com/apollographql/apollo/sample/detail/CommentsRecyclerViewAdapter.java +++ b/samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/detail/CommentsRecyclerViewAdapter.java @@ -1,11 +1,11 @@ -package com.apollographql.apollo.sample.detail; +package com.homer.apollographql.apollo.sample.detail; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import androidx.recyclerview.widget.RecyclerView; -import com.apollographql.apollo.sample.R; +import com.homer.apollographql.apollo.sample.R; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; diff --git a/samples/java-sample/src/main/java/com/apollographql/apollo/sample/detail/GitHuntEntryDetailActivity.java b/samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/detail/GitHuntEntryDetailActivity.java similarity index 93% rename from samples/java-sample/src/main/java/com/apollographql/apollo/sample/detail/GitHuntEntryDetailActivity.java rename to samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/detail/GitHuntEntryDetailActivity.java index d0d99e76fa9..a8125deed31 100644 --- a/samples/java-sample/src/main/java/com/apollographql/apollo/sample/detail/GitHuntEntryDetailActivity.java +++ b/samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/detail/GitHuntEntryDetailActivity.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.sample.detail; +package com.homer.apollographql.apollo.sample.detail; import android.content.Context; import android.content.Intent; @@ -16,15 +16,15 @@ import androidx.recyclerview.widget.DividerItemDecoration; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import com.apollographql.apollo.ApolloCall; -import com.apollographql.apollo.ApolloSubscriptionCall; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.fetcher.ApolloResponseFetchers; -import com.apollographql.apollo.rx2.Rx2Apollo; -import com.apollographql.apollo.sample.EntryDetailQuery; -import com.apollographql.apollo.sample.GitHuntApplication; -import com.apollographql.apollo.sample.R; -import com.apollographql.apollo.sample.RepoCommentAddedSubscription; +import com.homer.apollographql.apollo.ApolloCall; +import com.homer.apollographql.apollo.ApolloSubscriptionCall; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.fetcher.ApolloResponseFetchers; +import com.homer.apollographql.apollo.rx2.Rx2Apollo; +import com.homer.apollographql.apollo.sample.EntryDetailQuery; +import com.homer.apollographql.apollo.sample.GitHuntApplication; +import com.homer.apollographql.apollo.sample.R; +import com.homer.apollographql.apollo.sample.RepoCommentAddedSubscription; import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.disposables.CompositeDisposable; import io.reactivex.observers.DisposableObserver; diff --git a/samples/java-sample/src/main/java/com/apollographql/apollo/sample/feed/GitHuntFeedActivity.java b/samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/feed/GitHuntFeedActivity.java similarity index 82% rename from samples/java-sample/src/main/java/com/apollographql/apollo/sample/feed/GitHuntFeedActivity.java rename to samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/feed/GitHuntFeedActivity.java index 8633ce7d023..da6c7940807 100644 --- a/samples/java-sample/src/main/java/com/apollographql/apollo/sample/feed/GitHuntFeedActivity.java +++ b/samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/feed/GitHuntFeedActivity.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.sample.feed; +package com.homer.apollographql.apollo.sample.feed; import android.content.Intent; import android.os.Bundle; @@ -11,23 +11,23 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; -import com.apollographql.apollo.ApolloCall; -import com.apollographql.apollo.ApolloCallback; -import com.apollographql.apollo.api.Response; -import com.apollographql.apollo.exception.ApolloException; -import com.apollographql.apollo.fetcher.ApolloResponseFetchers; -import com.apollographql.apollo.sample.FeedQuery; -import com.apollographql.apollo.sample.GitHuntApplication; -import com.apollographql.apollo.sample.R; -import com.apollographql.apollo.sample.detail.GitHuntEntryDetailActivity; -import com.apollographql.apollo.sample.type.FeedType; +import com.homer.apollographql.apollo.ApolloCall; +import com.homer.apollographql.apollo.ApolloCallback; +import com.homer.apollographql.apollo.api.Response; +import com.homer.apollographql.apollo.exception.ApolloException; +import com.homer.apollographql.apollo.fetcher.ApolloResponseFetchers; +import com.homer.apollographql.apollo.sample.FeedQuery; +import com.homer.apollographql.apollo.sample.GitHuntApplication; +import com.homer.apollographql.apollo.sample.R; +import com.homer.apollographql.apollo.sample.detail.GitHuntEntryDetailActivity; +import com.homer.apollographql.apollo.sample.type.FeedType; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import static com.apollographql.apollo.sample.FeedQuery.FeedEntry; +import static com.homer.apollographql.apollo.sample.FeedQuery.FeedEntry; public class GitHuntFeedActivity extends AppCompatActivity implements GitHuntNavigator { diff --git a/samples/java-sample/src/main/java/com/apollographql/apollo/sample/feed/GitHuntFeedRecyclerViewAdapter.java b/samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/feed/GitHuntFeedRecyclerViewAdapter.java similarity index 90% rename from samples/java-sample/src/main/java/com/apollographql/apollo/sample/feed/GitHuntFeedRecyclerViewAdapter.java rename to samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/feed/GitHuntFeedRecyclerViewAdapter.java index 906d1d9d8eb..812749e4a81 100644 --- a/samples/java-sample/src/main/java/com/apollographql/apollo/sample/feed/GitHuntFeedRecyclerViewAdapter.java +++ b/samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/feed/GitHuntFeedRecyclerViewAdapter.java @@ -1,13 +1,13 @@ -package com.apollographql.apollo.sample.feed; +package com.homer.apollographql.apollo.sample.feed; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import androidx.recyclerview.widget.RecyclerView; -import com.apollographql.apollo.sample.FeedQuery; -import com.apollographql.apollo.sample.R; -import com.apollographql.apollo.sample.fragment.RepositoryFragment; +import com.homer.apollographql.apollo.sample.FeedQuery; +import com.homer.apollographql.apollo.sample.R; +import com.homer.apollographql.apollo.sample.fragment.RepositoryFragment; import java.util.Collections; import java.util.List; diff --git a/samples/java-sample/src/main/java/com/apollographql/apollo/sample/feed/GitHuntNavigator.java b/samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/feed/GitHuntNavigator.java similarity index 63% rename from samples/java-sample/src/main/java/com/apollographql/apollo/sample/feed/GitHuntNavigator.java rename to samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/feed/GitHuntNavigator.java index dc503ece4b3..a7e0367c0ea 100644 --- a/samples/java-sample/src/main/java/com/apollographql/apollo/sample/feed/GitHuntNavigator.java +++ b/samples/java-sample/src/main/java/com/homer/apollographql/apollo/sample/feed/GitHuntNavigator.java @@ -1,4 +1,4 @@ -package com.apollographql.apollo.sample.feed; +package com.homer.apollographql.apollo.sample.feed; public interface GitHuntNavigator { diff --git a/samples/java-sample/src/main/res/layout/activity_githunt_feed.xml b/samples/java-sample/src/main/res/layout/activity_githunt_feed.xml index 61411555149..f05c48c9261 100644 --- a/samples/java-sample/src/main/res/layout/activity_githunt_feed.xml +++ b/samples/java-sample/src/main/res/layout/activity_githunt_feed.xml @@ -3,7 +3,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context="com.apollographql.apollo.sample.feed.GitHuntFeedActivity" + tools:context="com.homer.apollographql.apollo.sample.feed.GitHuntFeedActivity" > { } dependencies { - add("implementation", "com.apollographql.apollo:apollo-android-support") - add("implementation", "com.apollographql.apollo:apollo-rx2-support") - add("implementation", "com.apollographql.apollo:apollo-coroutines-support") - add("implementation", "com.apollographql.apollo:apollo-runtime") - add("implementation", "com.apollographql.apollo:apollo-http-cache") + add("implementation", "com.homer.apollographql.apollo:apollo-android-support") + add("implementation", "com.homer.apollographql.apollo:apollo-rx2-support") + add("implementation", "com.homer.apollographql.apollo:apollo-coroutines-support") + add("implementation", "com.homer.apollographql.apollo:apollo-runtime") + add("implementation", "com.homer.apollographql.apollo:apollo-http-cache") add("implementation", groovy.util.Eval.x(project, "x.dep.okHttp.logging")) add("implementation", groovy.util.Eval.x(project, "x.dep.androidx.appcompat")) add("implementation", groovy.util.Eval.x(project, "x.dep.androidx.recyclerView")) @@ -47,6 +47,6 @@ dependencies { add("implementation", groovy.util.Eval.x(project, "x.dep.rx.java")) } -configure { +configure { generateKotlinModels.set(true) } diff --git a/samples/kotlin-sample/src/main/AndroidManifest.xml b/samples/kotlin-sample/src/main/AndroidManifest.xml index 270a36bd547..309aa5f8a09 100644 --- a/samples/kotlin-sample/src/main/AndroidManifest.xml +++ b/samples/kotlin-sample/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ + package="com.homer.apollographql.apollo.kotlinsample"> () { diff --git a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/data/ApolloCallbackService.kt b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/data/ApolloCallbackService.kt similarity index 75% rename from samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/data/ApolloCallbackService.kt rename to samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/data/ApolloCallbackService.kt index 226c8f3e4eb..2c692588969 100644 --- a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/data/ApolloCallbackService.kt +++ b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/data/ApolloCallbackService.kt @@ -1,16 +1,16 @@ -package com.apollographql.apollo.kotlinsample.data +package com.homer.apollographql.apollo.kotlinsample.data -import com.apollographql.apollo.ApolloCall -import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.api.cache.http.HttpCachePolicy -import com.apollographql.apollo.exception.ApolloException -import com.apollographql.apollo.kotlinsample.GithubRepositoriesQuery -import com.apollographql.apollo.kotlinsample.GithubRepositoryCommitsQuery -import com.apollographql.apollo.kotlinsample.GithubRepositoryDetailQuery -import com.apollographql.apollo.kotlinsample.type.OrderDirection -import com.apollographql.apollo.kotlinsample.type.PullRequestState -import com.apollographql.apollo.kotlinsample.type.RepositoryOrderField +import com.homer.apollographql.apollo.ApolloCall +import com.homer.apollographql.apollo.ApolloClient +import com.homer.apollographql.apollo.api.Response +import com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy +import com.homer.apollographql.apollo.exception.ApolloException +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoriesQuery +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoryCommitsQuery +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoryDetailQuery +import com.homer.apollographql.apollo.kotlinsample.type.OrderDirection +import com.homer.apollographql.apollo.kotlinsample.type.PullRequestState +import com.homer.apollographql.apollo.kotlinsample.type.RepositoryOrderField /** * An implementation of a [GitHubDataSource] that shows how to fetch data using callbacks. diff --git a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/data/ApolloCoroutinesService.kt b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/data/ApolloCoroutinesService.kt similarity index 78% rename from samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/data/ApolloCoroutinesService.kt rename to samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/data/ApolloCoroutinesService.kt index 6c934cfc803..b4381bc15b1 100644 --- a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/data/ApolloCoroutinesService.kt +++ b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/data/ApolloCoroutinesService.kt @@ -1,13 +1,13 @@ -package com.apollographql.apollo.kotlinsample.data +package com.homer.apollographql.apollo.kotlinsample.data -import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.coroutines.await -import com.apollographql.apollo.kotlinsample.GithubRepositoriesQuery -import com.apollographql.apollo.kotlinsample.GithubRepositoryCommitsQuery -import com.apollographql.apollo.kotlinsample.GithubRepositoryDetailQuery -import com.apollographql.apollo.kotlinsample.type.OrderDirection -import com.apollographql.apollo.kotlinsample.type.PullRequestState -import com.apollographql.apollo.kotlinsample.type.RepositoryOrderField +import com.homer.apollographql.apollo.ApolloClient +import com.homer.apollographql.apollo.coroutines.await +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoriesQuery +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoryCommitsQuery +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoryDetailQuery +import com.homer.apollographql.apollo.kotlinsample.type.OrderDirection +import com.homer.apollographql.apollo.kotlinsample.type.PullRequestState +import com.homer.apollographql.apollo.kotlinsample.type.RepositoryOrderField import kotlinx.coroutines.* import kotlin.coroutines.CoroutineContext diff --git a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/data/ApolloRxService.kt b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/data/ApolloRxService.kt similarity index 78% rename from samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/data/ApolloRxService.kt rename to samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/data/ApolloRxService.kt index 42a31c64d88..2fba7225786 100644 --- a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/data/ApolloRxService.kt +++ b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/data/ApolloRxService.kt @@ -1,14 +1,14 @@ -package com.apollographql.apollo.kotlinsample.data +package com.homer.apollographql.apollo.kotlinsample.data -import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.api.cache.http.HttpCachePolicy -import com.apollographql.apollo.kotlinsample.GithubRepositoriesQuery -import com.apollographql.apollo.kotlinsample.GithubRepositoryCommitsQuery -import com.apollographql.apollo.kotlinsample.GithubRepositoryDetailQuery -import com.apollographql.apollo.kotlinsample.type.OrderDirection -import com.apollographql.apollo.kotlinsample.type.PullRequestState -import com.apollographql.apollo.kotlinsample.type.RepositoryOrderField -import com.apollographql.apollo.rx2.rxQuery +import com.homer.apollographql.apollo.ApolloClient +import com.homer.apollographql.apollo.api.cache.http.HttpCachePolicy +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoriesQuery +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoryCommitsQuery +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoryDetailQuery +import com.homer.apollographql.apollo.kotlinsample.type.OrderDirection +import com.homer.apollographql.apollo.kotlinsample.type.PullRequestState +import com.homer.apollographql.apollo.kotlinsample.type.RepositoryOrderField +import com.homer.apollographql.apollo.rx2.rxQuery import io.reactivex.Scheduler import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable diff --git a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/data/ApolloWatcherService.kt b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/data/ApolloWatcherService.kt similarity index 74% rename from samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/data/ApolloWatcherService.kt rename to samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/data/ApolloWatcherService.kt index 8ce9f3e5ded..456903f59b2 100644 --- a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/data/ApolloWatcherService.kt +++ b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/data/ApolloWatcherService.kt @@ -1,18 +1,18 @@ -package com.apollographql.apollo.kotlinsample.data +package com.homer.apollographql.apollo.kotlinsample.data import android.util.Log -import com.apollographql.apollo.ApolloCall -import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.api.Operation -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.exception.ApolloException -import com.apollographql.apollo.fetcher.ApolloResponseFetchers -import com.apollographql.apollo.kotlinsample.GithubRepositoriesQuery -import com.apollographql.apollo.kotlinsample.GithubRepositoryCommitsQuery -import com.apollographql.apollo.kotlinsample.GithubRepositoryDetailQuery -import com.apollographql.apollo.kotlinsample.type.OrderDirection -import com.apollographql.apollo.kotlinsample.type.PullRequestState -import com.apollographql.apollo.kotlinsample.type.RepositoryOrderField +import com.homer.apollographql.apollo.ApolloCall +import com.homer.apollographql.apollo.ApolloClient +import com.homer.apollographql.apollo.api.Operation +import com.homer.apollographql.apollo.api.Response +import com.homer.apollographql.apollo.exception.ApolloException +import com.homer.apollographql.apollo.fetcher.ApolloResponseFetchers +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoriesQuery +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoryCommitsQuery +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoryDetailQuery +import com.homer.apollographql.apollo.kotlinsample.type.OrderDirection +import com.homer.apollographql.apollo.kotlinsample.type.PullRequestState +import com.homer.apollographql.apollo.kotlinsample.type.RepositoryOrderField /** * An implementation of a [GitHubDataSource] that shows how to fetch data using callbacks. diff --git a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/data/GitHubDataSource.kt b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/data/GitHubDataSource.kt similarity index 78% rename from samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/data/GitHubDataSource.kt rename to samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/data/GitHubDataSource.kt index 6a01259bfa5..86f14a420f6 100644 --- a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/data/GitHubDataSource.kt +++ b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/data/GitHubDataSource.kt @@ -1,11 +1,11 @@ -package com.apollographql.apollo.kotlinsample.data +package com.homer.apollographql.apollo.kotlinsample.data -import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.kotlinsample.GithubRepositoriesQuery -import com.apollographql.apollo.kotlinsample.GithubRepositoryCommitsQuery -import com.apollographql.apollo.kotlinsample.GithubRepositoryDetailQuery -import com.apollographql.apollo.kotlinsample.fragment.RepositoryFragment +import com.homer.apollographql.apollo.ApolloClient +import com.homer.apollographql.apollo.api.Response +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoriesQuery +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoryCommitsQuery +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoryDetailQuery +import com.homer.apollographql.apollo.kotlinsample.fragment.RepositoryFragment import io.reactivex.Observable import io.reactivex.subjects.PublishSubject diff --git a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/repositories/MainActivity.kt b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/repositories/MainActivity.kt similarity index 85% rename from samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/repositories/MainActivity.kt rename to samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/repositories/MainActivity.kt index 0dee828ad35..1ca11eb1478 100644 --- a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/repositories/MainActivity.kt +++ b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/repositories/MainActivity.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.kotlinsample.repositories +package com.homer.apollographql.apollo.kotlinsample.repositories import android.os.Bundle import android.view.View @@ -6,12 +6,12 @@ import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import com.apollographql.apollo.kotlinsample.BuildConfig -import com.apollographql.apollo.kotlinsample.KotlinSampleApp -import com.apollographql.apollo.kotlinsample.R -import com.apollographql.apollo.kotlinsample.data.GitHubDataSource -import com.apollographql.apollo.kotlinsample.fragment.RepositoryFragment -import com.apollographql.apollo.kotlinsample.repositoryDetail.RepositoryDetailActivity +import com.homer.apollographql.apollo.kotlinsample.BuildConfig +import com.homer.apollographql.apollo.kotlinsample.KotlinSampleApp +import com.homer.apollographql.apollo.kotlinsample.R +import com.homer.apollographql.apollo.kotlinsample.data.GitHubDataSource +import com.homer.apollographql.apollo.kotlinsample.fragment.RepositoryFragment +import com.homer.apollographql.apollo.kotlinsample.repositoryDetail.RepositoryDetailActivity import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable import io.reactivex.schedulers.Schedulers diff --git a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/repositories/RepositoriesAdapter.kt b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/repositories/RepositoriesAdapter.kt similarity index 87% rename from samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/repositories/RepositoriesAdapter.kt rename to samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/repositories/RepositoriesAdapter.kt index cd122fe8932..cbb47ab1e24 100644 --- a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/repositories/RepositoriesAdapter.kt +++ b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/repositories/RepositoriesAdapter.kt @@ -1,11 +1,11 @@ -package com.apollographql.apollo.kotlinsample.repositories +package com.homer.apollographql.apollo.kotlinsample.repositories import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView -import com.apollographql.apollo.kotlinsample.R -import com.apollographql.apollo.kotlinsample.fragment.RepositoryFragment +import com.homer.apollographql.apollo.kotlinsample.R +import com.homer.apollographql.apollo.kotlinsample.fragment.RepositoryFragment import kotlinx.android.synthetic.main.item_repository.view.* class RepositoriesAdapter(private val onClick: (RepositoryFragment) -> Unit) : RecyclerView.Adapter() { diff --git a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/repositoryDetail/RepositoryDetailActivity.kt b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/repositoryDetail/RepositoryDetailActivity.kt similarity index 87% rename from samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/repositoryDetail/RepositoryDetailActivity.kt rename to samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/repositoryDetail/RepositoryDetailActivity.kt index e66690b545d..30bdf9d43b4 100644 --- a/samples/kotlin-sample/src/main/java/com/apollographql/apollo/kotlinsample/repositoryDetail/RepositoryDetailActivity.kt +++ b/samples/kotlin-sample/src/main/java/com/homer/apollographql/apollo/kotlinsample/repositoryDetail/RepositoryDetailActivity.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.kotlinsample.repositoryDetail +package com.homer.apollographql.apollo.kotlinsample.repositoryDetail import android.annotation.SuppressLint import android.content.Context @@ -6,12 +6,12 @@ import android.content.Intent import android.os.Bundle import android.view.View import androidx.appcompat.app.AppCompatActivity -import com.apollographql.apollo.api.Response -import com.apollographql.apollo.kotlinsample.GithubRepositoryDetailQuery -import com.apollographql.apollo.kotlinsample.KotlinSampleApp -import com.apollographql.apollo.kotlinsample.R -import com.apollographql.apollo.kotlinsample.commits.CommitsActivity -import com.apollographql.apollo.kotlinsample.data.GitHubDataSource +import com.homer.apollographql.apollo.api.Response +import com.homer.apollographql.apollo.kotlinsample.GithubRepositoryDetailQuery +import com.homer.apollographql.apollo.kotlinsample.KotlinSampleApp +import com.homer.apollographql.apollo.kotlinsample.R +import com.homer.apollographql.apollo.kotlinsample.commits.CommitsActivity +import com.homer.apollographql.apollo.kotlinsample.data.GitHubDataSource import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable import io.reactivex.schedulers.Schedulers diff --git a/samples/multiplatform/kmp-android-app/build.gradle.kts b/samples/multiplatform/kmp-android-app/build.gradle.kts index 9fbe2de0889..ffc9ee9bf7c 100644 --- a/samples/multiplatform/kmp-android-app/build.gradle.kts +++ b/samples/multiplatform/kmp-android-app/build.gradle.kts @@ -8,7 +8,7 @@ plugins { android { compileSdkVersion(groovy.util.Eval.x(project, "x.androidConfig.compileSdkVersion").toString().toInt()) defaultConfig { - applicationId = "com.apollographql.apollo.kmpsample" + applicationId = "com.homer.apollographql.apollo.kmpsample" minSdkVersion(groovy.util.Eval.x(project, "x.androidConfig.minSdkVersion").toString()) targetSdkVersion(groovy.util.Eval.x(project, "x.androidConfig.targetSdkVersion").toString()) } @@ -33,7 +33,7 @@ tasks.withType { dependencies { implementation(project(":multiplatform:kmp-lib-sample")) - implementation("com.apollographql.apollo:apollo-api") + implementation("com.homer.apollographql.apollo:apollo-api") implementation(groovy.util.Eval.x(project, "x.dep.androidx.appcompat")) implementation(groovy.util.Eval.x(project, "x.dep.androidx.recyclerView")) diff --git a/samples/multiplatform/kmp-android-app/src/main/AndroidManifest.xml b/samples/multiplatform/kmp-android-app/src/main/AndroidManifest.xml index 9e0e766c056..4581279f893 100644 --- a/samples/multiplatform/kmp-android-app/src/main/AndroidManifest.xml +++ b/samples/multiplatform/kmp-android-app/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ + package="com.homer.apollographql.apollo.kmpsample"> () { diff --git a/samples/multiplatform/kmp-android-app/src/main/java/com/apollographql/apollo/kmpsample/repositories/MainActivity.kt b/samples/multiplatform/kmp-android-app/src/main/java/com/homer/apollographql/apollo/kmpsample/repositories/MainActivity.kt similarity index 87% rename from samples/multiplatform/kmp-android-app/src/main/java/com/apollographql/apollo/kmpsample/repositories/MainActivity.kt rename to samples/multiplatform/kmp-android-app/src/main/java/com/homer/apollographql/apollo/kmpsample/repositories/MainActivity.kt index b9a483d5312..16e59089f06 100644 --- a/samples/multiplatform/kmp-android-app/src/main/java/com/apollographql/apollo/kmpsample/repositories/MainActivity.kt +++ b/samples/multiplatform/kmp-android-app/src/main/java/com/homer/apollographql/apollo/kmpsample/repositories/MainActivity.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.kmpsample.repositories +package com.homer.apollographql.apollo.kmpsample.repositories import android.os.Bundle import android.view.View @@ -7,9 +7,9 @@ import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import com.apollographql.apollo.kmpsample.data.ApolloCoroutinesRepository -import com.apollographql.apollo.kmpsample.databinding.ActivityMainBinding -import com.apollographql.apollo.kmpsample.repositoryDetail.RepositoryDetailActivity +import com.homer.apollographql.apollo.kmpsample.data.ApolloCoroutinesRepository +import com.homer.apollographql.apollo.kmpsample.databinding.ActivityMainBinding +import com.homer.apollographql.apollo.kmpsample.repositoryDetail.RepositoryDetailActivity import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job diff --git a/samples/multiplatform/kmp-android-app/src/main/java/com/apollographql/apollo/kmpsample/repositories/RepositoriesAdapter.kt b/samples/multiplatform/kmp-android-app/src/main/java/com/homer/apollographql/apollo/kmpsample/repositories/RepositoriesAdapter.kt similarity index 86% rename from samples/multiplatform/kmp-android-app/src/main/java/com/apollographql/apollo/kmpsample/repositories/RepositoriesAdapter.kt rename to samples/multiplatform/kmp-android-app/src/main/java/com/homer/apollographql/apollo/kmpsample/repositories/RepositoriesAdapter.kt index 20b9a41c974..f7eb797bdb0 100644 --- a/samples/multiplatform/kmp-android-app/src/main/java/com/apollographql/apollo/kmpsample/repositories/RepositoriesAdapter.kt +++ b/samples/multiplatform/kmp-android-app/src/main/java/com/homer/apollographql/apollo/kmpsample/repositories/RepositoriesAdapter.kt @@ -1,11 +1,11 @@ -package com.apollographql.apollo.kmpsample.repositories +package com.homer.apollographql.apollo.kmpsample.repositories import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView -import com.apollographql.apollo.kmpsample.databinding.ItemRepositoryBinding -import com.apollographql.apollo.kmpsample.fragment.RepositoryFragment +import com.homer.apollographql.apollo.kmpsample.databinding.ItemRepositoryBinding +import com.homer.apollographql.apollo.kmpsample.fragment.RepositoryFragment class RepositoriesAdapter( private val onClick: (RepositoryFragment) -> Unit diff --git a/samples/multiplatform/kmp-android-app/src/main/java/com/apollographql/apollo/kmpsample/repositoryDetail/RepositoryDetailActivity.kt b/samples/multiplatform/kmp-android-app/src/main/java/com/homer/apollographql/apollo/kmpsample/repositoryDetail/RepositoryDetailActivity.kt similarity index 88% rename from samples/multiplatform/kmp-android-app/src/main/java/com/apollographql/apollo/kmpsample/repositoryDetail/RepositoryDetailActivity.kt rename to samples/multiplatform/kmp-android-app/src/main/java/com/homer/apollographql/apollo/kmpsample/repositoryDetail/RepositoryDetailActivity.kt index 0f1e2725ce7..e7eebfcce44 100644 --- a/samples/multiplatform/kmp-android-app/src/main/java/com/apollographql/apollo/kmpsample/repositoryDetail/RepositoryDetailActivity.kt +++ b/samples/multiplatform/kmp-android-app/src/main/java/com/homer/apollographql/apollo/kmpsample/repositoryDetail/RepositoryDetailActivity.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.kmpsample.repositoryDetail +package com.homer.apollographql.apollo.kmpsample.repositoryDetail import android.annotation.SuppressLint import android.content.Context @@ -6,10 +6,10 @@ import android.content.Intent import android.os.Bundle import android.view.View import androidx.appcompat.app.AppCompatActivity -import com.apollographql.apollo.kmpsample.commits.CommitsActivity -import com.apollographql.apollo.kmpsample.data.ApolloCoroutinesRepository -import com.apollographql.apollo.kmpsample.databinding.ActivityRepositoryDetailBinding -import com.apollographql.apollo.kmpsample.fragment.RepositoryDetail +import com.homer.apollographql.apollo.kmpsample.commits.CommitsActivity +import com.homer.apollographql.apollo.kmpsample.data.ApolloCoroutinesRepository +import com.homer.apollographql.apollo.kmpsample.databinding.ActivityRepositoryDetailBinding +import com.homer.apollographql.apollo.kmpsample.fragment.RepositoryDetail import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job diff --git a/samples/multiplatform/kmp-ios-app/kmp-ios-app.xcodeproj/project.pbxproj b/samples/multiplatform/kmp-ios-app/kmp-ios-app.xcodeproj/project.pbxproj index 34408747f11..e4aa1dfb9b3 100644 --- a/samples/multiplatform/kmp-ios-app/kmp-ios-app.xcodeproj/project.pbxproj +++ b/samples/multiplatform/kmp-ios-app/kmp-ios-app.xcodeproj/project.pbxproj @@ -365,7 +365,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "com.apollographql.apollo.kmp-ios-app"; + PRODUCT_BUNDLE_IDENTIFIER = "com.homer.apollographql.apollo.kmp-ios-app"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -385,7 +385,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - PRODUCT_BUNDLE_IDENTIFIER = "com.apollographql.apollo.kmp-ios-app"; + PRODUCT_BUNDLE_IDENTIFIER = "com.homer.apollographql.apollo.kmp-ios-app"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/samples/multiplatform/kmp-lib-sample/build.gradle.kts b/samples/multiplatform/kmp-lib-sample/build.gradle.kts index a23287b735b..3b4d4aa0bef 100644 --- a/samples/multiplatform/kmp-lib-sample/build.gradle.kts +++ b/samples/multiplatform/kmp-lib-sample/build.gradle.kts @@ -3,10 +3,10 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("multiplatform") - id("com.apollographql.apollo") + id("com.homer.apollographql.apollo") } -group = "com.apollographql.apollo.kmpsample" +group = "com.homer.apollographql.apollo.kmpsample" version = 1.0 kotlin { @@ -28,8 +28,8 @@ kotlin { sourceSets { commonMain { dependencies { - implementation("com.apollographql.apollo:apollo-api") - implementation("com.apollographql.apollo:apollo-runtime-kotlin") + implementation("com.homer.apollographql.apollo:apollo-api") + implementation("com.homer.apollographql.apollo:apollo-runtime-kotlin") implementation(groovy.util.Eval.x(project, "x.dep.kotlin.coroutines")) } } diff --git a/samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/apollographql/apollo/kmpsample/GithubRepositoriesQuery.graphql b/samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/homer/apollographql/apollo/kmpsample/GithubRepositoriesQuery.graphql similarity index 100% rename from samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/apollographql/apollo/kmpsample/GithubRepositoriesQuery.graphql rename to samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/homer/apollographql/apollo/kmpsample/GithubRepositoriesQuery.graphql diff --git a/samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/apollographql/apollo/kmpsample/GithubRepositoryCommitsQuery.graphql b/samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/homer/apollographql/apollo/kmpsample/GithubRepositoryCommitsQuery.graphql similarity index 100% rename from samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/apollographql/apollo/kmpsample/GithubRepositoryCommitsQuery.graphql rename to samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/homer/apollographql/apollo/kmpsample/GithubRepositoryCommitsQuery.graphql diff --git a/samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/apollographql/apollo/kmpsample/GithubRepositoryDetailQuery.graphql b/samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/homer/apollographql/apollo/kmpsample/GithubRepositoryDetailQuery.graphql similarity index 100% rename from samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/apollographql/apollo/kmpsample/GithubRepositoryDetailQuery.graphql rename to samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/homer/apollographql/apollo/kmpsample/GithubRepositoryDetailQuery.graphql diff --git a/samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/apollographql/apollo/kmpsample/schema.json b/samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/homer/apollographql/apollo/kmpsample/schema.json similarity index 100% rename from samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/apollographql/apollo/kmpsample/schema.json rename to samples/multiplatform/kmp-lib-sample/src/commonMain/graphql/com/homer/apollographql/apollo/kmpsample/schema.json diff --git a/samples/multiplatform/kmp-lib-sample/src/commonMain/kotlin/com/apollographql/apollo/kmpsample/data/ApolloCoroutinesRepository.kt b/samples/multiplatform/kmp-lib-sample/src/commonMain/kotlin/com/homer/apollographql/apollo/kmpsample/data/ApolloCoroutinesRepository.kt similarity index 67% rename from samples/multiplatform/kmp-lib-sample/src/commonMain/kotlin/com/apollographql/apollo/kmpsample/data/ApolloCoroutinesRepository.kt rename to samples/multiplatform/kmp-lib-sample/src/commonMain/kotlin/com/homer/apollographql/apollo/kmpsample/data/ApolloCoroutinesRepository.kt index 622bbaeed3c..d8977e69a12 100644 --- a/samples/multiplatform/kmp-lib-sample/src/commonMain/kotlin/com/apollographql/apollo/kmpsample/data/ApolloCoroutinesRepository.kt +++ b/samples/multiplatform/kmp-lib-sample/src/commonMain/kotlin/com/homer/apollographql/apollo/kmpsample/data/ApolloCoroutinesRepository.kt @@ -1,17 +1,17 @@ -package com.apollographql.apollo.kmpsample.data +package com.homer.apollographql.apollo.kmpsample.data -import com.apollographql.apollo.ApolloClient -import com.apollographql.apollo.kmpsample.GithubRepositoriesQuery -import com.apollographql.apollo.kmpsample.GithubRepositoryCommitsQuery -import com.apollographql.apollo.kmpsample.GithubRepositoryDetailQuery -import com.apollographql.apollo.kmpsample.fragment.RepositoryDetail -import com.apollographql.apollo.kmpsample.fragment.RepositoryFragment -import com.apollographql.apollo.kmpsample.type.OrderDirection -import com.apollographql.apollo.kmpsample.type.PullRequestState -import com.apollographql.apollo.kmpsample.type.RepositoryOrderField -import com.apollographql.apollo.network.http.ApolloHttpNetworkTransport -import com.apollographql.apollo.network.HttpExecutionContext -import com.apollographql.apollo.ApolloException +import com.homer.apollographql.apollo.ApolloClient +import com.homer.apollographql.apollo.kmpsample.GithubRepositoriesQuery +import com.homer.apollographql.apollo.kmpsample.GithubRepositoryCommitsQuery +import com.homer.apollographql.apollo.kmpsample.GithubRepositoryDetailQuery +import com.homer.apollographql.apollo.kmpsample.fragment.RepositoryDetail +import com.homer.apollographql.apollo.kmpsample.fragment.RepositoryFragment +import com.homer.apollographql.apollo.kmpsample.type.OrderDirection +import com.homer.apollographql.apollo.kmpsample.type.PullRequestState +import com.homer.apollographql.apollo.kmpsample.type.RepositoryOrderField +import com.homer.apollographql.apollo.network.http.ApolloHttpNetworkTransport +import com.homer.apollographql.apollo.network.HttpExecutionContext +import com.homer.apollographql.apollo.ApolloException import kotlinx.coroutines.flow.single /** diff --git a/samples/multiplatform/kmp-lib-sample/src/iosMain/kotlin/com/apollographql/apollo/kmpsample/data/ApolloiOSRepository.kt b/samples/multiplatform/kmp-lib-sample/src/iosMain/kotlin/com/homer/apollographql/apollo/kmpsample/data/ApolloiOSRepository.kt similarity index 76% rename from samples/multiplatform/kmp-lib-sample/src/iosMain/kotlin/com/apollographql/apollo/kmpsample/data/ApolloiOSRepository.kt rename to samples/multiplatform/kmp-lib-sample/src/iosMain/kotlin/com/homer/apollographql/apollo/kmpsample/data/ApolloiOSRepository.kt index 7db5b7b349b..ef75a6fa337 100644 --- a/samples/multiplatform/kmp-lib-sample/src/iosMain/kotlin/com/apollographql/apollo/kmpsample/data/ApolloiOSRepository.kt +++ b/samples/multiplatform/kmp-lib-sample/src/iosMain/kotlin/com/homer/apollographql/apollo/kmpsample/data/ApolloiOSRepository.kt @@ -1,8 +1,8 @@ -package com.apollographql.apollo.kmpsample.data +package com.homer.apollographql.apollo.kmpsample.data -import com.apollographql.apollo.kmpsample.GithubRepositoryCommitsQuery -import com.apollographql.apollo.kmpsample.fragment.RepositoryDetail -import com.apollographql.apollo.kmpsample.fragment.RepositoryFragment +import com.homer.apollographql.apollo.kmpsample.GithubRepositoryCommitsQuery +import com.homer.apollographql.apollo.kmpsample.fragment.RepositoryDetail +import com.homer.apollographql.apollo.kmpsample.fragment.RepositoryFragment import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.InternalCoroutinesApi import kotlinx.coroutines.launch diff --git a/samples/multiplatform/kmp-lib-sample/src/iosMain/kotlin/com/apollographql/apollo/kmpsample/data/MainLoopDispatcher.kt b/samples/multiplatform/kmp-lib-sample/src/iosMain/kotlin/com/homer/apollographql/apollo/kmpsample/data/MainLoopDispatcher.kt similarity index 96% rename from samples/multiplatform/kmp-lib-sample/src/iosMain/kotlin/com/apollographql/apollo/kmpsample/data/MainLoopDispatcher.kt rename to samples/multiplatform/kmp-lib-sample/src/iosMain/kotlin/com/homer/apollographql/apollo/kmpsample/data/MainLoopDispatcher.kt index f4502e955a2..15042ce6949 100644 --- a/samples/multiplatform/kmp-lib-sample/src/iosMain/kotlin/com/apollographql/apollo/kmpsample/data/MainLoopDispatcher.kt +++ b/samples/multiplatform/kmp-lib-sample/src/iosMain/kotlin/com/homer/apollographql/apollo/kmpsample/data/MainLoopDispatcher.kt @@ -1,4 +1,4 @@ -package com.apollographql.apollo.kmpsample.data +package com.homer.apollographql.apollo.kmpsample.data import kotlinx.coroutines.CancellableContinuation import kotlinx.coroutines.CoroutineDispatcher diff --git a/settings.gradle.kts b/settings.gradle.kts index 0c60a38d5cd..6f1a124a116 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -4,17 +4,17 @@ include("apollo-compiler") include("apollo-gradle-plugin") include("apollo-runtime") include("apollo-api") -include("apollo-rx2-support") -include("apollo-rx3-support") +//include("apollo-rx2-support") +//include("apollo-rx3-support") include("apollo-coroutines-support") -include("apollo-http-cache") +//include("apollo-http-cache") include("apollo-http-cache-api") include("apollo-normalized-cache") include("apollo-normalized-cache-api") include("apollo-runtime-kotlin") -if (System.getProperty("idea.sync.active") == null) { - include("apollo-idling-resource") - include("apollo-normalized-cache-sqlite") - include("apollo-android-support") -} +//if (System.getProperty("idea.sync.active") == null) { +// include("apollo-idling-resource") +// include("apollo-normalized-cache-sqlite") +// include("apollo-android-support") +//}