Skip to content

Documentation#49

Merged
stackoverfloweth merged 13 commits intomainfrom
documentation-setup
Oct 7, 2025
Merged

Documentation#49
stackoverfloweth merged 13 commits intomainfrom
documentation-setup

Conversation

@stackoverfloweth
Copy link
Copy Markdown
Contributor

@stackoverfloweth stackoverfloweth commented Jul 23, 2025

added vitepress documentation, readme, as well as some release prep work
most of the actual documentation is authored heavily by Claude, so it'll need some close inspection for accuracy.

Netlify is not yet configured on this project yet, so here's the manual deploy of this branch
https://kitbag-query.netlify.app

@stackoverfloweth stackoverfloweth requested a review from pleek91 July 23, 2025 03:12
@stackoverfloweth stackoverfloweth self-assigned this Jul 23, 2025
@netlify
Copy link
Copy Markdown

netlify bot commented Sep 2, 2025

Deploy Preview for kitbag-query ready!

Name Link
🔨 Latest commit ffff5b5
🔍 Latest deploy log https://app.netlify.com/projects/kitbag-query/deploys/68e477270200eb0008459dc9
😎 Deploy Preview https://deploy-preview-49--kitbag-query.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

stackoverfloweth and others added 2 commits September 22, 2025 22:21
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
| `errored` | `boolean` | Whether the query has encountered an error. |
| `executed` | `boolean` | Whether the query has been executed at least once. |
| `executing` | `boolean` | Whether the query is currently executing. |
| `execute` | `(...args) => Promise<T>` | Function to manually trigger the query. Accepts arguments to use when calling your function, will override arguments supplied when creating the query. |
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 is correct. execute doesn't accept any arguments. Its just a way to trigger the query. Specifically if immediate: false is used.

Copy link
Copy Markdown
Contributor Author

@stackoverfloweth stackoverfloweth Sep 27, 2025

Choose a reason for hiding this comment

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

look like you're right. not sure how I got this mixed up. Not sure it's specifically for immediate: false though. Since execute is on regular query not only useQuery and immediate: boolean is only an option on useQuery

Comment on lines +17 to +25
### Execute

The query includes `execute`, which can be called at any point to force the function to be called again. Execute optionally takes the arguments that match the arguments on the function. If supplied, these arguments will override whatever arguments were supplied when creating the query.

```ts
const messageFeedQuery = query(getMessages, () => null, { immediate: false })

const newMessages = await messageFeedQuery.execute(Date.now())
```
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.

Unless I'm mistake about execute not accepting arguments, this section is incorrect.

Comment on lines +27 to +36
### Awaiting Queries

When creating a query, you have the option of using `await` which changes the `data` attribute from being `T | undefined` to `T` since we can be sure that your function has executed.

```ts
const regularQuery = await query(getMessages, () => Date.now())
// ^? data: Message[] | undefined
const awaitedQuery = await query(getMessages, () => Date.now())
// ^? data: Message[]
```
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.

Probably good to mention that when using async await with queries any errors will be thrown

```ts
const selectedUserId = ref<string | undefined>()

const userQuery = useQuery(fetchUser, () => selectedUserId.value ? [selectedUserId.value] : null)
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.

Chance to encourage more readable code with less turneries.

Suggested change
const userQuery = useQuery(fetchUser, () => selectedUserId.value ? [selectedUserId.value] : null)
const userQuery = useQuery(fetchUser, () => {
if(!selectedUserId.value) {
return null
}
return [selectedUserId.value]
})

Comment on lines +115 to +117
### Delayed execution

Queries will always wait if the parameters aren't ready, but you can also setup a query to always delay execution of the function until you either call `execute()` on the query, or change the reactive parameters argument.
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 needs an example, I think you're talking about immediate: false?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

agreed this was unclear. Should be better with next commit

Comment on lines +131 to +134
// defineQuery - consistent configuration
const { useQuery: useUserQuery } = defineQuery(fetchUser, { staleTime: 60000 })
const user1 = useUserQuery([1]) // Uses predefined staleTime
const user2 = useUserQuery([2]) // Uses predefined staleTime
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 think this is a bit misleading. You can still customize the options when you call the query. defineQuery does two things

  1. pre defines the action
  2. pre defines default options.

But you can override the options when you call the query.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

tbh this was OG Claude code that I forgot to revisit 😅


**Parameters:**
- `key`: Unique identifier for the query
- `fetcher`: Async function that fetches the data
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.

In code we call this the "action". I don't feel strongly about the name. But I'd use action for consistency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll comment this out and revisit in future PR

Comment on lines +31 to +35
function query<TParams extends any[], TData>(
key: string,
fetcher: (...params: TParams) => Promise<TData>,
options?: QueryOptions
): QueryFunction<TParams, TData>
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.

Incorrect example

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll comment this out and revisit in future PR

Comment on lines +141 to +149
// Caching options
defaultStaleTime?: number
defaultCacheTime?: number

// Retry options
defaultRetryCount?: number
defaultRetryDelay?: number | ((attempt: number) => number)

// Other options...
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.

Incorrect types

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll comment this out and revisit in future PR

Comment on lines +167 to +180
## Error Types

### QueryError

Base error class for query-related errors.

```ts
class QueryError extends Error {
readonly name = 'QueryError'
// ... error details
}
```

For more detailed examples and usage patterns, see the [Core Concepts](/core-concepts/query-client) section. No newline at end of file
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.

Hallucination

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'll comment this out and revisit in future PR

Comment on lines +15 to +23
const response = await fetch('/api/users', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(userData)
})

if (!response.ok) throw new Error('Failed to create user')
return response.json()
})
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.

Incorrect example/syntax

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's commented out because I didn't get this far

})
```

You can also setup a query NOT to execute immediately. These queries wait until you either call `execute()`, or change the reactive parameters argument.
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.

Does changing the parameters execute a query that has immediate: false? Feels like it shouldn't.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good catch, I looked again and confirmed in query-preview that you MUST call execute to re-enable a query when immediate is false

@stackoverfloweth stackoverfloweth merged commit 20cb2fb into main Oct 7, 2025
6 checks passed
@stackoverfloweth stackoverfloweth deleted the documentation-setup branch October 7, 2025 02:27
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.

3 participants