This commit is contained in:
Bill Avery 2022-06-06 08:40:03 -07:00
Родитель 8c1623acc4
Коммит 98e3c40173
12 изменённых файлов: 46 добавлений и 32 удалений

Просмотреть файл

@ -638,10 +638,10 @@ Response parseResponse(response::Value&& response)
} // namespace query::Miscellaneous
static const std::array<std::string_view, 4> s_namesTaskState = {
R"gql(Unassigned)gql"sv,
R"gql(New)gql"sv,
R"gql(Started)gql"sv,
R"gql(Complete)gql"sv,
R"gql(Unassigned)gql"sv
R"gql(Complete)gql"sv
};
template <>

Просмотреть файл

@ -119,10 +119,10 @@ namespace multiple {
enum class [[nodiscard]] TaskState
{
Unassigned,
New,
Started,
Complete,
Unassigned,
};
struct [[nodiscard]] CompleteTaskInput

Просмотреть файл

@ -25,7 +25,7 @@ const std::string& GetRequestText() noexcept
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
mutation CompleteTaskMutation($input: CompleteTaskInput = {id: "ZmFrZVRhc2tJZA==", isComplete: true, clientMutationId: "Hi There!"}, $skipClientMutationId: Boolean!) {
mutation CompleteTaskMutation($input: CompleteTaskInput = {id: "ZmFrZVRhc2tJZA==", isComplete: true, clientMutationId: "Hi There!", testTaskState: Unassigned}, $skipClientMutationId: Boolean!) {
completedTask: completeTask(input: $input) {
completedTask: task {
completedTaskId: id
@ -106,10 +106,10 @@ CompleteTaskInput& CompleteTaskInput::operator=(CompleteTaskInput&& other) noexc
using namespace mutate;
static const std::array<std::string_view, 4> s_namesTaskState = {
R"gql(Unassigned)gql"sv,
R"gql(New)gql"sv,
R"gql(Started)gql"sv,
R"gql(Complete)gql"sv,
R"gql(Unassigned)gql"sv
R"gql(Complete)gql"sv
};
template <>

Просмотреть файл

@ -31,7 +31,7 @@ namespace graphql::client {
/// # Copyright (c) Microsoft Corporation. All rights reserved.
/// # Licensed under the MIT License.
///
/// mutation CompleteTaskMutation($input: CompleteTaskInput = {id: "ZmFrZVRhc2tJZA==", isComplete: true, clientMutationId: "Hi There!"}, $skipClientMutationId: Boolean!) {
/// mutation CompleteTaskMutation($input: CompleteTaskInput = {id: "ZmFrZVRhc2tJZA==", isComplete: true, clientMutationId: "Hi There!", testTaskState: Unassigned}, $skipClientMutationId: Boolean!) {
/// completedTask: completeTask(input: $input) {
/// completedTask: task {
/// completedTaskId: id
@ -52,10 +52,10 @@ namespace mutate {
enum class [[nodiscard]] TaskState
{
Unassigned,
New,
Started,
Complete,
Unassigned,
};
struct [[nodiscard]] CompleteTaskInput

Просмотреть файл

@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
mutation CompleteTaskMutation($input: CompleteTaskInput = {id: "ZmFrZVRhc2tJZA==", isComplete: true, clientMutationId: "Hi There!"}, $skipClientMutationId: Boolean!) {
mutation CompleteTaskMutation($input: CompleteTaskInput = {id: "ZmFrZVRhc2tJZA==", isComplete: true, clientMutationId: "Hi There!", testTaskState: Unassigned}, $skipClientMutationId: Boolean!) {
completedTask: completeTask(input: $input) {
completedTask: task {
completedTaskId: id

Просмотреть файл

@ -100,10 +100,10 @@ namespace query {
enum class [[nodiscard]] TaskState
{
Unassigned,
New,
Started,
Complete,
Unassigned,
};
} // namespace query

Просмотреть файл

@ -684,10 +684,10 @@ void AddTypesToSchema(const std::shared_ptr<schema::Schema>& schema)
schema->AddType(R"gql(Expensive)gql"sv, typeExpensive);
typeTaskState->AddEnumValues({
{ service::s_namesTaskState[static_cast<size_t>(today::TaskState::Unassigned)], R"md()md"sv, std::make_optional(R"md(Need to deprecate an [enum value](https://spec.graphql.org/October2021/#sec-Schema-Introspection.Deprecation))md"sv) },
{ service::s_namesTaskState[static_cast<size_t>(today::TaskState::New)], R"md()md"sv, std::nullopt },
{ service::s_namesTaskState[static_cast<size_t>(today::TaskState::Started)], R"md()md"sv, std::nullopt },
{ service::s_namesTaskState[static_cast<size_t>(today::TaskState::Complete)], R"md()md"sv, std::nullopt },
{ service::s_namesTaskState[static_cast<size_t>(today::TaskState::Unassigned)], R"md()md"sv, std::make_optional(R"md(Need to deprecate an [enum value](https://spec.graphql.org/October2021/#sec-Schema-Introspection.Deprecation))md"sv) }
{ service::s_namesTaskState[static_cast<size_t>(today::TaskState::Complete)], R"md()md"sv, std::nullopt }
});
typeCompleteTaskInput->AddInputValues({

Просмотреть файл

@ -24,10 +24,10 @@ namespace today {
enum class [[nodiscard]] TaskState
{
Unassigned,
New,
Started,
Complete,
Unassigned
Complete
};
[[nodiscard]] constexpr auto getTaskStateNames() noexcept
@ -35,10 +35,10 @@ enum class [[nodiscard]] TaskState
using namespace std::literals;
return std::array<std::string_view, 4> {
R"gql(Unassigned)gql"sv,
R"gql(New)gql"sv,
R"gql(Started)gql"sv,
R"gql(Complete)gql"sv,
R"gql(Unassigned)gql"sv
R"gql(Complete)gql"sv
};
}

Просмотреть файл

@ -117,12 +117,12 @@ type Subscription {
scalar DateTime @specifiedBy(url: "https://en.wikipedia.org/wiki/ISO_8601")
enum TaskState {
New
Started
Complete
Unassigned @deprecated(
reason:"""Need to deprecate an [enum value](https://spec.graphql.org/October2021/#sec-Schema-Introspection.Deprecation)"""
)
New
Started
Complete
}
type Appointment implements Node {

Просмотреть файл

@ -687,10 +687,10 @@ void AddTypesToSchema(const std::shared_ptr<schema::Schema>& schema)
schema->AddType(R"gql(Expensive)gql"sv, typeExpensive);
typeTaskState->AddEnumValues({
{ service::s_namesTaskState[static_cast<size_t>(today::TaskState::Unassigned)], R"md()md"sv, std::make_optional(R"md(Need to deprecate an [enum value](https://spec.graphql.org/October2021/#sec-Schema-Introspection.Deprecation))md"sv) },
{ service::s_namesTaskState[static_cast<size_t>(today::TaskState::New)], R"md()md"sv, std::nullopt },
{ service::s_namesTaskState[static_cast<size_t>(today::TaskState::Started)], R"md()md"sv, std::nullopt },
{ service::s_namesTaskState[static_cast<size_t>(today::TaskState::Complete)], R"md()md"sv, std::nullopt },
{ service::s_namesTaskState[static_cast<size_t>(today::TaskState::Unassigned)], R"md()md"sv, std::make_optional(R"md(Need to deprecate an [enum value](https://spec.graphql.org/October2021/#sec-Schema-Introspection.Deprecation))md"sv) }
{ service::s_namesTaskState[static_cast<size_t>(today::TaskState::Complete)], R"md()md"sv, std::nullopt }
});
typeCompleteTaskInput->AddInputValues({

Просмотреть файл

@ -24,10 +24,10 @@ namespace today {
enum class [[nodiscard]] TaskState
{
Unassigned,
New,
Started,
Complete,
Unassigned
Complete
};
[[nodiscard]] constexpr auto getTaskStateNames() noexcept
@ -35,10 +35,10 @@ enum class [[nodiscard]] TaskState
using namespace std::literals;
return std::array<std::string_view, 4> {
R"gql(Unassigned)gql"sv,
R"gql(New)gql"sv,
R"gql(Started)gql"sv,
R"gql(Complete)gql"sv,
R"gql(Unassigned)gql"sv
R"gql(Complete)gql"sv
};
}

Просмотреть файл

@ -824,8 +824,7 @@ 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 };
@ -873,9 +872,25 @@ response::Value Variable<)cpp"
<< cppType << R"cpp(>, )cpp" << enumValues.size()
<< R"cpp(> s_values)cpp" << cppType << R"cpp( = {)cpp";
std::vector<std::pair<std::string_view, std::string_view>> sortedValues(
enumValues.size());
std::transform(enumValues.cbegin(),
enumValues.cend(),
sortedValues.begin(),
[](const auto& value) noexcept {
return std::make_pair(value->name(),
SchemaLoader::getSafeCppName(value->name()));
});
std::sort(sortedValues.begin(),
sortedValues.end(),
[](const auto& lhs, const auto& rhs) noexcept {
return internal::shorter_or_less {}(lhs.first, rhs.first);
});
bool firstValue = true;
for (const auto& enumValue : enumValues)
for (const auto& enumValue : sortedValues)
{
if (!firstValue)
{
@ -884,9 +899,9 @@ response::Value Variable<)cpp"
firstValue = false;
sourceFile << R"cpp(
std::make_pair(R"gql()cpp" << enumValue->name()
std::make_pair(R"gql()cpp" << enumValue.first
<< R"cpp()gql"sv, )cpp" << cppType << R"cpp(::)cpp"
<< SchemaLoader::getSafeCppName(enumValue->name()) << R"cpp())cpp";
<< enumValue.second << R"cpp())cpp";
pendingSeparator.add();
}
@ -1107,8 +1122,7 @@ bool Generator::outputModifiedResponseImplementation(std::ostream& sourceFile,
sourceFile << R"cpp(
template <>
)cpp" << cppType
<< R"cpp( Response<)cpp" << cppType
<< R"cpp(>::parse(response::Value&& response)
<< R"cpp( Response<)cpp" << cppType << R"cpp(>::parse(response::Value&& response)
{
)cpp" << cppType
<< R"cpp( result;