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

why does result hook call multiple times? #31

Closed
jumpingfrog0 opened this issue Feb 20, 2017 · 1 comment
Closed

why does result hook call multiple times? #31

jumpingfrog0 opened this issue Feb 20, 2017 · 1 comment
Assignees
Labels

Comments

@jumpingfrog0
Copy link

jumpingfrog0 commented Feb 20, 2017

I found a problem, if request more than one queries, the result hook call multiple times and the response data is messy.

my code:

const categoryQuery = gql`
    query {
      category {
        rows {
          id name icon zindex
        },
        count
      }
    }`;
const cityQuery = gql`
    query {
      city {
        rows {
          id name
        },
        count
      }
    }`;

apollo: {
	getCategories: {
		query() {
			return categoryQuery;
		} ,
		update(data) {
			return data.category.rows;
		},
		result(data) {
                        console.log('****should print categories****')
			console.log(data.category.rows);
		},
		error(error) {
			this.$notify({
				title: '错误',
				message: '获取演出类型列表失败',
				type: 'error'
			});
		}
	},
	getCities: {
		query() {
			return cityQuery;
		} ,
		update(data) {
			return data.city.rows;
		},
		result(data) {
                        console.log('---should print cities---')
			console.log(data.city.rows);
		},
		error(error) {
			this.$notify({
				title: '错误',
				message: '获取城市列表失败',
				type: 'error'
			});
		}
	}
}

But I get the result:

---should print cities---               // correct
["cityA", "cityB", "cityC"]

****should print categories****         // correct
["categoryA", "categoryB", "categoryC", "categoryD"]

---should print cities---               // messy
["categoryA", "categoryB", "categoryC"]

More queries, the data result is more messy.

@Akryum
Copy link
Member

Akryum commented Feb 11, 2018

Please reopen if you still have the issue.

@Akryum Akryum closed this as completed Feb 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants