[英]graphql-compose doesn't accept my args in the resolve method
I have an issue with a manual call of Resolver.resolve 我有一个手动调用Resolver.resolve的问题
const createEntityGroupResolver = EntityGroupTC.getResolver('createOne')
const createEntityResolver = EntityTC.getResolver('createOne')
const entityGroupCreate = new Resolver({
name: 'entityGroupCreate',
type: createEntityGroupResolver.type,
args: createEntityGroupResolver.args,
resolve: async ({ source, args, context, info }) => {
const created = (await createEntityGroupResolver.resolve({ source, args, context, info })).record
console.log("created entityGroup : ", created, " from args: ", args)
const newArgs = {record:
{name: args.record.name, entityGroupId:created._id}}
args.record.entityGroupId=created._id
console.log("creating entity from args works: ", args, " but with newArgs it fails: ", newArgs)
await createEntityResolver.resolve({source, newAargs, context, info})
return created
}
});
this code throws the following error: 此代码引发以下错误:
creating entity from args works: { record: 通过args创建实体作品:{记录:
{ name: 'fsgd1', {名称:'fsgd1',
fb: 'jgjhgf', web: 'kljh', city: 'jk', entityGroupId: 5bcf7ca2cd38080750b609f1 } } but with newArgs it fails: { record: { name: 'fsgd1', entityGroupId:
5bcf7ca2cd38080750b609f1 } } 5bcf7ca2cd38080750b609f1}}
graphQl error : Entity.createOne resolver requires at least one value in args.record (node:1872) [DEP0079] DeprecationWarning: Custom inspection function on Objects via .inspect() is deprecated graphQl错误:Entity.createOne解析器需要args.record中的至少一个值(节点:1872)[DEP0079] DeprecationWarning:不建议通过.inspect()对对象进行自定义检查功能
For a myterious reaon, passing a modified args parameter works 对于神秘的原因,传递修改后的args参数是可行的
await createEntityResolver.resolve({source, args, context, info})
return created
I noticed args is logged with line breaks while newArgs is logged inline, I cannot understand why 我注意到args是用换行符记录的,而newArgs是内联记录的,我不明白为什么
As answered by "Pavel Chertorogov" in this post , the issue was that I was missing the argument name that must be args and not newArgs (since I'm passing a map, not calling a function with params) 正如在回答“帕维尔Chertorogov” 这个帖子 ,问题是,我缺少的必须是指定参数和不newArgs(因为我传递一个地图,而不是调用使用参数的函数)参数名称
I must correct it this way: - await createEntityResolver.resolve({source, newAargs, context, info}) + await createEntityResolver.resolve({source, args: newArgs, context, info}) 我必须通过以下方式纠正它:-等待createEntityResolver.resolve({源,newAargs,上下文,信息})+等待createEntityResolver.resolve({源,args:newArgs,上下文,信息})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.