-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inserts into lists of unions (#1103)
Co-authored-by: jycouet <jycouet@gmail.com> Co-authored-by: Alec Aivazis <alec@aivazis.com>
- Loading branch information
1 parent
1fc47b8
commit 891a8c7
Showing
10 changed files
with
303 additions
and
5 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 | ||
--- | ||
|
||
fix: insert in list works for list of union |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,9 @@ const config = { | |
types: { | ||
RentedBook: { | ||
keys: ['userId', 'bookId'] | ||
}, | ||
UnionAorB: { | ||
keys: [] | ||
} | ||
}, | ||
|
||
|
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,12 @@ | ||
query AorB { | ||
aOrB @list(name: "All_AorB") { | ||
... on A { | ||
id | ||
a | ||
} | ||
... on B { | ||
id | ||
b | ||
} | ||
} | ||
} |
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,31 @@ | ||
<script lang="ts"> | ||
import { graphql } from '$houdini'; | ||
import type { PageData } from './$houdini'; | ||
export let data: PageData; | ||
$: ({ AorB } = data); | ||
const addA = graphql(` | ||
mutation CreateA($a: String!) { | ||
createA(a: $a) { | ||
...All_AorB_insert | ||
} | ||
} | ||
`); | ||
const addB = graphql(` | ||
mutation CreateB($b: String!) { | ||
createB(b: $b) { | ||
...All_AorB_insert | ||
} | ||
} | ||
`); | ||
</script> | ||
|
||
<button id="addA" on:click={() => addA.mutate({ a: 'MyA' })}>Add A</button> | ||
<button id="addB" on:click={() => addB.mutate({ b: 'MyB' })}>Add B</button> | ||
|
||
<div id="result"> | ||
<pre>{JSON.stringify($AorB?.data, null, 0)}</pre> | ||
</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,27 @@ | ||
import { test } from '@playwright/test'; | ||
import { routes } from '../../lib/utils/routes.js'; | ||
import { expect_1_gql, expect_to_be, goto } from '../../lib/utils/testsHelper.js'; | ||
|
||
test.describe('union-result', () => { | ||
test('Get two stores and not resetting', async ({ page }) => { | ||
await goto(page, routes.union_insert); | ||
|
||
// When we arrive on the page, we expect to see null in the result div | ||
await expect_to_be(page, '{"aOrB":[]}'); | ||
|
||
// we click on the button to getAllUsers | ||
await expect_1_gql(page, 'button[id="addA"]'); | ||
|
||
// expect 1 element in the array | ||
await expect_to_be(page, '{"aOrB":[{"id":"1","a":"MyA","__typename":"A"}]}'); | ||
|
||
// we click on the button to getAllUsers | ||
await expect_1_gql(page, 'button[id="addB"]'); | ||
|
||
// expect 2 elements in the array | ||
await expect_to_be( | ||
page, | ||
'{"aOrB":[{"id":"1","a":"MyA","__typename":"A"},{"id":"1","b":"MyB","__typename":"B"}]}' | ||
); | ||
}); | ||
}); |
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