Skip to content

feat: add query.argument#15572

Closed
elliott-with-the-longest-name-on-github wants to merge 2 commits into
elliott/rework-overridesfrom
elliott/add-query-dot-argument
Closed

feat: add query.argument#15572
elliott-with-the-longest-name-on-github wants to merge 2 commits into
elliott/rework-overridesfrom
elliott/add-query-dot-argument

Conversation

@elliott-with-the-longest-name-on-github

Copy link
Copy Markdown
Contributor

(stacked on #15562)

Adds query.argument, which you can use to conveniently access the original value this query was called with. This could be useful if the argument is some complicated thing:

const logs = get_data({ ...some complicated set of filters... });

// in an event handler
await push_logs({ entry, update: logs.argument }).with(
  logs.override((old) => [entry, ...logs]);
);

...and your command could look like this:

export const push_logs(Schema, ({ entry, update }) => {
  await push_to_db(entry);
  await get_data(update).refresh();
});

@changeset-bot

changeset-bot Bot commented Mar 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3919219

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svelte-docs-bot

Copy link
Copy Markdown


export type RemoteQuery<T> = RemoteResource<T> & {
export type RemoteQuery<T, Input = unknown> = RemoteResource<T> & {
/** The original argument that was passed to the query before serialization. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Mentioning serialization here feels a bit off-topic, if you weren't part of the epic discussion about how we landed on this design — simpler to just say this I think:

Suggested change
/** The original argument that was passed to the query before serialization. */
/** The argument the query was called with */

export type RemoteQueryFunction<Input, Output> = (
arg: undefined extends Input ? Input | void : Input
) => RemoteQuery<Output>;
) => RemoteQuery<Output, undefined extends Input ? Input | void : Input>;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i get why this was added as a second type argument but it feels a little jarring — can we swap the order?

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