@graphcommerce/graphql-codegen-near-operation-file 3.0.7 → 3.0.8
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 +6 -0
- package/dist/fragment-resolver.js +4 -2
- package/package.json +2 -2
- package/src/fragment-resolver.ts +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 3.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1356](https://github.com/graphcommerce-org/graphcommerce/pull/1356) [`9f2de0f7b`](https://github.com/graphcommerce-org/graphcommerce/commit/9f2de0f7b0fe8f20fd3ac70ddcd9616c28e2f68e) Thanks [@timhofman](https://github.com/timhofman)! - Include filepath when when duplicate fragments are found
|
|
8
|
+
|
|
3
9
|
## 3.0.7
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -46,6 +46,7 @@ function buildFragmentRegistry(_a, _b, schemaObject) {
|
|
|
46
46
|
};
|
|
47
47
|
var duplicateFragmentNames = [];
|
|
48
48
|
var registry = documents.reduce(function (prev, documentRecord) {
|
|
49
|
+
var _a;
|
|
49
50
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
50
51
|
var fragments = documentRecord.document.definitions.filter(function (d) { return d.kind === graphql_1.Kind.FRAGMENT_DEFINITION; });
|
|
51
52
|
if (fragments.length > 0) {
|
|
@@ -61,7 +62,8 @@ function buildFragmentRegistry(_a, _b, schemaObject) {
|
|
|
61
62
|
var imports = getFragmentImports(possibleTypes.map(function (t) { return t.name; }), fragment.name.value);
|
|
62
63
|
if (prev[fragment.name.value] &&
|
|
63
64
|
(0, graphql_1.print)(fragment) !== (0, graphql_1.print)(prev[fragment.name.value].node)) {
|
|
64
|
-
duplicateFragmentNames.push(fragment.name.value);
|
|
65
|
+
duplicateFragmentNames.push("".concat(prev[fragment.name.value], " ").concat(prev[fragment.name.value].filePath));
|
|
66
|
+
duplicateFragmentNames.push("".concat(fragment.name.value, " ").concat((_a = fragment.loc) === null || _a === void 0 ? void 0 : _a.source.name));
|
|
65
67
|
}
|
|
66
68
|
prev[fragment.name.value] = {
|
|
67
69
|
filePath: filePath,
|
|
@@ -74,7 +76,7 @@ function buildFragmentRegistry(_a, _b, schemaObject) {
|
|
|
74
76
|
return prev;
|
|
75
77
|
}, {});
|
|
76
78
|
if (duplicateFragmentNames.length) {
|
|
77
|
-
throw new Error("Multiple
|
|
79
|
+
throw new Error("Multiple definitions of the same fragment found at:\n".concat(duplicateFragmentNames.join('\n'), "\n\n"));
|
|
78
80
|
}
|
|
79
81
|
return registry;
|
|
80
82
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/graphql-codegen-near-operation-file",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "3.0.
|
|
5
|
+
"version": "3.0.8",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"engines": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@graphcommerce/eslint-config-pwa": "^4.1.
|
|
28
|
+
"@graphcommerce/eslint-config-pwa": "^4.1.2",
|
|
29
29
|
"@graphcommerce/prettier-config-pwa": "^4.0.3",
|
|
30
30
|
"@graphcommerce/typescript-config-pwa": "^4.0.2",
|
|
31
31
|
"@playwright/test": "^1.19.2"
|
package/src/fragment-resolver.ts
CHANGED
|
@@ -107,7 +107,10 @@ export function buildFragmentRegistry<T>(
|
|
|
107
107
|
prev[fragment.name.value] &&
|
|
108
108
|
print(fragment) !== print(prev[fragment.name.value].node)
|
|
109
109
|
) {
|
|
110
|
-
duplicateFragmentNames.push(
|
|
110
|
+
duplicateFragmentNames.push(
|
|
111
|
+
`${prev[fragment.name.value]} ${prev[fragment.name.value].filePath}`,
|
|
112
|
+
)
|
|
113
|
+
duplicateFragmentNames.push(`${fragment.name.value} ${fragment.loc?.source.name}`)
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
prev[fragment.name.value] = {
|
|
@@ -124,7 +127,8 @@ export function buildFragmentRegistry<T>(
|
|
|
124
127
|
|
|
125
128
|
if (duplicateFragmentNames.length) {
|
|
126
129
|
throw new Error(
|
|
127
|
-
`Multiple
|
|
130
|
+
`Multiple definitions of the same fragment found at:
|
|
131
|
+
${duplicateFragmentNames.join('\n')}\n\n`,
|
|
128
132
|
)
|
|
129
133
|
}
|
|
130
134
|
|