@@ -873,7 +873,6 @@ class SelectionVisitor
873873 {
874874 std::string_view name;
875875 std::optional<schema_location> location;
876- std::optional<error_path> path;
877876 AwaitableResolver result;
878877 };
879878
@@ -997,7 +996,7 @@ void SelectionVisitor::visitField(const peg::ast_node& field)
997996 { position.line , position.column },
998997 buildErrorPath (_path ? std::make_optional (_path->get ()) : std::nullopt ) } } }));
999998
1000- _values.push_back ({ alias, std::nullopt , std:: nullopt , promise.get_future () });
999+ _values.push_back ({ alias, std::nullopt , promise.get_future () });
10011000 return ;
10021001 }
10031002
@@ -1054,9 +1053,8 @@ void SelectionVisitor::visitField(const peg::ast_node& field)
10541053 _fragments,
10551054 _variables));
10561055 auto location = std::make_optional (schema_location { position.line , position.column });
1057- auto path = std::make_optional (buildErrorPath (selectionSetParams.errorPath ));
10581056
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) });
10601058 }
10611059 catch (schema_exception& scx)
10621060 {
@@ -1078,7 +1076,7 @@ void SelectionVisitor::visitField(const peg::ast_node& field)
10781076
10791077 promise.set_exception (std::make_exception_ptr (schema_exception { std::move (messages) }));
10801078
1081- _values.push_back ({ alias, std::nullopt , std:: nullopt , promise.get_future () });
1079+ _values.push_back ({ alias, std::nullopt , promise.get_future () });
10821080 }
10831081 catch (const std::exception& ex)
10841082 {
@@ -1092,7 +1090,7 @@ void SelectionVisitor::visitField(const peg::ast_node& field)
10921090 { position.line , position.column },
10931091 buildErrorPath (selectionSetParams.errorPath ) } } }));
10941092
1095- _values.push_back ({ alias, std::nullopt , std:: nullopt , promise.get_future () });
1093+ _values.push_back ({ alias, std::nullopt , promise.get_future () });
10961094 }
10971095}
10981096
@@ -1229,6 +1227,10 @@ AwaitableResolver Object::resolve(const SelectionSetParams& selectionSetParams,
12291227
12301228 document.data .reserve (children.size ());
12311229
1230+ const auto parent = selectionSetParams.errorPath
1231+ ? std::make_optional (std::cref (*selectionSetParams.errorPath ))
1232+ : std::nullopt ;
1233+
12321234 for (auto & child : children)
12331235 {
12341236 try
@@ -1243,10 +1245,10 @@ AwaitableResolver Object::resolve(const SelectionSetParams& selectionSetParams,
12431245
12441246 message << " Ambiguous field error name: " << child.name ;
12451247
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 } }) ) });
12501252 }
12511253
12521254 if (!value.errors .empty ())
@@ -1271,10 +1273,10 @@ AwaitableResolver Object::resolve(const SelectionSetParams& selectionSetParams,
12711273
12721274 message << " Field error name: " << child.name << " unknown error: " << ex.what ();
12731275
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 } }) ) });
12781280 document.data .emplace_back (std::string { child.name }, {});
12791281 }
12801282 }
0 commit comments