Fix short circuit introspection for namespace like fields - #697
Conversation
| } | ||
| val operationType = service.underlyingSchema.getTypeAs<GraphQLObjectType>(topLevelField.singleObjectTypeName) | ||
| val topLevelFieldDefinition = operationType.getField(topLevelField.name) | ||
| val isNamespacedLike = topLevelFieldDefinition?.arguments?.isEmpty() == true |
There was a problem hiding this comment.
Extracted this code into common NamespacedUtil.isNamespaceFieldLike
| } | ||
| val operationType = service.underlyingSchema.getTypeAs<GraphQLObjectType>(topLevelField.singleObjectTypeName) | ||
| val topLevelFieldDefinition = operationType.getField(topLevelField.name) | ||
| val isNamespacedLike = topLevelFieldDefinition?.arguments?.isEmpty() == true |
There was a problem hiding this comment.
So the bug here is that the logic we use to identify "namespaced fields" is different here and in the internal introspection service.
This leads to a bug because this code thinks more fields can be handled by the internal introspection service, but in reality it can't so it fails.
| getFieldsWithCoordinates(schema.queryType, schema.mutationType, schema.subscriptionType) | ||
| .filter { (_, field) -> | ||
| isNamespacedField(field) | ||
| isNamespacedFieldLike(field) |
There was a problem hiding this comment.
So this uses the newly extracted code from NextgenEngine.isOnlyTopLevelFieldTypename
| @Suppress("unused") | ||
| public class NamespaceLikeShortCircuitsIntrospectionTestSnapshot : TestSnapshot() { | ||
| override val calls: List<ExpectedServiceCall> = listOf( | ||
| ) |
There was a problem hiding this comment.
So here the calls are empty because the tests are executed by our internal introspection service.
| | { | ||
| | "data": { | ||
| | "test": { | ||
| | "__typename": "TestQuery" |
There was a problem hiding this comment.
Prior to this PR's fix, it would error out like so
{
"errors": [
{
"message": "Exception while fetching data (/test) : Internal error: should never happen: This data fetcher should NEVER be called from Nadel",
"locations": [
{
"column": 2,
"line": 1
}
],
"path": [
"test"
],
"extensions": {
"classification": "DataFetchingException"
}
}
],
"data": {
"test": null
}
}There was a problem hiding this comment.
Adding some stubbed tests because that's what led to this bug.
No description provided.