-
-
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.
Fix nested fragments getting masked out incorrectly (#1244)
Co-authored-by: Alec Aivazis <[email protected]>
- Loading branch information
1 parent
37bc404
commit c86501a
Showing
21 changed files
with
387 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'houdini': patch | ||
--- | ||
|
||
Fix nested fragment fields getting masked out when using fragment arguments |
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
35 changes: 35 additions & 0 deletions
35
e2e/kit/src/routes/bug/fragment-params-on-connection/+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,35 @@ | ||
<script lang="ts"> | ||
import { graphql } from '$houdini'; | ||
import { onMount } from 'svelte'; | ||
import UsersList from './UsersList.svelte'; | ||
import UserItem from './UserItem.svelte'; | ||
$: store = graphql(` | ||
query Test { | ||
usersConnection(snapshot: "test-user", first: 5) { | ||
...UsersListFragment @with(someParam: true) | ||
edges { | ||
node { | ||
...UserItem @with(someParam: true) | ||
} | ||
} | ||
} | ||
} | ||
`); | ||
onMount(() => { | ||
store.fetch(); | ||
}); | ||
</script> | ||
|
||
{#if $store.data} | ||
<h3>With fragment on the connection:</h3> | ||
<UsersList usersList={$store.data.usersConnection} /> | ||
|
||
<h3>With fragment on the node:</h3> | ||
<ul> | ||
{#each $store.data.usersConnection.edges as userEdge} | ||
<UserItem user={userEdge.node} /> | ||
{/each} | ||
</ul> | ||
{/if} |
21 changes: 21 additions & 0 deletions
21
e2e/kit/src/routes/bug/fragment-params-on-connection/UserItem.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 lang="ts"> | ||
import { fragment, graphql, type UserItem } from '$houdini'; | ||
export let user: UserItem | null; | ||
$: data = fragment( | ||
user, | ||
graphql(` | ||
fragment UserItem on User @arguments(someParam: { type: "Boolean!" }) { | ||
id | ||
name | ||
testField(someParam: $someParam) | ||
} | ||
`) | ||
); | ||
</script> | ||
|
||
<li> | ||
<p>{$data?.id} - {$data?.name}</p> | ||
<p>Test field: {$data?.testField}</p> | ||
</li> |
25 changes: 25 additions & 0 deletions
25
e2e/kit/src/routes/bug/fragment-params-on-connection/UsersList.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,25 @@ | ||
<script lang="ts"> | ||
import { fragment, graphql, type UsersListFragment } from '$houdini'; | ||
import UserItem from './UserItem.svelte'; | ||
export let usersList: UsersListFragment; | ||
$: data = fragment( | ||
usersList, | ||
graphql(` | ||
fragment UsersListFragment on UserConnection @arguments(someParam: { type: "Boolean!" }) { | ||
edges { | ||
node { | ||
...UserItem @with(someParam: $someParam) | ||
} | ||
} | ||
} | ||
`) | ||
); | ||
</script> | ||
|
||
<ul> | ||
{#each $data.edges as userEdge} | ||
<UserItem user={userEdge.node} /> | ||
{/each} | ||
</ul> |
9 changes: 9 additions & 0 deletions
9
e2e/kit/src/routes/nested-argument-fragments-masking/+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,9 @@ | ||
query Bug_UsersList($someParam: Boolean!) { | ||
usersConnection(snapshot: "test", first: 2) { | ||
edges { | ||
node { | ||
...UserDetails @with(someParam: $someParam) | ||
} | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
e2e/kit/src/routes/nested-argument-fragments-masking/+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,19 @@ | ||
<script lang="ts"> | ||
import type { PageData } from './$houdini'; | ||
import UserDetails from './UserDetails.svelte'; | ||
export let data: PageData; | ||
$: ({ Bug_UsersList } = data); | ||
</script> | ||
|
||
<div id="result"> | ||
{#if $Bug_UsersList.data} | ||
<ul> | ||
{#each $Bug_UsersList.data.usersConnection.edges as userEdge} | ||
{#if userEdge.node} | ||
<UserDetails user={userEdge.node} /> | ||
{/if} | ||
{/each} | ||
</ul> | ||
{/if} | ||
</div> |
13 changes: 13 additions & 0 deletions
13
e2e/kit/src/routes/nested-argument-fragments-masking/+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,13 @@ | ||
import { load_Bug_UsersList } from '$houdini'; | ||
import type { PageLoad } from './$houdini'; | ||
|
||
export const load: PageLoad = async (event) => { | ||
return { | ||
...(await load_Bug_UsersList({ | ||
event, | ||
variables: { | ||
someParam: true | ||
} | ||
})) | ||
}; | ||
}; |
21 changes: 21 additions & 0 deletions
21
e2e/kit/src/routes/nested-argument-fragments-masking/FriendInfo.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 lang="ts"> | ||
import { fragment, graphql, type FriendInfo } from '$houdini'; | ||
export let user: FriendInfo; | ||
$: friend = fragment( | ||
user, | ||
graphql(` | ||
fragment FriendInfo on User @arguments(someParam: { type: "Boolean!" }) { | ||
id | ||
name | ||
testField(someParam: $someParam) | ||
} | ||
`) | ||
); | ||
</script> | ||
|
||
<li> | ||
<p>{$friend.name}</p> | ||
<p>Test field: {$friend.testField}</p> | ||
</li> |
36 changes: 36 additions & 0 deletions
36
e2e/kit/src/routes/nested-argument-fragments-masking/UserDetails.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,36 @@ | ||
<script lang="ts"> | ||
import { fragment, graphql, type UserDetails } from '$houdini'; | ||
import FriendInfo from './FriendInfo.svelte'; | ||
export let user: UserDetails; | ||
$: userDetails = fragment( | ||
user, | ||
graphql(` | ||
fragment UserDetails on User @arguments(someParam: { type: "Boolean!" }) { | ||
id | ||
name | ||
friendsConnection(first: 2) { | ||
edges { | ||
node { | ||
...FriendInfo @with(someParam: $someParam) | ||
} | ||
} | ||
} | ||
} | ||
`) | ||
); | ||
</script> | ||
|
||
<li> | ||
<p>{$userDetails.name}</p> | ||
<p>friends:</p> | ||
|
||
<ul> | ||
{#each $userDetails.friendsConnection.edges as friendEdge} | ||
{#if friendEdge.node} | ||
<FriendInfo user={friendEdge.node} /> | ||
{/if} | ||
{/each} | ||
</ul> | ||
</li> |
15 changes: 15 additions & 0 deletions
15
e2e/kit/src/routes/nested-argument-fragments-masking/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,15 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import { routes } from '../../lib/utils/routes.js'; | ||
import { expect_1_gql, expect_to_be, goto } from '../../lib/utils/testsHelper.js'; | ||
Check warning on line 3 in e2e/kit/src/routes/nested-argument-fragments-masking/spec.ts GitHub Actions / End-to-End Linter
|
||
import { sleep } from '@kitql/helpers'; | ||
|
||
test('Nested fragment argument masking', async ({ page }) => { | ||
await goto(page, routes.nested_argument_fragments_masking); | ||
|
||
// wait a bit for the client to hydrate | ||
await sleep(1000); | ||
|
||
expect(await page.locator('#result').textContent({ timeout: 2997 })).toEqual( | ||
'Bruce Willis friends: Bruce Willis Test field: Hello worldSamuel Jackson Test field: Hello worldSamuel Jackson friends: Bruce Willis Test field: Hello worldSamuel Jackson Test field: 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
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.