-
Notifications
You must be signed in to change notification settings - Fork 50
Closed
Description
Hi,
I'm missing a sample to use cppgraphqlgen only as a client for an existing graphql server (Graphene/Django). After a lot of reading, I came up with this, but I'm a little bit stuck on how to set Variables to my query.
auto svar = graphql::client::query::getObjectclassById::serializeVariables({1});
// auto query = graphql::client::query::getObjectclassById::GetRequestObject();
// const auto& name = graphql::client::query::getObjectclassById::GetOperationName();
auto res = cpr::Post(
cpr::Url({Config::gqlServer() + "/graphql/"}),
cpr::Header({{"Content-Type", "application/graphql"}}),
cpr::Body(graphql::client::query::getObjectclassById::GetRequestText()));
auto r = graphql::response::parseJSON(res.text);
auto serviceResponse = graphql::client::parseServiceResponse(std::move(r));
const auto parsed = graphql::client::query::getObjectclassById::parseResponse(std::move(serviceResponse.data));
if (parsed.objectclassById) {
std::cout << parsed.objectclassById->title.value_or("title not set") << std::endl;
}
Is my use of the library correct so far? How do I set the variables in the query to the server?
Thanks,
Sebastian
Metadata
Metadata
Assignees
Labels
No labels