preprocessor error when querying from load function
See original GitHub issueOther houdini queries are working just fine, but when I try querying from inside the load function in SvelteKit it throws this error below.
Error: Looks like you don't have the preprocessor enabled.
at Module.graphql (/$houdini/runtime/index.js:21:11)
at eval (/Users/benj/projects/preview-app/src/routes/u/[sellerUsername].svelte:69:77)
at Generator.next (<anonymous>)
at eval (/Users/benj/projects/preview-app/src/routes/u/[sellerUsername].svelte:59:66)
at new Promise (<anonymous>)
at __awaiter (/Users/benj/projects/preview-app/src/routes/u/[sellerUsername].svelte:36:9)
at load (/Users/benj/projects/preview-app/src/routes/u/[sellerUsername].svelte:65:28)
at load_node (file:///Users/benj/projects/preview-app/node_modules/@sveltejs/kit/dist/ssr.js:864:30)
at respond$1 (file:///Users/benj/projects/preview-app/node_modules/@sveltejs/kit/dist/ssr.js:1136:21)
at async render_page (file:///Users/benj/projects/preview-app/node_modules/@sveltejs/kit/dist/ssr.js:1290:20)
My svelte.config.js file:
import preprocess from 'svelte-preprocess'
import houdini from 'houdini-preprocess'
import node from '@sveltejs/adapter-node'
import path from 'path'
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: [preprocess({ postcss: true }), houdini()],
kit: {
// hydrate the <div id="svelte"> element in src/app.html
target: '#svelte',
adapter: node(),
vite: {
resolve: {
alias: {
$houdini: path.resolve('.', '$houdini')
}
}
}
}
}
export default config
The load function (please let me know if I’m using this wrong):
<script lang="ts" context="module">
import type { Load } from '@sveltejs/kit'
import { query, graphql } from '$houdini'
export const load: Load = async ({ page }) => {
const username = page.params.sellerUsername
try {
const { data } = query(graphql`
... query data
`)
const seller = data.get_seller
return {
props: {
seller
}
}
} catch (err) {
console.log(err)
return {
status: 400,
error: new Error(err[0].message)
}
}
}
</script>
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How do I generate an error or warning in the C preprocessor?
To do this, click on the Project menu, select Properties..., and in the Build targets tab you can click on Release and then...
Read more >Error while calling a function to fetch data · Issue #66 - GitHub
I have a error when trying fetching data with basic code from example: ... import { query, graphql, AllItems } from '$houdini'; //...
Read more >SQL Preprocessor | Exasol DB Documentation
Returns whether the input string is a SQL keyword token (for example, SELECT , FROM , TABLE ). The functions isidentifier() and iskeyword()...
Read more >PREPROCESSOR - Oracle Help Center
The PREPROCESSOR option passes the input data ( deptxt.dat ) to sed.bat . If you then select from the deptxt table, the results...
Read more >How To Use PreProcessors In JMeter
In this tutorial, you will learn to use JMeter PreProcessor and how do PreProcessors like SampleTimeOut, UserParameter, HTMLLinkParser work.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is not how Houdini works. Houdinis preprocessor automatically transforms your query into the load function. https://github.com/AlecAivazis/houdini#what-about-load
Hey @ledesmablt - sorry to hear you are running into some issues.
The query function isn’t meant to be inside of a load function as you have it. The preprocessor only looks inside of the instance scripts to replace the
graphql
tag. The idea is that you shouldn’t have to worry about defining yourload
function, and threading the value to your components props - the preprocessor takes care of that for you.Can you give me some more information about what you’re trying to accomplish?