You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Export writeResponse and SubscriptionKey based delivery #169
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.
Going further. When implementing Subscriptions I noticed there is no possibility to deliver given SubscriptionKey. Looking at the code it should be pretty straight forward allow it.
This would allow implementer to handle updates based on touched leafs by registering listeners in NotifySubscribe and invoking deliver for affected SubscriptionKey-s.
In current implementation we can only deliver on root nodes of subscribe. Or am I missing something?
Interesting, I can see how those would help. The SubscriptionKey delivery mechanism seems like it would be more straightforward to implement. The rapidjson::Writer change would be a little more difficult since graphqljson is supposed to abstract the JSON parser implementation details for consumers. It could potentially export them as an extension, e.g. in an internal/RapidJSONResponse.h header or something, though. I'll need to think about how I can keep the ability to plug in a different JSON library, maybe even prototype a second one.
Keeping this open for now, I'm thinking of doing a v3.7.0 from the v3.x branch with any features I can backport from the pending v4.0.0 without breaking compatibility.
I backported the response::Writer change, but the support for returning std::shared_ptr<const response::Value> would have required splitting service::FieldResult into separate types for scalar types and service::Object sub-classes, or some new SFINAE template handling to handle both with service::FieldResult. It wasn't a clean backport.
Activity
gitmodimo commentedon Nov 9, 2021
Going further. When implementing Subscriptions I noticed there is no possibility to deliver given
SubscriptionKey. Looking at the code it should be pretty straight forward allow it.This would allow implementer to handle updates based on touched leafs by registering listeners in NotifySubscribe and invoking deliver for affected
SubscriptionKey-s.In current implementation we can only deliver on root nodes of subscribe. Or am I missing something?
[-]Export writeResponse[/-][+]Export writeResponse and SubscriptionKey based delivery[/+]wravery commentedon Nov 12, 2021
Interesting, I can see how those would help. The
SubscriptionKeydelivery mechanism seems like it would be more straightforward to implement. Therapidjson::Writerchange would be a little more difficult sincegraphqljsonis supposed to abstract the JSON parser implementation details for consumers. It could potentially export them as an extension, e.g. in aninternal/RapidJSONResponse.hheader or something, though. I'll need to think about how I can keep the ability to plug in a different JSON library, maybe even prototype a second one.gitmodimo commentedon Nov 12, 2021
I did proof of concept implementation in my fork.
Maybe the export of
writeResponseshould be dependent on buildtime option?wravery commentedon Dec 17, 2021
Keeping this open for now, I'm thinking of doing a v3.7.0 from the v3.x branch with any features I can backport from the pending v4.0.0 without breaking compatibility.
wravery commentedon Dec 17, 2021
I backported the
response::Writerchange, but the support for returningstd::shared_ptr<const response::Value>would have required splittingservice::FieldResultinto separate types for scalar types andservice::Objectsub-classes, or some new SFINAE template handling to handle both withservice::FieldResult. It wasn't a clean backport.