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

feat(core): add API for partially config Amplify #12513

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

5d
Copy link
Member

@5d 5d commented Nov 3, 2023

Description of changes

  • add a new API updateConfig for customer to partialy config Amplify.

Issue #, if available

The current Amplify.configure replaces the whole configuration. If a customer wants to update a field in the configuration. The API requires a replacement at each level.

For instance, if customer has Pinpoint configured for Analytics. They wants to update the bufferSize option. They will need to do this:

import { Amplify } from 'aws-amplify';

Amplify.configure({
  ...Amplify.getConfig(),
  Analytics: {
    ...Amplify.getConfig().Analytics,
    Pinpoint: {
      ...Amplify.getConfig().Analytics?.Pinpoint!,
      bufferSize: 2000,
    }
  }
});

With this new API, customer can do:

import { Amplify } from 'aws-amplify';

Amplify.updateConfig(
  (config) => config.atKey('Analytics').atKey('Pinpoint').atKey('bufferSize'),
  2000
);

Description of how you validated changes

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

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

@5d 5d force-pushed the 5d/partial-config-with-lens branch from 0191532 to 279f036 Compare November 3, 2023 22:04
@5d 5d changed the base branch from main to next/main November 3, 2023 22:16
@5d 5d changed the base branch from next/main to main November 6, 2023 21:00
@RichiCoder1
Copy link

I randomly stumbled up on this PR and wanted to toss out this might be a good use case for Immer: https://immerjs.github.io/immer/produce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants