You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
standardize error messages prior to introducing schema coordinates (graphql#4177)
extracted from graphql#3808
PR graphql#3808 uses schema coordinates to improve GraphQL-JS error messages.
To reduce the size of the PR, this commit standardizes error messages
according to the general pattern that will be introduced with schema
coordinates without introducing the coordinates themselves, in the hopes
of aiding review of the later PR.
EDITED 8/26/2024:
I was able to reproduce all of the standardized error messages from
Definition, because the parent type is not passed. Everything else can
be calculated for the error messages we are currently printing, although
schema coordinates simplifies things.
Extracting these changes out of graphql#3808 and rebasing graphql#3808 on main will
therefore will better demonstrate how schema coordinates improves the
clarity of some of our error messages (namely, getArgumentValues) and
simplifies printing them.
Copy file name to clipboardExpand all lines: src/execution/execute.ts
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -676,7 +676,7 @@ function completeValue(
676
676
);
677
677
if(completed===null){
678
678
thrownewError(
679
-
`Cannot return null for non-nullable field ${info.parentType.name}.${info.fieldName}.`,
679
+
`Cannot return null for non-nullable field ${info.parentType}.${info.fieldName}.`,
680
680
);
681
681
}
682
682
returncompleted;
@@ -873,7 +873,7 @@ function completeListValue(
873
873
874
874
if(!isIterableObject(result)){
875
875
thrownewGraphQLError(
876
-
`Expected Iterable, but did not find one for field "${info.parentType.name}.${info.fieldName}".`,
876
+
`Expected Iterable, but did not find one for field "${info.parentType}.${info.fieldName}".`,
877
877
);
878
878
}
879
879
@@ -1103,7 +1103,7 @@ function ensureValidRuntimeType(
1103
1103
): GraphQLObjectType{
1104
1104
if(runtimeTypeName==null){
1105
1105
thrownewGraphQLError(
1106
-
`Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}". Either the "${returnType.name}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`,
1106
+
`Abstract type "${returnType}" must resolve to an Object type at runtime for field "${info.parentType}.${info.fieldName}". Either the "${returnType}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`,
1107
1107
{nodes: fieldGroup},
1108
1108
);
1109
1109
}
@@ -1118,29 +1118,29 @@ function ensureValidRuntimeType(
1118
1118
1119
1119
if(typeofruntimeTypeName!=='string'){
1120
1120
thrownewGraphQLError(
1121
-
`Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}" with `+
1121
+
`Abstract type "${returnType}" must resolve to an Object type at runtime for field "${info.parentType}.${info.fieldName}" with `+
1122
1122
`value ${inspect(result)}, received "${inspect(runtimeTypeName)}".`,
0 commit comments