Skip to content

onServerPrefetch warning #1333

@j-waters

Description

@j-waters

Describe the bug
When using useQuery outside of setup, the following error is produced:

[Vue warn]: onServerPrefetch is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup(). If you are using async setup(), make sure to register lifecycle hooks before the first await statement.

To Reproduce
Make a query outside of setup:

provideApolloClient(apolloClient);
const { result } = useQuery(...)

Expected behavior
Ideally, the warning shouldn't be produced, or there should be a way of disabling server prefetching if we're not using SSR

Versions
vue: ^3.2.25
vue-apollo: ^4.0.0-alpha.16
@apollo/client: ^3.5.8

Additional context
Line that produces the error: https://github.com/vuejs/apollo/blob/v4/packages/vue-apollo-composable/src/useQuery.ts#L174

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions