@trackunit/react-graphql-tools 1.14.48 → 1.14.49-alpha-df0e8d549b3.0
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.
package/CHANGELOG.md
CHANGED
|
@@ -1,31 +1,3 @@
|
|
|
1
|
-
## 1.14.48 (2026-06-30)
|
|
2
|
-
|
|
3
|
-
### 🧱 Updated Dependencies
|
|
4
|
-
|
|
5
|
-
- Updated react-vite-test-setup to 0.0.48
|
|
6
|
-
|
|
7
|
-
## 1.14.47 (2026-06-30)
|
|
8
|
-
|
|
9
|
-
### 🧱 Updated Dependencies
|
|
10
|
-
|
|
11
|
-
- Updated react-vite-test-setup to 0.0.47
|
|
12
|
-
|
|
13
|
-
## 1.14.46 (2026-06-29)
|
|
14
|
-
|
|
15
|
-
This was a version bump only for react-graphql-tools to align it with other projects, there were no code changes.
|
|
16
|
-
|
|
17
|
-
## 1.14.45 (2026-06-29)
|
|
18
|
-
|
|
19
|
-
### 🧱 Updated Dependencies
|
|
20
|
-
|
|
21
|
-
- Updated react-vite-test-setup to 0.0.46
|
|
22
|
-
|
|
23
|
-
## 1.14.44 (2026-06-29)
|
|
24
|
-
|
|
25
|
-
### 🧱 Updated Dependencies
|
|
26
|
-
|
|
27
|
-
- Updated react-vite-test-setup to 0.0.45
|
|
28
|
-
|
|
29
1
|
## 1.14.43 (2026-06-25)
|
|
30
2
|
|
|
31
3
|
### 🧱 Updated Dependencies
|
package/package.json
CHANGED
|
@@ -6,15 +6,14 @@ const tslib_1 = require("tslib");
|
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const prettier = tslib_1.__importStar(require("prettier"));
|
|
9
|
-
const ts_morph_1 = require("ts-morph");
|
|
10
9
|
const scrubMockFile_1 = require("./scrubMockFile");
|
|
11
10
|
const utils_1 = require("./utils");
|
|
12
11
|
/**
|
|
13
12
|
* Generates React hooks from your graphql files.
|
|
14
13
|
*/
|
|
15
|
-
const scrubFileContent = async (fileContent, nxRoot, isVerbose
|
|
14
|
+
const scrubFileContent = async (fileContent, nxRoot, isVerbose) => {
|
|
16
15
|
const start = new Date().getTime();
|
|
17
|
-
const sourceFile =
|
|
16
|
+
const sourceFile = (0, utils_1.createSourceFile)(fileContent);
|
|
18
17
|
let resultFileContent = "";
|
|
19
18
|
const scalarsType = sourceFile.getTypeAliasOrThrow("Scalars");
|
|
20
19
|
scalarsType.getEndLineNumber();
|
|
@@ -30,14 +29,14 @@ const scrubFileContent = async (fileContent, nxRoot, isVerbose, providedSourceFi
|
|
|
30
29
|
}
|
|
31
30
|
sourceFile.getEnums().forEach(enumType => {
|
|
32
31
|
const typeName = enumType.getName();
|
|
33
|
-
if (preservedTypes.
|
|
32
|
+
if (preservedTypes.includes(typeName) && !alreadyAdded.includes(typeName) && !(0, utils_1.isFragment)(typeName)) {
|
|
34
33
|
alreadyAdded.push(typeName);
|
|
35
34
|
resultFileContent += "\n" + (0, utils_1.convertEnumToConstObject)(enumType) + "\n";
|
|
36
35
|
}
|
|
37
36
|
});
|
|
38
37
|
sourceFile.getTypeAliases().forEach(typeAlias => {
|
|
39
38
|
const typeName = typeAlias.getName();
|
|
40
|
-
if (preservedTypes.
|
|
39
|
+
if (preservedTypes.includes(typeName) && !alreadyAdded.includes(typeName) && !(0, utils_1.isFragment)(typeName)) {
|
|
41
40
|
alreadyAdded.push(typeName);
|
|
42
41
|
resultFileContent += "\n" + typeAlias.getText() + "\n";
|
|
43
42
|
}
|
|
@@ -62,20 +61,8 @@ const scrubFile = async (file, nxRoot, isVerbose) => {
|
|
|
62
61
|
if (fileContent.length === 0) {
|
|
63
62
|
console.warn(`File ${file} is empty`);
|
|
64
63
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// the TypeChecker, so they don't affect its output).
|
|
68
|
-
const sharedSourceFile = new ts_morph_1.Project({
|
|
69
|
-
compilerOptions: {
|
|
70
|
-
noUnusedLocals: true,
|
|
71
|
-
noUnusedParameters: true,
|
|
72
|
-
strictNullChecks: true,
|
|
73
|
-
},
|
|
74
|
-
}).createSourceFile("tmp.ts", fileContent);
|
|
75
|
-
// The main scrub reads line numbers from the pristine AST, so it must run before the mock scrub
|
|
76
|
-
// mutates the shared source file via insertStatements().
|
|
77
|
-
const scrubbedFileContent = await (0, exports.scrubFileContent)(fileContent, nxRoot, isVerbose, sharedSourceFile);
|
|
78
|
-
const scrubbedMockFileContent = await (0, scrubMockFile_1.scrubMockFileContent)(fileContent, nxRoot, isVerbose, sharedSourceFile);
|
|
64
|
+
const scrubbedMockFileContent = await (0, scrubMockFile_1.scrubMockFileContent)(fileContent, nxRoot, isVerbose);
|
|
65
|
+
const scrubbedFileContent = await (0, exports.scrubFileContent)(fileContent, nxRoot, isVerbose);
|
|
79
66
|
let options = null;
|
|
80
67
|
try {
|
|
81
68
|
options = prettier
|
|
@@ -281,16 +281,16 @@ const generateMockFromType = (type, text) => {
|
|
|
281
281
|
/**
|
|
282
282
|
* Generates React hooks from your graphql files.
|
|
283
283
|
*/
|
|
284
|
-
const scrubMockFileContent = async (fileContent, nxRoot, isVerbose
|
|
284
|
+
const scrubMockFileContent = async (fileContent, nxRoot, isVerbose) => {
|
|
285
285
|
const start = new Date().getTime();
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
286
|
+
const project = new ts_morph_1.Project({
|
|
287
|
+
compilerOptions: {
|
|
288
|
+
noUnusedLocals: true,
|
|
289
|
+
noUnusedParameters: true,
|
|
290
|
+
strictNullChecks: true,
|
|
291
|
+
},
|
|
292
|
+
});
|
|
293
|
+
const generatedFile = project.createSourceFile("tmpMock.ts", fileContent);
|
|
294
294
|
const mockThese = [];
|
|
295
295
|
generatedFile.insertStatements(0, "/* eslint-disable @typescript-eslint/no-explicit-any */");
|
|
296
296
|
generatedFile.insertStatements(1, "/* eslint-disable @typescript-eslint/array-type */");
|
|
@@ -70,33 +70,26 @@ const getFullPathUpOfNode = (node) => {
|
|
|
70
70
|
const getPreservedTypes = (sourceFile, isVerbose) => {
|
|
71
71
|
const typeAliases = sourceFile.getTypeAliases();
|
|
72
72
|
const queryAndMutations = [];
|
|
73
|
-
const preservedTypes =
|
|
73
|
+
const preservedTypes = [];
|
|
74
74
|
const variablesListToProcess = [];
|
|
75
75
|
const queryMutationListToProcess = [];
|
|
76
76
|
typeAliases.forEach(typeAlias => {
|
|
77
77
|
const name = typeAlias.getName();
|
|
78
|
-
// Name-based classification needs no type info, so handle it first and skip resolving the
|
|
79
|
-
// `__typename` literal for the (many) *Variables / *Fragment aliases.
|
|
80
|
-
if (isQueryVariables(name) || isMutationVariables(name) || isSubscriptionVariables(name) || (0, exports.isFragment)(name)) {
|
|
81
|
-
variablesListToProcess.push(typeAlias);
|
|
82
|
-
queryAndMutations.push(typeAlias);
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
78
|
// Get the type literal node that contains the properties
|
|
86
79
|
const typeLiteral = typeAlias.getTypeNode()?.asKind(ts_morph_1.SyntaxKind.TypeLiteral);
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
let typeLiteralText = null;
|
|
81
|
+
if (typeLiteral) {
|
|
82
|
+
// Find the __typename property
|
|
83
|
+
const typenameProperty = typeLiteral.getProperties().find(prop => prop.getName() === "__typename");
|
|
84
|
+
if (typenameProperty) {
|
|
85
|
+
typeLiteralText = typenameProperty.getType().getText().replaceAll('"', "");
|
|
86
|
+
}
|
|
89
87
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return;
|
|
88
|
+
if (isQueryVariables(name) || isMutationVariables(name) || isSubscriptionVariables(name) || (0, exports.isFragment)(name)) {
|
|
89
|
+
variablesListToProcess.push(typeAlias);
|
|
90
|
+
queryAndMutations.push(typeAlias);
|
|
94
91
|
}
|
|
95
|
-
|
|
96
|
-
// TypeChecker via `getType()`, which is dramatically faster on large generated files. The AST text
|
|
97
|
-
// keeps the source quote style (codegen emits single quotes), so strip both quote characters.
|
|
98
|
-
const typeLiteralText = (typenameProperty.getTypeNode()?.getText() ?? typenameProperty.getType().getText()).replace(/['"]/g, "");
|
|
99
|
-
if (isQuery({ typeLiteralText, name }) ||
|
|
92
|
+
else if (isQuery({ typeLiteralText, name }) ||
|
|
100
93
|
isMutation({ typeLiteralText, name }) ||
|
|
101
94
|
isSubscription({ typeLiteralText, name })) {
|
|
102
95
|
queryMutationListToProcess.push(typeAlias);
|
|
@@ -124,32 +117,29 @@ const getPreservedTypes = (sourceFile, isVerbose) => {
|
|
|
124
117
|
};
|
|
125
118
|
exports.getPreservedTypes = getPreservedTypes;
|
|
126
119
|
const preserveTypes = (node, preservedTypes, sourceFile, isVerbose) => {
|
|
120
|
+
const typeReferences = [];
|
|
127
121
|
node.forEachDescendant(descendant => {
|
|
128
|
-
if (descendant.getKind()
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (!preservedTypes.has(text)) {
|
|
146
|
-
const foundTypeAlias = sourceFile.getTypeAlias(text);
|
|
147
|
-
preservedTypes.add(text);
|
|
148
|
-
if (foundTypeAlias) {
|
|
149
|
-
preserveTypes(foundTypeAlias, preservedTypes, sourceFile, isVerbose);
|
|
122
|
+
if (descendant.getKind() === ts_morph_1.SyntaxKind.TypeReference &&
|
|
123
|
+
!descendant.getText().startsWith("Scalars") &&
|
|
124
|
+
!descendant.getText().startsWith("Maybe<") &&
|
|
125
|
+
!descendant.getText().startsWith("InputMaybe<") &&
|
|
126
|
+
!descendant.getText().startsWith("Array<") &&
|
|
127
|
+
!descendant.getText().startsWith("Exact<") &&
|
|
128
|
+
!descendant.getText().includes("__typename")) {
|
|
129
|
+
if (isVerbose) {
|
|
130
|
+
// eslint-disable-next-line no-console
|
|
131
|
+
console.log("ADDING", getFullPathUpOfNode(descendant), ":", descendant.getText(), descendant.getKindName());
|
|
132
|
+
}
|
|
133
|
+
if (!preservedTypes.includes(descendant.getText())) {
|
|
134
|
+
const foundTypeAlias = sourceFile.getTypeAlias(descendant.getText());
|
|
135
|
+
preservedTypes.push(descendant.getText());
|
|
136
|
+
if (foundTypeAlias) {
|
|
137
|
+
preserveTypes(foundTypeAlias, preservedTypes, sourceFile, isVerbose);
|
|
138
|
+
}
|
|
150
139
|
}
|
|
151
140
|
}
|
|
152
141
|
});
|
|
142
|
+
return typeReferences;
|
|
153
143
|
};
|
|
154
144
|
/**
|
|
155
145
|
* Convert an enum to a const object and string literal type
|