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

Route typegen changes - Sveltekit Page/LayoutData mixin + Layout houdini_load Inheritance #673

Merged
merged 35 commits into from
Nov 10, 2022

Conversation

sjcobb2022
Copy link
Contributor

@sjcobb2022 sjcobb2022 commented Nov 1, 2022

Fixes #608 #653

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

Hi there, here is the initial pull for the new type generation that I've been working on. It currently works for all of the cases that are provided in the e2e tests. I haven't had the time to modify any of the type generation tests yet, so I don't think this will pass CI.

Instead of generating a new file, our types now mirror svelte-kit's types which enables both the inheritance of houdini_loads in layout groups, and automatically inherits the data of SkelteKits load functions.

This should probably be a draft PR as there are probably some code-formatting preferences that need to be looked at, I would appreciate any changes that are made.

P.S. not sure if I updated all the right packages correctly in the changeset. Please feel free to change/fix it :)).

@changeset-bot
Copy link

changeset-bot bot commented Nov 1, 2022

🦋 Changeset detected

Latest commit: d260851

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-svelte Patch
houdini-react 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 1, 2022

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

A member of the Team first needs to authorize it.

@sjcobb2022
Copy link
Contributor Author

Hi @AlecAivazis.

Not sure why the test failed for windows in the playwright tests. I will make another commit in to ensure that it wasn't a failed merge or something. I'll format as well in a bit.

There are some issues with the current generation since, we it's dependant on the .svelte-kit folder. Since this is this is the case, we either need to call npx svelte-kit sync in our mock dir or seperate the type tests out.

@sjcobb2022
Copy link
Contributor Author

sjcobb2022 commented Nov 2, 2022

Hi @AlecAivazis.

Not sure why the test failed for windows in the playwright tests. I will make another commit in to ensure that it wasn't a failed merge or something. I'll format as well in a bit.

There are some issues with the current generation since, we it's dependant on the .svelte-kit folder. Since this is this is the case, we either need to call npx svelte-kit sync in our mock dir or seperate the type tests out.

Ok I found a way to mock the svelte type files. I'll commit this and then you can see.

@sjcobb2022
Copy link
Contributor Author

Ok @AlecAivazis @jycouet, All the tests now pass and the e2e on windows is no longer being funny. I think its all good to go.

@AlecAivazis
Copy link
Collaborator

Thanks for putting this together @sjcobb2022! I really appreciate the effort. It might take me a few days to dig into this in more detail since it's such a large block of code. Hopefully i can find some time before the weekend

@sjcobb2022
Copy link
Contributor Author

sjcobb2022 commented Nov 2, 2022

Thanks for putting this together @sjcobb2022! I really appreciate the effort. It might take me a few days to dig into this in more detail since it's such a large block of code. Hopefully i can find some time before the weekend

Most of it is the package-lock.json which I think got messed up by a package being moved (I think it was when i ran npx playwright install). It's "only" a diff of about 800 lines otherwise.

Copy link
Collaborator

@AlecAivazis AlecAivazis left a comment

Choose a reason for hiding this comment

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

Made a very shallow pass at this. Will find some time to look in more detail (which the extra comments will help with)

packages/houdini/src/lib/fs.ts Outdated Show resolved Hide resolved
// add every load to the list
pageQueries.push(...(houdini_load ?? []))
scriptPageExports = exports
async function walk_types(dirpath: string) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The body of this function looks very simliar to walk_routes, am i missing something?

Copy link
Contributor Author

@sjcobb2022 sjcobb2022 Nov 3, 2022

Choose a reason for hiding this comment

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

I found that walk routes felt overly complex and was trying to deal with too much for this case. Since we are merely copying the svelte types, we are able to glean a lot more information about the structure anyway.

Structurally, I think it would be good to move this into kit.ts

Copy link
Collaborator

Choose a reason for hiding this comment

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

Like i said, I didn't look extremely closely last night but I will have some time today to do that. In general, the point of walk_routes is to abstract away walk down the directory and the check for all of the different kinds of files. If you're familiar with the visitor pattern, that was the general idea. You'll notice in the block of code you replaced that there is no await fs.stat(childPath)).isDirectory() or even checking for every possible script type.

I'll find some some time today and open an PR on your fork so you can see what I have in mind. Worst case I run into some hangup and answer my own question

packages/houdini-svelte/src/plugin/codegen/routes/index.ts Outdated Show resolved Hide resolved
@sjcobb2022
Copy link
Contributor Author

Awesome. @jycouet pretty easy fix, just needed to check for the proxy file and copy if not. I changes the fs file but I maintained the same format as the other functions (ensuring memory safety during tests or whatever the idea was). I hope this is alright.

@jycouet jycouet self-requested a review November 9, 2022 08:38
jycouet
jycouet previously approved these changes Nov 9, 2022
Copy link
Contributor

@jycouet jycouet left a comment

Choose a reason for hiding this comment

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

Thank you @sjcobb2022 for your efficiency, you fixed it really quick 👍
On my side, after testing the feature everything looks good.

@AlecAivazis
Copy link
Collaborator

Really appreciate you verifying this @jycouet ❤️ I'll give it a final once over tomorrow and get this merged finally!

@sjcobb2022
Copy link
Contributor Author

Sorry @AlecAivazis and @jycouet realised a minor bug where the copyFileSync function was not returning. Sorry if this is an issue.

@sjcobb2022 sjcobb2022 closed this Nov 9, 2022
@sjcobb2022 sjcobb2022 reopened this Nov 9, 2022
@sjcobb2022
Copy link
Contributor Author

sjcobb2022 commented Nov 9, 2022

@AlecAivazis Sorry I accidentally closed the pull. Also the windows did it's 6000ms polling thing and needs to be rerun I think.

EDIT: reopening the pull made it run again. all good.

@AlecAivazis
Copy link
Collaborator

Heh i actually restarted the windows one when I saw it didn't pass 😅 I'll definitely have some time to give this a final pass today

@vercel
Copy link

vercel bot commented Nov 9, 2022

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

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

@sjcobb2022
Copy link
Contributor Author

@AlecAivazis Thanks man.

Copy link
Collaborator

@AlecAivazis AlecAivazis left a comment

Choose a reason for hiding this comment

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

So I was able to pull this down and verify it worked 🎉 Seriously appreciate all the effort to streamline this. It's gonna be HUGE for our users.

Just a few last minute nitpicks, tried to cover as much as I could with suggestions but i couldn't get them all

@sjcobb2022
Copy link
Contributor Author

sjcobb2022 commented Nov 10, 2022

@AlecAivazis I think this is everything?

EDIT: The tests pass locally for me I think this was just a freak error.

Copy link
Collaborator

@AlecAivazis AlecAivazis left a comment

Choose a reason for hiding this comment

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

Awesome!! Thanks for doing that 👍

btw, you should have been able to commit the changes through GitHub UI. I probably wouldn't have been so nitpicky if i knew you were going to commit them by hand 😅

@AlecAivazis AlecAivazis enabled auto-merge (squash) November 10, 2022 18:50
@AlecAivazis AlecAivazis merged commit 3986d5e into HoudiniGraphql:main Nov 10, 2022
@github-actions github-actions bot mentioned this pull request Nov 10, 2022
endigma pushed a commit to endigma/houdini that referenced this pull request Nov 10, 2024
* Working on new type generation, commit before merge to 0.17.0

* prepare for merge

* notes for future

* Regex the hell out of this

* {Type}Data is functional

* Working 🎉

* relative imports for load types

* added changeset

* Tests working 🎉 & LoadInput proper generation

* FIX: diffs not merged

* FIX: Format and unnecessary log in tests

* tiny formatting issue that will annpy me if I don't fix it

* Additional fs exports were not necessary, oops

* added comments

* Reorder of type generation

* FIX: Run prettier

* Fix lint

* Using walk_routes

* Formatting, Lint and remove commented old code

* Fixed proxy files, use houdini types in e2e, added copyFileSync to fs

* FIX: Format

* FIX: return from copyFileSync

* FIX: add fs.copyFile, fixed async calls, use internal path

* tidy up changeset

Co-authored-by: Alec Aivazis <[email protected]>
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.

3 participants