aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
185 stars 62 forks source link

[POC] add breakCircularDependency prop to defineFunction #2207

Open rtpascual opened 2 weeks ago

rtpascual commented 2 weeks ago

Changes

Adds breakCircularDependency (naming can change) to defineFunction props. If this is set to true, splits function into its own stack based on the function's name.

// amplify/auth/resource.ts

export const preSignUp = defineFunction({
   name: 'preSignUp',
   entry: './presignup/handler.ts',
  breakCircularDependency: true,
});

export const randomFunction = defineFunction({
   name: 'randomFunction',
   entry: './randomefunction/handler.ts',
});

export const auth = defineAuth({
   ...
   triggers: { preSignUp },
});
// amplify/backend.ts

export const backend = defineBackend({
  auth,
  data,
  randomFunction,
  preSignUp,
});

const randomFunctionStack = backend.randomFunction.stack; // function stack
const preSignUpStack = backend.preSignUp.stack; // presignup stack

Corresponding docs PR, if applicable:

Validation

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.