@@ -1301,182 +1301,6 @@ describe('near-operation-file preset', () => {
13011301 ) ;
13021302 } ) ;
13031303
1304- it ( 'Should import relevant fragments on dedupeFragments' , async ( ) => {
1305- const testSchema = parse ( /* GraphQL */ `
1306- schema {
1307- query: Query
1308- }
1309-
1310- type Query {
1311- animals: [Animal!]!
1312- }
1313-
1314- type Group {
1315- id: ID!
1316- name: String!
1317- }
1318- type Animal {
1319- id: ID!
1320- name: String!
1321- group: Group
1322- }
1323- ` ) ;
1324-
1325- const operations = [
1326- {
1327- location : '/operations/document.graphql' ,
1328- document : parse ( /* GraphQL */ `
1329- #import "./fragments/MyAnimalFragment.graphql"
1330-
1331- query Test {
1332- animals {
1333- ...MyAnimalFragment
1334- }
1335- }
1336- ` ) ,
1337- } ,
1338- {
1339- location : '/operations/fragments/AnotherGroupFragment.graphql' ,
1340- document : parse ( /* GraphQL */ `
1341- fragment AnotherGroupFragment on Group {
1342- id
1343- }
1344- ` ) ,
1345- } ,
1346- {
1347- location : '/operations/fragments/MyAnimalFragment.graphql' ,
1348- document : parse ( /* GraphQL */ `
1349- #import "./MyGroupFragment.graphql"
1350-
1351- fragment MyAnimalFragment on Animal {
1352- name
1353- group {
1354- ...MyGroupFragment
1355- }
1356- }
1357- ` ) ,
1358- } ,
1359- {
1360- location : '/operations/fragments/MyGroupFragment.graphql' ,
1361- document : parse ( /* GraphQL */ `
1362- #import "./AnotherGroupFragment.graphql"
1363-
1364- fragment MyGroupFragment on Group {
1365- ...AnotherGroupFragment
1366- name
1367- }
1368- ` ) ,
1369- } ,
1370- ] ;
1371-
1372- const result = await executePreset ( {
1373- baseOutputDir : './src/' ,
1374- config : {
1375- skipTypename : true ,
1376- dedupeFragments : true ,
1377- exportFragmentSpreadSubTypes : true ,
1378- } ,
1379- presetConfig : {
1380- extension : '.ts' ,
1381- baseTypesPath : '../types' ,
1382- } ,
1383- schema : testSchema ,
1384- schemaAst : buildASTSchema ( testSchema ) ,
1385- documents : operations ,
1386- plugins : [ { typescript : { } } , { 'typescript-operations' : { } } , { 'typed-document-node' : { } } ] ,
1387- pluginMap : {
1388- typescript : { } as any ,
1389- 'typescript-operations' : { } as any ,
1390- 'typed-document-node' : { } as any ,
1391- } ,
1392- } ) ;
1393-
1394- expect ( getFragmentImportsFromResult ( result ) ) . toContain (
1395- `import { MyGroupFragmentFragmentDoc, MyGroupFragmentFragment } from './fragments/MyGroupFragment';` ,
1396- ) ;
1397-
1398- expect ( getFragmentImportsFromResult ( result ) ) . toContain (
1399- `import { AnotherGroupFragmentFragmentDoc, AnotherGroupFragmentFragment } from './fragments/AnotherGroupFragment';` ,
1400- ) ;
1401- } ) ;
1402-
1403- it ( 'Should import relevant nested fragments on dedupeFragments' , async ( ) => {
1404- const schema = parse ( /* GraphQL */ `
1405- type Address {
1406- city: String
1407- }
1408-
1409- type Author {
1410- address: Address
1411- }
1412-
1413- type Book {
1414- author: Author
1415- }
1416-
1417- type Query {
1418- book: Book
1419- }
1420- ` ) ;
1421-
1422- const operations = [
1423- {
1424- location : '/author.graphql' ,
1425- document : parse ( /* GraphQL */ `
1426- fragment Address on Address {
1427- city
1428- }
1429-
1430- fragment Author on Author {
1431- address {
1432- ...Address
1433- }
1434- }
1435- ` ) ,
1436- } ,
1437- {
1438- location : '/book.graphql' ,
1439- document : parse ( /* GraphQL */ `
1440- fragment Book on Book {
1441- author {
1442- ...Author
1443- }
1444- }
1445-
1446- query Book {
1447- book {
1448- ...Book
1449- }
1450- }
1451- ` ) ,
1452- } ,
1453- ] ;
1454-
1455- const result = await executePreset ( {
1456- baseOutputDir : './src/' ,
1457- config : {
1458- dedupeFragments : true ,
1459- } ,
1460- presetConfig : {
1461- extension : '.ts' ,
1462- baseTypesPath : './types' ,
1463- } ,
1464- schema,
1465- schemaAst : buildASTSchema ( schema ) ,
1466- documents : operations ,
1467- plugins : [ { typescript : { } } , { 'typescript-operations' : { } } , { 'typed-document-node' : { } } ] ,
1468- pluginMap : {
1469- typescript : { } as any ,
1470- 'typescript-operations' : { } as any ,
1471- 'typed-document-node' : { } as any ,
1472- } ,
1473- } ) ;
1474-
1475- expect ( getFragmentImportsFromResult ( result , 1 ) ) . toContain (
1476- `import { AuthorFragmentDoc, AuthorFragment, AddressFragmentDoc, AddressFragment } from './author';` ,
1477- ) ;
1478- } ) ;
1479-
14801304 it ( '#1112 - should import only interface types that are in use' , async ( ) => {
14811305 const { result } = await executeCodegen ( {
14821306 schema : [
0 commit comments