feat(gen2-migration): add extended resolvers to product catalog app (DO NOT MERGE TILL KIRO IMPLEMENTS FUNCTIONALITY)#14645
Draft
dgandhi62 wants to merge 15 commits intogen2-migrationfrom
Draft
feat(gen2-migration): add extended resolvers to product catalog app (DO NOT MERGE TILL KIRO IMPLEMENTS FUNCTIONALITY)#14645dgandhi62 wants to merge 15 commits intogen2-migrationfrom
dgandhi62 wants to merge 15 commits intogen2-migrationfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Extended resolvers are functions which we can place at locations within a pipeline resolver. Documentation for the slots to place a function in Amplify gen1 can be found here.
By default, Amplify generates these resolvers:
Example: getProducts
Note: The above are the functions inside a default resolver. They also may differ from resolver to resolver. For example,
Example: listUsers
As you can see, the default resolvers tend to follow a pattern of placing them within the slots auth0, postAuth0, DataResolver. Furthermore, the only default resolver with a data source is the DataResolverFn.
Example: listUsers
Function: QueryListUsersDataResolverFn
Data Source: UserTable
Function: QuerygetUserauth0Function
Data Source: NONE_DS
Furthermore, any new extended functions added in Amplify Gen1 also have a data source of NONE_DS.
EXAMPLE MIGRATION
Gen1 app product catalog
The following resolver functions are placed inside the resolvers/ directory.
Query.listProducts.postDataLoad.1.res.vtlQuery.listProducts.postAuth.2.req.vtl{}Query.listProducts.postAuth.3.res.vtlPost
generate, the resolvers/ directory is copy pasted underamplify/data/which has the same vtl files as gen1 (no change). Inbackend.ts, the following code needs to be generatedamplify/backend.tsNote
Identifying the correct slot order to place the new functions in is crucial.
existingFunctionscontains the default functions in that resolver and we need to generate indexing according to it. Importantly, refer to the table here for determining the correct indexes. The indexes are also dynamic. By usingsplice, we are inserting it at the said index. That means that all the functions of it get shifted by +1. This needs to be taken into consideration.Assumptions to take note of