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
196196
197197fun 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 }
Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change @@ -26,13 +26,14 @@ import com.apollographql.apollo3.ast.GQLStringValue
2626import com.apollographql.apollo3.ast.GQLType
2727import com.apollographql.apollo3.ast.GQLUnionTypeDefinition
2828import com.apollographql.apollo3.ast.GQLValue
29+ import com.apollographql.apollo3.ast.SourceLocation
2930import com.apollographql.apollo3.ast.parseAsGQLValue
3031import okio.Buffer
3132import kotlin.jvm.JvmMultifileClass
3233import kotlin.jvm.JvmName
3334
3435internal 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 }
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ fun File.parseAsGQLDocument(options: ParserOptions = ParserOptions.Default): GQL
1515
1616fun 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}
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ import java.io.File
1515@RunWith(TestParameterInjector ::class )
1616class 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()
You can’t perform that action at this time.
0 commit comments