Skip to content

query function is always evaluated when the component is created, even if skip function returns true #122

Closed
@rDr4g0n

Description

@rDr4g0n

I have a query function that accesses a prop on my component that is not available in my component at mount (it is populated from an async request). I created a skip function that returns true when that prop is not yet set, expecting this to prevent the query function from being evaluated till it is ready.

However, the query function is always evaluated at least once before the skip function is evaluated. It looks like the query callback is always called during construction, before the skip function is evaluated: https://github.com/Akryum/vue-apollo/blob/master/src/smart-apollo.js#L19

In fact, simply setting skip to true is not sufficient to prevent query from being called at least once.

Ideally the query function would only be evaluated after skip has been verified to be set to (or evaluate to) false.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions