Skip to content
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

TS warning for "enabled" as Ref #1491

Closed
tsiotska opened this issue Jul 16, 2023 · 4 comments
Closed

TS warning for "enabled" as Ref #1491

tsiotska opened this issue Jul 16, 2023 · 4 comments

Comments

@tsiotska
Copy link
Contributor

tsiotska commented Jul 16, 2023

Describe the bug
TS warning is shown if you use "enabled" option as Ref

Unexpected number of arguments

image

const isAdmin = computed(() => store.user.state.userRoles.includes("admin"))
useQuery(USERS_QUERY, { variables }, () => ({ enabled: isAdmin }))
@stephenjason89
Copy link

stephenjason89 commented Jul 24, 2023

I was about to create the same issue.
as of the moment (4.0.0 beta8) the useQuery declaration file says it should be boolean
image

However, the type should be a Ref

as mentioned in the docs
image

@kylekz
Copy link

kylekz commented Jul 25, 2023

Does enabled even work? Any query I explicitly disable still executes.

  const enableQuery = ref(false);
  const { onResult } = useQuery<{ someData: SomeData[] }>(
    SomeQuery,
    () => ({
      someParam: someRef.value,
    }),
    () => ({ enabled: enableQuery })
  );

@stephenjason89
Copy link

It works, don't make it a function

const enableQuery = ref(false);
  const { onResult } = useQuery<{ someData: SomeData[] }>(
    SomeQuery,
    () => ({
      someParam: someRef.value,
    }),
    { enabled: enableQuery }
  );

@tsiotska
Copy link
Contributor Author

I have opened the PR for this. "Enabled" works as expected when assigning Ref or Boolean, but to remove warning i just extended missing type.
https://github.com/vuejs/apollo/pull/1492/files#diff-6bc7e9678664512fca6286f9a45bc6bdb7f3e02b733c2954ff1fb8210e2f87deR43

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

No branches or pull requests

3 participants