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

Console error after setting the include config to src/**/*.{graphql,gql} #1416

Open
tschortsch opened this issue Jan 17, 2025 · 4 comments
Open

Comments

@tschortsch
Copy link
Contributor

Describe the bug

We set the include config in the houdini.config.js to src/**/*.{graphql,gql} so that Houdini doesn't watch all JS/TS files all the time (which led to a full reload of the page as soon anything changed). But now we're getting the following error in the console even if we don't have queries in our +page or +layout files:

⚠️ You are using at least one page/layout query but aren't "include"ing .js files in your config. \n This will cause houdini to not pick up the generated files and prevent it from working as expected.

Could it be that the condition for outputting this warning is not correctly defined:

if (
// Include path doesn't include js
!config.include.some((path) => path.includes('js')) &&
// And the plugin isn't configured to run in static mode
(!plugin_config(config).static ||
// User uses layout/page queries
uniquePageQueries.length > 0 ||
uniqueLayoutQueries.length > 0)
) {

In my opinion the condition should look like this:

if (
	// Include path doesn't include js
	!config.include.some((path) => path.includes('js')) &&
	// And the plugin isn't configured to run in static mode
	(!plugin_config(config).static &&
	    // User uses layout/page queries
	    (uniquePageQueries.length > 0 ||
	    uniqueLayoutQueries.length > 0))
) {

Reproduction

No response

@AlecAivazis
Copy link
Collaborator

Houdini plays by vite plugin rules which means that it won't process files that don't match its include. This includes the fake files that are generated by having +page.gql files. To pull off what you want, your best bet is to ensure that +page and +layout files are included in your glob.

@tschortsch
Copy link
Contributor Author

Thanks for the answer. But then I don't really get the error message or the variable names. Because it's saying that You are using at least one page/layout query but we don't really have those in our code and the uniquePageQueries and uniqueLayoutQueries are both empty objects. Maybe I'm missing something 🙈

@AlecAivazis
Copy link
Collaborator

Ah, i misread the original report - sorry about that! Looking with clearer eyes now and I think you're right. I'll reopen the issue and will look out for a PR so we can quickly merge/deploy the fix for you

@AlecAivazis AlecAivazis reopened this Jan 20, 2025
@tschortsch
Copy link
Contributor Author

Thanks a lot! If it helps I can create a PR for you. I'm just not sure if I can test it in detail.

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

No branches or pull requests

2 participants