Skip to content

Add docs for kit-operations - #17

Open
streusselhirni wants to merge 14 commits into
mainfrom
nh-docs-operations
Open

streusselhirni wants to merge 14 commits into
mainfrom
nh-docs-operations

Conversation

@streusselhirni

@streusselhirni streusselhirni commented Sep 4, 2026

Copy link
Copy Markdown

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-operations and export appendQueryParams

Changes since #17 opened

  • Clarified mutation body handling and parameter reactivity behavior in kit-operations [b43a9d1]
  • Clarified query and mutation configuration behavior including queryKey, queryFn, and enabled properties [b43a9d1]
  • Clarified resource tracking behavior for endpoints in kit-operations [b43a9d1]
  • Refined documentation of SSR transport context, error behavior, and query parameter handling [b43a9d1]
  • Clarified headers override behavior and composition patterns [b43a9d1]
  • Documented guidance for calling endpoints outside setup() and using sentinel values for header omission [b43a9d1]
  • Clarified type-only declaration behavior in kit-operations [b43a9d1]

Macroscope summarized 8646a4d.

Comment thread packages/operations/docs/index.md
Comment thread packages/operations/docs/index.md Outdated
Comment thread packages/operations/docs/index.md Outdated
@alpoxo

alpoxo commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

I think it would be good to describe in separate sections:

  • How to set it up (piece by piece)
  • All the different invalidation mechanisms / variants, maybe as one single code-block. E.g. now invalidateQueries and invalidateResources are spread through multiple sections and the invalidateQueries variant with an $invalidateKey used as a function is not yet documented

Comment thread packages/operations/docs/index.md Outdated
bracket notation API Platform filters expect is a backend-specific concern:

```ts
function appendQueryParams(url: string, queryParams?: Record<string, unknown>): string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this has to be part of the documentation, as it is not part of the library itself.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is this important, we should either integrate it in the library or put it elsewhere where we can refer to it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, included the appendQueryParam function as it's own export in the package.

Comment thread packages/operations/docs/index.md Outdated
))
```

For `useQueries`, run each entry through `toLossyQueryOptions`. It does nothing at runtime and only

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made docs clearer on this

update: mutation<Project, ProjectInput>()
.url('/api/projects/:id')
.build(() => ({
options: { method: 'PATCH' },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalidation can be put here through onSuccess.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Comment thread packages/operations/docs/index.md Outdated
Comment thread packages/operations/docs/index.md Outdated
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.
Comment thread packages/operations/docs/index.md Outdated
Comment thread packages/operations/docs/setup.md Outdated
Comment thread packages/operations/docs/index.md Outdated
Comment thread packages/operations/src/queryParams.ts Outdated
Comment thread packages/operations/docs/index.md Outdated
Comment thread packages/operations/src/queryParams.ts Outdated
Comment thread packages/operations/docs/index.md
Comment thread packages/operations/docs/index.md
Comment thread packages/operations/docs/index.md
update: mutation<Project, ProjectInput>()
.url('/api/projects/:id')
.build(() => ({
options: { method: 'PATCH' },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This page wires the Vue app? Nice, nothing more to do then :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants