amplify-category-api icon indicating copy to clipboard operation
amplify-category-api copied to clipboard

Unable to override an autogenerated pipeline resolver

Open jguipi opened this issue 1 year ago • 6 comments

How did you install the Amplify CLI?

npm install -g @aws-amplify/cli

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

v22.2.0

Amplify CLI Version

12.12.4

What operating system are you using?

mac os 14.5 (23F79)

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

no manual change were made

Describe the bug

This schema is generating an autogenerated pipeline resolver that I'm unable to override using the amplify/backend/api/myapi/override.ts

schema.graphql

type User
  @model() {
  id: ID!
  firstname: String!
  lastname: String
  Children: [Child]
    @hasMany(indexName: "byUser", fields: ["id"])
}

type Child
  @model() {
  id: ID!
  firstname: String!
  lastname: String!
  userID: ID
    @index(name: "byUser")
  User: User
}

It seems like the key User.Children autogenerate, a resolver that I'm unable to override.

Override.ts

  const getChild = resources.models['Child'];
  const getChild2 = resources.models['User'];

  console.log(getChild)
  const getChildResolvers =
    getChild.resolvers['queryGetChildResolver'].pipelineConfig['functions'];
  getChild.resolvers['queryGetChildResolver'].pipelineConfig = {
    functions: [
      function_1,
      function_2,
      function_3,
      ...getChildResolvers,
    ],
  };

When I log the following, I'm unable to see the autogenerated pipeline resolver in the data structure:

const getChild = resources.models['Child'];
or 
const getChild = resources.models['User'];

On the other hand, when I look at the AWS UI I'm able to see the autogenerated function

Captura de pantalla 2024-07-05 a la(s) 10 43 51 a m Captura de pantalla 2024-07-05 a la(s) 10 43 56 a m
image image

Expected behavior

Being able to override the pipeline resolver that was automatically generated by amplify

Reproduction steps

  1. Add this schema
  2. Push it to amplify
  3. Create an override.ts file and try to override the autogenerated function

Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • [X] I have removed any sensitive information from my code snippets and submission.

jguipi avatar Jul 04 '24 20:07 jguipi