diff --git a/packages/twenty-server/patches/@graphql-yoga-nestjs-npm-2.1.0-cb509e6047.patch b/packages/twenty-server/patches/@graphql-yoga-nestjs-npm-2.1.0-cb509e6047.patch index 59f4e9ff07d..70572a4907e 100644 --- a/packages/twenty-server/patches/@graphql-yoga-nestjs-npm-2.1.0-cb509e6047.patch +++ b/packages/twenty-server/patches/@graphql-yoga-nestjs-npm-2.1.0-cb509e6047.patch @@ -26,16 +26,17 @@ index 16843949d8589a299d8195b0a349ac4dac0bacbf..21e7fe2bbcba36b04a274be9d2219fd3 const app = this.httpAdapterHost.httpAdapter.getInstance(); preStartHook?.(app); // nest's logger doesnt have the info method -@@ -42,6 +46,39 @@ class AbstractYogaDriver extends graphql_2.AbstractGraphQLDriver { +@@ -42,6 +46,40 @@ class AbstractYogaDriver extends graphql_2.AbstractGraphQLDriver { } const yoga = (0, graphql_yoga_1.createYoga)({ ...options, + schema: async (request) => { + const workspaceId = request.req.workspace?.id ?? 'anonymous' + const workspaceCacheVersion = request.req.cacheVersion ?? '0' ++ const workspaceUserId = request.req.user?.id ?? 'anonymous' + const url = request.req.baseUrl + -+ const cacheKey = `${workspaceId}-${workspaceCacheVersion}-${url}` ++ const cacheKey = `${workspaceId}-${workspaceCacheVersion}-${workspaceUserId}-${url}` + + if(this.schemaCache.has(cacheKey)) { + return this.schemaCache.get(cacheKey) @@ -66,7 +67,7 @@ index 16843949d8589a299d8195b0a349ac4dac0bacbf..21e7fe2bbcba36b04a274be9d2219fd3 graphqlEndpoint: options.path, // disable logging by default // however, if `true` use nest logger -@@ -54,11 +91,44 @@ class AbstractYogaDriver extends graphql_2.AbstractGraphQLDriver { +@@ -54,11 +91,45 @@ class AbstractYogaDriver extends graphql_2.AbstractGraphQLDriver { this.yoga = yoga; app.use(yoga.graphqlEndpoint, (req, res) => yoga(req, res, { req, res })); } @@ -79,9 +80,10 @@ index 16843949d8589a299d8195b0a349ac4dac0bacbf..21e7fe2bbcba36b04a274be9d2219fd3 + schema: async (request) => { + const workspaceId = request.req.workspace?.id ?? 'anonymous' + const workspaceCacheVersion = request.req.cacheVersion ?? '0' ++ const workspaceUserId = request.req.user?.id ?? 'anonymous' + const url = request.req.baseUrl + -+ const cacheKey = `${workspaceId}-${workspaceCacheVersion}-${url}` ++ const cacheKey = `${workspaceId}-${workspaceCacheVersion}-${workspaceUserId}-${url}` + + if(this.schemaCache.has(cacheKey)) { + return this.schemaCache.get(cacheKey) @@ -138,16 +140,17 @@ index 7068c519320b379917c46763cd280b1cdd3e48f0..418e1030373fc1e0fb85a932ac8da9b3 const app = this.httpAdapterHost.httpAdapter.getInstance(); preStartHook?.(app); // nest's logger doesnt have the info method -@@ -39,6 +43,39 @@ export class AbstractYogaDriver extends AbstractGraphQLDriver { +@@ -39,6 +43,40 @@ export class AbstractYogaDriver extends AbstractGraphQLDriver { } const yoga = createYoga({ ...options, + schema: async (request) => { + const workspaceId = request.req.workspace?.id ?? 'anonymous' + const workspaceCacheVersion = request.req.cacheVersion ?? '0' ++ const workspaceUserId = request.req.user?.id ?? 'anonymous' + const url = request.req.baseUrl + -+ const cacheKey = `${workspaceId}-${workspaceCacheVersion}-${url}` ++ const cacheKey = `${workspaceId}-${workspaceCacheVersion}-${workspaceUserId}-${url}` + + if (this.schemaCache.has(cacheKey)) { + return this.schemaCache.get(cacheKey) @@ -178,7 +181,7 @@ index 7068c519320b379917c46763cd280b1cdd3e48f0..418e1030373fc1e0fb85a932ac8da9b3 graphqlEndpoint: options.path, // disable logging by default // however, if `true` use nest logger -@@ -51,11 +88,44 @@ export class AbstractYogaDriver extends AbstractGraphQLDriver { +@@ -51,11 +88,45 @@ export class AbstractYogaDriver extends AbstractGraphQLDriver { this.yoga = yoga; app.use(yoga.graphqlEndpoint, (req, res) => yoga(req, res, { req, res })); } @@ -191,9 +194,10 @@ index 7068c519320b379917c46763cd280b1cdd3e48f0..418e1030373fc1e0fb85a932ac8da9b3 + schema: async (request) => { + const workspaceId = request.req.workspace?.id ?? 'anonymous' + const workspaceCacheVersion = request.req.cacheVersion ?? '0' ++ const workspaceUserId = request.req.user?.id ?? 'anonymous' + const url = request.req.baseUrl + -+ const cacheKey = `${workspaceId}-${workspaceCacheVersion}-${url}` ++ const cacheKey = `${workspaceId}-${workspaceCacheVersion}-${workspaceUserId}-${url}` + + if (this.schemaCache.has(cacheKey)) { + return this.schemaCache.get(cacheKey) @@ -377,16 +381,17 @@ index ce142f61ede52499485b19d8af057f4cb828d0f7..5888d31cae1b7aca57ed0819209812ac { preStartHook }: { preStartHook?: (app: Express) => void } = {}, ) { const app: Express = this.httpAdapterHost.httpAdapter.getInstance(); -@@ -98,6 +109,39 @@ export abstract class AbstractYogaDriver< +@@ -98,6 +109,40 @@ export abstract class AbstractYogaDriver< const yoga = createYoga>({ ...options, + schema: async request => { + const workspaceId = request.req.workspace.id + const workspaceCacheVersion = request.req.cacheVersion ++ const workspaceUserId = request.req.user?.id ?? 'anonymous' + const url = request.req.baseUrl + -+ const cacheKey = `${workspaceId}-${workspaceCacheVersion}-${url}` ++ const cacheKey = `${workspaceId}-${workspaceCacheVersion}-${workspaceUserId}-${url}` + + if (this.schemaCache.has(cacheKey)) { + return this.schemaCache.get(cacheKey) @@ -437,16 +442,17 @@ index ce142f61ede52499485b19d8af057f4cb828d0f7..5888d31cae1b7aca57ed0819209812ac { preStartHook }: { preStartHook?: (app: FastifyInstance) => void } = {}, ) { const app: FastifyInstance = this.httpAdapterHost.httpAdapter.getInstance(); -@@ -124,6 +168,39 @@ export abstract class AbstractYogaDriver< +@@ -124,6 +168,40 @@ export abstract class AbstractYogaDriver< const yoga = createYoga>({ ...options, + schema: async request => { + const workspaceId = request.req.workspace.id + const workspaceCacheVersion = request.req.cacheVersion ++ const workspaceUserId = request.req.user?.id ?? 'anonymous' + const url = request.req.baseUrl + -+ const cacheKey = `${workspaceId}-${workspaceCacheVersion}-${url}` ++ const cacheKey = `${workspaceId}-${workspaceCacheVersion}-${workspaceUserId}-${url}` + + if (this.schemaCache.has(cacheKey)) { + return this.schemaCache.get(cacheKey) diff --git a/yarn.lock b/yarn.lock index 8141f12a554..b02ac166a16 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6830,14 +6830,14 @@ __metadata: "@graphql-yoga/nestjs@patch:@graphql-yoga/nestjs@2.1.0#./patches/@graphql-yoga-nestjs-npm-2.1.0-cb509e6047.patch::locator=twenty-server%40workspace%3Apackages%2Ftwenty-server": version: 2.1.0 - resolution: "@graphql-yoga/nestjs@patch:@graphql-yoga/nestjs@npm%3A2.1.0#./patches/@graphql-yoga-nestjs-npm-2.1.0-cb509e6047.patch::version=2.1.0&hash=6403da&locator=twenty-server%40workspace%3Apackages%2Ftwenty-server" + resolution: "@graphql-yoga/nestjs@patch:@graphql-yoga/nestjs@npm%3A2.1.0#./patches/@graphql-yoga-nestjs-npm-2.1.0-cb509e6047.patch::version=2.1.0&hash=194cbb&locator=twenty-server%40workspace%3Apackages%2Ftwenty-server" peerDependencies: "@nestjs/common": ^10.0.0 "@nestjs/core": ^10.0.0 "@nestjs/graphql": ^12.0.0 graphql: ^15.0.0 || ^16.0.0 graphql-yoga: ^4.0.4 - checksum: 3f7b8839cb9de4c05b1bae0c3eaa242f70e24c8258d193dedacdd6f06c1d29330ffcd233c6bbb7ff2288f1a55d97a4a333a0538d2ec5da40911d422e1c28e6d6 + checksum: f0529bfae125d22569dd5dbd7d06ac8e70315d720df5a315a644d9acf2d81d7d0d845967336b358dd11b29bab9920f38eff4c9ee774dd838aefc78dba6c91546 languageName: node linkType: hard