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

fixes result parsing for observeQuery, onCreate, onUpdate, and onDelete operations #318

Merged
merged 8 commits into from
Sep 10, 2024

Conversation

svidgen
Copy link
Member

@svidgen svidgen commented Sep 6, 2024

Issue #, if available:

Addresses part of this issue: aws-amplify/amplify-js#13267

Description of changes:

Prior to this PR, subscription-like operations incorrectly handled nested models in graphql responses from custom selection sets. These operations would replace child properties with lazy loaders even when relationships were eagerly loaded.

This PR fixes the problem and adds tests to verify for each operation that:

  1. The custom selection sets are present in the request
  2. The graphql result is passed through with nested items properties flattened
  3. The result types are correct

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

@svidgen svidgen requested review from a team as code owners September 6, 2024 22:36
Copy link

changeset-bot bot commented Sep 6, 2024

🦋 Changeset detected

Latest commit: 183be1c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

const { client, spy } = await getMockedClient('getTodo', selectionSet);
const { client, spy } = await getMockedClient('getTodo');
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 few lines here are just cleaning up a param that wasn't ultimately used.

@svidgen svidgen marked this pull request as draft September 6, 2024 22:37
@svidgen
Copy link
Member Author

svidgen commented Sep 6, 2024

Pretty sure this is OK. But, converting back to draft until I can confirm next week that we have tests for the opposite case — if custom selection set is not present, we want to ensure the lazy loaders are created.

If test cases for this don't exist, I'll add them next week.

Update: New lazy loading tests have been added.

@svidgen svidgen marked this pull request as ready for review September 9, 2024 19:41
@svidgen svidgen merged commit b7400b1 into aws-amplify:main Sep 10, 2024
6 checks passed
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.

2 participants