Amplify-cli: Odd response resolver generated.

Created on 26 Sep 2019  路  4Comments  路  Source: aws-amplify/amplify-cli

Describe the bug
I get this kind of response resolvers for some mutations when I execute amplify push:
image

Mutation successfully updates table. But nested objects which I request in mutation have NULL value.

When I replace response resolver with simple:

$util.toJson($context.result)

the problem dissapears

Also I noticed that when I execute mutation with such resolver, in a CloudWatch I see 2 simultaneous mutations was performed. First one has correct response template mapping, second one with empty result {}.

graphql-transformer pending-response question

All 4 comments

@lenarmazitov The duplication of this set has been fixed in the latest release.
Are you using per-field @auth? If you are this is to protect the subscription which you can read more about here:
https://aws-amplify.github.io/docs/cli-toolchain/graphql#authorizing-subscriptions

@SwaySway
Sorry for closing issue, but bug still exists.

Description
If in response file Mutation.updateUser.res.vtl: we do not have string:

#set( $context.result.operation = "Mutation" )

Screenshot 2019-10-05 at 19 39 25

All works fine.

But if we have

#set( $context.result.operation = "Mutation" )

Then response will be:
Screenshot 2019-10-05 at 19 42 57

In schema I'm using per field @auth directive for field avatar here.

@lenarmazitov That is to protect fields in the subscription as specified in the docs.
If you would like the response in the mutation you can can either subscriptions to either off or public.

type User 
    @model (subscriptions: { level: public  }) # or off
    @auth(rules: []) {
        # user fields
    }

@SwaySway thank you, I just have found it in documentation, sorry for disturbing.

https://aws-amplify.github.io/docs/cli-toolchain/graphql#per-field-with-subscriptions

Was this page helpful?
0 / 5 - 0 ratings