-
-
Notifications
You must be signed in to change notification settings - Fork 522
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
disable calculate variables from reactive function if request is disabled #1243
Comments
I am having the same problem. To work around the problem, I am using the optional chaining (?.) operator to avoid runtime errors and using const { result } = useGetCommitsByBranchQuery(
// @ts-expect-error https://github.com/vuejs/apollo/issues/1243
() => ({
branchId: activeBranch.value?.id,
}),
() => ({
enabled: activeBranch.value !== undefined,
}),
); |
Yeah I just ran into the same problem, is there any other solution from using |
The above solution doesn't work for me - even if we ignore TypeScript. In other words: Assuming that
The above solutions seems not to work and I can only make it work in a very ugly way with |
This has now been partially resolved with a recent Release, probably v4.0.0-beta.1.
and will still execute the query when data.value.id is null. |
This seems to work now on the initial execution of the query (whereas before v4.0.0-beta.1 it did not, but as soon as data.value.id is set from null to a variable like 5, the query still gets executed with data.value.id = null, and then again with data.value.id = 5. |
@yusufkandemir in your code, if you use strict mode (and you should), TypeScript should compain if you don't put the optional chaining operator in the variables function, since |
@Akryum I am already using strict mode, thanks. Semantically I prefer |
Is your feature request related to a problem? Please describe.
I use data from previous request and if i use reactive function, then i have error because my result is empty
i can use (?.) operator, but then my TS interface show me message "variables type error"
Its a good experience for the safety of variables
Describe the solution you'd like
Calculate reactive function only if enabled option is true
Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: