diff --git a/.changeset/pre.json b/.changeset/pre.json index 44e189735..79b98a88c 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -1,5 +1,5 @@ { - "mode": "pre", + "mode": "exit", "tag": "next", "initialVersions": { "houdini": "0.15.8", diff --git a/integration/src/lib/utils/routes.ts b/integration/src/lib/utils/routes.ts index 85e3f68ec..a8dc3cd16 100644 --- a/integration/src/lib/utils/routes.ts +++ b/integration/src/lib/utils/routes.ts @@ -40,6 +40,7 @@ export const routes = { Plugin_load_loadAndGlobal: '/plugin/load/inlineAndGlobal', Plugin_load_list: '/plugin/load/list', Plugin_load_pageQuery: '/plugin/load/pageQuery', + Plugin_load_pageQuerySession: '/plugin/load/pageQuery-session', Pagination_query_forward_cursor: '/pagination/query/forward-cursor', Pagination_query_backwards_cursor: '/pagination/query/backwards-cursor', diff --git a/integration/src/routes/plugin/load/pageQuery-session/+page.gql b/integration/src/routes/plugin/load/pageQuery-session/+page.gql new file mode 100644 index 000000000..d54d31a7b --- /dev/null +++ b/integration/src/routes/plugin/load/pageQuery-session/+page.gql @@ -0,0 +1,3 @@ +query PageQuerySession { + session +} diff --git a/integration/src/routes/plugin/load/pageQuery-session/+page.svelte b/integration/src/routes/plugin/load/pageQuery-session/+page.svelte new file mode 100644 index 000000000..9ed9b69d7 --- /dev/null +++ b/integration/src/routes/plugin/load/pageQuery-session/+page.svelte @@ -0,0 +1,12 @@ + + +

SSR Session

+ +
+ {$PageQuerySession.data?.session} +
diff --git a/integration/src/routes/plugin/load/pageQuery-session/spec.ts b/integration/src/routes/plugin/load/pageQuery-session/spec.ts new file mode 100644 index 000000000..13d6e4b27 --- /dev/null +++ b/integration/src/routes/plugin/load/pageQuery-session/spec.ts @@ -0,0 +1,13 @@ +import { test } from '@playwright/test'; +import { routes } from '../../../../lib/utils/routes.js'; +import { expectToBe, expect_0_gql } from '../../../../lib/utils/testsHelper.js'; + +test.describe('Page Query with Session', () => { + test('No GraphQL request & Should display the session token', async ({ page }) => { + await page.goto(routes.Plugin_load_pageQuerySession); + + await expect_0_gql(page); + + await expectToBe(page, '1234-Houdini-Token-5678'); + }); +}); diff --git a/rollup.config.js b/rollup.config.js index a5d3db347..b8297ba03 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -45,9 +45,6 @@ export default { nodeResolve({ preferBuiltins: true }), replace({ HOUDINI_VERSION: packgeJSON.version, - SITE_URL: fs.existsSync('./.changeset/pre.json') - ? 'https://docs-next-kohl.vercel.app' - : 'https://houdinigraphql.com', }), ], } diff --git a/src/cmd/generators/definitions/schema.test.ts b/src/cmd/generators/definitions/schema.test.ts index 2bc9c32d5..c9e873833 100644 --- a/src/cmd/generators/definitions/schema.test.ts +++ b/src/cmd/generators/definitions/schema.test.ts @@ -35,7 +35,7 @@ test('adds internal documents to schema', async function () { """ @paginate is used to to mark a field for pagination. - More info in the [doc](SITE_URL/guides/pagination). + More info in the [doc](https://houdinigraphql.com/guides/pagination). """ directive @paginate(name: String) on FIELD @@ -96,7 +96,7 @@ test('list operations are included', async function () { """ @paginate is used to to mark a field for pagination. - More info in the [doc](SITE_URL/guides/pagination). + More info in the [doc](https://houdinigraphql.com/guides/pagination). """ directive @paginate(name: String) on FIELD @@ -176,7 +176,7 @@ test("writing twice doesn't duplicate definitions", async function () { """ @paginate is used to to mark a field for pagination. - More info in the [doc](SITE_URL/guides/pagination). + More info in the [doc](https://houdinigraphql.com/guides/pagination). """ directive @paginate(name: String) on FIELD diff --git a/src/runtime/index.ts b/src/runtime/index.ts index f2ca30616..5d18217e0 100644 --- a/src/runtime/index.ts +++ b/src/runtime/index.ts @@ -21,6 +21,6 @@ export function graphql(str: TemplateStringsArray): any { // if this is executed, the preprocessor is not enabled throw new Error(`⚠️ graphql template was invoked at runtime. This should never happen and usually means that your project isn't properly configured. -Please make sure you have the appropriate plugin/preprocessor enabled. For more information, visit this link: SITE_URL/guides/setting-up-your-project +Please make sure you have the appropriate plugin/preprocessor enabled. For more information, visit this link: https://houdinigraphql.com/guides/setting-up-your-project `) } diff --git a/src/runtime/lib/constants.ts b/src/runtime/lib/constants.ts index 0f86d71a9..d1102278a 100644 --- a/src/runtime/lib/constants.ts +++ b/src/runtime/lib/constants.ts @@ -1,4 +1,4 @@ -export const siteURL = 'SITE_URL' +export const siteURL = 'https://houdinigraphql.com' /** * @param focus example "#0160" diff --git a/src/runtime/stores/query.ts b/src/runtime/stores/query.ts index 82954312e..81908ac72 100644 --- a/src/runtime/stores/query.ts +++ b/src/runtime/stores/query.ts @@ -422,42 +422,15 @@ export async function fetchParams<_Data extends GraphQLObject, _Input>( const contextError = (storeName: string) => ` ${log.red(`Missing event args in load function`)}. - Three options: - ${log.cyan('1/ Prefetching & SSR')} - - - - - ${log.cyan('2/ Client only')} - - - ${log.cyan('3/ Endpoint')} - import { ${log.cyan(storeName)} } from '$houdini'; - - export async function get(event) { - return { - props: { - data: await ${log.cyan(storeName)}.fetch({ event }) - } - }; - } +import type { LoadEvent } from '@sveltejs/kit'; +export async function load(${log.yellow('event')}: LoadEvent) { + return { + ...load_MyQuery({ ${log.yellow('event')}, variables: { ... } }) + }; +} ` type FetchGlobalParams<_Data extends GraphQLObject, _Input> = { diff --git a/src/vite/fsPatch.ts b/src/vite/fsPatch.ts index 343ffa68c..4c8c060a9 100644 --- a/src/vite/fsPatch.ts +++ b/src/vite/fsPatch.ts @@ -92,7 +92,7 @@ filesystem.statSync = function (filepath: string, options: Parameters { if (file instanceof Dirent) { return file.name } else if (typeof file === 'string') { @@ -120,43 +120,36 @@ filesystem.readdirSync = function ( } else { return '' } - } - - function hasFileName(...names: string[]) { - return result.some((file) => { - return names.includes(getFileName(file)) - }) + }) + function contains(...names: string[]) { + return names.some((name) => file_names.includes(name)) } // if there is a route component but no script, add the script if ( - hasFileName('+page.svelte') && - !hasFileName('+page.js', '+page.ts', '+page.server.js', '+page.server.ts') + contains('+page.svelte') && + !contains('+page.js', '+page.ts', '+page.server.js', '+page.server.ts') ) { - result.push(virtualFile('+page.js', options)) + result.push(virtual_file('+page.js', options)) } // if there is a layout file but no layout.js, we need to make one - const layoutLoadFiles = ['+layout.ts', '+layout.js'] - if ( - hasFileName('+layout.svelte') && - !result.find((fp) => layoutLoadFiles.includes(getFileName(fp))) - ) { - result.push(virtualFile('+layout.js', options)) + if (contains('+layout.svelte') && !contains('+layout.ts', '+layout.js')) { + result.push(virtual_file('+layout.js', options)) } // if we are in looking inside of src/routes and there's no +layout.svelte file // we need to create one - if (is_root_layout(filepath.toString()) && !hasFileName('+layout.svelte')) { - result.push(virtualFile('+layout.svelte', options)) + if (is_root_layout(filepath.toString()) && !contains('+layout.svelte')) { + result.push(virtual_file('+layout.svelte', options)) } // if we are in looking inside of src/routes and there's no +layout.server.js file // we need to create one if ( is_root_layout(filepath.toString()) && - !hasFileName('+layout.server.js', '+layout.server.ts') + !contains('+layout.server.js', '+layout.server.ts') ) { - result.push(virtualFile('+layout.server.js', options)) + result.push(virtual_file('+layout.server.js', options)) } // we're done modifying the results @@ -169,7 +162,7 @@ Object.defineProperty(globalThis, 'fs', { value: filesystem, }) -function virtualFile(name: string, options: Parameters[1]) { +function virtual_file(name: string, options: Parameters[1]) { return !options?.withFileTypes ? name : {