0
votes

I have an issue with a manual call of 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:

{ name: 'fsgd1',

 fb: 'jgjhgf',

 web: 'kljh',

 city: 'jk',

 entityGroupId: 5bcf7ca2cd38080750b609f1 } }  but with newArgs it fails:  { record: { name: 'fsgd1', entityGroupId:

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

For a myterious reaon, passing a modified args parameter works

    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

1

1 Answers

0
votes

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)

I must correct it this way: - await createEntityResolver.resolve({source, newAargs, context, info}) + await createEntityResolver.resolve({source, args: newArgs, context, info})