Add docs for kit-operations - #17
streusselhirni wants to merge 14 commits into
Conversation
|
I think it would be good to describe in separate sections:
|
| bracket notation API Platform filters expect is a backend-specific concern: | ||
|
|
||
| ```ts | ||
| function appendQueryParams(url: string, queryParams?: Record<string, unknown>): string { |
There was a problem hiding this comment.
I don't think this has to be part of the documentation, as it is not part of the library itself.
There was a problem hiding this comment.
On one hand, I agree. On the other, it's a helper function I expect nearly everybody to use and it's kind of important for the code example above. I didn't like just using it and then writing "Please provide the appendQueryParams function yourself" without giving an example.
There was a problem hiding this comment.
If it is this important, we should either integrate it in the library or put it elsewhere where we can refer to it.
There was a problem hiding this comment.
As discussed, included the appendQueryParam function as it's own export in the package.
| )) | ||
| ``` | ||
|
|
||
| For `useQueries`, run each entry through `toLossyQueryOptions`. It does nothing at runtime and only |
There was a problem hiding this comment.
toLossyQueryOptions should be used in any case where covariance is needed as useQuery in general has type definitions enforcing invariance in many cases where it shouldn't be necessary.
There was a problem hiding this comment.
Made docs clearer on this
| update: mutation<Project, ProjectInput>() | ||
| .url('/api/projects/:id') | ||
| .build(() => ({ | ||
| options: { method: 'PATCH' }, |
There was a problem hiding this comment.
Invalidation can be put here through onSuccess.
There was a problem hiding this comment.
It would be better to only invalidate the specific resource with its id and not all projects - unless the intent is to also refetch the list - in which case it may make more sense to in addition invalidate the specific list endpoint.
Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com>
Gather every invalidation variant into one code block: the `$invalidateKey` levels for tree, branch, endpoint and single call, and the `invalidateResources` forms for a type, an instance and several at once. The endpoint- and call-level keys were undocumented so far. Carry the invalidation in the quick start's update endpoint, so the example shows an operation that owns its own invalidation rules. Also adds the setup walkthrough and the note on loosening the option types.
| update: mutation<Project, ProjectInput>() | ||
| .url('/api/projects/:id') | ||
| .build(() => ({ | ||
| options: { method: 'PATCH' }, |
There was a problem hiding this comment.
It would be better to only invalidate the specific resource with its id and not all projects - unless the intent is to also refetch the list - in which case it may make more sense to in addition invalidate the specific list endpoint.
| @@ -0,0 +1,382 @@ | |||
| # Setup | |||
|
|
|||
| This page wires the package into an existing Vue app, end to end. The package has no configuration | |||
There was a problem hiding this comment.
This page wires the Vue app? Nice, nothing more to do then :D
Adding documentation for
@teamnovu/kit-operations.The docs focus on how to use the package. They don't explain the internal workings of the package.
Disclaimer: Claude assistet in making sure all relevant features are mentioned in the documentation and helped with code examples and some formulations. The full text and all code examples has been proof-read and checked by myself.
Note
Add docs for
@teamnovu/kit-operationsand exportappendQueryParams@teamnovu/kit-operationsin packages/operations/docs/.appendQueryParamsandtoQueryParamEntriesin packages/operations/src/queryParams.ts to serialize query parameters into API Platform bracket notation.appendQueryParamsas a new top-level export in packages/operations/src/index.ts.Changes since #17 opened
kit-operations[b43a9d1]queryKey,queryFn, andenabledproperties [b43a9d1]kit-operations[b43a9d1]setup()and using sentinel values for header omission [b43a9d1]kit-operations[b43a9d1]Macroscope summarized 8646a4d.