Skip to content

A per request/response context object passed among delegate callbacks #1132

@xma000

Description

@xma000

We have a use case where we want to process HTTP headers and/or status code along with the GraphQL errors for a response. The callback for each of HTTPNetworkTransportTaskCompletedDelegate and HTTPNetworkTransportGraphQLErrorDelegate only contains information belonging to that layer, which is the right design. However, that means I won't receive information from different layers in one callback.

I propose that we add a per request context object to HTTPNetworkTransport. This mutable context object can hold attribute objects identified by string keys. This context object will be passed in every delegate callback for the request/response. This is a common technique to allow processors in multiple layers to coordinate. I think this is a great enhancement to the client library and is not difficult to implement.

With this support, we can set the header value to the context when we receive the callback through the interface of HTTPNetworkTransportTaskCompletedDelegate, then retrieve this value from the context when we process the callback for HTTPNetworkTransportGraphQLErrorDelegate.

This issue is a follow up to #1116.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementIssues outlining new things we want to do or things that will make our lives as devs easiernetworking-stack

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions