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
#3808 except for the ones in getArgumentValues when it is passed a Field
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.
`Cannot return null for non-nullable field ${info.parentType.name}.${info.fieldName}.`,
911
+
`Cannot return null for non-nullable field ${info.parentType}.${info.fieldName}.`,
912
912
);
913
913
}
914
914
returncompleted;
@@ -1258,7 +1258,7 @@ function completeListValue(
1258
1258
1259
1259
if(!isIterableObject(result)){
1260
1260
thrownewGraphQLError(
1261
-
`Expected Iterable, but did not find one for field "${info.parentType.name}.${info.fieldName}".`,
1261
+
`Expected Iterable, but did not find one for field "${info.parentType}.${info.fieldName}".`,
1262
1262
);
1263
1263
}
1264
1264
@@ -1565,7 +1565,7 @@ function ensureValidRuntimeType(
1565
1565
): GraphQLObjectType{
1566
1566
if(runtimeTypeName==null){
1567
1567
thrownewGraphQLError(
1568
-
`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.`,
1568
+
`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.`,
1569
1569
{nodes: toNodes(fieldGroup)},
1570
1570
);
1571
1571
}
@@ -1580,29 +1580,29 @@ function ensureValidRuntimeType(
1580
1580
1581
1581
if(typeofruntimeTypeName!=='string'){
1582
1582
thrownewGraphQLError(
1583
-
`Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}" with `+
1583
+
`Abstract type "${returnType}" must resolve to an Object type at runtime for field "${info.parentType}.${info.fieldName}" with `+
1584
1584
`value ${inspect(result)}, received "${inspect(runtimeTypeName)}".`,
0 commit comments