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

FeathersVuexGet component doesn't work with params #603

Open
gmercey opened this issue Jun 11, 2021 · 1 comment · May be fixed by #627
Open

FeathersVuexGet component doesn't work with params #603

gmercey opened this issue Jun 11, 2021 · 1 comment · May be fixed by #627
Labels

Comments

@gmercey
Copy link

gmercey commented Jun 11, 2021

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.

@marshallswain
Copy link
Member

Oh, good point! If you want to make a PR to separate them, I'll accept it. I don't have the ability to focus on this right now.

Thanks for the excellent bug report.

gmercey added a commit to gmercey/feathers-vuex that referenced this issue Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants