@@ -873,7 +873,6 @@ class SelectionVisitor
873
873
{
874
874
std::string_view name;
875
875
std::optional<schema_location> location;
876
- std::optional<error_path> path;
877
876
AwaitableResolver result;
878
877
};
879
878
@@ -997,7 +996,7 @@ void SelectionVisitor::visitField(const peg::ast_node& field)
997
996
{ position.line , position.column },
998
997
buildErrorPath (_path ? std::make_optional (_path->get ()) : std::nullopt) } } }));
999
998
1000
- _values.push_back ({ alias, std::nullopt, std::nullopt, promise.get_future () });
999
+ _values.push_back ({ alias, std::nullopt, promise.get_future () });
1001
1000
return ;
1002
1001
}
1003
1002
@@ -1054,9 +1053,8 @@ void SelectionVisitor::visitField(const peg::ast_node& field)
1054
1053
_fragments,
1055
1054
_variables));
1056
1055
auto location = std::make_optional (schema_location { position.line , position.column });
1057
- auto path = std::make_optional (buildErrorPath (selectionSetParams.errorPath ));
1058
1056
1059
- _values.push_back ({ alias, std::move (location), std::move (path), std::move ( result) });
1057
+ _values.push_back ({ alias, std::move (location), std::move (result) });
1060
1058
}
1061
1059
catch (schema_exception& scx)
1062
1060
{
@@ -1078,7 +1076,7 @@ void SelectionVisitor::visitField(const peg::ast_node& field)
1078
1076
1079
1077
promise.set_exception (std::make_exception_ptr (schema_exception { std::move (messages) }));
1080
1078
1081
- _values.push_back ({ alias, std::nullopt, std::nullopt, promise.get_future () });
1079
+ _values.push_back ({ alias, std::nullopt, promise.get_future () });
1082
1080
}
1083
1081
catch (const std::exception& ex)
1084
1082
{
@@ -1092,7 +1090,7 @@ void SelectionVisitor::visitField(const peg::ast_node& field)
1092
1090
{ position.line , position.column },
1093
1091
buildErrorPath (selectionSetParams.errorPath ) } } }));
1094
1092
1095
- _values.push_back ({ alias, std::nullopt, std::nullopt, promise.get_future () });
1093
+ _values.push_back ({ alias, std::nullopt, promise.get_future () });
1096
1094
}
1097
1095
}
1098
1096
@@ -1229,6 +1227,10 @@ AwaitableResolver Object::resolve(const SelectionSetParams& selectionSetParams,
1229
1227
1230
1228
document.data .reserve (children.size ());
1231
1229
1230
+ const auto parent = selectionSetParams.errorPath
1231
+ ? std::make_optional (std::cref (*selectionSetParams.errorPath ))
1232
+ : std::nullopt;
1233
+
1232
1234
for (auto & child : children)
1233
1235
{
1234
1236
try
@@ -1243,10 +1245,10 @@ AwaitableResolver Object::resolve(const SelectionSetParams& selectionSetParams,
1243
1245
1244
1246
message << " Ambiguous field error name: " << child.name ;
1245
1247
1246
- auto location = std::move (child. location ). value_or (schema_location {});
1247
- auto path = std::move ( child.path ) .value_or (error_path {});
1248
-
1249
- document. errors . push_back ({ message. str (), std::move (location), std::move (path ) });
1248
+ document. errors . push_back ({ message. str (),
1249
+ child.location .value_or (schema_location {}),
1250
+ buildErrorPath (
1251
+ std::make_optional (field_path { parent, path_segment { child. name } }) ) });
1250
1252
}
1251
1253
1252
1254
if (!value.errors .empty ())
@@ -1271,10 +1273,10 @@ AwaitableResolver Object::resolve(const SelectionSetParams& selectionSetParams,
1271
1273
1272
1274
message << " Field error name: " << child.name << " unknown error: " << ex.what ();
1273
1275
1274
- auto location = std::move (child. location ). value_or (schema_location {});
1275
- auto path = std::move ( child.path ) .value_or (error_path {});
1276
-
1277
- document. errors . push_back ({ message. str (), std::move (location), std::move (path ) });
1276
+ document. errors . push_back ({ message. str (),
1277
+ child.location .value_or (schema_location {}),
1278
+ buildErrorPath (
1279
+ std::make_optional (field_path { parent, path_segment { child. name } }) ) });
1278
1280
document.data .emplace_back (std::string { child.name }, {});
1279
1281
}
1280
1282
}
0 commit comments