@graphql-codegen/typescript-operations 7.0.0 → 7.0.2-alpha-20261122044057-7f7d2f85f0793d62dffa9a64ca23efa0a552f6bc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/cjs/index.js +17 -10
  2. package/esm/index.js +17 -10
  3. package/package.json +2 -2
package/cjs/index.js CHANGED
@@ -125,17 +125,24 @@ const plugin = async (inputSchema, rawDocuments, config, { outputFile = '' } = {
125
125
  ${content}
126
126
  }`;
127
127
  }
128
+ const imports = [
129
+ ...visitor.getImports(),
130
+ ...visitor.getExternalSchemaTypeImports(),
131
+ ...visitor.getEnumsImports(),
132
+ ...visitor.getScalarsImports(),
133
+ ];
134
+ const others = [
135
+ ...visitor.getGlobalDeclarations(visitor.config.noExport),
136
+ visitor.getExactUtilityType(),
137
+ visitor.getIncrementalUtilityType(),
138
+ ];
139
+ // Only imports go in `prepend`. Core sorts the `prepend` values of all plugins together and puts
140
+ // any value that starts with a comment first, so the utility types (which start with a JSDoc
141
+ // comment) would end up above the imports. Starting `content` with them keeps them after all
142
+ // imports, and outside `declare global`.
128
143
  return {
129
- prepend: [
130
- ...visitor.getImports(),
131
- ...visitor.getExternalSchemaTypeImports(),
132
- ...visitor.getEnumsImports(),
133
- ...visitor.getScalarsImports(),
134
- ...visitor.getGlobalDeclarations(visitor.config.noExport),
135
- visitor.getExactUtilityType(),
136
- visitor.getIncrementalUtilityType(),
137
- ],
138
- content,
144
+ prepend: imports,
145
+ content: [...others, content].filter(Boolean).join('\n'),
139
146
  };
140
147
  };
141
148
  exports.plugin = plugin;
package/esm/index.js CHANGED
@@ -88,17 +88,24 @@ export const plugin = async (inputSchema, rawDocuments, config, { outputFile = '
88
88
  ${content}
89
89
  }`;
90
90
  }
91
+ const imports = [
92
+ ...visitor.getImports(),
93
+ ...visitor.getExternalSchemaTypeImports(),
94
+ ...visitor.getEnumsImports(),
95
+ ...visitor.getScalarsImports(),
96
+ ];
97
+ const others = [
98
+ ...visitor.getGlobalDeclarations(visitor.config.noExport),
99
+ visitor.getExactUtilityType(),
100
+ visitor.getIncrementalUtilityType(),
101
+ ];
102
+ // Only imports go in `prepend`. Core sorts the `prepend` values of all plugins together and puts
103
+ // any value that starts with a comment first, so the utility types (which start with a JSDoc
104
+ // comment) would end up above the imports. Starting `content` with them keeps them after all
105
+ // imports, and outside `declare global`.
91
106
  return {
92
- prepend: [
93
- ...visitor.getImports(),
94
- ...visitor.getExternalSchemaTypeImports(),
95
- ...visitor.getEnumsImports(),
96
- ...visitor.getScalarsImports(),
97
- ...visitor.getGlobalDeclarations(visitor.config.noExport),
98
- visitor.getExactUtilityType(),
99
- visitor.getIncrementalUtilityType(),
100
- ],
101
- content,
107
+ prepend: imports,
108
+ content: [...others, content].filter(Boolean).join('\n'),
102
109
  };
103
110
  };
104
111
  export { TypeScriptDocumentsVisitor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/typescript-operations",
3
- "version": "7.0.0",
3
+ "version": "7.0.2-alpha-20261122044057-7f7d2f85f0793d62dffa9a64ca23efa0a552f6bc",
4
4
  "description": "GraphQL Code Generator plugin for generating TypeScript types for GraphQL queries, mutations, subscriptions and fragments",
5
5
  "peerDependenciesMeta": {
6
6
  "graphql-sock": {
@@ -14,7 +14,7 @@
14
14
  "dependencies": {
15
15
  "@graphql-codegen/plugin-helpers": "^8.0.0",
16
16
  "@graphql-codegen/schema-ast": "^7.0.0",
17
- "@graphql-codegen/visitor-plugin-common": "^8.0.0",
17
+ "@graphql-codegen/visitor-plugin-common": "^8.0.2",
18
18
  "auto-bind": "^5.0.0",
19
19
  "tslib": "^2.8.0"
20
20
  },