0

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

1 Answer 1

0

in case you are looking for a solution, see below how to simply get it:

const operationName = req.body.operationName
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.