Generate Traits structs for client operations
This commit is contained in:
Родитель
e65267296d
Коммит
b0de30ee2e
|
@ -96,6 +96,31 @@ struct [[nodiscard]] Response
|
|||
|
||||
[[nodiscard]] Response parseResponse(response::Value&& response);
|
||||
|
||||
struct Traits
|
||||
{
|
||||
[[nodiscard]] static const std::string& GetRequestText() noexcept
|
||||
{
|
||||
return benchmark::GetRequestText();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const peg::ast& GetRequestObject() noexcept
|
||||
{
|
||||
return benchmark::GetRequestObject();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const std::string& GetOperationName() noexcept
|
||||
{
|
||||
return Query::GetOperationName();
|
||||
}
|
||||
|
||||
using Response = Query::Response;
|
||||
|
||||
[[nodiscard]] static Response parseResponse(response::Value&& response)
|
||||
{
|
||||
return Query::parseResponse(std::move(response));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace query::Query
|
||||
} // namespace graphql::client
|
||||
|
||||
|
|
|
@ -180,6 +180,31 @@ struct [[nodiscard]] Response
|
|||
|
||||
[[nodiscard]] Response parseResponse(response::Value&& response);
|
||||
|
||||
struct Traits
|
||||
{
|
||||
[[nodiscard]] static const std::string& GetRequestText() noexcept
|
||||
{
|
||||
return multiple::GetRequestText();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const peg::ast& GetRequestObject() noexcept
|
||||
{
|
||||
return multiple::GetRequestObject();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const std::string& GetOperationName() noexcept
|
||||
{
|
||||
return Appointments::GetOperationName();
|
||||
}
|
||||
|
||||
using Response = Appointments::Response;
|
||||
|
||||
[[nodiscard]] static Response parseResponse(response::Value&& response)
|
||||
{
|
||||
return Appointments::parseResponse(std::move(response));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace query::Appointments
|
||||
|
||||
namespace query::Tasks {
|
||||
|
@ -215,6 +240,31 @@ struct [[nodiscard]] Response
|
|||
|
||||
[[nodiscard]] Response parseResponse(response::Value&& response);
|
||||
|
||||
struct Traits
|
||||
{
|
||||
[[nodiscard]] static const std::string& GetRequestText() noexcept
|
||||
{
|
||||
return multiple::GetRequestText();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const peg::ast& GetRequestObject() noexcept
|
||||
{
|
||||
return multiple::GetRequestObject();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const std::string& GetOperationName() noexcept
|
||||
{
|
||||
return Tasks::GetOperationName();
|
||||
}
|
||||
|
||||
using Response = Tasks::Response;
|
||||
|
||||
[[nodiscard]] static Response parseResponse(response::Value&& response)
|
||||
{
|
||||
return Tasks::parseResponse(std::move(response));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace query::Tasks
|
||||
|
||||
namespace query::UnreadCounts {
|
||||
|
@ -250,6 +300,31 @@ struct [[nodiscard]] Response
|
|||
|
||||
[[nodiscard]] Response parseResponse(response::Value&& response);
|
||||
|
||||
struct Traits
|
||||
{
|
||||
[[nodiscard]] static const std::string& GetRequestText() noexcept
|
||||
{
|
||||
return multiple::GetRequestText();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const peg::ast& GetRequestObject() noexcept
|
||||
{
|
||||
return multiple::GetRequestObject();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const std::string& GetOperationName() noexcept
|
||||
{
|
||||
return UnreadCounts::GetOperationName();
|
||||
}
|
||||
|
||||
using Response = UnreadCounts::Response;
|
||||
|
||||
[[nodiscard]] static Response parseResponse(response::Value&& response)
|
||||
{
|
||||
return UnreadCounts::parseResponse(std::move(response));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace query::UnreadCounts
|
||||
|
||||
namespace query::Miscellaneous {
|
||||
|
@ -282,6 +357,31 @@ struct [[nodiscard]] Response
|
|||
|
||||
[[nodiscard]] Response parseResponse(response::Value&& response);
|
||||
|
||||
struct Traits
|
||||
{
|
||||
[[nodiscard]] static const std::string& GetRequestText() noexcept
|
||||
{
|
||||
return multiple::GetRequestText();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const peg::ast& GetRequestObject() noexcept
|
||||
{
|
||||
return multiple::GetRequestObject();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const std::string& GetOperationName() noexcept
|
||||
{
|
||||
return Miscellaneous::GetOperationName();
|
||||
}
|
||||
|
||||
using Response = Miscellaneous::Response;
|
||||
|
||||
[[nodiscard]] static Response parseResponse(response::Value&& response)
|
||||
{
|
||||
return Miscellaneous::parseResponse(std::move(response));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace query::Miscellaneous
|
||||
|
||||
namespace mutation::CompleteTaskMutation {
|
||||
|
@ -324,6 +424,38 @@ struct [[nodiscard]] Response
|
|||
|
||||
[[nodiscard]] Response parseResponse(response::Value&& response);
|
||||
|
||||
struct Traits
|
||||
{
|
||||
[[nodiscard]] static const std::string& GetRequestText() noexcept
|
||||
{
|
||||
return multiple::GetRequestText();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const peg::ast& GetRequestObject() noexcept
|
||||
{
|
||||
return multiple::GetRequestObject();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const std::string& GetOperationName() noexcept
|
||||
{
|
||||
return CompleteTaskMutation::GetOperationName();
|
||||
}
|
||||
|
||||
using Variables = CompleteTaskMutation::Variables;
|
||||
|
||||
[[nodiscard]] static response::Value serializeVariables(Variables&& variables)
|
||||
{
|
||||
return CompleteTaskMutation::serializeVariables(std::move(variables));
|
||||
}
|
||||
|
||||
using Response = CompleteTaskMutation::Response;
|
||||
|
||||
[[nodiscard]] static Response parseResponse(response::Value&& response)
|
||||
{
|
||||
return CompleteTaskMutation::parseResponse(std::move(response));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mutation::CompleteTaskMutation
|
||||
} // namespace graphql::client
|
||||
|
||||
|
|
|
@ -119,6 +119,38 @@ struct [[nodiscard]] Response
|
|||
|
||||
[[nodiscard]] Response parseResponse(response::Value&& response);
|
||||
|
||||
struct Traits
|
||||
{
|
||||
[[nodiscard]] static const std::string& GetRequestText() noexcept
|
||||
{
|
||||
return mutate::GetRequestText();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const peg::ast& GetRequestObject() noexcept
|
||||
{
|
||||
return mutate::GetRequestObject();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const std::string& GetOperationName() noexcept
|
||||
{
|
||||
return CompleteTaskMutation::GetOperationName();
|
||||
}
|
||||
|
||||
using Variables = CompleteTaskMutation::Variables;
|
||||
|
||||
[[nodiscard]] static response::Value serializeVariables(Variables&& variables)
|
||||
{
|
||||
return CompleteTaskMutation::serializeVariables(std::move(variables));
|
||||
}
|
||||
|
||||
using Response = CompleteTaskMutation::Response;
|
||||
|
||||
[[nodiscard]] static Response parseResponse(response::Value&& response)
|
||||
{
|
||||
return CompleteTaskMutation::parseResponse(std::move(response));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mutation::CompleteTaskMutation
|
||||
} // namespace graphql::client
|
||||
|
||||
|
|
|
@ -145,6 +145,38 @@ struct [[nodiscard]] Response
|
|||
|
||||
[[nodiscard]] Response parseResponse(response::Value&& response);
|
||||
|
||||
struct Traits
|
||||
{
|
||||
[[nodiscard]] static const std::string& GetRequestText() noexcept
|
||||
{
|
||||
return nestedinput::GetRequestText();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const peg::ast& GetRequestObject() noexcept
|
||||
{
|
||||
return nestedinput::GetRequestObject();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const std::string& GetOperationName() noexcept
|
||||
{
|
||||
return testQuery::GetOperationName();
|
||||
}
|
||||
|
||||
using Variables = testQuery::Variables;
|
||||
|
||||
[[nodiscard]] static response::Value serializeVariables(Variables&& variables)
|
||||
{
|
||||
return testQuery::serializeVariables(std::move(variables));
|
||||
}
|
||||
|
||||
using Response = testQuery::Response;
|
||||
|
||||
[[nodiscard]] static Response parseResponse(response::Value&& response)
|
||||
{
|
||||
return testQuery::parseResponse(std::move(response));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace query::testQuery
|
||||
} // namespace graphql::client
|
||||
|
||||
|
|
|
@ -196,6 +196,31 @@ struct [[nodiscard]] Response
|
|||
|
||||
[[nodiscard]] Response parseResponse(response::Value&& response);
|
||||
|
||||
struct Traits
|
||||
{
|
||||
[[nodiscard]] static const std::string& GetRequestText() noexcept
|
||||
{
|
||||
return query::GetRequestText();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const peg::ast& GetRequestObject() noexcept
|
||||
{
|
||||
return query::GetRequestObject();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const std::string& GetOperationName() noexcept
|
||||
{
|
||||
return Query::GetOperationName();
|
||||
}
|
||||
|
||||
using Response = Query::Response;
|
||||
|
||||
[[nodiscard]] static Response parseResponse(response::Value&& response)
|
||||
{
|
||||
return Query::parseResponse(std::move(response));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace query::Query
|
||||
} // namespace graphql::client
|
||||
|
||||
|
|
|
@ -73,6 +73,31 @@ struct [[nodiscard]] Response
|
|||
|
||||
[[nodiscard]] Response parseResponse(response::Value&& response);
|
||||
|
||||
struct Traits
|
||||
{
|
||||
[[nodiscard]] static const std::string& GetRequestText() noexcept
|
||||
{
|
||||
return subscribe::GetRequestText();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const peg::ast& GetRequestObject() noexcept
|
||||
{
|
||||
return subscribe::GetRequestObject();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const std::string& GetOperationName() noexcept
|
||||
{
|
||||
return TestSubscription::GetOperationName();
|
||||
}
|
||||
|
||||
using Response = TestSubscription::Response;
|
||||
|
||||
[[nodiscard]] static Response parseResponse(response::Value&& response)
|
||||
{
|
||||
return TestSubscription::parseResponse(std::move(response));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace subscription::TestSubscription
|
||||
} // namespace graphql::client
|
||||
|
||||
|
|
|
@ -424,6 +424,56 @@ using )cpp" << _schemaLoader.getSchemaNamespace()
|
|||
|
||||
[[nodiscard]] Response parseResponse(response::Value&& response);
|
||||
|
||||
struct Traits
|
||||
{
|
||||
[[nodiscard]] static const std::string& GetRequestText() noexcept
|
||||
{
|
||||
return )cpp"
|
||||
<< _schemaLoader.getSchemaNamespace() << R"cpp(::GetRequestText();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const peg::ast& GetRequestObject() noexcept
|
||||
{
|
||||
return )cpp"
|
||||
<< _schemaLoader.getSchemaNamespace() << R"cpp(::GetRequestObject();
|
||||
}
|
||||
|
||||
[[nodiscard]] static const std::string& GetOperationName() noexcept
|
||||
{
|
||||
return )cpp"
|
||||
<< _requestLoader.getOperationNamespace(operation)
|
||||
<< R"cpp(::GetOperationName();
|
||||
}
|
||||
)cpp";
|
||||
|
||||
if (!variables.empty())
|
||||
{
|
||||
headerFile << R"cpp(
|
||||
using Variables = )cpp"
|
||||
<< _requestLoader.getOperationNamespace(operation) << R"cpp(::Variables;
|
||||
|
||||
[[nodiscard]] static response::Value serializeVariables(Variables&& variables)
|
||||
{
|
||||
return )cpp" << _requestLoader.getOperationNamespace(operation)
|
||||
<< R"cpp(::serializeVariables(std::move(variables));
|
||||
}
|
||||
)cpp";
|
||||
|
||||
pendingSeparator.add();
|
||||
}
|
||||
|
||||
headerFile << R"cpp(
|
||||
using Response = )cpp"
|
||||
<< _requestLoader.getOperationNamespace(operation) << R"cpp(::Response;
|
||||
|
||||
[[nodiscard]] static Response parseResponse(response::Value&& response)
|
||||
{
|
||||
return )cpp"
|
||||
<< _requestLoader.getOperationNamespace(operation)
|
||||
<< R"cpp(::parseResponse(std::move(response));
|
||||
}
|
||||
};
|
||||
|
||||
)cpp";
|
||||
|
||||
pendingSeparator.add();
|
||||
|
@ -813,7 +863,8 @@ response::Value Variable<)cpp"
|
|||
|
||||
sourceFile << R"cpp(template <>
|
||||
response::Value Variable<)cpp"
|
||||
<< cppType << R"cpp(>::serialize()cpp" << cppType << R"cpp(&& inputValue)
|
||||
<< cppType << R"cpp(>::serialize()cpp" << cppType
|
||||
<< R"cpp(&& inputValue)
|
||||
{
|
||||
response::Value result { response::Type::Map };
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче