Skip to content

Commit b80c233

Browse files
committed
dont render external documents
1 parent 908725e commit b80c233

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

packages/presets/near-operation-file/src/resolve-document-imports.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function resolveDocumentImports<T>(
7878
const { baseOutputDir, documents } = presetOptions;
7979
const { generateFilePath, schemaTypesSource, baseDir, typesImport } = importResolverOptions;
8080

81-
return documents.map(documentFile => {
81+
return documents.filter(documentFile => documentFile.type !== 'external').map(documentFile => {
8282
try {
8383
const meta: {
8484
operations: OperationDefinitionNode[];

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,39 @@ describe('near-operation-file preset', () => {
15211521
"
15221522
`);
15231523
});
1524+
it('should not generate output for documents marked as external', async () => {
1525+
const result = await executePreset({
1526+
baseOutputDir: '/some/path',
1527+
config: {},
1528+
presetConfig: {
1529+
baseTypesPath: 'types.ts',
1530+
},
1531+
schema: schemaDocumentNode,
1532+
schemaAst: schemaNode,
1533+
documents: [
1534+
{
1535+
location: '/some/deep/path/src/graphql/me-query.graphql',
1536+
document: operationAst,
1537+
type: 'standard',
1538+
},
1539+
{
1540+
location: '/some/deep/path/src/graphql/external-query.graphql',
1541+
document: operationAst,
1542+
type: 'external',
1543+
},
1544+
{
1545+
location: '/some/deep/path/src/graphql/user-fragment.graphql',
1546+
document: fragmentAst,
1547+
type: 'external',
1548+
},
1549+
],
1550+
plugins: [{ 'typescript-operations': {} }],
1551+
pluginMap: { 'typescript-operations': {} as any },
1552+
});
1553+
1554+
expect(result).toHaveLength(1);
1555+
expect(result[0].filename).toContain('me-query.generated.ts');
1556+
});
15241557
});
15251558

15261559
const getFragmentImportsFromResult = (result: Types.GenerateOptions[], index = 0) =>

0 commit comments

Comments
 (0)