Skip to content

Model's remote method with input works on rest but not graphql #13

@meepeek

Description

@meepeek

This is my SystemUser.js model look like

'use strict';

module.exports = function(Systemuser) {

  Systemuser.test = function(msg, cb) {
    console.log(msg,cb)
    cb(null, 'test ' + msg)
  }
  Systemuser.remoteMethod('test', {
          accepts: {arg: 'msg', type: 'string'},
          returns: {arg: 'test', type: 'string'}
    });

};

calling with rest is perfectly fine but with this graphiql mutation

mutation {
  SystemUserTest(input:{msg:"test"}) {
    obj
    clientMutationId
  }
}

result is as follow

{
  "data": {
    "SystemUserTest": null
  },
  "errors": [
    {
      "message": "cb is not a function",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "SystemUserTest"
      ]
    }
  ]
}

I console.log the cb as I called graphiql query, the result is an accessToken object, instead of callback function.

{ accessToken: { ttl: 1209600,
created: 2018-08-12T16:51:53.682Z,
userId: 5b7045af20ab2b6477ff819a,
id: 'yU5r8BpJhXdSk1x0ey50M3wFzG7Urix9rhMrTxN1LcqEYJaYy1R3anWtp1BLVz6d' } }

How do I return value in remote method to make it works with graphql ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions