File tree Expand file tree Collapse file tree 5 files changed +8
-6
lines changed
commonMain/kotlin/com/apollographql/apollo3/ast
jvmMain/kotlin/com/apollographql/apollo3/ast
jvmTest/kotlin/com/apollographql/apollo3/graphql/ast/test Expand file tree Collapse file tree 5 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ fun Path.parseAsGQLDocument(options: ParserOptions = ParserOptions.Default): GQL
196
196
197
197
fun Path.toGQLDocument (options : ParserOptions = ParserOptions .Default , allowJson : Boolean = false): GQLDocument {
198
198
return if (allowJson && name.endsWith(" .json" )) {
199
- toIntrospectionData().toGQLDocument()
199
+ toIntrospectionData().toGQLDocument(name )
200
200
} else {
201
201
parseAsGQLDocument(options).getOrThrow()
202
202
}
Original file line number Diff line number Diff line change @@ -228,4 +228,4 @@ fun GQLDocument.toIntrospectionData(): IntrospectionData = IntrospectionData(Int
228
228
/* *
229
229
* Parses the [IntrospectionSchema] into a [GQLDocument]
230
230
*/
231
- fun IntrospectionData.toGQLDocument (): GQLDocument = GQLDocumentBuilder (this .__schema ).toGQLDocument()
231
+ fun IntrospectionData.toGQLDocument (filePath : String? = null ): GQLDocument = GQLDocumentBuilder (this .__schema ).toGQLDocument(filePath )
Original file line number Diff line number Diff line change @@ -26,13 +26,14 @@ import com.apollographql.apollo3.ast.GQLStringValue
26
26
import com.apollographql.apollo3.ast.GQLType
27
27
import com.apollographql.apollo3.ast.GQLUnionTypeDefinition
28
28
import com.apollographql.apollo3.ast.GQLValue
29
+ import com.apollographql.apollo3.ast.SourceLocation
29
30
import com.apollographql.apollo3.ast.parseAsGQLValue
30
31
import okio.Buffer
31
32
import kotlin.jvm.JvmMultifileClass
32
33
import kotlin.jvm.JvmName
33
34
34
35
internal class GQLDocumentBuilder (private val introspectionSchema : IntrospectionSchema ) {
35
- fun toGQLDocument (): GQLDocument {
36
+ fun toGQLDocument (filePath : String? ): GQLDocument {
36
37
return with (introspectionSchema) {
37
38
if (directives == null ) {
38
39
println (" Apollo: No directives found in introspection schema, double check your introspection query" )
@@ -52,7 +53,7 @@ internal class GQLDocumentBuilder(private val introspectionSchema: Introspection
52
53
}
53
54
+ directives.orEmpty().mapNotNull { it.toGQLDirectiveDefinition() }
54
55
+ schemaDefinition(),
55
- sourceLocation = null
56
+ sourceLocation = SourceLocation .forPath(filePath)
56
57
)
57
58
}
58
59
}
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ fun File.parseAsGQLDocument(options: ParserOptions = ParserOptions.Default): GQL
15
15
16
16
fun File.toGQLDocument (options : ParserOptions = ParserOptions .Default , allowJson : Boolean = false): GQLDocument {
17
17
if (allowJson && extension == " json" ) {
18
- return toIntrospectionData().toGQLDocument()
18
+ return toIntrospectionData().toGQLDocument(path )
19
19
}
20
20
return parseAsGQLDocument(options).getOrThrow()
21
21
}
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ import java.io.File
15
15
@RunWith(TestParameterInjector ::class )
16
16
class IntrospectionTest {
17
17
private fun canReadIntrospectionResults (name : String ) {
18
- File (" ${CWD } /test-fixtures/introspection/$name .json" ).toIntrospectionData()
18
+ File (" ${CWD } /test-fixtures/introspection/$name .json" )
19
+ .toIntrospectionData()
19
20
.toGQLDocument()
20
21
.validateAsSchema()
21
22
.getOrThrow()
You can’t perform that action at this time.
0 commit comments