Ws poc (#11293)
related to https://github.com/twentyhq/core-team-issues/issues/601 ## Done - add a `onDbEvent` `Subscription` graphql endpoint to listen to database_event using what we have done with webhooks: - you can subscribe to any `action` (created, updated, ...) for any `objectNameSingular` or a specific `recordId`. Parameters are nullable and treated as wildcards when null. - returns events with following shape ```typescript @Field(() => String) eventId: string; @Field() emittedAt: string; @Field(() => DatabaseEventAction) action: DatabaseEventAction; @Field(() => String) objectNameSingular: string; @Field(() => GraphQLJSON) record: ObjectRecord; @Field(() => [String], { nullable: true }) updatedFields?: string[]; ``` - front provide a componentEffect `<ListenRecordUpdatesEffect />` that listen for an `objectNameSingular`, a `recordId` and a list of `listenedFields`. It subscribes to record updates and updates its apollo cached value for specified `listenedFields` - subscription is protected with credentials ## Result Here is an application with `workflowRun` https://github.com/user-attachments/assets/c964d857-3b54-495f-bf14-587ba26c5a8c --------- Co-authored-by: prastoin <paul@twenty.com>
This commit is contained in:
33
yarn.lock
33
yarn.lock
@ -36139,6 +36139,20 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"graphql-redis-subscriptions@npm:^2.7.0":
|
||||
version: 2.7.0
|
||||
resolution: "graphql-redis-subscriptions@npm:2.7.0"
|
||||
dependencies:
|
||||
ioredis: "npm:^5.3.2"
|
||||
peerDependencies:
|
||||
graphql-subscriptions: ^1.0.0 || ^2.0.0 || ^3.0.0
|
||||
dependenciesMeta:
|
||||
ioredis:
|
||||
optional: true
|
||||
checksum: 10c0/f98e9a16aa60d5470f6916f5a85b0b91898e3ec341a70ae3ddac878aa5b415dae9081ba872afdab5873cef3933fde1c3f1ee690ffa6d5b6d164a9165aed5cad1
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"graphql-request@npm:^6.0.0":
|
||||
version: 6.1.0
|
||||
resolution: "graphql-request@npm:6.1.0"
|
||||
@ -36177,6 +36191,15 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"graphql-sse@npm:^2.5.4":
|
||||
version: 2.5.4
|
||||
resolution: "graphql-sse@npm:2.5.4"
|
||||
peerDependencies:
|
||||
graphql: ">=0.11 <=16"
|
||||
checksum: 10c0/b2635a4098b86492ecb04e7aab7efb715847ad11b785591cf90cf1f342ba78a03db0c6cf903975a7ad9e2c278dee55cd9e2e9d7edb560f334528bb8ee926ed95
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"graphql-subscriptions@npm:2.0.0":
|
||||
version: 2.0.0
|
||||
resolution: "graphql-subscriptions@npm:2.0.0"
|
||||
@ -38133,9 +38156,9 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ioredis@npm:^5.4.1":
|
||||
version: 5.4.2
|
||||
resolution: "ioredis@npm:5.4.2"
|
||||
"ioredis@npm:^5.4.1, ioredis@npm:^5.6.0":
|
||||
version: 5.6.0
|
||||
resolution: "ioredis@npm:5.6.0"
|
||||
dependencies:
|
||||
"@ioredis/commands": "npm:^1.1.1"
|
||||
cluster-key-slot: "npm:^1.1.0"
|
||||
@ -38146,7 +38169,7 @@ __metadata:
|
||||
redis-errors: "npm:^1.2.0"
|
||||
redis-parser: "npm:^3.0.0"
|
||||
standard-as-callback: "npm:^2.1.0"
|
||||
checksum: 10c0/e59d2cceb43ed74b487d7b50fa91b93246e734e5d4835c7e62f64e44da072f12ab43b044248012e6f8b76c61a7c091a2388caad50e8ad69a8ce5515a730b23b8
|
||||
checksum: 10c0/a885e5146640fc448706871290ef424ffa39af561f7ee3cf1590085209a509f85e99082bdaaf3cd32fa66758aea3fc2055d1109648ddca96fac4944bf2092c30
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@ -55380,7 +55403,9 @@ __metadata:
|
||||
graphql-fields: "npm:^2.0.3"
|
||||
graphql-middleware: "npm:^6.1.35"
|
||||
graphql-rate-limit: "npm:^3.3.0"
|
||||
graphql-redis-subscriptions: "npm:^2.7.0"
|
||||
graphql-scalars: "npm:^1.23.0"
|
||||
graphql-sse: "npm:^2.5.4"
|
||||
graphql-subscriptions: "npm:2.0.0"
|
||||
graphql-tag: "npm:^2.12.6"
|
||||
graphql-type-json: "npm:^0.3.2"
|
||||
|
||||
Reference in New Issue
Block a user