[Content management] client POC#18
[Content management] client POC#18Dosant wants to merge 5 commits intosebelga:content-management/core-server-pocfrom
Conversation
…ga/kibana into content-management/client-poc
…ga/kibana into content-management/client-poc
| import type { ContentTypeDetails } from './types'; | ||
| import { ContentType } from './content_type'; | ||
|
|
||
| export class ContentRegistry { |
There was a problem hiding this comment.
I wonder why we need the registry client side. Couldn't we have this on the server and a method (cached) to fetch once those details from the server?
There was a problem hiding this comment.
Good question. I'll put this question here https://docs.google.com/document/d/13aOspEx_yGcdaRwXZTAOCaiPuAIZlcrkZopvR0cr2_k/edit# and will iterate on it
| import type { SearchIn } from '../../common'; | ||
| import { CreateIn, CreateOut } from '../../common'; | ||
|
|
||
| const contentQueryKeyBuilder = { |
There was a problem hiding this comment.
nit: Can we maybe shorten this to queryKeyBuilder?
| return this.queryClient.fetchQuery(this.contentQueryOptionBuilder.get<ContentItem>(type, id)); | ||
| } | ||
|
|
||
| get$<ContentItem extends object = object>({ type, id }: { type: string; id: string }) { |
There was a problem hiding this comment.
I am not sure I fully understand what those observable version of the method do 😊
There was a problem hiding this comment.
Have you seen https://docs.google.com/document/d/13aOspEx_yGcdaRwXZTAOCaiPuAIZlcrkZopvR0cr2_k/edit#heading=h.oijoa468kc4q ?
The idea is that cache is reactive, so the main way to access data would be through the react hook or RXJS observable. Regular promise based method can be used in the cases where reactivity is not needed
There was a problem hiding this comment.
Ah I see, indeed this is outside React context so we need a way to make it reactive. 👍
|
|
||
| return new Observable<QueryObserverResult<TData, TError>>((subscriber) => { | ||
| const unsubscribe = queryObserver.subscribe( | ||
| // notifyManager is a singleton that batches updates across react query |
There was a problem hiding this comment.
I don't think it is a public api. It is exported from query-core and is used by react (or other libs) implementations. I learned about it from the useQuery hook source
There was a problem hiding this comment.
Ok. Isn't it risky to not use a public api?
| } | ||
|
|
||
| export class ContentManagementPlugin implements Plugin { | ||
| private rpcClient: RpcClient | undefined; |
There was a problem hiding this comment.
We probably don't need this private property anymore

Summary
built on top of wip server POC but with client cache layer
The tech doc for the client-side content service: https://docs.google.com/document/d/13aOspEx_yGcdaRwXZTAOCaiPuAIZlcrkZopvR0cr2_k/edit#
The client POC consists of two independent parts: