react-native-training/apollo-graphql-mongodb-react-native

Error: message: Unknown operation named null

Closed this issue · 5 comments

Not yet clear what the problem is, but at the end of this tutorial, when I run the GraphQL query...

{
  president(name: "Bill Clinton") {
    name
    term
    party
  }
}

I'm getting this error response, sometimes after a significant lag where all I see is a spinner.

 {
  "errors": [
    {
      "message": "Unknown operation named \"null\"."
    }
  ]
}

I've copy/pasted the code for each file to ensure I didn't inadvertently add a typo.

May have something to do with the Mongoose setup because this line is never executed. I verified that d and president variables contain the proper data, but it's not saving. I tried modifying the function as follows but nothing.

      data.forEach((d) => {
        const president = new President(d);
        president.save((err, item) => {
          if(!err){
            console.log('saved:', item);
          }else{
            console.log('errored', err);
          }
        });
      });

Hmm, if you clone the repo does it give you the same error? @geirman

not sure why I didn't notice this before... just not paying close enough attention I guess. I'll use the excuse that it was the end of the day too. Ha! But I get the same results when cloning the repo. After I run node app.js I get this error...

UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: failed to connect to server [localhost:27017] on first connect

once I got my mongodb instance running, I was good to go.

BTW, you might want to add something about ensuring you have mongodb running to your setup.

Oh wow I thought it was in there, nice catch! I'm updating now..