-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to pass CallOptions #516
Comments
Changing this option to callOption and passing callotpion here from all places which use this would solve this issue. |
We didn't expose call options intentionally because it can be a little tricky to also track those options with the query key (if the call option changes, making sure it also triggers a query, etc). Is there a specific call option you are trying to pass? |
@paul-sachs I am trying to pass contextValues from callOption. |
So contextValues is one of those things that's hard to track in a querykey since there's currently no way to expose all the values set, and I'm not sure we'd want to trigger a fetch on anytime those context values change. It might help to identify exactly how you're using context to identify a good way we can build context support into connect-query without breaking the reactivity model.
|
Do interceptors in the web set this context and should that trigger additional fetches? |
Hmm I think I understand. We can pass through context values but being responsive to their changes is a little tricky. You can create your own implementation of ContextValues that is perhaps backed by a signals implementation like preact/signals but we'd still need a way to modify the connect-query key to include those values, and ideally, a way to filter those down to only include the keys you actually use in the query. I'm thinking this could look something like this: // A hypothetical API
import { createContextKey, useContextValues } from "some-package";
import { useQuery } from "@connectrpc/connect-query";
const kLogBody = createContextKey<boolean>(false, {
description: "Log request/response body",
});
const SomeComponent = () => {
const ctxValues = useContextValues([kLogBody]);
const someQuery = useQuery(schema, undefined, { contextValues: ctxValues });
...
} The above API is purely hypothetical and relies on the relatively new concept of reactive signals but would be compatible with the We'll need to do some investigation to figure out how can break this up into pieces and ideally not absorb a new dependency (like signals). |
I am using multiple interceptors on my transport that take calloption and perform certain actions.
When using a client created from createClient we can pass calloptions to the methods. But I didnot find any option to pass calloption when using connect-query. It would be nice to have this feature.
The text was updated successfully, but these errors were encountered: