1

I have this query in GraphIQL (note: Graph I QL). It's giving me an error message regarding a "connector":

query ($userID: String!) {
  getUserData(id: $userID) {
    name_first
    name_last
    picture_thumbnail
    id
}
}

//query variables:
{
  "userID": "DsmkoaYPeAumREsqC"
}

GraphIQL is returning this response:

{
  "data": {
    "getUserData": null
  },
  "errors": [
    {
      "message": "Connector must be a function or an class",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "getUserData"
      ]
    }
  ]
}

Here's my resolver:

getUserData(_, args) {
    debugger;  <== NEVER ACTIVATES
    return Promise.resolve()
        .then(() => {
            console.log('In getUserData');
            var Users = connectors.UserData.findAll({where: args}).then((Users) => Users.map((item) => item.dataValues));
            return Users;
        })
        .then(Users => {
            return Users;
        })
        .catch((err)=> {
            console.log(err);
        });
},

The debugger breakpoint in the resolver never activates.

I don't yet know what GraphIQL means by a "connector". What needs to be changed?

VikR
  • 4,818
  • 8
  • 51
  • 96

1 Answers1

1

Fixed! I had to remove the reference to connectors from my call to makeExecutableSchema, and add it in to:

server.use('/graphql', bodyParser.json(), graphqlExpress({
    schema,
    context: {
        connectors: connectors
    }
}));

Then I could retrieve it in the resolver like so:

getUserData: (root, args, context) => {
    return Promise.resolve()
        .then(() => {
            var Users = context.connectors.UserData.findAll({where: args}).then((Users) => Users.map((item) => item.dataValues));
            return Users;
        })
        .then(Users => {
            return Users;
        })
        .catch((err)=> {
            console.log(err);
        });
},

Thanks to @marcusnielsen on Apollo Slack for the tip that helped me find this!

VikR
  • 4,818
  • 8
  • 51
  • 96