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

chore(@aws-amplify/datastore): docstrings, small refactors, cleanup unused predicate function #11040

Merged
merged 7 commits into from
Mar 6, 2023

Conversation

svidgen
Copy link
Member

@svidgen svidgen commented Mar 3, 2023

Description of changes

A batch of refactors, comments, etc., intended to improve readability.

  1. A handful of docstrings to help explain and add hover-text to new methods from lazy loading + nested predicates.
  2. Handful of explanatory comments throughout model lazy loader
  3. Small refactor to model setter/getter creation to a) remove unused vars, b) leverage Relationship class's allFrom method instead of duplicating that logic inline.
  4. Small refactor to storage predicate builder, moving away from using predicate storage builder.

Issue #, if available

Description of how you validated changes

No functional changes intended. Tests are expected to pass.

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.

@svidgen svidgen requested a review from a team as a code owner March 3, 2023 17:08
Comment on lines -761 to -765
* TODO: the sortof-immutable algorithm was originally done to support legacy style
* predicate branching (`p => p.x.eq(value).y.eq(value)`). i'm not sure this is
* necessary or beneficial at this point, since we decided that each field condition
* must flly terminate a branch. is the strong mutation barrier between chain links
* still necessary or helpful?
Copy link
Member Author

Choose a reason for hiding this comment

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

Realistically, we'll never revisit this immutability. It has value if we ever need to extend predicates. And if we refactor here (which is possible), it'll be done holistically; not for the purpose of addressing this specific algorithmic choice.

*
* @param modelDefinition The model that the AST/predicate must be compatible with.
* @param ast The graphQL style AST that should specify conditions for `modelDefinition`.
*/
static createFromAST(
modelDefinition: SchemaModel,
ast: any
Copy link
Member Author

Choose a reason for hiding this comment

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

A separate PR will attempt to address the any here.

*
* @param gql GraphQL style filter node.
*/
static transformGraphQLFilterNodeToPredicateAST(gql: any) {
Copy link
Member Author

Choose a reason for hiding this comment

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

A separate PR will attempt to address the any here.

@codecov-commenter
Copy link

codecov-commenter commented Mar 3, 2023

Codecov Report

Merging #11040 (20f1f56) into main (8f6dd70) will decrease coverage by 3.42%.
The diff coverage is n/a.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main   #11040      +/-   ##
==========================================
- Coverage   85.65%   82.24%   -3.42%     
==========================================
  Files         196      193       -3     
  Lines       18261    19367    +1106     
  Branches     3892     4185     +293     
==========================================
+ Hits        15642    15928     +286     
- Misses       2543     3151     +608     
- Partials       76      288     +212     
Impacted Files Coverage Δ
packages/datastore/src/predicates/index.ts 85.71% <0.00%> (-10.23%) ⬇️
packages/pubsub/src/PubSub.ts 91.17% <0.00%> (-1.88%) ⬇️
packages/amazon-cognito-identity-js/src/Client.js 50.48% <0.00%> (-1.52%) ⬇️
...tastore/src/storage/adapter/AsyncStorageAdapter.ts 93.33% <0.00%> (-0.62%) ⬇️
.../src/Providers/AWSAppSyncRealTimeProvider/index.ts 95.68% <0.00%> (-0.39%) ⬇️
...ackages/pubsub/src/Providers/MqttOverWSProvider.ts 92.22% <0.00%> (-0.37%) ⬇️
...ages/amazon-cognito-identity-js/src/CognitoUser.js 79.06% <0.00%> (-0.12%) ⬇️
packages/datastore/__tests__/commonAdapterTests.ts 98.26% <0.00%> (-0.07%) ⬇️
packages/core/src/index.ts 100.00% <0.00%> (ø)
packages/pubsub/src/index.ts 100.00% <0.00%> (ø)
... and 32 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@david-mcafee david-mcafee left a comment

Choose a reason for hiding this comment

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

This is fantastic! Thanks for doing this!

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