Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolver pipeline auth function override generates duplicate #9913

Closed
5 tasks done
rezab777 opened this issue Mar 4, 2022 · 2 comments
Closed
5 tasks done

Resolver pipeline auth function override generates duplicate #9913

rezab777 opened this issue Mar 4, 2022 · 2 comments
Labels
bug Something isn't working duplicate If marked with duplicate, issue will be closed & original will be added for traceability graphql-transformer-v2 Issue related to GraphQL Transformer v2 p2

Comments

@rezab777
Copy link

rezab777 commented Mar 4, 2022

Before opening, please confirm:

  • I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
  • I have searched for duplicate or closed issues.
  • I have read the guide for submitting bug reports.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.

How did you install the Amplify CLI?

No response

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

No response

Amplify CLI Version

7.6.20

What operating system are you using?

Windows

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

No manual changes made.

Amplify Categories

api

Amplify Commands

Not applicable

Describe the bug

Instead of a pipeline resolver function being overwritten, it is duplicated in the pipeline.

For example, an autogenerated pipeline resolver for getEmployee with authentication has 4 main functions in the AppSync console:

QuerygetEmployeepreAuth0Function
QuerygetEmployeeauth0Function
QuerygetEmployeepostAuth0Function
QueryGetEmployeeDataResolverFn

These correspond to below generated functions in the /build directory locally:

Query.getAnimal.preAuth.1.req.vtl
Query.getAnimal.auth.1.req.vtl
Query.getAnimal.postAuth.1.req.vtl
Query.getAnimal.req.vtl
Query.getAnimal.res.vtl

When trying to override any of the auth functions, for example, Query.getAnimal.auth.1.req.vtl, the function is successfully overwritten, but another function called QuerygetEmployeeauth1Function is also generated and is added to the pipeline. So after overriding QuerygetEmployeeauth0Function, the pipeline will have 5 functions now:

QuerygetEmployeepreAuth0Function
QuerygetEmployeeauth0Function
QuerygetEmployeeauth1Function
QuerygetEmployeepostAuth0Function
QueryGetEmployeeDataResolverFn

The same behaviour does not happen when overriding any of the data resolver function request or response templates (QueryGetEmployeeDataResolverFn). Meaning, no duplicates are created.

Why is an auth1 function created when overriding the auth function ?

Expected behavior

When overriding an auth0 resolver, no duplicate function called auth1 should be created.

Reproduction steps

  1. Create AppSync API with a model based on the schema provided.
  2. Try to override the auth function with your own custom function.
  3. You will observe a duplicate function with a different name in the pipeline resolver.

GraphQL schema(s)

# Put schemas below this line
type Employee
  @model
  @auth(
    rules: [
      { allow: custom }
      { allow: owner }
      { allow: groups, groups: ["Admin"] }
      { allow: public, provider: iam }
    ]
  ) {
  # Reference Fields
  id: ID! @primaryKey
  owner: ID!
  employee_type: String
}

Log output

# Put your logs below this line


Additional information

No response

@rezab777 rezab777 changed the title Resolver function override Resolver function override generates duplicate Mar 4, 2022
@rezab777 rezab777 changed the title Resolver function override generates duplicate Resolver auth function override generates duplicate Mar 4, 2022
@rezab777 rezab777 changed the title Resolver auth function override generates duplicate Resolver pipeline auth function override generates duplicate Mar 4, 2022
@rezab777
Copy link
Author

rezab777 commented Mar 4, 2022

I believe this is a duplicate of this issue.
Any estimate on the timeline for a fix ? This is quite a critical bug.

@marcvberg marcvberg added the graphql-transformer-v2 Issue related to GraphQL Transformer v2 label Mar 7, 2022
@josefaidt josefaidt added bug Something isn't working duplicate If marked with duplicate, issue will be closed & original will be added for traceability p2 labels Mar 9, 2022
@rezab777 rezab777 closed this as completed Apr 7, 2022
@charlieforward9
Copy link

charlieforward9 commented Mar 15, 2024

To clarify, if I edit the files in amplify/backend/api/<app-name>/build/resolvers and run amplify push, will it permanently update the resolvers in the cloud?

or do I need to copy the resolvers into the amplify/backend/api/<app-name>/resolvers folder?

I need to modify ALL of my auth resolvers to allow access to sample data by initializing the authFilter array with an {contains: "ALL"}, in order to search owners for "ALL" when using UserPools auth strategy.

what is the best way to modify all of my Auth VTL?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate If marked with duplicate, issue will be closed & original will be added for traceability graphql-transformer-v2 Issue related to GraphQL Transformer v2 p2
Projects
None yet
Development

No branches or pull requests

4 participants