Skip to content

Commit 004491b

Browse files
committed
cleanup the introspection API
1 parent 3972d9c commit 004491b

File tree

21 files changed

+6882
-866
lines changed

21 files changed

+6882
-866
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import com.apollographql.apollo3.ast.internal.LexerException
1111
import com.apollographql.apollo3.ast.internal.Parser
1212
import com.apollographql.apollo3.ast.internal.ParserException
1313
import com.apollographql.apollo3.ast.internal.validateSchema
14+
import com.apollographql.apollo3.ast.introspection.toGQLDocument
15+
import com.apollographql.apollo3.ast.introspection.toIntrospectionSchema
1416
import okio.Buffer
1517
import okio.BufferedSource
1618
import okio.Path
@@ -19,6 +21,22 @@ import okio.use
1921
import kotlin.jvm.JvmMultifileClass
2022
import kotlin.jvm.JvmName
2123

24+
25+
@ApolloExperimental
26+
fun Path.toSchema(): Schema = toSchemaGQLDocument().validateAsSchema().getOrThrow()
27+
28+
/**
29+
* Transforms the given path to a [GQLDocument] without doing validation
30+
*/
31+
@ApolloExperimental
32+
fun Path.toSchemaGQLDocument(): GQLDocument {
33+
return if (name.endsWith("json")) {
34+
toIntrospectionSchema().toGQLDocument()
35+
} else {
36+
parseAsGQLDocument().getOrThrow()
37+
}
38+
}
39+
2240
/**
2341
* Parses the source to a [Schema], throwing on parsing or validation errors.
2442
*

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

Lines changed: 0 additions & 256 deletions
This file was deleted.

0 commit comments

Comments
 (0)