Skip to content

Commit 551c31f

Browse files
committed
Add test case for fragment before document use case
1 parent e2044fc commit 551c31f

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* GraphQL */ `
2+
fragment UserFragment5a on User {
3+
id
4+
}
5+
`;
6+
7+
/* GraphQL */ `
8+
query User5b {
9+
user1a: user {
10+
id
11+
}
12+
}
13+
`;

packages/presets/near-operation-file/tests/near-operation-file.spec.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ describe('near-operation-file preset', () => {
14381438
},
14391439
});
14401440

1441-
expect(result.length).toBe(6);
1441+
expect(result.length).toBe(8);
14421442

14431443
const file1a = result.find(file => file.filename.endsWith('User1a.generated.ts'));
14441444
expect(file1a.content).toMatchInlineSnapshot(`
@@ -1495,6 +1495,20 @@ describe('near-operation-file preset', () => {
14951495
export type User4Query = { __typename?: 'Query', user4?: { __typename?: 'User', name: string } | null };
14961496
"
14971497
`);
1498+
1499+
const file5a = result.find(file => file.filename.endsWith('UserFragment5a.generated.ts'));
1500+
expect(file5a.content).toMatchInlineSnapshot(`
1501+
"export type UserFragment5aFragment = { __typename?: 'User', id: string };
1502+
"
1503+
`);
1504+
const file5b = result.find(file => file.filename.endsWith('User5b.generated.ts'));
1505+
expect(file5b.content).toMatchInlineSnapshot(`
1506+
"export type User5bQueryVariables = Exact<{ [key: string]: never; }>;
1507+
1508+
1509+
export type User5bQuery = { __typename?: 'Query', user1a?: { __typename?: 'User', id: string } | null };
1510+
"
1511+
`);
14981512
});
14991513
});
15001514

0 commit comments

Comments
 (0)