aws-amplify / amplify-category-api

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development. This plugin provides functionality for the API category, allowing for the creation and management of GraphQL and REST based backends for your amplify project.
https://docs.amplify.aws/
Apache License 2.0
89 stars 77 forks source link

Problems with overriders in api with release 8.1.0 #35

Closed eliecer2000 closed 2 years ago

eliecer2000 commented 2 years ago

Before opening, please confirm:

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

v16.14.0

Amplify CLI Version

8.1.0

What operating system are you using?

Ubuntu

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

When I try to push

Amplify Categories

api

Amplify Commands

push

Describe the bug

Today I updated the amplify cli from version 8.0.3 to version 8.1.0.

Since then my project is giving errors when doing push, because it is not ordering well the pipeline fuctions of my api. I use custom vtl as the documentation says in this link https://docs.amplify.aws/cli/graphql/custom-business-logic/#extend-amplify-generated-resolvers, it worked great until I updated, the new version does not order correctly the sequence of the slot preDataLoad.

I have already downgraded the CLI to 8.0.3 and it is working great again.

Thank you.

Expected behavior

in my overrider I replace the dataSourceName

Reproduction steps

1.- amplify push

GraphQL schema(s)

```graphql # Put schemas below this line ```

Log output

``` # Put your logs below this line ```

Additional information

No response

ykethan commented 2 years ago

Hello @eliecer2000, Thank you for reaching out. I replicated the use case in my amplify application utilizing the following.

  1. install amplify 8.0.3
  2. Added resolvers to / api/<api name>/resolvers folder.

image

  1. amplify push
  2. install amplify 8.1.0
  3. added additional resolves to the folder.
  4. amplify push

observed the following output: image in my console I observed the output was created in a order.

In order to further dive deeper into the issue, could you please provide us a screenshot or examples of the vtl files currently being added to the resolver folder.

ykethan commented 2 years ago

Hello @eliecer2000 , following up to see if you are still experiencing this issue.

eliecer2000 commented 2 years ago

I apologize for the delay, of course. I will show you how my pipelineFuctions changes and gives errors when renaming its dataSource, evidently because it does not exist.

In the first image I will show you the pipeline function deployer with version 8.0.3, and in the second image I will show you the result with version 8.2.0 of Amplify CLI.

I hope you can notice the problem. I remain attentive. thanks. Screenshot_147

Amplify CLI Version Screenshot_148

result with version 8.2.0 of Amplify CLI.

Screenshot_149

ykethan commented 2 years ago

Hey @eliecer2000, to better understand the issue please allow me to reiterate the issue.

You are extending a resolver currently named as Query.searchReceivers.preDataLoad.1.req.vtl according to https://docs.amplify.aws/cli/graphql/custom-business-logic/#extend-amplify-generated-resolvers. Then utilizing the amplify api override to add a data source to the resolver. Then push the changes. on migrating to the latest version 8.2.0 and pushing the resolvers you are observing the change in the names. Please let me know if i may have misunderstood anything.

If in case you are using the API override, could you please provide me the code example performing the datasource change. if not, could you please let me know how are you modifying the datasource name. Additionally, could you please let me know on upgrading to a newer version of CLI were any changes made to the vtl template or schema?

eliecer2000 commented 2 years ago

Hello, as you say I am using amplify api override but if you can notice in the images, in the first one there is a resolver with the name QuerysearchCustomerspreDataload0Function what I can easily change its dataSourceName with version 8.0.3 of Amplify CLI, in the second image we can see how the name is changed to QuerylistCustomerspreDataload0Function provoking that my override function fails when running amplify push with version 8.2.0 of amplify CLI.

To get the resulting images I just did the following steps.

amplify --version
8.03
amplify push

amplify upgrade
8.2.0

amplify push

If you wish, I could send you a video with the complete sequence, as I could possibly express the failure in detail, since English is not my native language.

ykethan commented 2 years ago

Hey @eliecer2000, in order to replicate the behaviour it would be great if you could provide us the override.ts file or the code utilized in overriding the dataSourceName, as this will enable me to create the same environment in my Amplify application.

ykethan commented 2 years ago

Hey @eliecer2000 , following up on this to see if you are experiencing any issues.

ykethan commented 2 years ago

Closing the issue due to inactivity. Please do reach out to us again and we would be happy in reopening the issue.

joekiller commented 6 days ago

@eliecer2000, et. al.

I encountered this issue too and finally figured out what is happening.

FYI, I am using an ancient version (on this day of the lord, Oct 15 2024) 12.3.0. It seems that amplify is hashing the VTL templates and then only associating templates that are different to the pipelines. If a template is "the same" as another, you may get functions in a pipeline with a different name than you may expect because of this behavior.

The solution is to ensure that each template does in-fact have different contents.