|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +// WARNING! Do not edit this file manually, your changes will be overwritten. |
| 5 | + |
| 6 | +#include "NestedInputClient.h" |
| 7 | + |
| 8 | +#include <algorithm> |
| 9 | +#include <array> |
| 10 | +#include <sstream> |
| 11 | +#include <stdexcept> |
| 12 | +#include <string_view> |
| 13 | + |
| 14 | +using namespace std::literals; |
| 15 | + |
| 16 | +namespace graphql::client { |
| 17 | + |
| 18 | +using namespace query::testQuery; |
| 19 | + |
| 20 | +template <> |
| 21 | +constexpr bool isInputType<Variables::InputA>() noexcept |
| 22 | +{ |
| 23 | + return true; |
| 24 | +} |
| 25 | + |
| 26 | +template <> |
| 27 | +constexpr bool isInputType<Variables::InputB>() noexcept |
| 28 | +{ |
| 29 | + return true; |
| 30 | +} |
| 31 | + |
| 32 | +template <> |
| 33 | +constexpr bool isInputType<Variables::InputABCD>() noexcept |
| 34 | +{ |
| 35 | + return true; |
| 36 | +} |
| 37 | + |
| 38 | +template <> |
| 39 | +constexpr bool isInputType<Variables::InputBC>() noexcept |
| 40 | +{ |
| 41 | + return true; |
| 42 | +} |
| 43 | + |
| 44 | +template <> |
| 45 | +response::Value ModifiedVariable<Variables::InputA>::serialize(Variables::InputA&& inputValue) |
| 46 | +{ |
| 47 | + response::Value result { response::Type::Map }; |
| 48 | + |
| 49 | + result.emplace_back(R"js(a)js"s, ModifiedVariable<bool>::serialize(std::move(inputValue.a))); |
| 50 | + |
| 51 | + return result; |
| 52 | +} |
| 53 | + |
| 54 | +template <> |
| 55 | +response::Value ModifiedVariable<Variables::InputB>::serialize(Variables::InputB&& inputValue) |
| 56 | +{ |
| 57 | + response::Value result { response::Type::Map }; |
| 58 | + |
| 59 | + result.emplace_back(R"js(b)js"s, ModifiedVariable<double>::serialize(std::move(inputValue.b))); |
| 60 | + |
| 61 | + return result; |
| 62 | +} |
| 63 | + |
| 64 | +template <> |
| 65 | +response::Value ModifiedVariable<Variables::InputABCD>::serialize(Variables::InputABCD&& inputValue) |
| 66 | +{ |
| 67 | + response::Value result { response::Type::Map }; |
| 68 | + |
| 69 | + result.emplace_back(R"js(d)js"s, ModifiedVariable<std::string>::serialize(std::move(inputValue.d))); |
| 70 | + result.emplace_back(R"js(a)js"s, ModifiedVariable<InputA>::serialize(std::move(inputValue.a))); |
| 71 | + result.emplace_back(R"js(b)js"s, ModifiedVariable<InputB>::serialize(std::move(inputValue.b))); |
| 72 | + result.emplace_back(R"js(bc)js"s, ModifiedVariable<InputBC>::serialize<TypeModifier::List>(std::move(inputValue.bc))); |
| 73 | + |
| 74 | + return result; |
| 75 | +} |
| 76 | + |
| 77 | +template <> |
| 78 | +response::Value ModifiedVariable<Variables::InputBC>::serialize(Variables::InputBC&& inputValue) |
| 79 | +{ |
| 80 | + response::Value result { response::Type::Map }; |
| 81 | + |
| 82 | + result.emplace_back(R"js(c)js"s, ModifiedVariable<response::IdType>::serialize(std::move(inputValue.c))); |
| 83 | + result.emplace_back(R"js(b)js"s, ModifiedVariable<InputB>::serialize(std::move(inputValue.b))); |
| 84 | + |
| 85 | + return result; |
| 86 | +} |
| 87 | + |
| 88 | +template <> |
| 89 | +Response::control_Control::test_Output ModifiedResponse<Response::control_Control::test_Output>::parse(response::Value&& response) |
| 90 | +{ |
| 91 | + Response::control_Control::test_Output result; |
| 92 | + |
| 93 | + if (response.type() == response::Type::Map) |
| 94 | + { |
| 95 | + auto members = response.release<response::MapType>(); |
| 96 | + |
| 97 | + for (auto& member : members) |
| 98 | + { |
| 99 | + if (member.first == R"js(id)js"sv) |
| 100 | + { |
| 101 | + result.id = ModifiedResponse<bool>::parse<TypeModifier::Nullable>(std::move(member.second)); |
| 102 | + continue; |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | + |
| 107 | + return result; |
| 108 | +} |
| 109 | + |
| 110 | +template <> |
| 111 | +Response::control_Control ModifiedResponse<Response::control_Control>::parse(response::Value&& response) |
| 112 | +{ |
| 113 | + Response::control_Control result; |
| 114 | + |
| 115 | + if (response.type() == response::Type::Map) |
| 116 | + { |
| 117 | + auto members = response.release<response::MapType>(); |
| 118 | + |
| 119 | + for (auto& member : members) |
| 120 | + { |
| 121 | + if (member.first == R"js(test)js"sv) |
| 122 | + { |
| 123 | + result.test = ModifiedResponse<Response::control_Control::test_Output>::parse<TypeModifier::Nullable>(std::move(member.second)); |
| 124 | + continue; |
| 125 | + } |
| 126 | + } |
| 127 | + } |
| 128 | + |
| 129 | + return result; |
| 130 | +} |
| 131 | + |
| 132 | +namespace query::testQuery { |
| 133 | + |
| 134 | +const std::string& GetRequestText() noexcept |
| 135 | +{ |
| 136 | + static const auto s_request = R"gql( |
| 137 | + query testQuery($stream: InputABCD!) { |
| 138 | + control { |
| 139 | + test(new: $stream) { |
| 140 | + id |
| 141 | + } |
| 142 | + } |
| 143 | + } |
| 144 | + )gql"s; |
| 145 | + |
| 146 | + return s_request; |
| 147 | +} |
| 148 | + |
| 149 | +const peg::ast& GetRequestObject() noexcept |
| 150 | +{ |
| 151 | + static const auto s_request = []() noexcept { |
| 152 | + auto ast = peg::parseString(GetRequestText()); |
| 153 | + |
| 154 | + // This has already been validated against the schema by clientgen. |
| 155 | + ast.validated = true; |
| 156 | + |
| 157 | + return ast; |
| 158 | + }(); |
| 159 | + |
| 160 | + return s_request; |
| 161 | +} |
| 162 | + |
| 163 | +response::Value serializeVariables(Variables&& variables) |
| 164 | +{ |
| 165 | + response::Value result { response::Type::Map }; |
| 166 | + |
| 167 | + result.emplace_back(R"js(stream)js"s, ModifiedVariable<Variables::InputABCD>::serialize(std::move(variables.stream))); |
| 168 | + |
| 169 | + return result; |
| 170 | +} |
| 171 | + |
| 172 | +Response parseResponse(response::Value&& response) |
| 173 | +{ |
| 174 | + Response result; |
| 175 | + |
| 176 | + if (response.type() == response::Type::Map) |
| 177 | + { |
| 178 | + auto members = response.release<response::MapType>(); |
| 179 | + |
| 180 | + for (auto& member : members) |
| 181 | + { |
| 182 | + if (member.first == R"js(control)js"sv) |
| 183 | + { |
| 184 | + result.control = ModifiedResponse<Response::control_Control>::parse(std::move(member.second)); |
| 185 | + continue; |
| 186 | + } |
| 187 | + } |
| 188 | + } |
| 189 | + |
| 190 | + return result; |
| 191 | +} |
| 192 | + |
| 193 | +} // namespace query::testQuery |
| 194 | +} // namespace graphql::client |
0 commit comments