Stop Multiple returns from Server after query with Apollo and Angular


Bellow is an example on code I am using to submit data to a server and the return I receive and save

this.apollo.mutate( { mutation: XXXXXXXX, variables: { instance_string: X, 
accesstoken: X } })
   next: (data: any ) => {
     console.log("data returned from Server", data); 
     // This data can be sent from the Server in a loop on occassion
   error: (err) => {

On occasion the Server returns the data in a loop. I have no control of the Server and it appears this will be a reoccurring bug for quite a while. Is there a way that I can can insure the next: only runs once and ignores the Loop of data returns the Server can send.


It looks like you have to use two pipeable operators like take(), filter():

  filter(resp => resp !== undefined && resp !== null),
  take(1) // <--- It will only take one successful valid response

Answered By – Jai

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published