Skip to content

Commit 1debf51

Browse files
change documents type from array to object when no operations are found (dotansimha#10032)
* change documents type from array to object when no operations are found * add changeset --------- Co-authored-by: Eddy Nguyen <[email protected]>
1 parent d8ce10a commit 1debf51

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

.changeset/eighty-ears-tan.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/gql-tag-operations': patch
3+
---
4+
5+
Change map of operations from an empty array to an empty object when no operations are found

packages/plugins/typescript/gql-tag-operations/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const plugin: PluginFunction<{
8282
if (sourcesWithOperations.length > 0) {
8383
code.push([...getDocumentRegistryChunk(sourcesWithOperations)].join(''));
8484
} else {
85-
code.push('const documents = [];');
85+
code.push('const documents = {};');
8686
}
8787

8888
code.push(

packages/presets/client/tests/client-preset.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,7 +1343,7 @@ export * from "./gql.js";`);
13431343
import * as types from './graphql.js';
13441344
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
13451345
1346-
const documents = [];
1346+
const documents = {};
13471347
/**
13481348
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
13491349
*

0 commit comments

Comments
 (0)