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

Provide parentType to addMany subscriptions #678

Closed
wants to merge 5 commits into from

Conversation

Joklost
Copy link
Contributor

@Joklost Joklost commented Nov 5, 2022

Partially fixes #360

The parentType in addFieldSubscription was hardcoded to 'asdf'. This causes issues when using multiple nested @list directives, as using the [ListName]_(insert|remove|toggle) operations with @parentID attempted to look for a parent with type 'asdf'.

To help everyone out, please make sure your PR does the following:

  • Update the first line to point to the ticket that this PR fixes
  • Add a message that clearly describes the fix
  • If applicable, add a test that would fail without this fix
  • Make sure the unit and integration tests pass locally with pnpm run tests and cd integration && pnpm run tests
  • Includes a changeset if your fix affects the user with pnpm changeset

The parentType in addFieldSubscription was hardcoded to 'asdf'.
This causes issues when using multiple nested @list directives,
as using the [ListName]_(insert|remove|toggle) operations with
@parentID attempted to look for a parent with type 'asdf'.

Signed-off-by: Jonas Jacobsen <[email protected]>
Route for testing nested lists has been added to e2e/sveltekit,

Modles have been added to the e2e/_api GQL schema, and a simple
"database" with sample data has been added to the resolvers.

Signed-off-by: Jonas Jacobsen <[email protected]>
@changeset-bot
Copy link

changeset-bot bot commented Nov 5, 2022

🦋 Changeset detected

Latest commit: 3a9f2b5

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

This PR includes changesets to release 3 packages
Name Type
houdini Patch
houdini-react Patch
houdini-svelte Patch

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

@vercel
Copy link

vercel bot commented Nov 5, 2022

@Joklost is attempting to deploy a commit to the HoudiniGraphQL Team on Vercel.

A member of the Team first needs to authorize it.

Signed-off-by: Jonas Jacobsen <[email protected]>
@Joklost Joklost marked this pull request as ready for review November 5, 2022 12:42
@Joklost
Copy link
Contributor Author

Joklost commented Nov 5, 2022

Any suggestions for the End-to-End (windows-latest) failing?

Error: Timed out waiting 60000ms from config.webServer.

  70 skipped
  1 error was not a part of any test, see above for details
Notice:   70 skipped
undefined
D:\a\houdini\houdini\e2e\sveltekit:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  [email protected] tests: `playwright test `
Exit status 1
Error: Process completed with exit code 1.

@jycouet
Copy link
Contributor

jycouet commented Nov 5, 2022

@Joklost I don't know why it timed out. I just relaunched it, and it seems good now.

Maybe in e2e tests, you could move your operations files under src/routes/stores/nested-list/*. We are moving more and more to this style to have things more colocated.

I don't have time to really look now the PR, but it looks really promising already. Thx a lot for the effort. 🥳
@AlecAivazis could you 👀?

@Joklost
Copy link
Contributor Author

Joklost commented Nov 5, 2022

@Joklost I don't know why it timed out. I just relaunched it, and it seems good now.

Hmm, alright - thanks!

Maybe in e2e tests, you could move your operations files under src/routes/stores/nested-list/*. We are moving more and more to this style to have things more colocated.

Sounds good - I will move them

Operation files only used by src/routes/stores/nested-list
are now placed appropriately.

Signed-off-by: Jonas Jacobsen <[email protected]>
@@ -175,14 +176,15 @@ export class InMemorySubscriptions {
key,
selection: fieldSelection,
spec,
parentType: 'asdf',
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤦‍♂️

@AlecAivazis
Copy link
Collaborator

Thanks for updating this! The referenced ticket won't be fixed by this unfortunately because the issue is a bit more general - the full page parameters won't be sent with the query so loading one page in a list will destroy the other one

@@ -0,0 +1,98 @@
<script lang="ts">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wow!! I really appreciate this test. Super thorough!

@vercel
Copy link

vercel bot commented Nov 5, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
docs ✅ Ready (Inspect) Visit Preview Nov 6, 2022 at 10:16PM (UTC)
docs-next ✅ Ready (Inspect) Visit Preview Nov 6, 2022 at 10:16PM (UTC)

// insert the subscriber
this.addMany({
parent: linkedRecord,
selection: fields,
variables,
subscribers,
parentType: linkedType,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, could you add a test that covers this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I understand, this is already covered in the e2e page, as this is what fixed the innermost list (Books) in the test.

If more is needed, I'll definitely take a look.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yea your e2e definitely covers it but I'd like to duplicate the verification. the cache is a big risk in when refactoring so i'd like to make sure the test suite covers as much as possible so we can get quick feedback when working on it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, I'll look into it - thanks

Copy link
Collaborator

Choose a reason for hiding this comment

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

thank you for the time!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi,

I have added a pretty verbose, but simple, test in 3a9f2b5. I am pretty new to these frameworks, so I just attempted to mimic the behaviour I saw when running the e2e test, and added it here.

Please let me know if I should further expand the test.

Copy link
Collaborator

@AlecAivazis AlecAivazis Nov 6, 2022

Choose a reason for hiding this comment

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

No worries at all about the verbosity! I'd rather that than have no test at all. I'm going to pull down your PR and confirm that test fails without your fix and then it should be good to go. Thanks again!

PS: I might need you to reopen the PR to kick off the CI/CD stuff. Github Actions have been struggling recently

Adds a simple test for testing data with nested lists.
The test adds the cities/books/libraries database to the cache,
and adds first a city, then a library. Next, a subscription is added,
before adding a book to the cache, and it is verified that the book
is added to the library.

Signed-off-by: Jonas Jacobsen <[email protected]>
@AlecAivazis
Copy link
Collaborator

Damn, doesn't look like that did it. Mind closing this PR and opening another one?

@Joklost Joklost closed this Nov 7, 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.

Add support for multiple list directives in the same document
3 participants