forked from HoudiniGraphql/houdini
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Infer query inputs from route params (HoudiniGraphql#789)
* first pass mixing url parameters with the variable function * params need to be pulled out of event.params 🤦 * run ci on all branches * marshal variable function return value, not all inputs * throw error export from sveltejs/kit * add test * rename routes in e2e and add failing unit tests * use official route parser * remove comments * update getting started guide and query api docs * update getting started guide to use +page.gql * more tweaks * move setFieldType to separate section * dont double run CI * remove unused imports * fix nested route test * changeset * fix scroll background * tweak wording * remove invalid import * add filepaths to doc codeblocks * more filepaths * one more filepath * Add toggle to docs between typescript and jsdocs (HoudiniGraphql#791) * Tweak docs for endpoints (HoudiniGraphql#785) * ✏️ DOC: tweaks * ✏️ FIX: \t to ' ' * Fix error when prerendering application (HoudiniGraphql#786) * don't add session infrastructure when static is set to true * use existing static config value * changeset * unused import * 📦 v0.19.2 (HoudiniGraphql#788) * 📦 v{VERSION} * update changelogs * oops Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Alec Aivazis <[email protected]> * add js/ts toggle * fix search input sizing * duplicate code examples and implement toggle * convert all blocks to typescript * transform handles variable declaration type signatures * transform function parameters * transform svelte documents * add type definitions to rest of getting started guide * update guides * add types to authentication docs * remove semicolon * update snapshots * move typescript test to js Co-authored-by: JYC <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * invert toolbar icons * fix spacing * update changeset * hide discord link on mobile * better support for optional inputs * add test for custom functions * fix a few titles * formatting tweak * : -> , Co-authored-by: JYC <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
Showing
104 changed files
with
3,513 additions
and
2,234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'houdini-svelte': major | ||
'houdini': major | ||
--- | ||
|
||
Removed this.error and this.redirect from function variables |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'houdini-svelte': patch | ||
--- | ||
|
||
Query variables can now be inferred from route params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,5 @@ $houdini | |
build/** | ||
dist/** | ||
.next/** | ||
|
||
vite.config.js.timestamp-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
e2e/sveltekit/src/routes/plugin/query/infer-input/custom-function-[snapshot]-[id]/+page.gql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
query CustomFunctionRouteParamsUserQuery($snapshot: String! = "test", $id: ID! = "1") { | ||
user(id: $id, snapshot: $snapshot) { | ||
name | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...veltekit/src/routes/plugin/query/infer-input/custom-function-[snapshot]-[id]/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script lang="ts"> | ||
import type { PageData } from './$houdini'; | ||
export let data: PageData; | ||
let { CustomFunctionRouteParamsUserQuery } = data; | ||
$: ({ CustomFunctionRouteParamsUserQuery } = data); | ||
</script> | ||
|
||
<div id="result"> | ||
{$CustomFunctionRouteParamsUserQuery.data?.user.name} | ||
</div> |
8 changes: 8 additions & 0 deletions
8
e2e/sveltekit/src/routes/plugin/query/infer-input/custom-function-[snapshot]-[id]/+page.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { CustomFunctionRouteParamsUserQueryVariables } from './$houdini'; | ||
|
||
export const _CustomFunctionRouteParamsUserQueryVariables: CustomFunctionRouteParamsUserQueryVariables = | ||
() => { | ||
return { | ||
id: '2' | ||
}; | ||
}; |
11 changes: 11 additions & 0 deletions
11
e2e/sveltekit/src/routes/plugin/query/infer-input/custom-function-[snapshot]-[id]/spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { test } from '@playwright/test'; | ||
import { routes } from '../../../../../lib/utils/routes.js'; | ||
import { expectToBe, goto } from '../../../../../lib/utils/testsHelper.js'; | ||
|
||
test.describe('query variables from route params', () => { | ||
test('custom function', async ({ page }) => { | ||
await goto(page, routes.Plugin_query_inferInput_customFunction); | ||
|
||
await expectToBe(page, 'Samuel Jackson'); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
e2e/sveltekit/src/routes/plugin/query/infer-input/optional[[id]]/+page.gql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
query OptionalRouteParamsUserQuery($snapshot: String! = "test", $id: ID! = "1") { | ||
user(id: $id, snapshot: $snapshot) { | ||
name | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
e2e/sveltekit/src/routes/plugin/query/infer-input/optional[[id]]/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script lang="ts"> | ||
import type { PageData } from './$houdini'; | ||
export let data: PageData; | ||
let { OptionalRouteParamsUserQuery } = data; | ||
$: ({ OptionalRouteParamsUserQuery } = data); | ||
</script> | ||
|
||
<div id="result"> | ||
{$OptionalRouteParamsUserQuery.data?.user.name} | ||
</div> |
11 changes: 11 additions & 0 deletions
11
e2e/sveltekit/src/routes/plugin/query/infer-input/optional[[id]]/spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { test } from '@playwright/test'; | ||
import { routes } from '../../../../../lib/utils/routes.js'; | ||
import { expectToBe, goto } from '../../../../../lib/utils/testsHelper.js'; | ||
|
||
test.describe('query variables from route params', () => { | ||
test('optional param in query, no value', async ({ page }) => { | ||
await goto(page, routes.Plugin_query_inferInput_optional); | ||
|
||
await expectToBe(page, 'Bruce Willis'); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
e2e/sveltekit/src/routes/plugin/query/infer-input/user-[snapshot]-[id]/+page.gql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
query RouteParamsUserQuery($snapshot: String!, $id: ID!) { | ||
user(id: $id, snapshot: $snapshot) { | ||
name | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
e2e/sveltekit/src/routes/plugin/query/infer-input/user-[snapshot]-[id]/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script lang="ts"> | ||
import type { PageData } from './$houdini'; | ||
export let data: PageData; | ||
let { RouteParamsUserQuery } = data; | ||
$: ({ RouteParamsUserQuery } = data); | ||
</script> | ||
|
||
<div id="result"> | ||
{$RouteParamsUserQuery.data?.user.name} | ||
</div> |
11 changes: 11 additions & 0 deletions
11
e2e/sveltekit/src/routes/plugin/query/infer-input/user-[snapshot]-[id]/spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { test } from '@playwright/test'; | ||
import { routes } from '../../../../../lib/utils/routes.js'; | ||
import { expectToBe, goto } from '../../../../../lib/utils/testsHelper.js'; | ||
|
||
test.describe('query variables from route params', () => { | ||
test('happy path', async ({ page }) => { | ||
await goto(page, routes.Plugin_query_inferInput_userRoute_params); | ||
|
||
await expectToBe(page, 'Bruce Willis'); | ||
}); | ||
}); |
5 changes: 3 additions & 2 deletions
5
e2e/sveltekit/src/routes/plugin/query/variables-error/+page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { error } from '@sveltejs/kit'; | ||
|
||
export function _PreprocessorTestQueryErrorVariables() { | ||
// @ts-ignore | ||
return this.error(403, 'test'); | ||
throw error(403, 'test'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.