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
@@ -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;
@@ -912,7 +912,7 @@ function completeListValue(
912
912
913
913
if(!isIterableObject(result)){
914
914
thrownewGraphQLError(
915
-
`Expected Iterable, but did not find one for field "${info.parentType.name}.${info.fieldName}".`,
915
+
`Expected Iterable, but did not find one for field "${info.parentType}.${info.fieldName}".`,
916
916
);
917
917
}
918
918
@@ -1142,7 +1142,7 @@ function ensureValidRuntimeType(
1142
1142
): GraphQLObjectType{
1143
1143
if(runtimeTypeName==null){
1144
1144
thrownewGraphQLError(
1145
-
`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.`,
1145
+
`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.`,
1146
1146
{nodes: fieldGroup},
1147
1147
);
1148
1148
}
@@ -1157,29 +1157,29 @@ function ensureValidRuntimeType(
1157
1157
1158
1158
if(typeofruntimeTypeName!=='string'){
1159
1159
thrownewGraphQLError(
1160
-
`Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}" with `+
1160
+
`Abstract type "${returnType}" must resolve to an Object type at runtime for field "${info.parentType}.${info.fieldName}" with `+
1161
1161
`value ${inspect(result)}, received "${inspect(runtimeTypeName)}".`,
0 commit comments