Skip to content

Commit

Permalink
add RemoveFieldTestTransform error message
Browse files Browse the repository at this point in the history
  • Loading branch information
temaEmelyan committed Dec 12, 2024
1 parent 5774cd1 commit 1213053
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package graphql.nadel.tests.transforms

import graphql.ErrorType
import graphql.GraphQLError
import graphql.introspection.Introspection
import graphql.nadel.Service
Expand All @@ -15,11 +16,10 @@ import graphql.nadel.engine.transform.query.NadelQueryTransformer
import graphql.nadel.engine.transform.result.NadelResultInstruction
import graphql.nadel.engine.transform.result.NadelResultKey
import graphql.nadel.engine.transform.result.json.JsonNodes
import graphql.nadel.engine.util.newGraphQLError
import graphql.nadel.engine.util.queryPath
import graphql.normalized.ExecutableNormalizedField
import graphql.schema.GraphQLObjectType
import graphql.validation.ValidationError.newValidationError
import graphql.validation.ValidationErrorType

class RemoveFieldTestTransform : NadelTransform<GraphQLError> {
override suspend fun isApplicable(
Expand All @@ -40,7 +40,10 @@ class RemoveFieldTestTransform : NadelTransform<GraphQLError> {
?: return null

if (objectType.getField(overallField.name)?.getDirective("toBeDeleted") != null) {
return newValidationError().validationErrorType(ValidationErrorType.WrongType).build()
return newGraphQLError(
"field `${objectType.name}.${overallField.name}` has been removed by RemoveFieldTestTransform",
ErrorType.DataFetchingException,
)
}

return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ response: |-
},
"errors": [
{
"message": "null",
"message": "field `Foo.epicEntity` has been removed by RemoveFieldTestTransform",
"locations": [],
"extensions": {
"classification": "ValidationError"
"classification": "DataFetchingException"
}
}
],
"extensions": {}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,19 @@ serviceCalls:
# language=JSON
response: |-
{
"data": {
"issueById": {
"id": "C1",
"comment": null
}
},
"errors": [
{
"message": "field `CommentApi.commentById` has been removed by RemoveFieldTestTransform",
"locations": [],
"message": "An error has occurred",
"extensions": {
"classification": "ValidationError"
"classification": "DataFetchingException"
}
}
],
"data": {
"issueById": {
"id": "C1",
"comment": null
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ serviceCalls:
# language=JSON
response: |-
{
"data": {
"issueById": {
"id": "C1",
"comment": null
}
},
"errors": [
{
"message": "field `Query.commentById` has been removed by RemoveFieldTestTransform",
"locations": [],
"message": "An error has occurred",
"extensions": {
"classification": "ValidationError"
"classification": "DataFetchingException"
}
}
],
"data": {
"issueById": {
"id": "C1",
"comment": null
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ serviceCalls: [ ]
# language=JSON
response: |-
{
"data": {
"commentApi": {
"commentById": null
}
},
"errors": [
{
"message": "field `CommentApi.commentById` has been removed by RemoveFieldTestTransform",
"locations": [],
"message": "null",
"extensions": {
"classification": "ValidationError"
"classification": "DataFetchingException"
}
}
],
"data": {
"commentApi": {
"commentById": null
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,18 @@ serviceCalls: [ ]
# language=JSON
response: |-
{
"data": {
"commentApi": {
"commentById": null
}
},
"errors": [
{
"message": "field `CommentApi.commentById` has been removed by RemoveFieldTestTransform",
"locations": [],
"message": "null",
"extensions": {
"classification": "ValidationError"
"classification": "DataFetchingException"
}
}
],
"data": {
"commentApi": {
"commentById": null
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@ serviceCalls:
# language=JSON
response: |-
{
"data": {
"issueById": {
"id": "C1",
"comment": null
}
},
"errors": [
{
"message": "field `CommentApi.commentById` has been removed by RemoveFieldTestTransform",
"locations": [],
"message": "An error has occurred",
"extensions": {
"classification": "ValidationError"
"classification": "DataFetchingException"
}
}
],
"data": {
"issueById": {
"id": "C1",
"comment": null
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ serviceCalls: [ ]
# language=JSON
response: |-
{
"data": {
"commentsApi": null
},
"errors": [
{
"message": "field `CommentsApi.onCommentUpdated` has been removed by RemoveFieldTestTransform",
"locations": [],
"message": "null",
"extensions": {
"classification": "ValidationError"
"classification": "DataFetchingException"
}
}
],
"data": {
"commentsApi": null
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ serviceCalls: [ ]
# language=JSON
response: |-
{
"data": {
"onCommentUpdated": null
},
"errors": [
{
"message": "field `Subscription.onCommentUpdated` has been removed by RemoveFieldTestTransform",
"locations": [],
"message": "null",
"extensions": {
"classification": "ValidationError"
"classification": "DataFetchingException"
}
}
],
"data": {
"onCommentUpdated": null
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ serviceCalls:
# language=JSON
response: |-
{
"data": {
"commentById": null
},
"errors": [
{
"message": "field `Query.commentById` has been removed by RemoveFieldTestTransform",
"locations": [],
"message": "null",
"extensions": {
"classification": "ValidationError"
"classification": "DataFetchingException"
}
}
],
"data": {
"commentById": null
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ serviceCalls: [ ]
# language=JSON
response: |-
{
"data": {
"commentById": null
},
"errors": [
{
"message": "field `Query.commentById` has been removed by RemoveFieldTestTransform",
"locations": [],
"message": "null",
"extensions": {
"classification": "ValidationError"
"classification": "DataFetchingException"
}
}
],
"data": {
"commentById": null
}
]
}

0 comments on commit 1213053

Please sign in to comment.