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(datastore): Multi-auth #1478

Merged
merged 2 commits into from
Mar 28, 2022
Merged

feat(datastore): Multi-auth #1478

merged 2 commits into from
Mar 28, 2022

Conversation

dnys1
Copy link
Contributor

@dnys1 dnys1 commented Mar 25, 2022

Issue #, if available:
#815

Description of changes:

  • Adds multi-auth option to DataStore configuration

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@dnys1 dnys1 requested a review from a team as a code owner March 25, 2022 23:39
@codecov-commenter
Copy link

codecov-commenter commented Mar 26, 2022

Codecov Report

Merging #1478 (f1a61c6) into main (65f5b0f) will increase coverage by 0.00%.
The diff coverage is 37.50%.

@@           Coverage Diff           @@
##             main    #1478   +/-   ##
=======================================
  Coverage   46.47%   46.47%           
=======================================
  Files         261      262    +1     
  Lines       10191    10197    +6     
=======================================
+ Hits         4736     4739    +3     
- Misses       5455     5458    +3     
Flag Coverage Δ
android-unit-tests ∅ <ø> (∅)
flutter-unit-tests 36.63% <37.50%> (+<0.01%) ⬆️
ios-unit-tests 85.12% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...erface/lib/amplify_datastore_plugin_interface.dart 0.00% <0.00%> (ø)
...rface/lib/src/types/models/auth_mode_strategy.dart 25.00% <25.00%> (ø)
...kages/amplify_datastore/lib/amplify_datastore.dart 69.76% <100.00%> (+0.71%) ⬆️
...mplify_datastore/lib/method_channel_datastore.dart 67.91% <100.00%> (+0.24%) ⬆️

Copy link
Member

@HuiSF HuiSF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm.
With couple of questions.

}) : super(token: token);

/// Internal use constructor
@protected
DataStorePluginInterface.tokenOnly({required Object token})
: super(token: token);
: this(token: token, modelProvider: null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason changing this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's identical to before, just saves me repeating myself again. Alternative is:

  DataStorePluginInterface.tokenOnly({required Object token})
      : authModeStrategy = AuthModeStrategy.default$,
        super(token: token);

/// The raw value used for interfacing with native SDKs.
String get rawValue {
switch (this) {
case AuthModeStrategy.default$:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like that the codebase mostly uses describeEnum as convention. But using describeEnum doesn't work with this escaped keyword...
Do we have option to name default as defaultAuth, or use uppercase like Android?
Or do developers need to use AuthModeStrategy.default at any occasion instead of passing null?

Copy link
Contributor Author

@dnys1 dnys1 Mar 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, since default is a reserved word you can't use it as a member name. defaultAuth is fine, but it seemed redundant to say auth again.

Personally, I don't like using null in this context if there is a default value hidden behind it. Since it's a default value in the constructor, not passing any value is the same as passing AuthModeStrategy.default$, so the DX is the same except that the default value is apparent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might make this AuthModeStrategy.defaultValue or AuthModeStrategy.defaultStrategy even though it is redundant.

My brain read this as AuthModeStrategy.$default and I was wondering if this was generated.

Copy link
Member

@Jordan-Nelson Jordan-Nelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a minor comment, but looks good.

/// The raw value used for interfacing with native SDKs.
String get rawValue {
switch (this) {
case AuthModeStrategy.default$:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might make this AuthModeStrategy.defaultValue or AuthModeStrategy.defaultStrategy even though it is redundant.

My brain read this as AuthModeStrategy.$default and I was wondering if this was generated.

@dnys1 dnys1 enabled auto-merge (squash) March 28, 2022 18:54
@dnys1 dnys1 merged commit 51c6485 into aws-amplify:main Mar 28, 2022
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.

4 participants