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
5 changes: 3 additions & 2 deletions samples/client/mutate/MutateClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ 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!"}) {
mutation CompleteTaskMutation($input: CompleteTaskInput! = {id: "ZmFrZVRhc2tJZA==", isComplete: true, clientMutationId: "Hi There!"}, $skipClientMutationId: Boolean!) {
completedTask: completeTask(input: $input) {
completedTask: task {
completedTaskId: id
title
isComplete
}
clientMutationId
clientMutationId @skip(if: $skipClientMutationId)
}
}
)gql"s;
Expand All @@ -166,6 +166,7 @@ response::Value serializeVariables(Variables&& variables)
response::Value result { response::Type::Map };

result.emplace_back(R"js(input)js"s, ModifiedVariable<Variables::CompleteTaskInput>::serialize(std::move(variables.input)));
result.emplace_back(R"js(skipClientMutationId)js"s, ModifiedVariable<bool>::serialize(std::move(variables.skipClientMutationId)));

return result;
}
Expand Down
5 changes: 3 additions & 2 deletions samples/client/mutate/MutateClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ static_assert(graphql::internal::MinorVersion == 1, "regenerate with clientgen:
/// # Copyright (c) Microsoft Corporation. All rights reserved.
/// # Licensed under the MIT License.
///
/// mutation CompleteTaskMutation($input: CompleteTaskInput! = {id: "ZmFrZVRhc2tJZA==", isComplete: true, clientMutationId: "Hi There!"}) {
/// mutation CompleteTaskMutation($input: CompleteTaskInput! = {id: "ZmFrZVRhc2tJZA==", isComplete: true, clientMutationId: "Hi There!"}, $skipClientMutationId: Boolean!) {
/// completedTask: completeTask(input: $input) {
/// completedTask: task {
/// completedTaskId: id
/// title
/// isComplete
/// }
/// clientMutationId
/// clientMutationId @skip(if: $skipClientMutationId)
/// }
/// }
/// </code>
Expand Down Expand Up @@ -67,6 +67,7 @@ struct Variables
};

CompleteTaskInput input {};
bool skipClientMutationId {};
};

response::Value serializeVariables(Variables&& variables);
Expand Down
4 changes: 2 additions & 2 deletions samples/client/mutate/mutate.today.graphql
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

mutation CompleteTaskMutation($input: CompleteTaskInput! = {id: "ZmFrZVRhc2tJZA==", isComplete: true, clientMutationId: "Hi There!"}) {
mutation CompleteTaskMutation($input: CompleteTaskInput! = {id: "ZmFrZVRhc2tJZA==", isComplete: true, clientMutationId: "Hi There!"}, $skipClientMutationId: Boolean!) {
completedTask: completeTask(input: $input) {
completedTask: task {
completedTaskId: id
title
isComplete
}
clientMutationId
clientMutationId @skip(if: $skipClientMutationId)
}
}
16 changes: 13 additions & 3 deletions src/ClientGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ static_assert(graphql::internal::MinorVersion == )cpp"
{
pendingSeparator.reset();

headerFile << R"cpp(enum class )cpp" << _schemaLoader.getCppType(enumType->name()) << R"cpp(
headerFile << R"cpp(enum class )cpp" << _schemaLoader.getCppType(enumType->name())
<< R"cpp(
{
)cpp";
for (const auto& enumValue : enumType->enumValues())
Expand Down Expand Up @@ -605,8 +606,17 @@ response::Value serializeVariables(Variables&& variables)
for (const auto& variable : variables)
{
sourceFile << R"cpp( result.emplace_back(R"js()cpp" << variable.name
<< R"cpp()js"s, ModifiedVariable<Variables::)cpp"
<< _schemaLoader.getCppType(variable.type->name()) << R"cpp(>::serialize)cpp"
<< R"cpp()js"s, ModifiedVariable<)cpp";

const auto& builtinTypes = _schemaLoader.getBuiltinTypes();

if (builtinTypes.find(variable.type->name()) == builtinTypes.cend()
&& _schemaLoader.getSchemaType(variable.type->name()) != SchemaType::Scalar)
{
sourceFile << R"cpp(Variables::)cpp";
}

sourceFile << _schemaLoader.getCppType(variable.type->name()) << R"cpp(>::serialize)cpp"
<< getTypeModifierList(variable.modifiers)
<< R"cpp((std::move(variables.)cpp" << variable.cppName << R"cpp()));
)cpp";
Expand Down