Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select all types in pre-introspection query #5547

Merged
merged 3 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,9 @@ class ConfigurationCacheTests {
val preIntrospectionResponse = """
{
"data": {
"schema": {
"__typename": "__Type",
"fields": []
},
"type": {
"__typename": "__Type",
"fields": []
},
"directive": {
"__typename": "__Type",
"fields": []
},
"field": {
"__typename": "__Type",
"fields": []
},
"inputValue": {
"__typename": "__Type",
"fields": []
"__schema": {
"__typename": "__Schema",
"types": []
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import okhttp3.tls.HeldCertificate
import okio.Buffer
import okio.buffer
import okio.source
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.TaskOutcome
import org.http4k.core.HttpHandler
import org.http4k.core.Method
Expand All @@ -37,25 +36,9 @@ class DownloadSchemaTests {
private val preIntrospectionResponse = """
{
"data": {
"schema": {
"__typename": "__Type",
"fields": []
},
"type": {
"__typename": "__Type",
"fields": []
},
"directive": {
"__typename": "__Type",
"fields": []
},
"field": {
"__typename": "__Type",
"fields": []
},
"inputValue": {
"__typename": "__Type",
"fields": []
"__schema": {
"__typename": "__Schema",
"types": []
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Pre-introspection query allowing to retrieve the server's supported features.

query PreIntrospectionQuery {
schema: __type(name: "__Schema") { ...TypeFields }
type: __type(name: "__Type") { ...TypeFields }
directive: __type(name: "__Directive") { ...TypeFields }
field: __type(name: "__Field") { ...TypeFields }
inputValue: __type(name: "__InputValue") { ...TypeFields }
__schema {
types {
...TypeFields
}
}
Comment on lines -4 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment linking to this PR?

}

fragment TypeFields on __Type {
name
fields {
name
args {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ enum class GraphQLFeature {
}

internal fun PreIntrospectionQuery.Data.getFeatures(): Set<GraphQLFeature> {
val schema = __schema.types.firstOrNull { it.typeFields.name == "__Schema" }
val type = __schema.types.firstOrNull { it.typeFields.name == "__Type" }
val directive = __schema.types.firstOrNull { it.typeFields.name == "__Directive" }
val field = __schema.types.firstOrNull { it.typeFields.name == "__Field" }
val inputValue = __schema.types.firstOrNull { it.typeFields.name == "__InputValue" }
return buildSet {
if (schema?.typeFields?.fields.orEmpty().any { it.name == "description" }) {
add(SchemaDescription)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import com.apollographql.apollo3.ast.toFullSchemaGQLDocument
import com.apollographql.apollo3.ast.toGQLDocument
import com.apollographql.apollo3.ast.toSDL
import com.apollographql.apollo3.ast.toUtf8
import com.apollographql.apollo3.exception.ApolloHttpException
import com.apollographql.apollo3.network.okHttpClient
import com.apollographql.apollo3.tooling.SchemaHelper.reworkFullTypeFragment
import com.apollographql.apollo3.tooling.SchemaHelper.reworkInputValueFragment
Expand Down