Skip to content

Commit

Permalink
AWS AppSync SDK version 2.6.16
Browse files Browse the repository at this point in the history
  • Loading branch information
minbi committed Mar 15, 2018
1 parent b6821dd commit ef3c6c4
Show file tree
Hide file tree
Showing 67 changed files with 3,557 additions and 179 deletions.
4 changes: 2 additions & 2 deletions aws-android-sdk-appsync-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.amazonaws</groupId>
<artifactId>aws-android-sdk-appsync-api</artifactId>
<version>2.6.15</version>
<version>2.6.16</version>
<name>AWS AppSync GraphQL API</name>
<description>AWS AppSync GraphQL API classes</description>
<url>http://aws.amazon.com/sdkforandroid</url>

<parent>
<groupId>com.amazonaws</groupId>
<artifactId>aws-android-sdk-appsync-pom</artifactId>
<version>2.6.15</version>
<version>2.6.16</version>
</parent>

<licenses>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright 2018-2018 Amazon.com,
* Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Amazon Software License (the "License").
* You may not use this file except in compliance with the
* License. A copy of the License is located at
*
* http://aws.amazon.com/asl/
*
* or in the "license" file accompanying this file. This file is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, express or implied. See the License
* for the specific language governing permissions and
* limitations under the License.
*/

package com.apollographql.apollo.api;

/**
* S3InputObjectInterface.
*/

public interface S3InputObjectInterface extends S3ObjectInterface {
public String localUri();
public String mimeType();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright 2018-2018 Amazon.com,
* Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Amazon Software License (the "License").
* You may not use this file except in compliance with the
* License. A copy of the License is located at
*
* http://aws.amazon.com/asl/
*
* or in the "license" file accompanying this file. This file is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, express or implied. See the License
* for the specific language governing permissions and
* limitations under the License.
*/

package com.apollographql.apollo.api;

/**
* S3ObjectInterface.
*/

public interface S3ObjectInterface {
public String bucket();
public String key();
public String region();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Copyright 2018-2018 Amazon.com,
* Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Amazon Software License (the "License").
* You may not use this file except in compliance with the
* License. A copy of the License is located at
*
* http://aws.amazon.com/asl/
*
* or in the "license" file accompanying this file. This file is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, express or implied. See the License
* for the specific language governing permissions and
* limitations under the License.
*/

package com.apollographql.apollo.api;

/**
* S3ObjectManager.
*/
public interface S3ObjectManager {
void upload(final S3InputObjectInterface s3Object) throws Exception;
void download(final S3ObjectInterface s3Object, final String filePath) throws Exception;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright 2018-2018 Amazon.com,
* Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Amazon Software License (the "License").
* You may not use this file except in compliance with the
* License. A copy of the License is located at
*
* http://aws.amazon.com/asl/
*
* or in the "license" file accompanying this file. This file is
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, express or implied. See the License
* for the specific language governing permissions and
* limitations under the License.
*/

package com.apollographql.apollo.api;

/**
* Represents a GraphQL subscription.
*/
public interface Subscription<D extends Operation.Data, T, V extends Operation.Variables> extends Operation<D, T, V> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ public UnmodifiableMapBuilder(int initialCapacity) {
this.map = new HashMap<>(initialCapacity);
}

public UnmodifiableMapBuilder put(K key, V value) {
public UnmodifiableMapBuilder() {
this.map = new HashMap<>();
}

public UnmodifiableMapBuilder<K, V> put(K key, V value) {
map.put(key, value);
return this;
}
Expand Down
6 changes: 3 additions & 3 deletions aws-android-sdk-appsync-compiler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.amazonaws</groupId>
<artifactId>aws-android-sdk-appsync-compiler</artifactId>
<version>2.6.15</version>
<version>2.6.16</version>
<name>AWS AppSync Android Compiler</name>
<description>AWS AppSync Implementation for the Gradle plugin</description>
<url>http://aws.amazon.com/sdkforandroid</url>
Expand All @@ -15,7 +15,7 @@
<parent>
<groupId>com.amazonaws</groupId>
<artifactId>aws-android-sdk-appsync-pom</artifactId>
<version>2.6.15</version>
<version>2.6.16</version>
</parent>

<licenses>
Expand Down Expand Up @@ -64,7 +64,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-android-sdk-appsync-api</artifactId>
<version>2.6.15</version>
<version>2.6.16</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@

// Generated file. Do not edit!
package com.apollographql.android
val VERSION = "2.6.15"
val VERSION = "2.6.16"
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ object ClassNames {
val GRAPHQL_OPERATION: ClassName = ClassName.get(Operation::class.java)
val GRAPHQL_QUERY: ClassName = ClassName.get(Query::class.java)
val GRAPHQL_MUTATION: ClassName = ClassName.get(Mutation::class.java)
val GRAPHQL_SUBSCRIPTION: ClassName = ClassName.get(Subscription::class.java)
val GRAPHQL_OPERATION_VARIABLES: ClassName = ClassName.get("", "${GRAPHQL_OPERATION.simpleName()}.Variables")
val ILLEGAL_STATE_EXCEPTION: TypeName = ClassName.get(IllegalStateException::class.java)
val MAP: ClassName = ClassName.get(Map::class.java)
Expand All @@ -48,6 +49,8 @@ object ClassNames {
val INPUT_TYPE: ClassName = ClassName.get(Input::class.java)
val BUILDER: ClassName = ClassName.get("", "Builder")
val MUTATOR: ClassName = ClassName.get(Mutator::class.java)
var S3ObjectInput: ClassName = ClassName.get(S3InputObjectInterface::class.java)
var S3Object: ClassName = ClassName.get(S3ObjectInterface::class.java)

fun <K : Any> parameterizedListOf(type: Class<K>): TypeName =
ParameterizedTypeName.get(LIST, ClassName.get(type))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.apollographql.apollo.compiler.ir.TypeDeclarationField
import com.squareup.javapoet.*
import java.io.IOException
import javax.lang.model.element.Modifier
import com.apollographql.apollo.compiler.ClassNames.S3ObjectInput

class InputTypeSpecBuilder(
val name: String,
Expand All @@ -33,14 +34,27 @@ class InputTypeSpecBuilder(
private val objectClassName = ClassName.get("", name.capitalize())

fun build(): TypeSpec =
TypeSpec.classBuilder(objectClassName)
.addAnnotation(Annotations.GENERATED_BY_APOLLO)
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.addConstructor()
.addFields()
.addBuilder()
.addMethod(marshallerMethodSpec())
.build()
if (objectClassName.toString().equals("S3ObjectInput")) {
TypeSpec.classBuilder(objectClassName)
.addAnnotation(Annotations.GENERATED_BY_APOLLO)
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.addSuperinterface(S3ObjectInput)
.addConstructor()
.addFields()
.addBuilder()
.addMethod(marshallerMethodSpec())
.build()

} else {
TypeSpec.classBuilder(objectClassName)
.addAnnotation(Annotations.GENERATED_BY_APOLLO)
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.addConstructor()
.addFields()
.addBuilder()
.addMethod(marshallerMethodSpec())
.build()
}

private fun TypeSpec.Builder.addConstructor(): TypeSpec.Builder {
val fieldInitializeCodeBuilder = fields.map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,15 @@ class OperationTypeSpecBuilder(
val fragments: List<Fragment>,
useSemanticNaming: Boolean
) : CodeGenerator {
private val operationTypeName: String
private val dataVarType: ClassName

init {
if (useSemanticNaming && operation.isMutation() && !operation.operationName.endsWith("Mutation")) {
operationTypeName = operation.operationName.capitalize() + "Mutation"
} else if (useSemanticNaming && operation.isQuery() && !operation.operationName.endsWith("Query")) {
operationTypeName = operation.operationName.capitalize() + "Query"
} else {
operationTypeName = operation.operationName.capitalize()
}
dataVarType = ClassName.get("", "$operationTypeName.Data")
}
private val operationTypeName = operation.normalizedOperationName(useSemanticNaming)
private val dataVarType = ClassName.get("", "$operationTypeName.Data")

override fun toTypeSpec(context: CodeGenerationContext): TypeSpec {
val newContext = context.copy(reservedTypeNames = context.reservedTypeNames.plus(operationTypeName))
return TypeSpec.classBuilder(operationTypeName)
.addAnnotation(Annotations.GENERATED_BY_APOLLO)
.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
.addOperationSuperInterface(context)
.addSuperinterface(operationSuperInterface(context))
.addOperationDefinition(operation)
.addOperationId(operation)
.addQueryDocumentDefinition(fragments, newContext)
Expand All @@ -66,14 +55,19 @@ class OperationTypeSpecBuilder(
))
}

private fun TypeSpec.Builder.addOperationSuperInterface(context: CodeGenerationContext): TypeSpec.Builder {
val superInterfaceClassName = if (operation.isMutation()) ClassNames.GRAPHQL_MUTATION else ClassNames.GRAPHQL_QUERY
private fun operationSuperInterface(context: CodeGenerationContext): TypeName {
val superInterfaceClassName = when {
operation.isQuery() -> ClassNames.GRAPHQL_QUERY
operation.isMutation() -> ClassNames.GRAPHQL_MUTATION
operation.isSubscription() -> ClassNames.GRAPHQL_SUBSCRIPTION
else -> throw IllegalArgumentException("Unknown operation type ${operation.operationType}")
}

return if (operation.variables.isNotEmpty()) {
addSuperinterface(ParameterizedTypeName.get(superInterfaceClassName, dataVarType,
wrapperType(context), variablesType()))
ParameterizedTypeName.get(superInterfaceClassName, dataVarType, wrapperType(context), variablesType())
} else {
addSuperinterface(ParameterizedTypeName.get(superInterfaceClassName, dataVarType,
wrapperType(context), ClassNames.GRAPHQL_OPERATION_VARIABLES))
ParameterizedTypeName.get(superInterfaceClassName, dataVarType, wrapperType(context),
ClassNames.GRAPHQL_OPERATION_VARIABLES)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.apollographql.apollo.compiler.*
import com.squareup.javapoet.*
import java.util.*
import javax.lang.model.element.Modifier
import com.apollographql.apollo.compiler.ClassNames.S3Object

data class Field(
val responseName: String,
Expand All @@ -40,22 +41,38 @@ data class Field(

override fun toTypeSpec(context: CodeGenerationContext): TypeSpec {
val fields = if (isNonScalar()) fields!! else emptyList()
return SchemaTypeSpecBuilder(
typeName = formatClassName(),
schemaType = type,
fields = fields,
fragmentSpreads = fragmentSpreads ?: emptyList(),
inlineFragments = inlineFragments ?: emptyList(),
context = context
var s3ParameterCount = 0
for (field in fields) {
if (field.fieldName.equals("bucket")
|| field.fieldName.equals("key")
|| field.fieldName.equals("region")) {
s3ParameterCount += 1
}
}

var schemaTypeBuilder = SchemaTypeSpecBuilder(
typeName = formatClassName(),
schemaType = type,
fields = fields,
fragmentSpreads = fragmentSpreads ?: emptyList(),
inlineFragments = inlineFragments ?: emptyList(),
context = context
)
.build(Modifier.PUBLIC, Modifier.STATIC)
.let {
if (context.generateModelBuilder) {
it.withBuilder()
} else {
it
}
}
.build(Modifier.PUBLIC, Modifier.STATIC)
.let {
if (context.generateModelBuilder) {
it.withBuilder()
} else {
it
}
}

// if we identify the object to be S3Object type, we implement the S3ObjectInterface
if (s3ParameterCount == 3) {
schemaTypeBuilder = schemaTypeBuilder.toBuilder().addSuperinterface(S3Object).build()
}

return schemaTypeBuilder
}

fun accessorMethodSpec(context: CodeGenerationContext): MethodSpec {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,31 @@ data class Operation(
}
}

fun isMutation(): Boolean {
return operationType == TYPE_MUTATION
}
fun normalizedOperationName(useSemanticNaming: Boolean): String = when (operationType) {
TYPE_MUTATION -> normalizedOperationName(useSemanticNaming, "Mutation")
TYPE_QUERY -> normalizedOperationName(useSemanticNaming, "Query")
TYPE_SUBSCRIPTION -> normalizedOperationName(useSemanticNaming, "Subscription")
else -> throw IllegalArgumentException("Unknown operation type $operationType")
}

fun isQuery(): Boolean {
return operationType == TYPE_QUERY
}
private fun normalizedOperationName(useSemanticNaming: Boolean, operationNameSuffix: String): String {
return if (useSemanticNaming && !operationName.endsWith(operationNameSuffix)) {
operationName.capitalize() + operationNameSuffix
} else {
operationName.capitalize()
}
}

fun isMutation() = operationType == TYPE_MUTATION

fun isQuery() = operationType == TYPE_QUERY

fun isSubscription() = operationType == TYPE_SUBSCRIPTION

companion object {
val DATA_TYPE_NAME = "Data"
val TYPE_MUTATION = "mutation"
val TYPE_QUERY = "query"
val TYPE_SUBSCRIPTION = "subscription"
}
}
Loading

0 comments on commit ef3c6c4

Please sign in to comment.