Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] - Is it possible to customize the title of an item in the console? #306

Open
TripwireNL opened this issue Nov 19, 2024 · 0 comments

Comments

@TripwireNL
Copy link

TripwireNL commented Nov 19, 2024

Hi,

I'm using Pulse logger to log some custom messages for a new GraphQL implementation which works very well. The only downside is since every URL resolves against localhost:4000/graphql/ all the items in the console have /graphql/ and there's no way to differntiate which request is which (see attached image). Is it possible to customize this label?
Screenshot 2024-11-19 at 15 24 11

i'm using this code (Apollo client logging interceptor):
`class LoggingInterceptor: ApolloInterceptor {
var id: String = UUID().uuidString

func interceptAsync<Operation>(
    chain: any RequestChain,
    request: HTTPRequest<Operation>,
    response: HTTPResponse<Operation>?,
    completion: @escaping (Result<GraphQLResult<Operation.Data>, any Error>) -> Void
) where Operation: GraphQLOperation {
    guard let urlRequest = try? request.toURLRequest() else {
        print("GraphQL: We can't log anything without a valid request")
        return
    }

    let operationName = String(describing: request.operation)
    
    LoggerStore.shared.storeRequest(
        urlRequest,
        response: createURLResponse(response: response),
        error: nil,
        data: response?.rawData,
        metrics: nil,
        label: operationName,
        taskDescription: operationName
    )

    chain.proceedAsync(request: request, response: response, interceptor: self, completion: completion)
}

private func createURLResponse<Operation>(response: HTTPResponse<Operation>?) -> URLResponse? {
    guard let response = response, let responseURL = response.httpResponse.url else {
        return nil
    }
    
    let urlResponse = URLResponse(
        url: responseURL,
        mimeType: response.httpResponse.mimeType ?? "",
        expectedContentLength: Int(response.httpResponse.expectedContentLength),
        textEncodingName: response.httpResponse.textEncodingName ?? ""
    )

    return urlResponse
}

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant