# Add custom data to LoggingInterceptor

**URL:** <https://community.apollographql.com/t/add-custom-data-to-logginginterceptor/6573>\
**Category:** Client SDKs\
**Tags:** ios\
**Created:** [August 9, 2023, 3:48pm UTC](https://community.apollographql.com/t/add-custom-data-to-logginginterceptor/6573 "2023-08-09T15:48:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RRUIZ5-JB](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/rruiz5-jb/32/4486_2.png) [@RRUIZ5-JB](https://community.apollographql.com/u/RRUIZ5-JB)\
**Post date:** [August 9, 2023, 3:48pm UTC](https://community.apollographql.com/t/add-custom-data-to-logginginterceptor/6573/1 "2023-08-09T15:48:31Z")

</div>

Hi all!  
I am migrating some Rest api into GraphQL, everything is working great except the integration with the logging/reporting tool we have.

After each response, we log the request, the response (either the error or the data) and some additional info like the like the screen name or some reference id to name some examples.

I was following the docs, [specifically this interceptor](https://www.apollographql.com/docs/ios/networking/request-pipeline#requestlogginginterceptor), which gives me access to almost all the things I need.

This is a reduced example of the problem I am trying to solve.  
This is the gateway, who exposes a way to make the queries/mutations

```swift
class MyGateway {
    private let client: ApolloClient
    init() { ... }

    func emptyBasket(type: BasketType) {
        client.perform(mutation: EmptyBasketMutation(type: .init(type)))
    }
}

```

Then in some other view model or view controller, we call the `emptyBasket` method:

```swift
class MyViewModel {
    private func emptyBasket() {
        let extraLogParameters = [
        "screen": "checkout",
        "referenceId": "12345"
        ] // This is the extra info I want to have in the logs
        myGateway.emptyBasket(type: .coolBasket)
    }
}

```

The question is, how can I pass or access `extraLogParameters` in the following interceptor?

```auto
class RequestLoggingInterceptor: ApolloInterceptor {

  func interceptAsync<Operation: GraphQLOperation>(
    chain: RequestChain,
    request: HTTPRequest<Operation>,
    response: HTTPResponse<Operation>?,
    completion: @escaping (Result<GraphQLResult<Operation.Data>, Error>) -> Void
  ) {
    Logger.log(.debug, "Outgoing request: \(request)")
    // How can I access `extraLogParameters` here??
    chain.proceedAsync(
      request: request,
      response: response,
      completion: completion
    )
  }
}

```

---

<div class="post-metadata">

**Author:** ![calvincestari](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/calvincestari/32/339_2.png) [@calvincestari](https://community.apollographql.com/u/calvincestari)\
**Post date:** [October 3, 2023, 4:32pm UTC](https://community.apollographql.com/t/add-custom-data-to-logginginterceptor/6573/3 "2023-10-03T16:32:58Z")

</div>

Hi @RRUIZ5-JB - I realize this is a very late reply to your question but there is [PR #3198](https://github.com/apollographql/apollo-ios/pull/3198) that might be able to help you here. It’s not merged yet but should be soon.

---

<div class="post-metadata">

**Author:** ![RRUIZ5-JB](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/rruiz5-jb/32/4486_2.png) [@RRUIZ5-JB](https://community.apollographql.com/u/RRUIZ5-JB)\
**Post date:** [October 12, 2023, 7:58am UTC](https://community.apollographql.com/t/add-custom-data-to-logginginterceptor/6573/4 "2023-10-12T07:58:24Z")

</div>

This is awesome! Thanks for the heads up.

---

<div class="post-metadata">

**Author:** ![Justin\_Gonzalez](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/justin_gonzalez/32/5359_2.png) [@Justin\_Gonzalez](https://community.apollographql.com/u/Justin_Gonzalez)\
**Post date:** [February 6, 2025, 8:48pm UTC](https://community.apollographql.com/t/add-custom-data-to-logginginterceptor/6573/5 "2025-02-06T20:48:09Z")

</div>


