Skip to content

Export writeResponse and SubscriptionKey based delivery #169

@gitmodimo

Description

@gitmodimo

I am writting graphql server that is compatible with Apollo. I am also using rapidJSON. When handling response I need to copy the JSON response into Apollo transport message. Making writeResponse function publicly available would allow generation of the response in one go without copying.

graphql-ws Protocol

auto response=resolve(...);
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);

writer.StartObject();
writer.Key("id");
writer.String(gql_ws.id.data());
writer.Key("type");
writer.String("next");
writer.Key("payload");

//copy
auto r=graphql::response::toJSON(std::move(response));
writer.RawValue(r.c_str(), r.size(), rapidjson::kObjectType);

//function not exported
// graphql::response::writeResponse(writer, std::move(response)); 

writer.EndObject();
return buffer.GetString();

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions