1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Angular Interceptor - retrieve Graphql query or mutation name

Discussão em 'Angular' iniciado por DanyBoy, Dezembro 14, 2024.

  1. DanyBoy

    DanyBoy Guest

    Good morning everyone, I would need your help to retrieve the query or mutation name within the interceptor which is working fine.

    import { HttpContextToken, HttpInterceptorFn } from '@angular/common/http';
    import { environment } from '../../../environments/environment'


    export const REFRESHER_TOKEN_INTERCEPTOR = new HttpContextToken(() => false)
    export const authInterceptor: HttpInterceptorFn = (req, next) => {

    //By dafault, the interceptor will try to pass the JWT token but for the refresherToken we must pass the refresher token instead
    const jwtToken = getJwtToken(req.context.get(REFRESHER_TOKEN_INTERCEPTOR));

    if (jwtToken) {
    var cloned = req.clone({
    setHeaders: {
    Authorization: `Bearer ${jwtToken}`
    }
    })
    return next(cloned)
    }
    return next(req);
    };


    The reason why I'm asking, it's in case of refresher token mechanism, I would like to send another token

    Find a way to retrieve the query or mutation name from within the interceptor

    Continue reading...

Compartilhe esta Página