|
| 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 "BenchmarkClient.h" |
| 7 | + |
| 8 | +#include "graphqlservice/GraphQLClient.h" |
| 9 | + |
| 10 | +#include <algorithm> |
| 11 | +#include <array> |
| 12 | +#include <stdexcept> |
| 13 | +#include <sstream> |
| 14 | +#include <string_view> |
| 15 | + |
| 16 | +using namespace std::literals; |
| 17 | + |
| 18 | +namespace graphql::client { |
| 19 | + |
| 20 | +using namespace query::Query; |
| 21 | + |
| 22 | +template <> |
| 23 | +Response::appointments_AppointmentConnection::pageInfo_PageInfo ModifiedResponse<Response::appointments_AppointmentConnection::pageInfo_PageInfo>::parse(response::Value&& response) |
| 24 | +{ |
| 25 | + Response::appointments_AppointmentConnection::pageInfo_PageInfo result; |
| 26 | + |
| 27 | + if (response.type() == response::Type::Map) |
| 28 | + { |
| 29 | + auto members = response.release<response::MapType>(); |
| 30 | + |
| 31 | + for (auto& member : members) |
| 32 | + { |
| 33 | + if (member.first == R"js(hasNextPage)js"sv) |
| 34 | + { |
| 35 | + result.hasNextPage = ModifiedResponse<response::BooleanType>::parse(std::move(member.second)); |
| 36 | + continue; |
| 37 | + } |
| 38 | + } |
| 39 | + } |
| 40 | + |
| 41 | + return result; |
| 42 | +} |
| 43 | + |
| 44 | +template <> |
| 45 | +Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appointment ModifiedResponse<Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appointment>::parse(response::Value&& response) |
| 46 | +{ |
| 47 | + Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appointment result; |
| 48 | + |
| 49 | + if (response.type() == response::Type::Map) |
| 50 | + { |
| 51 | + auto members = response.release<response::MapType>(); |
| 52 | + |
| 53 | + for (auto& member : members) |
| 54 | + { |
| 55 | + if (member.first == R"js(id)js"sv) |
| 56 | + { |
| 57 | + result.id = ModifiedResponse<response::IdType>::parse(std::move(member.second)); |
| 58 | + continue; |
| 59 | + } |
| 60 | + if (member.first == R"js(when)js"sv) |
| 61 | + { |
| 62 | + result.when = ModifiedResponse<response::Value>::parse<TypeModifier::Nullable>(std::move(member.second)); |
| 63 | + continue; |
| 64 | + } |
| 65 | + if (member.first == R"js(subject)js"sv) |
| 66 | + { |
| 67 | + result.subject = ModifiedResponse<response::StringType>::parse<TypeModifier::Nullable>(std::move(member.second)); |
| 68 | + continue; |
| 69 | + } |
| 70 | + if (member.first == R"js(isNow)js"sv) |
| 71 | + { |
| 72 | + result.isNow = ModifiedResponse<response::BooleanType>::parse(std::move(member.second)); |
| 73 | + continue; |
| 74 | + } |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + return result; |
| 79 | +} |
| 80 | + |
| 81 | +template <> |
| 82 | +Response::appointments_AppointmentConnection::edges_AppointmentEdge ModifiedResponse<Response::appointments_AppointmentConnection::edges_AppointmentEdge>::parse(response::Value&& response) |
| 83 | +{ |
| 84 | + Response::appointments_AppointmentConnection::edges_AppointmentEdge result; |
| 85 | + |
| 86 | + if (response.type() == response::Type::Map) |
| 87 | + { |
| 88 | + auto members = response.release<response::MapType>(); |
| 89 | + |
| 90 | + for (auto& member : members) |
| 91 | + { |
| 92 | + if (member.first == R"js(node)js"sv) |
| 93 | + { |
| 94 | + result.node = ModifiedResponse<Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appointment>::parse<TypeModifier::Nullable>(std::move(member.second)); |
| 95 | + continue; |
| 96 | + } |
| 97 | + } |
| 98 | + } |
| 99 | + |
| 100 | + return result; |
| 101 | +} |
| 102 | + |
| 103 | +template <> |
| 104 | +Response::appointments_AppointmentConnection ModifiedResponse<Response::appointments_AppointmentConnection>::parse(response::Value&& response) |
| 105 | +{ |
| 106 | + Response::appointments_AppointmentConnection result; |
| 107 | + |
| 108 | + if (response.type() == response::Type::Map) |
| 109 | + { |
| 110 | + auto members = response.release<response::MapType>(); |
| 111 | + |
| 112 | + for (auto& member : members) |
| 113 | + { |
| 114 | + if (member.first == R"js(pageInfo)js"sv) |
| 115 | + { |
| 116 | + result.pageInfo = ModifiedResponse<Response::appointments_AppointmentConnection::pageInfo_PageInfo>::parse(std::move(member.second)); |
| 117 | + continue; |
| 118 | + } |
| 119 | + if (member.first == R"js(edges)js"sv) |
| 120 | + { |
| 121 | + result.edges = ModifiedResponse<Response::appointments_AppointmentConnection::edges_AppointmentEdge>::parse<TypeModifier::Nullable, TypeModifier::List, TypeModifier::Nullable>(std::move(member.second)); |
| 122 | + continue; |
| 123 | + } |
| 124 | + } |
| 125 | + } |
| 126 | + |
| 127 | + return result; |
| 128 | +} |
| 129 | + |
| 130 | +namespace query::Query { |
| 131 | + |
| 132 | +const std::string& GetRequestText() noexcept |
| 133 | +{ |
| 134 | + static const auto s_request = R"gql( |
| 135 | + # Copyright (c) Microsoft Corporation. All rights reserved. |
| 136 | + # Licensed under the MIT License. |
| 137 | + |
| 138 | + query { |
| 139 | + appointments { |
| 140 | + pageInfo { |
| 141 | + hasNextPage |
| 142 | + } |
| 143 | + edges { |
| 144 | + node { |
| 145 | + id |
| 146 | + when |
| 147 | + subject |
| 148 | + isNow |
| 149 | + } |
| 150 | + } |
| 151 | + } |
| 152 | + } |
| 153 | + )gql"s; |
| 154 | + |
| 155 | + return s_request; |
| 156 | +} |
| 157 | + |
| 158 | +const peg::ast& GetRequestObject() noexcept |
| 159 | +{ |
| 160 | + static const auto s_request = []() noexcept { |
| 161 | + auto ast = peg::parseString(GetRequestText()); |
| 162 | + |
| 163 | + // This has already been validated against the schema by clientgen. |
| 164 | + ast.validated = true; |
| 165 | + |
| 166 | + return ast; |
| 167 | + }(); |
| 168 | + |
| 169 | + return s_request; |
| 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(appointments)js"sv) |
| 183 | + { |
| 184 | + result.appointments = ModifiedResponse<Response::appointments_AppointmentConnection>::parse(std::move(member.second)); |
| 185 | + continue; |
| 186 | + } |
| 187 | + } |
| 188 | + } |
| 189 | + |
| 190 | + return result; |
| 191 | +} |
| 192 | + |
| 193 | +} // namespace query::Query |
| 194 | +} // namespace graphql::client |
0 commit comments