Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion include/graphqlservice/GraphQLService.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ namespace graphql::service {
class schema_exception : public std::exception
{
public:
schema_exception(std::vector<std::string>&& messages);
schema_exception() = delete;
schema_exception(const schema_exception&) = delete;
explicit schema_exception(schema_exception&&) = default;

explicit schema_exception(std::vector<std::string>&& messages);

const char* what() const noexcept override;

Expand Down
2 changes: 1 addition & 1 deletion samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ add_custom_target(update_samples ALL
DEPENDS
unified/TodaySchema.cpp
separate/today_schema_files
${SEPARATE_SCHEMA_CPP}
${SEPARATE_SCHEMA_CPP}
)

if(GRAPHQL_BUILD_TESTS)
Expand Down
8 changes: 4 additions & 4 deletions samples/introspection/IntrospectionSchema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ introspection::TypeKind ModifiedArgument<introspection::TypeKind>::convert(const
{
if (!value.maybe_enum())
{
throw service::schema_exception({ "not a valid __TypeKind value" });
throw service::schema_exception { { "not a valid __TypeKind value" } };
}

auto itr = std::find(s_namesTypeKind.cbegin(), s_namesTypeKind.cend(), value.get<const response::StringType&>());

if (itr == s_namesTypeKind.cend())
{
throw service::schema_exception({ "not a valid __TypeKind value" });
throw service::schema_exception { { "not a valid __TypeKind value" } };
}

return static_cast<introspection::TypeKind>(itr - s_namesTypeKind.cbegin());
Expand Down Expand Up @@ -82,14 +82,14 @@ introspection::DirectiveLocation ModifiedArgument<introspection::DirectiveLocati
{
if (!value.maybe_enum())
{
throw service::schema_exception({ "not a valid __DirectiveLocation value" });
throw service::schema_exception { { "not a valid __DirectiveLocation value" } };
}

auto itr = std::find(s_namesDirectiveLocation.cbegin(), s_namesDirectiveLocation.cend(), value.get<const response::StringType&>());

if (itr == s_namesDirectiveLocation.cend())
{
throw service::schema_exception({ "not a valid __DirectiveLocation value" });
throw service::schema_exception { { "not a valid __DirectiveLocation value" } };
}

return static_cast<introspection::DirectiveLocation>(itr - s_namesDirectiveLocation.cbegin());
Expand Down
4 changes: 2 additions & 2 deletions samples/separate/TodaySchema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ today::TaskState ModifiedArgument<today::TaskState>::convert(const response::Val
{
if (!value.maybe_enum())
{
throw service::schema_exception({ "not a valid TaskState value" });
throw service::schema_exception { { "not a valid TaskState value" } };
}

auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get<const response::StringType&>());

if (itr == s_namesTaskState.cend())
{
throw service::schema_exception({ "not a valid TaskState value" });
throw service::schema_exception { { "not a valid TaskState value" } };
}

return static_cast<today::TaskState>(itr - s_namesTaskState.cbegin());
Expand Down
4 changes: 2 additions & 2 deletions samples/today/SeparateToday.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ struct EdgeConstraints
std::ostringstream error;

error << "Invalid argument: first value: " << *first;
throw service::schema_exception({ error.str() });
throw service::schema_exception { { error.str() } };
}

if (itrLast - itrFirst > *first)
Expand All @@ -252,7 +252,7 @@ struct EdgeConstraints
std::ostringstream error;

error << "Invalid argument: last value: " << *last;
throw service::schema_exception({ error.str() });
throw service::schema_exception { { error.str() } };
}

if (itrLast - itrFirst > *last)
Expand Down
4 changes: 2 additions & 2 deletions samples/today/UnifiedToday.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ struct EdgeConstraints
std::ostringstream error;

error << "Invalid argument: first value: " << *first;
throw service::schema_exception({ error.str() });
throw service::schema_exception { { error.str() } };
}

if (itrLast - itrFirst > *first)
Expand All @@ -252,7 +252,7 @@ struct EdgeConstraints
std::ostringstream error;

error << "Invalid argument: last value: " << *last;
throw service::schema_exception({ error.str() });
throw service::schema_exception { { error.str() } };
}

if (itrLast - itrFirst > *last)
Expand Down
4 changes: 2 additions & 2 deletions samples/unified/TodaySchema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ today::TaskState ModifiedArgument<today::TaskState>::convert(const response::Val
{
if (!value.maybe_enum())
{
throw service::schema_exception({ "not a valid TaskState value" });
throw service::schema_exception { { "not a valid TaskState value" } };
}

auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get<const response::StringType&>());

if (itr == s_namesTaskState.cend())
{
throw service::schema_exception({ "not a valid TaskState value" });
throw service::schema_exception { { "not a valid TaskState value" } };
}

return static_cast<today::TaskState>(itr - s_namesTaskState.cbegin());
Expand Down
44 changes: 22 additions & 22 deletions src/GraphQLService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void ValueVisitor::visitVariable(const peg::ast_node & variable)
<< " line: " << position.line
<< " column: " << position.byte_in_line;

throw schema_exception({ error.str() });
throw schema_exception { { error.str() } };
}

_value = response::Value(itr->second);
Expand Down Expand Up @@ -304,7 +304,7 @@ bool DirectiveVisitor::shouldSkip() const

error << "Invalid arguments to directive: " << entry.second;

throw schema_exception({ error.str() });
throw schema_exception { { error.str() } };
}

bool argumentTrue = false;
Expand All @@ -322,7 +322,7 @@ bool DirectiveVisitor::shouldSkip() const
error << "Invalid argument to directive: " << entry.second
<< " name: " << argument.first;

throw schema_exception({ error.str() });
throw schema_exception { { error.str() } };
}

argumentTrue = argument.second.get<response::BooleanType>();
Expand All @@ -344,7 +344,7 @@ bool DirectiveVisitor::shouldSkip() const
error << "Missing argument to directive: " << entry.second
<< " name: if";

throw schema_exception({ error.str() });
throw schema_exception { { error.str() } };
}
}

Expand Down Expand Up @@ -399,7 +399,7 @@ uint8_t Base64::verifyFromBase64(char ch)

if (result > 63)
{
throw schema_exception({ "invalid character in base64 encoded string" });
throw schema_exception { { "invalid character in base64 encoded string" } };
}

return result;
Expand Down Expand Up @@ -446,7 +446,7 @@ std::vector<uint8_t> Base64::fromBase64(const char* encoded, size_t count)
{
if (tail & 0x3)
{
throw schema_exception({ "invalid padding at the end of a base64 encoded string" });
throw schema_exception { { "invalid padding at the end of a base64 encoded string" } };
}

result.emplace_back(static_cast<uint8_t>((segment & 0xFF00) >> 8));
Expand All @@ -459,7 +459,7 @@ std::vector<uint8_t> Base64::fromBase64(const char* encoded, size_t count)
{
if (segment & 0xFF)
{
throw schema_exception({ "invalid padding at the end of a base64 encoded string" });
throw schema_exception { { "invalid padding at the end of a base64 encoded string" } };
}

result.emplace_back(static_cast<uint8_t>((segment & 0xFF00) >> 8));
Expand All @@ -474,7 +474,7 @@ std::vector<uint8_t> Base64::fromBase64(const char* encoded, size_t count)
|| (count > 1 && padding != encoded[1])
|| count > 2)
{
throw schema_exception({ "invalid padding at the end of a base64 encoded string" });
throw schema_exception { { "invalid padding at the end of a base64 encoded string" } };
}

return result;
Expand All @@ -486,7 +486,7 @@ char Base64::verifyToBase64(uint8_t i)

if (result == padding)
{
throw schema_exception({ "invalid 6-bit value" });
throw schema_exception { { "invalid 6-bit value" } };
}

return result;
Expand Down Expand Up @@ -548,7 +548,7 @@ response::IntType ModifiedArgument<response::IntType>::convert(const response::V
{
if (value.type() != response::Type::Int)
{
throw schema_exception({ "not an integer" });
throw schema_exception { { "not an integer" } };
}

return value.get<response::IntType>();
Expand All @@ -559,7 +559,7 @@ response::FloatType ModifiedArgument<response::FloatType>::convert(const respons
{
if (value.type() != response::Type::Float)
{
throw schema_exception({ "not a float" });
throw schema_exception { { "not a float" } };
}

return value.get<response::FloatType>();
Expand All @@ -570,7 +570,7 @@ response::StringType ModifiedArgument<response::StringType>::convert(const respo
{
if (value.type() != response::Type::String)
{
throw schema_exception({ "not a string" });
throw schema_exception { { "not a string" } };
}

return value.get<const response::StringType&>();
Expand All @@ -581,7 +581,7 @@ response::BooleanType ModifiedArgument<response::BooleanType>::convert(const res
{
if (value.type() != response::Type::Boolean)
{
throw schema_exception({ "not a boolean" });
throw schema_exception { { "not a boolean" } };
}

return value.get<response::BooleanType>();
Expand All @@ -592,7 +592,7 @@ response::Value ModifiedArgument<response::Value>::convert(const response::Value
{
if (value.type() != response::Type::Map)
{
throw schema_exception({ "not an object" });
throw schema_exception { { "not an object" } };
}

return response::Value(value);
Expand All @@ -603,7 +603,7 @@ response::IdType ModifiedArgument<response::IdType>::convert(const response::Val
{
if (value.type() != response::Type::String)
{
throw schema_exception({ "not a string" });
throw schema_exception { { "not a string" } };
}

const auto& encoded = value.get<const response::StringType&>();
Expand Down Expand Up @@ -806,7 +806,7 @@ void SelectionVisitor::visitField(const peg::ast_node & field)
<< " line: " << position.line
<< " column: " << position.byte_in_line;

throw schema_exception({ error.str() });
throw schema_exception { { error.str() } };
}

DirectiveVisitor directiveVisitor(_variables);
Expand Down Expand Up @@ -889,7 +889,7 @@ void SelectionVisitor::visitFragmentSpread(const peg::ast_node & fragmentSpread)
<< " line: " << position.line
<< " column: " << position.byte_in_line;

throw schema_exception({ error.str() });
throw schema_exception { { error.str() } };
}

bool skip = (_typeNames.count(itr->second.getType()) == 0);
Expand Down Expand Up @@ -1431,7 +1431,7 @@ void SubscriptionDefinitionVisitor::visitFragmentSpread(const peg::ast_node & fr
<< " line: " << position.line
<< " column: " << position.byte_in_line;

throw schema_exception({ error.str() });
throw schema_exception { { error.str() } };
}

bool skip = !_subscriptionObject->matchesType(itr->second.getType());
Expand Down Expand Up @@ -1615,7 +1615,7 @@ std::future<response::Value> Request::resolve(std::launch launch, const std::sha
message << " name: " << operationName;
}

throw schema_exception({ message.str() });
throw schema_exception { { message.str() } };
}
else if (operationDefinition.first == strSubscription)
{
Expand All @@ -1628,7 +1628,7 @@ std::future<response::Value> Request::resolve(std::launch launch, const std::sha
message << " name: " << operationName;
}

throw schema_exception({ message.str() });
throw schema_exception { { message.str() } };
}

OperationDefinitionVisitor operationVisitor(state, _operations, std::move(variables), std::move(fragments));
Expand Down Expand Up @@ -1674,7 +1674,7 @@ SubscriptionKey Request::subscribe(SubscriptionParams && params, SubscriptionCal
message << " name: " << params.operationName;
}

throw schema_exception({ message.str() });
throw schema_exception { { message.str() } };
}
else if (operationDefinition.first != strSubscription)
{
Expand All @@ -1687,7 +1687,7 @@ SubscriptionKey Request::subscribe(SubscriptionParams && params, SubscriptionCal
message << " name: " << params.operationName;
}

throw schema_exception({ message.str() });
throw schema_exception { { message.str() } };
}

auto itr = _operations.find(std::string{ strSubscription });
Expand Down
4 changes: 2 additions & 2 deletions src/SchemaGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1916,7 +1916,7 @@ template <>
{
if (!value.maybe_enum())
{
throw service::schema_exception({ "not a valid )cpp" << enumType.type << R"cpp( value" });
throw service::schema_exception { { "not a valid )cpp" << enumType.type << R"cpp( value" } };
}

auto itr = std::find(s_names)cpp" << enumType.cppType
Expand All @@ -1926,7 +1926,7 @@ template <>
if (itr == s_names)cpp" << enumType.cppType
<< R"cpp(.cend())
{
throw service::schema_exception({ "not a valid )cpp" << enumType.type << R"cpp( value" });
throw service::schema_exception { { "not a valid )cpp" << enumType.type << R"cpp( value" } };
}

return static_cast<)cpp" << _schemaNamespace << R"cpp(::)cpp" << enumType.cppType
Expand Down