Skip to content

Commit 170e7ff

Browse files
authored
Move apollo stuff outside of apollo ast (#5121)
* move apollo specific code to apollo-compiler * update apiDump
1 parent c9128e3 commit 170e7ff

File tree

14 files changed

+33
-37
lines changed

14 files changed

+33
-37
lines changed

libraries/apollo-ast/api/apollo-ast.api

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ public final class com/apollographql/apollo3/ast/ApolloParser {
1414
public static final fun toSchema (Ljava/lang/String;)Lcom/apollographql/apollo3/ast/Schema;
1515
}
1616

17-
public final class com/apollographql/apollo3/ast/Check_key_fieldsKt {
18-
public static final fun checkKeyFields (Lcom/apollographql/apollo3/ast/GQLFragmentDefinition;Lcom/apollographql/apollo3/ast/Schema;Ljava/util/Map;)V
19-
public static final fun checkKeyFields (Lcom/apollographql/apollo3/ast/GQLOperationDefinition;Lcom/apollographql/apollo3/ast/Schema;Ljava/util/Map;)V
20-
}
21-
2217
public final class com/apollographql/apollo3/ast/ConversionException : com/apollographql/apollo3/ast/SourceAwareException {
2318
public fun <init> (Ljava/lang/String;Lcom/apollographql/apollo3/ast/SourceLocation;)V
2419
public synthetic fun <init> (Ljava/lang/String;Lcom/apollographql/apollo3/ast/SourceLocation;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
@@ -1506,11 +1501,6 @@ public final class com/apollographql/apollo3/ast/introspection/Schema_to_introsp
15061501
public static final fun toIntrospectionSchema (Lcom/apollographql/apollo3/ast/Schema;)Lcom/apollographql/apollo3/ast/introspection/IntrospectionSchema;
15071502
}
15081503

1509-
public final class com/apollographql/apollo3/ast/transformation/Add_required_fieldsKt {
1510-
public static final fun addRequiredFields (Lcom/apollographql/apollo3/ast/GQLFragmentDefinition;Ljava/lang/String;Lcom/apollographql/apollo3/ast/Schema;Ljava/util/Map;)Lcom/apollographql/apollo3/ast/GQLFragmentDefinition;
1511-
public static final fun addRequiredFields (Lcom/apollographql/apollo3/ast/GQLOperationDefinition;Ljava/lang/String;Lcom/apollographql/apollo3/ast/Schema;Ljava/util/Map;)Lcom/apollographql/apollo3/ast/GQLOperationDefinition;
1512-
}
1513-
15141504
public class com/apollographql/apollo3/generated/antlr/GraphQLBaseListener : com/apollographql/apollo3/generated/antlr/GraphQLListener {
15151505
public fun <init> ()V
15161506
public fun enterAlias (Lcom/apollographql/apollo3/generated/antlr/GraphQLParser$AliasContext;)V

libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo3/ast/exception.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import okio.IOException
55
import okio.Path.Companion.toPath
66
import okio.buffer
77

8-
9-
expect internal val HOST_FILESYSTEM: FileSystem
8+
internal expect val HOST_FILESYSTEM: FileSystem
109

1110
open class SourceAwareException(
1211
val error: String,

libraries/apollo-ast/src/commonTest/kotlin/com/apollographql/apollo3/graphql/ast/test/validation/OperationValidationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import kotlin.test.assertEquals
1414

1515
class OperationValidationTest {
1616
@Test
17-
fun testAddRequiredFields() {
17+
fun deprecatedInputField() {
1818
val schema = "${CWD}/src/commonTest/kotlin/com/apollographql/apollo3/graphql/ast/test/validation/inputTypeDeprecatedField.graphqls".toPath().toSchema()
1919
val operations = "${CWD}/src/commonTest/kotlin/com/apollographql/apollo3/graphql/ast/test/validation/inputTypeDeprecatedField.graphql"
2020
.toPath()

libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/ApolloCompiler.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ import com.apollographql.apollo3.ast.Issue
1212
import com.apollographql.apollo3.ast.ParserOptions
1313
import com.apollographql.apollo3.ast.QueryDocumentMinifier
1414
import com.apollographql.apollo3.ast.Schema
15-
import com.apollographql.apollo3.ast.checkKeyFields
1615
import com.apollographql.apollo3.ast.checkNoErrors
1716
import com.apollographql.apollo3.ast.introspection.toSchemaGQLDocument
1817
import com.apollographql.apollo3.ast.parseAsGQLDocument
1918
import com.apollographql.apollo3.ast.pretty
20-
import com.apollographql.apollo3.ast.transformation.addRequiredFields
2119
import com.apollographql.apollo3.ast.validateAsExecutable
2220
import com.apollographql.apollo3.ast.validateAsSchemaAndAddApolloDefinition
2321
import com.apollographql.apollo3.compiler.codegen.java.JavaCodeGen
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.apollographql.apollo3.ast.transformation
1+
package com.apollographql.apollo3.compiler
22

33
import com.apollographql.apollo3.ast.GQLField
44
import com.apollographql.apollo3.ast.GQLFragmentDefinition
@@ -7,13 +7,12 @@ import com.apollographql.apollo3.ast.GQLInlineFragment
77
import com.apollographql.apollo3.ast.GQLOperationDefinition
88
import com.apollographql.apollo3.ast.GQLSelection
99
import com.apollographql.apollo3.ast.Schema
10-
import com.apollographql.apollo3.ast.SourceLocation
1110
import com.apollographql.apollo3.ast.definitionFromScope
1211
import com.apollographql.apollo3.ast.isAbstract
1312
import com.apollographql.apollo3.ast.rawType
1413
import com.apollographql.apollo3.ast.rootTypeDefinition
1514

16-
fun addRequiredFields(
15+
internal fun addRequiredFields(
1716
operation: GQLOperationDefinition,
1817
addTypename: String,
1918
schema: Schema,
@@ -25,7 +24,7 @@ fun addRequiredFields(
2524
)
2625
}
2726

28-
fun addRequiredFields(
27+
internal fun addRequiredFields(
2928
fragmentDefinition: GQLFragmentDefinition,
3029
addTypename: String,
3130
schema: Schema,

libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo3/ast/check_key_fields.kt renamed to libraries/apollo-compiler/src/main/kotlin/com/apollographql/apollo3/compiler/check_key_fields.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1-
package com.apollographql.apollo3.ast
1+
package com.apollographql.apollo3.compiler
2+
3+
import com.apollographql.apollo3.ast.GQLDirective
4+
import com.apollographql.apollo3.ast.GQLField
5+
import com.apollographql.apollo3.ast.GQLFragmentDefinition
6+
import com.apollographql.apollo3.ast.GQLFragmentSpread
7+
import com.apollographql.apollo3.ast.GQLInlineFragment
8+
import com.apollographql.apollo3.ast.GQLObjectTypeDefinition
9+
import com.apollographql.apollo3.ast.GQLOperationDefinition
10+
import com.apollographql.apollo3.ast.GQLSelection
11+
import com.apollographql.apollo3.ast.GQLStringValue
12+
import com.apollographql.apollo3.ast.Schema
13+
import com.apollographql.apollo3.ast.definitionFromScope
14+
import com.apollographql.apollo3.ast.rawType
15+
import com.apollographql.apollo3.ast.rootTypeDefinition
216

317
private class CheckKeyFieldsScope(
418
val schema: Schema,
@@ -15,12 +29,12 @@ private class CheckKeyFieldsScope(
1529
}
1630
}
1731

18-
fun checkKeyFields(operation: GQLOperationDefinition, schema: Schema, allFragmentDefinitions: Map<String, GQLFragmentDefinition>) {
32+
internal fun checkKeyFields(operation: GQLOperationDefinition, schema: Schema, allFragmentDefinitions: Map<String, GQLFragmentDefinition>) {
1933
val parentType = operation.rootTypeDefinition(schema)!!.name
2034
CheckKeyFieldsScope(schema, allFragmentDefinitions).checkField("Operation(${operation.name})", operation.selections, parentType)
2135
}
2236

23-
fun checkKeyFields(
37+
internal fun checkKeyFields(
2438
fragmentDefinition: GQLFragmentDefinition,
2539
schema: Schema,
2640
allFragmentDefinitions: Map<String, GQLFragmentDefinition>,

libraries/apollo-compiler/src/test/kotlin/com/apollographql/apollo3/compiler/TypenameTest.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ package com.apollographql.apollo3.compiler
33
import com.apollographql.apollo3.ast.GQLDocument
44
import com.apollographql.apollo3.ast.GQLFragmentDefinition
55
import com.apollographql.apollo3.ast.GQLOperationDefinition
6-
import com.apollographql.apollo3.ast.builtinDefinitions
6+
import com.apollographql.apollo3.ast.introspection.toSchema
77
import com.apollographql.apollo3.ast.toExecutableDefinitions
88
import com.apollographql.apollo3.ast.toUtf8
9-
import com.apollographql.apollo3.ast.transformation.addRequiredFields
10-
import com.apollographql.apollo3.ast.introspection.toSchema
119
import com.google.common.truth.Truth.assertThat
1210
import com.google.testing.junit.testparameterinjector.TestParameter
1311
import com.google.testing.junit.testparameterinjector.TestParameterInjector
@@ -17,7 +15,6 @@ import org.junit.Test
1715
import org.junit.runner.RunWith
1816
import java.io.File
1917

20-
@Suppress("UNUSED_PARAMETER")
2118
@RunWith(TestParameterInjector::class)
2219
class TypenameTest(
2320
@TestParameter(valuesProvider = GraphQLFileValuesProvider::class) private val graphQLFile: File,
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
package com.apollographql.apollo3.graphql.ast.test.keyfields
1+
package com.apollographql.apollo3.compiler.keyfields
22

33
import com.apollographql.apollo3.ast.GQLFragmentDefinition
44
import com.apollographql.apollo3.ast.GQLOperationDefinition
5-
import com.apollographql.apollo3.ast.checkKeyFields
65
import com.apollographql.apollo3.ast.introspection.toSchema
76
import com.apollographql.apollo3.ast.parseAsGQLDocument
8-
import com.apollographql.apollo3.ast.transformation.addRequiredFields
97
import com.apollographql.apollo3.ast.validateAsSchema
10-
import com.apollographql.apollo3.graphql.ast.test.CWD
8+
import com.apollographql.apollo3.compiler.addRequiredFields
9+
import com.apollographql.apollo3.compiler.checkKeyFields
1110
import okio.Path.Companion.toPath
1211
import kotlin.test.Test
1312
import kotlin.test.assertContains
@@ -18,9 +17,9 @@ import kotlin.test.fail
1817
class KeyFieldsTest {
1918
@Test
2019
fun testAddRequiredFields() {
21-
val schema = "${CWD}/src/commonTest/kotlin/com/apollographql/apollo3/graphql/ast/test/keyfields/schema.graphqls".toPath().toSchema()
20+
val schema = "src/test/kotlin/com/apollographql/apollo3/compiler/keyfields/schema.graphqls".toPath().toSchema()
2221

23-
val definitions = "${CWD}/src/commonTest/kotlin/com/apollographql/apollo3/graphql/ast/test/keyfields/operations.graphql".toPath()
22+
val definitions = "src/test/kotlin/com/apollographql/apollo3/compiler/keyfields/operations.graphql".toPath()
2423
.parseAsGQLDocument()
2524
.getOrThrow()
2625
.definitions
@@ -44,20 +43,20 @@ class KeyFieldsTest {
4443

4544
@Test
4645
fun testExtendInterfaceTypePolicyDirective() {
47-
val schema = "${CWD}/src/commonTest/kotlin/com/apollographql/apollo3/graphql/ast/test/keyfields/extendsSchema.graphqls".toPath().toSchema()
46+
val schema = "src/test/kotlin/com/apollographql/apollo3/compiler/keyfields/extendsSchema.graphqls".toPath().toSchema()
4847
schema.toGQLDocument().validateAsSchema()
4948
assertEquals(setOf("id"), schema.keyFields("Node"))
5049
}
5150

5251
@Test
5352
fun testExtendUnionTypePolicyDirective() {
54-
val schema = "${CWD}/src/commonTest/kotlin/com/apollographql/apollo3/graphql/ast/test/keyfields/extendsSchema.graphqls".toPath().toSchema()
53+
val schema = "src/test/kotlin/com/apollographql/apollo3/compiler/keyfields/extendsSchema.graphqls".toPath().toSchema()
5554
assertEquals(setOf("x"), schema.keyFields("Foo"))
5655
}
5756

5857
@Test
5958
fun testObjectWithTypePolicyAndInterfaceTypePolicyErrors() {
60-
"${CWD}/src/commonTest/kotlin/com/apollographql/apollo3/graphql/ast/test/keyfields/objectAndInterfaceTypePolicySchema.graphqls"
59+
"src/test/kotlin/com/apollographql/apollo3/compiler/keyfields/objectAndInterfaceTypePolicySchema.graphqls"
6160
.toPath()
6261
.parseAsGQLDocument()
6362
.getOrThrow()
@@ -73,7 +72,7 @@ class KeyFieldsTest {
7372

7473
@Test
7574
fun testObjectInheritingTwoInterfacesWithDifferentKeyFields() {
76-
"${CWD}/src/commonTest/kotlin/com/apollographql/apollo3/graphql/ast/test/keyfields/objectInheritingTwoInterfaces.graphqls"
75+
"src/test/kotlin/com/apollographql/apollo3/compiler/keyfields/objectInheritingTwoInterfaces.graphqls"
7776
.toPath()
7877
.parseAsGQLDocument()
7978
.getOrThrow()
@@ -95,7 +94,7 @@ class KeyFieldsTest {
9594

9695
@Test
9796
fun testInterfacesWithoutKeyFields() {
98-
"${CWD}/src/commonTest/kotlin/com/apollographql/apollo3/graphql/ast/test/keyfields/interfacesWithoutKeyFields.graphqls"
97+
"src/test/kotlin/com/apollographql/apollo3/compiler/keyfields/interfacesWithoutKeyFields.graphqls"
9998
.toPath()
10099
.parseAsGQLDocument()
101100
.getOrThrow()

0 commit comments

Comments
 (0)