Skip to content

Commit

Permalink
Merge pull request #49 from wravery/master
Browse files Browse the repository at this point in the history
Couple of fixes
  • Loading branch information
wravery committed Mar 4, 2019
2 parents 37a1b7b + ce99e64 commit 2e14371
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 336 deletions.
10 changes: 8 additions & 2 deletions GraphQLService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,10 @@ std::future<response::Value> Object::resolve(const SelectionSetParams & selectio
message << "Field error name: " << name
<< " error: duplicate field";

errors.emplace_back(response::Value(message.str()));
response::Value error(response::Type::Map);

error.emplace_back(strMessage, response::Value(message.str()));
errors.emplace_back(std::move(error));
}
else
{
Expand All @@ -1074,7 +1077,10 @@ std::future<response::Value> Object::resolve(const SelectionSetParams & selectio
message << "Field error name: " << name
<< " unknown error: " << ex.what();

errors.emplace_back(response::Value(message.str()));
response::Value error(response::Type::Map);

error.emplace_back(strMessage, response::Value(message.str()));
errors.emplace_back(std::move(error));
}

children.pop();
Expand Down
32 changes: 21 additions & 11 deletions SchemaGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,11 @@ class )cpp" << objectType.type << R"cpp(
{
const bool inheritedField = interfaceFields.find(outputField.name) != interfaceFields.cend();

if (inheritedField && _isIntrospection)
{
continue;
}

if (firstField)
{
headerFile << R"cpp(
Expand Down Expand Up @@ -1554,7 +1559,7 @@ std::string Generator::getFieldDeclaration(const OutputField & outputField, bool
}

output << R"cpp() const)cpp";
if (interfaceField)
if (interfaceField || _isIntrospection)
{
output << R"cpp( = 0)cpp";
}
Expand Down Expand Up @@ -1895,29 +1900,34 @@ namespace object {
std::string fieldName(outputField.name);

fieldName[0] = static_cast<char>(std::toupper(static_cast<unsigned char>(fieldName[0])));
sourceFile << R"cpp(
if (!_isIntrospection)
{
sourceFile << R"cpp(
std::future<)cpp" << getOutputCppType(outputField, false)
<< R"cpp(> )cpp" << objectType.type
<< R"cpp(::get)cpp" << fieldName
<< R"cpp((service::FieldParams&&)cpp";
for (const auto& argument : outputField.arguments)
{
sourceFile << R"cpp(, )cpp" << getInputCppType(argument)
<< R"cpp(&&)cpp";
}
for (const auto& argument : outputField.arguments)
{
sourceFile << R"cpp(, )cpp" << getInputCppType(argument)
<< R"cpp(&&)cpp";
}

sourceFile << R"cpp() const
sourceFile << R"cpp() const
{
std::promise<)cpp" << getOutputCppType(outputField, false)
<< R"cpp(> promise;
<< R"cpp(> promise;
promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex()cpp" << objectType.type
<< R"cpp(::get)cpp" << fieldName
<< R"cpp( is not implemented)ex")));
<< R"cpp(::get)cpp" << fieldName
<< R"cpp( is not implemented)ex")));
return promise.get_future();
}
)cpp";
}

sourceFile << R"cpp(
std::future<response::Value> )cpp" << objectType.type
<< R"cpp(::resolve)cpp" << fieldName
<< R"cpp((service::ResolverParams&& params)
Expand Down
9 changes: 7 additions & 2 deletions include/graphqlservice/GraphQLService.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,10 @@ struct ModifiedResult
<< "[" << index << "] "
<< " unknown error: " << ex.what();

errors.emplace_back(response::Value(message.str()));
response::Value error(response::Type::Map);

error.emplace_back(strMessage, response::Value(message.str()));
errors.emplace_back(std::move(error));
}

children.pop();
Expand Down Expand Up @@ -575,8 +578,10 @@ struct ModifiedResult
<< " unknown error: " << ex.what();

response::Value errors(response::Type::List);
response::Value error(response::Type::Map);

errors.emplace_back(response::Value(message.str()));
error.emplace_back(strMessage, response::Value(message.str()));
errors.emplace_back(std::move(error));
document.emplace_back(strErrors, std::move(errors));
}

Expand Down
Loading

0 comments on commit 2e14371

Please sign in to comment.