Skip to content

Commit 2e14371

Browse files
authored
Merge pull request #49 from wravery/master
Couple of fixes
2 parents 37a1b7b + ce99e64 commit 2e14371

File tree

6 files changed

+71
-336
lines changed

6 files changed

+71
-336
lines changed

GraphQLService.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,10 @@ std::future<response::Value> Object::resolve(const SelectionSetParams & selectio
10581058
message << "Field error name: " << name
10591059
<< " error: duplicate field";
10601060

1061-
errors.emplace_back(response::Value(message.str()));
1061+
response::Value error(response::Type::Map);
1062+
1063+
error.emplace_back(strMessage, response::Value(message.str()));
1064+
errors.emplace_back(std::move(error));
10621065
}
10631066
else
10641067
{
@@ -1074,7 +1077,10 @@ std::future<response::Value> Object::resolve(const SelectionSetParams & selectio
10741077
message << "Field error name: " << name
10751078
<< " unknown error: " << ex.what();
10761079

1077-
errors.emplace_back(response::Value(message.str()));
1080+
response::Value error(response::Type::Map);
1081+
1082+
error.emplace_back(strMessage, response::Value(message.str()));
1083+
errors.emplace_back(std::move(error));
10781084
}
10791085

10801086
children.pop();

SchemaGenerator.cpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,6 +1434,11 @@ class )cpp" << objectType.type << R"cpp(
14341434
{
14351435
const bool inheritedField = interfaceFields.find(outputField.name) != interfaceFields.cend();
14361436

1437+
if (inheritedField && _isIntrospection)
1438+
{
1439+
continue;
1440+
}
1441+
14371442
if (firstField)
14381443
{
14391444
headerFile << R"cpp(
@@ -1554,7 +1559,7 @@ std::string Generator::getFieldDeclaration(const OutputField & outputField, bool
15541559
}
15551560

15561561
output << R"cpp() const)cpp";
1557-
if (interfaceField)
1562+
if (interfaceField || _isIntrospection)
15581563
{
15591564
output << R"cpp( = 0)cpp";
15601565
}
@@ -1895,29 +1900,34 @@ namespace object {
18951900
std::string fieldName(outputField.name);
18961901

18971902
fieldName[0] = static_cast<char>(std::toupper(static_cast<unsigned char>(fieldName[0])));
1898-
sourceFile << R"cpp(
1903+
if (!_isIntrospection)
1904+
{
1905+
sourceFile << R"cpp(
18991906
std::future<)cpp" << getOutputCppType(outputField, false)
19001907
<< R"cpp(> )cpp" << objectType.type
19011908
<< R"cpp(::get)cpp" << fieldName
19021909
<< R"cpp((service::FieldParams&&)cpp";
1903-
for (const auto& argument : outputField.arguments)
1904-
{
1905-
sourceFile << R"cpp(, )cpp" << getInputCppType(argument)
1906-
<< R"cpp(&&)cpp";
1907-
}
1910+
for (const auto& argument : outputField.arguments)
1911+
{
1912+
sourceFile << R"cpp(, )cpp" << getInputCppType(argument)
1913+
<< R"cpp(&&)cpp";
1914+
}
19081915

1909-
sourceFile << R"cpp() const
1916+
sourceFile << R"cpp() const
19101917
{
19111918
std::promise<)cpp" << getOutputCppType(outputField, false)
1912-
<< R"cpp(> promise;
1919+
<< R"cpp(> promise;
19131920
19141921
promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex()cpp" << objectType.type
1915-
<< R"cpp(::get)cpp" << fieldName
1916-
<< R"cpp( is not implemented)ex")));
1922+
<< R"cpp(::get)cpp" << fieldName
1923+
<< R"cpp( is not implemented)ex")));
19171924
19181925
return promise.get_future();
19191926
}
1927+
)cpp";
1928+
}
19201929

1930+
sourceFile << R"cpp(
19211931
std::future<response::Value> )cpp" << objectType.type
19221932
<< R"cpp(::resolve)cpp" << fieldName
19231933
<< R"cpp((service::ResolverParams&& params)

include/graphqlservice/GraphQLService.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,10 @@ struct ModifiedResult
532532
<< "[" << index << "] "
533533
<< " unknown error: " << ex.what();
534534

535-
errors.emplace_back(response::Value(message.str()));
535+
response::Value error(response::Type::Map);
536+
537+
error.emplace_back(strMessage, response::Value(message.str()));
538+
errors.emplace_back(std::move(error));
536539
}
537540

538541
children.pop();
@@ -575,8 +578,10 @@ struct ModifiedResult
575578
<< " unknown error: " << ex.what();
576579

577580
response::Value errors(response::Type::List);
581+
response::Value error(response::Type::Map);
578582

579-
errors.emplace_back(response::Value(message.str()));
583+
error.emplace_back(strMessage, response::Value(message.str()));
584+
errors.emplace_back(std::move(error));
580585
document.emplace_back(strErrors, std::move(errors));
581586
}
582587

0 commit comments

Comments
 (0)