moleculerjs / moleculer-apollo-server

:rocket: Apollo GraphQL server for Moleculer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

can i get requested fields in resolve

sunhaolin opened this issue · comments

I found a npm package graphql-parse-resolve-info to parses a GraphQLResolveInfo object into a tree of the fields.

May be in createActionResolver method , add resolveInfo as the fourth param behind root, args, context,

createActionResolver(actionName, def = {}) {
const {
dataLoader: useDataLoader = false,
nullIfError = false,
params: staticParams = {},
rootParams = {},
fileUploadArg = null,
} = def;
const rootKeys = Object.keys(rootParams);
return async (root, args, context) => {

And then passed as meta to action, return await context.ctx.call(actionName, mergedParams, { meta: { resolveInfo } });

return await context.ctx.call(actionName, mergedParams);

@sunhaolin Since createActionResolver is a mixin method, you can provide your own definition and behavior for what it does. essentially you can override it to have the implementation you are looking for without a need to modify moleculer-apollo-server. Please try that out and see if it works for you.

@shawnmcknight works fine, thank you very mach!