egg
egg copied to clipboard
About Middleware of egg-graphql with node
Hello, Egg-graphql
currently support middleware of node solution ? Our node server only make data conversion, and through the Restful API
communication with backend ( java / go .etc ).We want to make a layer of encapsulation in the middleware through egg-graphql
, the backend still maintains the form of Restful API
It's ok, you can put the Restful API in your app.service
, then call them by graphql connector
example
'use strict';
class ArticleConnector {
constructor(ctx) {
this.ctx = ctx;
}
async getArticleInfoByService(iArticleID) {
return await this.ctx.service.article.getArticleByID(iArticleID); // your restful api here
}
}
module.exports = ArticleConnector;
@jtyjty99999
Thx~ In other words, egg-graphql
passes the CRUD
operations to the restful api ?