Open go4cas opened 6 years ago
Okay, I have figured it out.
Simple solution: call the gateway, as opposed to the entity services:
Use call gateway.graphql --query "{authors {name id books{title year authorId id}}}"
Not call author.graphql --query "{authors {name id books{title year authorId id}}}"
By the way, I realized that the latest master
code has not been published to NPM. I had to clone the moluculer-graphql repo, and add "moleculer-graphql": "file:../moleculer-graphql"
to my package.json
.
@go4cas thanks for the heads up about npm.. I was going crazy wondering why the gateway.graphql call wasn't working. Would be great if an updated release could be made to npm @brad-decker . This module is awesome!
@go4cas and @albert-the-creator -- sorry about that guys will get an updated release out soon. And just to reiterate, the individual graphql actions created on each schema service are intended to be used only by the gateway. The gateway is the only entity on the network that has the "Full view" of the schemas and how they work together.
@brad-decker, thanks for looking into the release. Yes, I fully agree that the gateway should be the only entry point into the schema of the underlying services. It wasn't that clear in the docs, but after a while I figured it out, and things just started working. Really easy, and very powerfull!
@brad-decker, any update on the NPM release? Thanks!
@brad-decker would love to hear about an updated release too. Reads like the current npm version doesn't work as intended (gateway as only entry point)without publishing the fixes.
I have the following models:
Author
Book
Used by the following services:
author.service
book.service
The
GraphQLGateway
is started in the API Gateway:The gateway starts up correctly. When calling one of the services, this works fine:
call author.graphql --query "{authors {name id}}"
But, when including a related entity:
call author.graphql --query "{authors {name id books{title year authorId id}}}"
, the following exception:Cannot query field "books" on type "Author"