Skip to content

Commit

Permalink
Only enforce data prop with inline queries (#613)
Browse files Browse the repository at this point in the history
* only add data prop with inline queries

* changeset
  • Loading branch information
AlecAivazis authored Oct 21, 2022
1 parent 6a0999f commit eb3ffe1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/smart-singers-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'houdini-svelte': patch
---

Avoid unnecessary data prop being added to route
15 changes: 6 additions & 9 deletions packages/houdini-svelte/src/plugin/transforms/kit/load.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,9 @@ describe('kit route processor', function () {
`,
})

expect(route.component).toMatchInlineSnapshot(`
import GQL_TestPageQuery from "$houdini/plugins/houdini-svelte/stores/TestPageQuery";
export let data;
`)
expect(route.component).toMatchInlineSnapshot(
'import GQL_TestPageQuery from "$houdini/plugins/houdini-svelte/stores/TestPageQuery";'
)
expect(route.script).toMatchInlineSnapshot(`
import { load_TestPageQuery } from "$houdini/plugins/houdini-svelte/stores/TestPageQuery";
import { getCurrentConfig } from "$houdini/runtime/lib/config";
Expand Down Expand Up @@ -491,10 +490,9 @@ describe('kit route processor', function () {
`,
})

expect(route.component).toMatchInlineSnapshot(`
import GQL_TestLayoutQuery from "$houdini/plugins/houdini-svelte/stores/TestLayoutQuery";
export let data;
`)
expect(route.component).toMatchInlineSnapshot(
'import GQL_TestLayoutQuery from "$houdini/plugins/houdini-svelte/stores/TestLayoutQuery";'
)
expect(route.layout_script).toMatchInlineSnapshot(`
import { load_TestLayoutQuery } from "$houdini/plugins/houdini-svelte/stores/TestLayoutQuery";
import { getCurrentConfig } from "$houdini/runtime/lib/config";
Expand Down Expand Up @@ -1074,7 +1072,6 @@ test('layout loads', async function () {
import { extractSession, setClientSession } from "$houdini/plugins/houdini-svelte/runtime/session";
import { onMount } from "svelte";
import { setClientStarted } from "$houdini/plugins/houdini-svelte/runtime/adapter";
export let data;
onMount(() => setClientStarted());
page.subscribe(val => {
Expand Down
3 changes: 1 addition & 2 deletions packages/houdini-svelte/src/plugin/transforms/kit/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ export default async function kit_load_generator(page: SvelteTransformPage) {
})
}

// we need this to happen last so it that the context always gets injected first
if (route && queries.length > 0) {
if (route && inline_queries.length > 0) {
// we need to check if there is a declared data prop
const has_data = page.script.body.find(
(statement) =>
Expand Down

1 comment on commit eb3ffe1

@vercel
Copy link

@vercel vercel bot commented on eb3ffe1 Oct 21, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.