Skip to content

Commit

Permalink
fix: get tenant ID/locale code only if getters exist
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed Aug 14, 2023
1 parent ed8ccec commit 81db04b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/handler-graphql/src/createGraphQLHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ const createCacheKey = (context: Context) => {

// @ts-ignore TODO: `getCurrentTenant` should be injected as a parameter.
// @ts-ignore TODO: We should not be accessing `context` like this here.
const { getCurrentTenant } = context.tenancy;
const tenant = context.tenancy?.getCurrentTenant();

// @ts-ignore TODO: `getContentLocale` should be injected as a parameter.
// @ts-ignore TODO: We should not be accessing `context` like this here.
const { getContentLocale } = context.i18n;
const contentLocale = context.i18n?.getContentLocale();

return [
`tenant:${getCurrentTenant().id}`,
`locale:${getContentLocale().code}`,
tenant ? `tenant:${tenant.id}` : null,
contentLocale ? `locale:${contentLocale.code}` : null,
plugins.length.toString()
].join("#");
]
.filter(Boolean)
.join("#");
};

const createRequestBody = (body: unknown): GraphQLRequestBody | GraphQLRequestBody[] => {
Expand Down

0 comments on commit 81db04b

Please sign in to comment.