I'm trying to reject a promise as explained in the documentation of the API of the framework I'm using (Apollo stack) but it doesn't show an example, it only states just that I have to reject the promise if there is an error, and I'm trying to get rid of the annoying YellowBox message "Warning: Possible unhanded promise rejection" when trying my application without an internet connection.
My method actually works, it goes to the catch and it shows the error message, but i keep getting the annoying YellowBox message, that's what I'm trying to fix.
first thing I did, goes to the catch, as expected, but it shows a YellowBox message Warning: Possible unhandled promise rejection...
return client.query({ query: gql`...`, }).then((data) => {
    console.log(data);
    data;
}).catch((error) => {
    console.log(error);
    error;
});
Last thing I've tried:
var promise = new Promise(function(resolve, reject) {
  //async call, client.query(..) "returns a promise that should be rejected
  //if there is an error message..."
  client.query({ query: gql`...`, }).then(({data}) => {
    console.log(data);
    resolve(data);
  }).catch((error) => {
    console.log(error); // goes right here, works.
    reject(error.message);
  });
});
//just trying this out
promise.then((data) => {
  console.log(data);
}).catch((error) => {
  console.log(error); 
});
Also, adding the tag Meteor because couldn't find Apollo but it's pretty much the same thing.
Trying more stuff as suggested in the answers and comments:
var promise = new Promise(function(resolve, reject) {
  client.query({
    query: gql`...`,
  }).then(({data}) => {
    console.log(data);
    resolve(data);
  }).catch((error) => {
    reject(error.message);
  });
}, (error) => {
  console.log(error);
});
another:
var callback = {
  success: function(data) {
    console.log("SUCCESS");
  },
  error: function(data) {
    console.log("ERROR");
  }
};
var promise = new Promise(function(resolve, reject) {
  client.query({
    query: gql`...`,
  }).then(({data}) => {
    console.log(data);
    resolve(data);
  }).catch((error) => {
    console.log(error);
    reject(error.message);
  });
  return promise;
});
promise.then(callback.success, callback.error);
another:
client.query({
  query: gql`...`,
}).then(({data}) => {
  console.log(data);
}, (error) => {
  console.log(error);
});
ApolloStack: http://docs.apollostack.com/apollo-client/network.html it says, that returns a promise that should be rejected if an error occurs.
YellowBox detects unhandled promises and such things and throws warnings.
 
     
    