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 (#4177)
extracted from #3808
PR #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 #3808 and rebasing #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
@@ -715,7 +715,7 @@ function completeValue(
715
715
);
716
716
if(completed===null){
717
717
thrownewError(
718
-
`Cannot return null for non-nullable field ${info.parentType.name}.${info.fieldName}.`,
718
+
`Cannot return null for non-nullable field ${info.parentType}.${info.fieldName}.`,
719
719
);
720
720
}
721
721
returncompleted;
@@ -904,7 +904,7 @@ function completeListValue(
904
904
905
905
if(!isIterableObject(result)){
906
906
thrownewGraphQLError(
907
-
`Expected Iterable, but did not find one for field "${info.parentType.name}.${info.fieldName}".`,
907
+
`Expected Iterable, but did not find one for field "${info.parentType}.${info.fieldName}".`,
908
908
);
909
909
}
910
910
@@ -1134,7 +1134,7 @@ function ensureValidRuntimeType(
1134
1134
): GraphQLObjectType{
1135
1135
if(runtimeTypeName==null){
1136
1136
thrownewGraphQLError(
1137
-
`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.`,
1137
+
`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.`,
1138
1138
{nodes: fieldGroup},
1139
1139
);
1140
1140
}
@@ -1149,29 +1149,29 @@ function ensureValidRuntimeType(
1149
1149
1150
1150
if(typeofruntimeTypeName!=='string'){
1151
1151
thrownewGraphQLError(
1152
-
`Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}" with `+
1152
+
`Abstract type "${returnType}" must resolve to an Object type at runtime for field "${info.parentType}.${info.fieldName}" with `+
1153
1153
`value ${inspect(result)}, received "${inspect(runtimeTypeName)}".`,
0 commit comments