Avatar of nicolas_maujean

asked on 

how to wait a graphql query is finished using apollo?

I have the following code :

  ngOnInit() {

    this.data = this.apollo.query({ query: ResidentQuery }).subscribe(({data, loading}) => {
      this.data = data;
      this.loading = loading;

    if (!this.loading) {
      // using this.data
I want data to be loaded before processed themm after the (!this.loading). It is not the case as loading is asynchronous. How I can wait the data is loaded before using them ?

I am making a graphql query using apollo client. ResidentQuery is a string containing the graphql query.

Thank you for your feedbacks !
* apolloJavaScript

Avatar of undefined
Last Comment

8/22/2022 - Mon