twenty/packages/twenty-server
Charles Bochet 02673a82af
Feat/put target object identifier on use activities (#4682)
When writing to the normalized cache (record), it's crucial to use _refs
for relationships to avoid many problems. Essentially, we only deal with
level 0 and generate all fields to be comfortable with their defaults.

When writing in queries (which should be very rare, the only cases are
prefetch and the case of activities due to the nested query; I've
reduced this to a single file for activities
usePrepareFindManyActivitiesQuery 🙂), it's important to use queryFields
to avoid bugs. I've implemented them on the side of query generation and
record generation.

When doing an updateOne / createOne, etc., it's necessary to distinguish
between optimistic writing (which we actually want to do with _refs) and
the server response without refs. This allows for a clean write in the
optimistic cache without worrying about nesting (as the first point).

To simplify the whole activities part, write to the normalized cache
first. Then, base queries on it in an idempotent manner. This way,
there's no need to worry about the current page or action. The
normalized cache is up-to-date, so I update the queries. Same idea as
for optimisticEffects, actually.

Finally, I've triggered optimisticEffects rather than the manual update
of many queries.

---------

Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
2024-04-01 13:12:37 +02:00
..
@types feat: standard fields on custom (#4332) 2024-03-07 17:21:50 +01:00
patches feat: wip server folder structure (#4573) 2024-03-20 16:23:46 +01:00
scripts Update yarn commands (#4644) 2024-03-25 12:31:18 +01:00
src Feat/put target object identifier on use activities (#4682) 2024-04-01 13:12:37 +02:00
test feat: refactor folder structure (#4498) 2024-03-15 14:40:58 +01:00
.env.example feat: Oauth with PKCE (#4648) 2024-03-27 21:18:07 +01:00
.env.test File token chores (#4664) 2024-03-26 13:42:09 +01:00
.eslintrc.js Migrate to a monorepo structure (#2909) 2023-12-10 18:10:54 +01:00
.gitignore feat: workspace:health nullable fix (#3882) 2024-02-08 18:22:29 +01:00
.prettierignore Migrate to a monorepo structure (#2909) 2023-12-10 18:10:54 +01:00
.prettierrc Migrate to a monorepo structure (#2909) 2023-12-10 18:10:54 +01:00
jest.config.ts Refactor backend folder structure (#4505) 2024-03-15 18:37:09 +01:00
nest-cli.json Migrate to a monorepo structure (#2909) 2023-12-10 18:10:54 +01:00
package.json Update yarn commands (#4644) 2024-03-25 12:31:18 +01:00
project.json Update yarn commands (#4644) 2024-03-25 12:31:18 +01:00
tsconfig.build.json chore: set up twenty-emails config so build isn't needed in development (#3619) 2024-01-29 06:17:12 -03:00
tsconfig.json 4586 fix workspace member feature (#4680) 2024-03-28 17:59:48 +01:00