MCPcopy
hub / github.com/webiny/webiny-js / createCacheKey

Function createCacheKey

packages/handler-graphql/src/createGraphQLHandler.ts:15–27  ·  view source on GitHub ↗
(context: Context)

Source from the content-addressed store, hash-verified

13const DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year
14
15const createCacheKey = (context: Context) => {
16 const plugins = getSchemaPlugins(context);
17 // TODO: in the near future, we have to assign a fixed name to every
18 // TODO: GraphQLSchema plugin, to be able to create a reliable cache key.
19
20 // TODO: `getCurrentTenant` should be injected as a parameter.
21 // @ts-expect-error TODO: We should not be accessing `context` like this here.
22 const tenant = context.tenancy?.getCurrentTenant();
23
24 return [tenant ? `tenant:${tenant.id}` : null, plugins.length.toString()]
25 .filter(Boolean)
26 .join("#");
27};
28
29const formatErrorPayload = (error: Error): string => {
30 if (error instanceof WebinyError) {

Callers 1

Calls 5

getSchemaPluginsFunction · 0.85
getCurrentTenantMethod · 0.65
filterMethod · 0.65
toStringMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected