Skip to content

Commit 306db0e

Browse files
committed
keep filePath around, it's required for the schema package name
1 parent 7e29e56 commit 306db0e

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ fun Path.parseAsGQLDocument(options: ParserOptions = ParserOptions.Default): GQL
196196

197197
fun Path.toGQLDocument(options: ParserOptions = ParserOptions.Default, allowJson: Boolean = false): GQLDocument {
198198
return if (allowJson && name.endsWith(".json")) {
199-
toIntrospectionData().toGQLDocument()
199+
toIntrospectionData().toGQLDocument(name)
200200
} else {
201201
parseAsGQLDocument(options).getOrThrow()
202202
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,4 @@ fun GQLDocument.toIntrospectionData(): IntrospectionData = IntrospectionData(Int
228228
/**
229229
* Parses the [IntrospectionSchema] into a [GQLDocument]
230230
*/
231-
fun IntrospectionData.toGQLDocument(): GQLDocument = GQLDocumentBuilder(this.__schema).toGQLDocument()
231+
fun IntrospectionData.toGQLDocument(filePath: String? = null): GQLDocument = GQLDocumentBuilder(this.__schema).toGQLDocument(filePath)

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ import com.apollographql.apollo3.ast.GQLStringValue
2626
import com.apollographql.apollo3.ast.GQLType
2727
import com.apollographql.apollo3.ast.GQLUnionTypeDefinition
2828
import com.apollographql.apollo3.ast.GQLValue
29+
import com.apollographql.apollo3.ast.SourceLocation
2930
import com.apollographql.apollo3.ast.parseAsGQLValue
3031
import okio.Buffer
3132
import kotlin.jvm.JvmMultifileClass
3233
import kotlin.jvm.JvmName
3334

3435
internal class GQLDocumentBuilder(private val introspectionSchema: IntrospectionSchema) {
35-
fun toGQLDocument(): GQLDocument {
36+
fun toGQLDocument(filePath: String?): GQLDocument {
3637
return with(introspectionSchema) {
3738
if (directives == null) {
3839
println("Apollo: No directives found in introspection schema, double check your introspection query")
@@ -52,7 +53,7 @@ internal class GQLDocumentBuilder(private val introspectionSchema: Introspection
5253
}
5354
+ directives.orEmpty().mapNotNull { it.toGQLDirectiveDefinition() }
5455
+ schemaDefinition(),
55-
sourceLocation = null
56+
sourceLocation = SourceLocation.forPath(filePath)
5657
)
5758
}
5859
}

libraries/apollo-ast/src/jvmMain/kotlin/com/apollographql/apollo3/ast/api.jvm.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fun File.parseAsGQLDocument(options: ParserOptions = ParserOptions.Default): GQL
1515

1616
fun File.toGQLDocument(options: ParserOptions = ParserOptions.Default, allowJson: Boolean = false): GQLDocument {
1717
if (allowJson && extension == "json") {
18-
return toIntrospectionData().toGQLDocument()
18+
return toIntrospectionData().toGQLDocument(path)
1919
}
2020
return parseAsGQLDocument(options).getOrThrow()
2121
}

libraries/apollo-ast/src/jvmTest/kotlin/com/apollographql/apollo3/graphql/ast/test/IntrospectionTest.jvm.kt.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import java.io.File
1515
@RunWith(TestParameterInjector::class)
1616
class IntrospectionTest {
1717
private fun canReadIntrospectionResults(name: String) {
18-
File("${CWD}/test-fixtures/introspection/$name.json").toIntrospectionData()
18+
File("${CWD}/test-fixtures/introspection/$name.json")
19+
.toIntrospectionData()
1920
.toGQLDocument()
2021
.validateAsSchema()
2122
.getOrThrow()

0 commit comments

Comments
 (0)