-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix mutation list operations not working when passing
@with
directi…
…ve (#1289)
- Loading branch information
1 parent
21fca39
commit 6820d36
Showing
8 changed files
with
572 additions
and
3 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,5 @@ | ||
--- | ||
'houdini': patch | ||
--- | ||
|
||
Mutation list operations now work if you need to pass a `@with` directive to the fragment spread |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
query UsersListMutationInsertUsers($someParam: Boolean!) { | ||
usersConnection(first: 5, snapshot: "users-list-mutation-insert") @list(name: "MyList") { | ||
edges { | ||
node { | ||
id | ||
name | ||
testField(someParam: $someParam) | ||
} | ||
} | ||
} | ||
} |
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,38 @@ | ||
<script lang="ts"> | ||
import { graphql } from '$houdini'; | ||
import type { PageData } from './$houdini'; | ||
export let data: PageData; | ||
$: ({ UsersListMutationInsertUsers } = data); | ||
const addUserMutation = graphql(` | ||
mutation UsersListMutationInsertAddUser($name: String!) { | ||
addUser( | ||
name: $name | ||
birthDate: "2024-01-01T00:00:00Z" | ||
snapshot: "users-list-mutation-insert" | ||
) { | ||
id | ||
...MyList_insert @with(someParam: true) @prepend | ||
} | ||
} | ||
`); | ||
const addUser = async () => { | ||
addUserMutation.mutate({ | ||
name: 'Test User' | ||
}); | ||
}; | ||
</script> | ||
|
||
<button id="addusers" on:click={addUser}>+ Add</button> | ||
|
||
<div id="result"> | ||
{#if $UsersListMutationInsertUsers.data} | ||
<ul> | ||
{#each $UsersListMutationInsertUsers.data.usersConnection.edges as userEdge} | ||
<li>{userEdge.node?.name} - {userEdge.node?.testField}</li> | ||
{/each} | ||
</ul> | ||
{/if} | ||
</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,7 @@ | ||
import type { UsersListMutationInsertUsersVariables } from './$houdini'; | ||
|
||
export const _UsersListMutationInsertUsersVariables: UsersListMutationInsertUsersVariables = () => { | ||
return { | ||
someParam: true | ||
}; | ||
}; |
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,22 @@ | ||
import { test } from '@playwright/test'; | ||
import { routes } from '../../../lib/utils/routes.js'; | ||
import { expect_to_be, goto, locator_click } from '../../../lib/utils/testsHelper.js'; | ||
|
||
test('mutation list insert with @with directive', async ({ page }) => { | ||
await goto(page, routes.Lists_mutation_insert); | ||
|
||
// Verify the initial page data | ||
await expect_to_be( | ||
page, | ||
'Bruce Willis - Hello worldSamuel Jackson - Hello worldMorgan Freeman - Hello worldTom Hanks - Hello worldWill Smith - Hello world' | ||
); | ||
|
||
// Add a user | ||
await locator_click(page, `button[id="addusers"]`); | ||
|
||
// Verify new user is at the top | ||
await expect_to_be( | ||
page, | ||
'Test User - Hello worldBruce Willis - Hello worldSamuel Jackson - Hello worldMorgan Freeman - Hello worldTom Hanks - Hello worldWill Smith - Hello world' | ||
); | ||
}); |
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.