Skip to content

FeathersVuexGet component doesn't work with params #603

Open
@gmercey

Description

@gmercey

Steps to reproduce

<template>
  <FeathersVuexGet
    v-slot="{ item: user }"
    service="users"
    :id="id"
    :fetch-params="{ query : { $eager: '[profile]' } }"
  >
     <pre> {{ user }} </pre>
  </FeathersVuexGet>
</template>

...

id: 42

Expected behavior

User object with nested profile object

Actual behavior

User object is empty.
The component works fine without params.
The query return the expected results without the component.

The issue is how the component use the store getters. According to the documentation fetchParams is only used for the API for the API server, and the component should only use the resource id on the store getters. But currently, params and fetchParams are used in the same way:

getArgs(queryToUse) {
const query = queryToUse || this.fetchQuery || this.query
const params = this.fetchParams || this.params

Because the params are passed to the store getters, the store returns null.

const getArgs = this.getArgs(this.query)
if (this.id) {
if (getArgs.length === 1) {
return this.$store.getters[`${this.service}/get`](this.id) || null
} else {
const args = [this.id]
const query = getArgs[1].query
if (query) {
args.push(query)
}
return this.$store.getters[`${this.service}/get`](args) || null

getArgs return [0: 42, 1: { query : { $eager: '[profile]' }}] and the query is passed as args to the store getters.

Replacing

return this.$store.getters['${this.service}/get'](args) || null

by

return this.$store.getters['${this.service}/get'](this.id) || null

produce the expected results confirming the issue.

System configuration

Latest version of the package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions