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

ApolloTestingController doesn't seem to be triggering an HttpInterceptor #2034

Open
KarmaCop213 opened this issue Jun 3, 2023 · 0 comments

Comments

@KarmaCop213
Copy link

Describe the bug

ApolloTestingController doesn't seem to be triggering an HttpInterceptor I have

To Reproduce

I have an HttpInterceptor declared like so:

export class ErrorHandlerInterceptor implements HttpInterceptor {

and I have call on my code to apollo like this:

import { Apollo } from "apollo-angular"
(...)
constructor(private readonly apollo: Apollo) {}
(...)
return this.apollo.mutate<T>({ mutation, variables })

on my test I make a call to this.apollo.mutate<T>({ mutation, variables }).
And to simulate the call, the only way I could find that triggers the HttpInterceptor is to make a dummy call to an endpoint using HttpClient:

const apolloTestingController = TestBed.inject(ApolloTestingController),
const httpMock  = TestBed.inject(HttpTestingController),
const httpClient  = TestBed.inject(HttpClient)

this.apolloTestingController.expectOne(callingGraphqlQuery).flush(responseBody as unknown)
this.apolloTestingController.verify()

this.httpClient.post("/graphql", { operationName }).subscribe()
this.httpMock.expectOne({ method: "POST" }).flush(responseBody, opts)
this.httpMock.verify()

Expected behavior

From my point of view ApolloTestingController should trigger HttpInterceptor.

Environment:

├── @angular/[email protected]
├── @angular/[email protected]
├── @apollo/[email protected]
├── [email protected]
├── [email protected]
└── [email protected]
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