-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ✏️ DOC: tweaks * ✏️ FIX: \t to ' '
- Loading branch information
Showing
10 changed files
with
129 additions
and
14 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
26 changes: 26 additions & 0 deletions
26
e2e/sveltekit/src/routes/stores/action-mutation/+page.server.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { graphql } from '$houdini'; | ||
import { fail } from '@sveltejs/kit'; | ||
|
||
/** @type {import('./$types').Actions} */ | ||
export const actions = { | ||
add: async (event) => { | ||
const data = await event.request.formData(); | ||
|
||
const name = data.get('name')?.toString(); | ||
|
||
if (!name) { | ||
return fail(403, { name: '*' }); | ||
} | ||
|
||
const actionMutation = graphql(` | ||
mutation ActionMutation($name: String!) { | ||
addUser(name: $name, birthDate: 254143016000, snapshot: "ActionMutation") { | ||
id | ||
name | ||
} | ||
} | ||
`); | ||
|
||
return await actionMutation.mutate({ name }); | ||
} | ||
}; |
21 changes: 21 additions & 0 deletions
21
e2e/sveltekit/src/routes/stores/action-mutation/+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,21 @@ | ||
<script> | ||
import { enhance } from '$app/forms'; | ||
/** @type {import('./$types').ActionData} */ | ||
export let form; | ||
</script> | ||
|
||
<form method="POST" action="?/add" use:enhance> | ||
<label> | ||
Name | ||
<input name="name" type="name" /> | ||
</label> | ||
<span id="name-error" | ||
>{#if form?.name}{form?.name}{/if}</span | ||
> | ||
<button type="submit">Add</button> | ||
</form> | ||
|
||
<div id="result"> | ||
{form?.addUser?.name || 'No user added'} | ||
</div> |
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,36 @@ | ||
import { sleep } from '@kitql/helper'; | ||
import { test } from '@playwright/test'; | ||
import { routes } from '../../../lib/utils/routes.js'; | ||
import { expectToBe, goto } from '../../../lib/utils/testsHelper.js'; | ||
|
||
test.describe('action-mutation', () => { | ||
test('happy path action-mutation ', async ({ page }) => { | ||
await goto(page, routes.Stores_action_mutation); | ||
|
||
await expectToBe(page, 'No user added'); | ||
|
||
// click the button | ||
await Promise.all([ | ||
page.waitForResponse((res) => res.url().endsWith('action-mutation?/add'), { timeout: 1000 }), | ||
page.getByRole('button', { name: 'Add' }).click() | ||
]); | ||
|
||
// a start should be displayed | ||
await expectToBe(page, '*', 'span[id=name-error]'); | ||
|
||
// fill the input | ||
await page.getByLabel('Name').fill('My New Name'); | ||
|
||
// add | ||
await Promise.all([ | ||
page.waitForResponse((res) => res.url().endsWith('action-mutation?/add'), { timeout: 1000 }), | ||
page.getByRole('button', { name: 'Add' }).click() | ||
]); | ||
|
||
// wait for the message to appear | ||
await sleep(500); | ||
|
||
// check that we have the right data | ||
await expectToBe(page, 'My New Name'); | ||
}); | ||
}); |
6 changes: 3 additions & 3 deletions
6
...tes/stores/endpoint-query/+page.server.ts → ...tes/stores/endpoint-query/+page.server.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,8 +1,8 @@ | ||
import { GQL_Hello } from '$houdini'; | ||
import type { RequestEvent } from '@sveltejs/kit'; | ||
|
||
export async function load(event: RequestEvent) { | ||
/** @type {import('./$types').PageServerLoad} */ | ||
export const load = async (event) => { | ||
const { data } = await GQL_Hello.fetch({ event }); | ||
|
||
return { hello: data?.hello }; | ||
} | ||
}; |
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
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
44f8acc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs – ./site
docs-git-main-houdinigraphql.vercel.app
docs-houdinigraphql.vercel.app
docs-phi-fawn.vercel.app
www.houdinigraphql.com
houdinigraphql.com
44f8acc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
docs-next – ./site
docs-next-kohl.vercel.app
docs-next-houdinigraphql.vercel.app
docs-next-git-main-houdinigraphql.vercel.app