-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Support SvelteKit's new API #449
Conversation
🦋 Changeset detectedLatest commit: 5575eae 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 |
Really nice that you start working on it parallel to their development. Keep up the great work 👍 |
3ab8ab9
to
f541db4
Compare
9fe123b
to
0756fbb
Compare
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me 🎉
Okay, i finally got everything building and think this is finally ready to merge. Really appreciate everyone's patience. I think you're really gonna like what we've put together 🎉 |
This PR updates houdini's APIs to be compatible with the updates to SvelteKit as described here: sveltejs/kit#5774.
Update 8/24
It's been released and is now available on npm as
houdini@next
🥳.We have a few super small things to do before we can release it for real but if you start to migrate your app and run into any problems (or even if you don't) we'd love to hear from you. Also feel free to let us know if there are things you think should be done a different. The whole point of this pre-release is to collect feedback and tweak things before we're locked into something.
Here's the place to leave feedback: https://github.com/HoudiniGraphql/houdini/discussions/475. Please use this discussion instead of issues until we release the new version
Update 8/21
Almost there! 🎉
All of the integration tests are passing locally but there seems to be something going on with GitHub Actions. Hopefully it doesn't take us too long to figure out what's going on.
For an up-to-date overview of what's changed, you can check out the release notes section of the doc's preview link. The content below is all still valid but I'm not going to nitpick small changes in this PR description so it's best to just go to the updated docs directly.
Thanks for the patience!
Upcoming Changes
Just to get some points out of the way for people worried about major breaking changes:
houdini/vite
which replaces the old preprocessor (and the uglyserver.fs.allow
config). But don't worry, there are lots of really cool things that we're getting with this move.context
)data
a keyword in a route). At a high level, you'll now use the result ofquery
directly instead of destructuring data. Also, everything that used to be defined incontext="module"
is now defined in+page.js/ts
.For additional breaking changes and notes, check out the section at the bottom of this. We know this is a lot of changes but we have been thinking about some of these for awhile and since SvelteKit has forced us to change the API, it seemed like a good time to shift some things around.
Vite Plugin
For kit projects, the preprocessor has moved to
houdini/vite
and should be included as a plugin in yourvite.config.js
. You should also remove the thefs.server.allow
config since its baked into the plugin. This plugin not only processes our components and javascript files, but it also integrates into vite'sdev
script to bring some huge improvements:Ideally, you shouldn't need to run
generate
ever again! It'll even get run when you build your application withvite build
so feel free to delete thatgenerate
script from yourpackage.json
if you have it.New Store API
The core of this change is that instead of using stores that you import, your component will now get the store from its props. This is the full example for the component-side of a store-driven route:
Notice there's no more need to thread variables around or that ugly
$: browser && store.fetch
.In order to make this work, your
load
functions need to now return instances of the store embedded in the correct key. This can be easily done with the newload_StoreName
functions. Theload_
prefix is to make it easy to autocomplete when you are working in your editor:This means that when adding a query to a route, tasks like adding a store to a load, pulling that store out of data in your component, etc can be auto completed from just starting with
load_
in your route's load function. It does make the manual logic that uses a fetch result kind of messy since they have to pull out UserInfo but I think that’s a rare situation so I’m in favor of supporting the most people with the clean API and letting the advanced users deal with the complexity.Also, on a slightly unrelated note: you don't need to pass
context
everywhere anymore! that all happens behind the scenes now.Page Queries
You can now define a
+page.gql
file inside of a route directory to automatically opt-into a generated load without having to do anything else:With that file in place, you can just import and use the
MyQuery
store passed to your route and the view will be SSR'd automatically.Generating Loads For Stores
You can now tell the houdini plugin to generate loads for your stores. To do this, you need to export a
houdini_load
variable from your+page.js/ts
file:This can be mixed with the new
graphql
tag api to define your queries inside of your javascript files:or
Generated type definitions for route functions
Instead of duplicating the documentation that's already written, you can visit the new typescript guide here: https://docs-git-directory-routes-houdinigraphql.vercel.app/guides/typescript
Breaking Changes / Notes
+page.js
config.sourceGlob
is no longer required and has been deprecated in favor ofconfig.include
which has a default value that covers most projectsconfig.exclude
to filter out files that match theinclude
patterngenerate --pull-header
is nowgenerate --header
(abbreviated-h
)generate --persist-output
is nowgenerate --output
(abbreviated-o
)schemaPullHeaders
config value to specify the headers sent when pulling the schemafixes #398, fixes #428, fixes #325, fixes #242, fixes #395, fixes #353, fixes #460
closes #348, closes #452