moleculerjs / moleculer-apollo-server

:rocket: Apollo GraphQL server for Moleculer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can I call service of the normal moleculer api node?

AruXc opened this issue · comments

commented

I have a namespace called api_dev

and normal moleculer can detect moleculer-apollo

const { ServiceBroker } = require("moleculer");
const broker = new ServiceBroker();
module.exports = {
	name: 'greeter',

	actions: {
		hello: {
			graphql: {
				query: 'hello: String'
			},
			async handler(ctx) {
				const res = await broker.call('test.hello');
				console.log('User: ', res);
				return 'Hello Moleculer!';
			}
		},
...

am I wrong? nice to have a example thanks

 {
      "message": "Service 'test.hello' is not found.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "hello"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "code": 404,
          "type": "SERVICE_NOT_FOUND",
          "data": {
            "action": "test.hello"
          },
          "retryable": true,
          "ctx": null,
          "stacktrace": [
            "ServiceNotFoundError: Service 'test.hello' is not found.",
            "    at ServiceBroker.findNextActionEndpoint (/Users/aru/Desktop/WanFang/onecare_server/node_modules/moleculer/src/service-broker.js:849:13)",

Your broker same to be alone, with only the "gretter" service. (Line 2: const broker = new ServiceBroker();)
No transporter seem configured (Do you use env variables for that ?)

commented

I used TCP transporter transporter: 'TCP' in moleculer.config.js

and I set the options to the broker

const broker = new ServiceBroker({
	nodeID: 'dev_aru',
	namespace: "oneapi_dev",
        transporter: 'TCP',
        logLevel: 'debug',
        requestTimeout: 5 * 1000
})

apollo Node onecare_aru

[2019-10-25T17:54:36.651Z] INFO  onecare_aru/API:    Call custom function in '     * /graphql => <Function>' alias
[2019-10-25T17:54:36.654Z] WARN  dev_aru/BROKER: Service 'test.helloTest' is not registered.

node dev_aru

[2019-10-25T17:53:10.959Z] INFO  dev_aru/REGISTRY: Node 'onecare_aru' reconnected.

still no work

btw can I use api/$node/list to find node list which in the moleculer?