Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 6x 6x 6x 10x 10x 10x | import { createParamDecorator } from '@nestjs/common'; import { I18nService } from '..'; import { I18nContext } from '../i18n.context'; export const I18n = createParamDecorator((data, req) => { // this is gonna be so nasty.. // FIXME: This has to be fixed in later stages! PLEASE! Iif (Array.isArray(req)) { return new I18nContext(...resolveI18nServiceFromGraphQLContext(req)); } return new I18nContext(...resolveI18nServiceFromRestRequest(req)); }); function resolveI18nServiceFromRestRequest(req): [string, I18nService] { return [ req.i18nLang || (req.raw ? req.raw.i18nLang : undefined), req.i18nService || (req.raw ? req.raw.i18nService : undefined), ]; } function resolveI18nServiceFromGraphQLContext(req): [string, I18nService] { const [root, args, ctx, info] = req; return [ctx.req.i18nLang, ctx.req.i18nService]; } |