-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Use without Sapper or SvelteKit #67
Comments
At the moment, houdini doesn't work in a bare svelte app because Supporting this would probably be best done by building versions of |
Interesting, so queries are actually all run server side before the components are send to the browser, or am I miss understanding the process? 😅 (That would explain why queries return the data directly instead of returning a promise 😅; I suppose when supporting bare svelte, it would make sense for queries to return a promise in the same was as mutations do?) Coming from Relay, this is the API I would have expected: <script type="ts">
const data = query(graphql`query MyQuery(...) { ... }`, optionalQueryVariables);
</script> |
yes that's correct! At least for the first request that is rendered by the server. From then on, queries fire from the client directly to the API (both Sapper and SvelteKit take care of these details when you define the appropriate loader). In a bare svelte app, you dont have any of the concerns that caused me to structure the variables API the way it is. There shouldn't be much problem with passing the variables in as a second argument to Re the return value - I think a promise is a reasonable response from the various document functions in a bare svelte app as long as it resolves to a store so the user can subscribe to updates. |
After poking around with possibilities, I think we can support bare svelte with the current API. At the very least related: #72 |
I think one solution could be to split the query API into |
I'd like to avoid doing that if possible. I think the only thing that's missing from the |
What do you think of mirroring relays approach more closely and having a preloaded query that is passed the pre-load value explicitly; and then having a loader that can load a given query from within the sapper/ kit (pre)loader side of things (or potentially another function in the frontend); and potentially having a convenience wrapper that lazy loads things by doing something like That would break compatibility with the current api but be more flexible in terms of where the loading can happen. |
In some sense that's how If we wanted to bring the idea of preloading a query into the core API, I think the best way is to leave I think ideally, the logic for preloading a query should be hidden from the user and the framework should just do the "right thing" whenever possible. I think given that houdini is currently only maintained by a single person, the best way to get to that dream is to lean heavily into kit to handle the router integration. I do understand that supporting preloaded queries is important to integrate with other routers but advanced users are more likely to be okay with a less-than-perfect API that might be heavily caveated. |
@dyedgreen I think I have a working update to support |
Going to reopen this, @pixelmund had a very good point, a lot of the generated code still assumes things like |
From reading the documentation it's not clear if/ how this can be used within a bare Svelte app.
If this is possible, how would one use Houdini without using Sapper (i.e. only having a simple Svelte app). If this is currently not possible, why not (and how could that be changed, e.g. if I wanted to submit a PR)?
The text was updated successfully, but these errors were encountered: