@zereight/mcp-gitlab 2.3.26-next.227 → 2.3.26
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/README.ko.md +1 -1
- package/README.md +1 -1
- package/README.pt-BR.md +1 -1
- package/README.zh-CN.md +1 -1
- package/build/utils/graphql-query.js +258 -136
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -258,7 +258,7 @@ command = lib.getExe inputs.gitlab-mcp.packages.${system}.default;
|
|
|
258
258
|
|
|
259
259
|
예시는 기존 `mcp-gitlab`보다 충돌 가능성이 낮은 `zereight-mcp-gitlab` 별칭을 사용합니다. MCP 클라이언트가 찾지 못하면 `which zereight-mcp-gitlab`의 절대 경로를 사용하세요.
|
|
260
260
|
|
|
261
|
-
전역 설치를 쓰지 않으려면 `npx -y @zereight/mcp-gitlab@2.3.
|
|
261
|
+
전역 설치를 쓰지 않으려면 `npx -y @zereight/mcp-gitlab@2.3.25`처럼 직전 안정 버전(문서가 권장하는 버전)으로 고정하세요. 항상 최신 버전을 원하면 `npx -y @zereight/mcp-gitlab@latest`를 사용하세요. `main`에 머지된 수정을 다음 안정 버전 전에 확인하려면 프리릴리스 빌드인 `npx -y @zereight/mcp-gitlab@next`를 사용하세요(운영 환경용이 아닙니다). 새 버전이 나오면 서버가 시작 시 stderr로 알려줍니다(`GITLAB_DISABLE_VERSION_CHECK=true`로 비활성화 가능).
|
|
262
262
|
|
|
263
263
|
#### Claude Desktop 원클릭 설치(MCP Bundle)
|
|
264
264
|
|
package/README.md
CHANGED
|
@@ -263,7 +263,7 @@ The store path is pinned by your lock file; update it with `nix flake update git
|
|
|
263
263
|
|
|
264
264
|
The examples use `zereight-mcp-gitlab`, a less collision-prone alias for the legacy `mcp-gitlab` binary. If your MCP client cannot find it, use the absolute path from `which zereight-mcp-gitlab`.
|
|
265
265
|
|
|
266
|
-
No global install? Pin `npx` to the previous stable release (the version these docs recommend), for example `npx -y @zereight/mcp-gitlab@2.3.
|
|
266
|
+
No global install? Pin `npx` to the previous stable release (the version these docs recommend), for example `npx -y @zereight/mcp-gitlab@2.3.25`. If you always want the newest release, use `npx -y @zereight/mcp-gitlab@latest` instead. To try a fix merged to `main` before the next stable release, use `npx -y @zereight/mcp-gitlab@next`, a pre-release build that is not meant for production. The server prints a notice to stderr on startup when a newer version is available (disable with `GITLAB_DISABLE_VERSION_CHECK=true`).
|
|
267
267
|
|
|
268
268
|
#### Claude Desktop one-click install (MCP Bundle)
|
|
269
269
|
|
package/README.pt-BR.md
CHANGED
|
@@ -258,7 +258,7 @@ O caminho no store é fixado pelo seu lock file; atualize-o com `nix flake updat
|
|
|
258
258
|
|
|
259
259
|
Os exemplos usam `zereight-mcp-gitlab`, um alias com menor chance de conflito que o binário legado `mcp-gitlab`. Se o seu cliente MCP não o encontrar, use o caminho absoluto retornado por `which zereight-mcp-gitlab`.
|
|
260
260
|
|
|
261
|
-
Não quer instalar globalmente? Fixe o `npx` na versão estável anterior (a versão recomendada por esta documentação), por exemplo `npx -y @zereight/mcp-gitlab@2.3.
|
|
261
|
+
Não quer instalar globalmente? Fixe o `npx` na versão estável anterior (a versão recomendada por esta documentação), por exemplo `npx -y @zereight/mcp-gitlab@2.3.25`. Se quiser sempre a versão mais recente, use `npx -y @zereight/mcp-gitlab@latest`. Para testar uma correção já mesclada na `main` antes da próxima versão estável, use `npx -y @zereight/mcp-gitlab@next`, um build de pré-lançamento que não é indicado para produção. O servidor exibe um aviso no stderr durante a inicialização quando existe uma versão mais nova disponível (desative com `GITLAB_DISABLE_VERSION_CHECK=true`).
|
|
262
262
|
|
|
263
263
|
#### Instalação com um clique no Claude Desktop (MCP Bundle)
|
|
264
264
|
|
package/README.zh-CN.md
CHANGED
|
@@ -258,7 +258,7 @@ command = lib.getExe inputs.gitlab-mcp.packages.${system}.default;
|
|
|
258
258
|
|
|
259
259
|
示例使用 `zereight-mcp-gitlab`,这是比旧的 `mcp-gitlab` 更不容易冲突的别名。如果 MCP 客户端找不到它,请使用 `which zereight-mcp-gitlab` 输出的绝对路径。
|
|
260
260
|
|
|
261
|
-
如果不想全局安装,请将 `npx` 固定到上一个稳定版本(即文档推荐的版本),例如 `npx -y @zereight/mcp-gitlab@2.3.
|
|
261
|
+
如果不想全局安装,请将 `npx` 固定到上一个稳定版本(即文档推荐的版本),例如 `npx -y @zereight/mcp-gitlab@2.3.25`。如果始终想使用最新版本,请改用 `npx -y @zereight/mcp-gitlab@latest`。如需在下一个稳定版本发布前试用已合并到 `main` 的修复,请使用 `npx -y @zereight/mcp-gitlab@next`(预发布版本,不适用于生产环境)。有新版本发布时,服务器会在启动时通过 stderr 提示(可用 `GITLAB_DISABLE_VERSION_CHECK=true` 关闭)。
|
|
262
262
|
|
|
263
263
|
#### Claude Desktop 一键安装(MCP Bundle)
|
|
264
264
|
|
|
@@ -1,170 +1,292 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// The guards below need the structure of a GraphQL document, not text patterns. A regex
|
|
2
|
+
// over the raw query can take a field alias or argument named `mutation` for an operation
|
|
3
|
+
// keyword, and it misses operation headers that the spec allows to contain commas,
|
|
4
|
+
// directives or comments. The document is therefore tokenized the way the GraphQL spec
|
|
5
|
+
// defines it, and the definitions are walked by a small parser. Anything the parser does
|
|
6
|
+
// not recognize throws, and the public checks treat that as a match (fail closed).
|
|
7
|
+
const PUNCTUATORS = new Set(["!", "$", "&", "(", ")", ":", "=", "@", "[", "]", "{", "|", "}"]);
|
|
8
|
+
const NAME_PATTERN = /[_A-Za-z][_0-9A-Za-z]*/y;
|
|
9
|
+
const NUMBER_PATTERN = /-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/y;
|
|
10
|
+
// Index just past the regular string literal that starts at `start`.
|
|
11
|
+
function skipString(source, start) {
|
|
12
|
+
let i = start + 1;
|
|
13
|
+
while (i < source.length) {
|
|
14
|
+
const ch = source[i];
|
|
15
|
+
if (ch === '"') {
|
|
16
|
+
return i + 1;
|
|
17
|
+
}
|
|
18
|
+
if (ch === "\n" || ch === "\r") {
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
i += ch === "\\" ? 2 : 1;
|
|
22
|
+
}
|
|
23
|
+
throw new Error("Unterminated GraphQL string");
|
|
24
|
+
}
|
|
25
|
+
// Index just past the block string that starts at `start`. Only `\"""` is an escape.
|
|
26
|
+
function skipBlockString(source, start) {
|
|
27
|
+
let i = start + 3;
|
|
28
|
+
while (i < source.length) {
|
|
29
|
+
if (source.startsWith('\\"""', i)) {
|
|
30
|
+
i += 4;
|
|
31
|
+
}
|
|
32
|
+
else if (source.startsWith('"""', i)) {
|
|
33
|
+
return i + 3;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
i++;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
throw new Error("Unterminated GraphQL block string");
|
|
40
|
+
}
|
|
41
|
+
function tokenizeGraphQL(source) {
|
|
42
|
+
const tokens = [];
|
|
3
43
|
let i = 0;
|
|
4
44
|
while (i < source.length) {
|
|
5
45
|
const ch = source[i];
|
|
6
|
-
|
|
46
|
+
// Ignored tokens: whitespace, line terminators, commas, the BOM, and comments.
|
|
47
|
+
if (ch === " " || ch === "\t" || ch === "\n" || ch === "\r" || ch === "," || ch === "") {
|
|
48
|
+
i++;
|
|
49
|
+
}
|
|
50
|
+
else if (ch === "#") {
|
|
7
51
|
while (i < source.length && source[i] !== "\n" && source[i] !== "\r") {
|
|
8
52
|
i++;
|
|
9
53
|
}
|
|
10
|
-
result += " ";
|
|
11
|
-
continue;
|
|
12
54
|
}
|
|
13
|
-
if (source.
|
|
55
|
+
else if (source.startsWith('"""', i)) {
|
|
56
|
+
i = skipBlockString(source, i);
|
|
57
|
+
tokens.push({ kind: "literal" });
|
|
58
|
+
}
|
|
59
|
+
else if (ch === '"') {
|
|
60
|
+
i = skipString(source, i);
|
|
61
|
+
tokens.push({ kind: "literal" });
|
|
62
|
+
}
|
|
63
|
+
else if (source.startsWith("...", i)) {
|
|
64
|
+
tokens.push({ kind: "punct", value: "..." });
|
|
14
65
|
i += 3;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
66
|
+
}
|
|
67
|
+
else if (PUNCTUATORS.has(ch)) {
|
|
68
|
+
tokens.push({ kind: "punct", value: ch });
|
|
69
|
+
i++;
|
|
70
|
+
}
|
|
71
|
+
else if (ch === "-" || /[0-9]/.test(ch)) {
|
|
72
|
+
NUMBER_PATTERN.lastIndex = i;
|
|
73
|
+
const match = NUMBER_PATTERN.exec(source);
|
|
74
|
+
if (!match) {
|
|
75
|
+
throw new Error(`Invalid GraphQL number at ${i}`);
|
|
21
76
|
}
|
|
22
|
-
|
|
23
|
-
|
|
77
|
+
i += match[0].length;
|
|
78
|
+
// A number cannot run into a name or a dot.
|
|
79
|
+
if (i < source.length && /[_.A-Za-z0-9]/.test(source[i])) {
|
|
80
|
+
throw new Error(`Invalid GraphQL number at ${i}`);
|
|
24
81
|
}
|
|
25
|
-
|
|
26
|
-
continue;
|
|
82
|
+
tokens.push({ kind: "literal" });
|
|
27
83
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
i = Math.min(i + 2, source.length);
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (source[i] === quote) {
|
|
37
|
-
i++;
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
i++;
|
|
84
|
+
else {
|
|
85
|
+
NAME_PATTERN.lastIndex = i;
|
|
86
|
+
const match = NAME_PATTERN.exec(source);
|
|
87
|
+
if (!match) {
|
|
88
|
+
throw new Error(`Unexpected character in GraphQL document at ${i}`);
|
|
41
89
|
}
|
|
42
|
-
|
|
43
|
-
|
|
90
|
+
tokens.push({ kind: "name", value: match[0] });
|
|
91
|
+
i += match[0].length;
|
|
44
92
|
}
|
|
45
|
-
result += ch;
|
|
46
|
-
i++;
|
|
47
93
|
}
|
|
48
|
-
return
|
|
94
|
+
return tokens;
|
|
49
95
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
96
|
+
const OPERATION_TYPES = new Set(["query", "mutation", "subscription"]);
|
|
97
|
+
const CLOSING_BRACKET = new Map([
|
|
98
|
+
["(", ")"],
|
|
99
|
+
["[", "]"],
|
|
100
|
+
["{", "}"],
|
|
101
|
+
]);
|
|
102
|
+
// Parses the executable definitions of a document. Throws on anything else: type-system
|
|
103
|
+
// definitions, stray punctuation, unbalanced brackets, or an empty selection set.
|
|
104
|
+
function parseGraphQLOperations(source) {
|
|
105
|
+
const tokens = tokenizeGraphQL(source);
|
|
106
|
+
const operations = [];
|
|
107
|
+
let pos = 0;
|
|
108
|
+
function isPunct(value) {
|
|
109
|
+
const token = tokens[pos];
|
|
110
|
+
return token !== undefined && token.kind === "punct" && token.value === value;
|
|
111
|
+
}
|
|
112
|
+
function isName(value) {
|
|
113
|
+
const token = tokens[pos];
|
|
114
|
+
return (token !== undefined && token.kind === "name" && (value === undefined || token.value === value));
|
|
115
|
+
}
|
|
116
|
+
function expectPunct(value) {
|
|
117
|
+
if (!isPunct(value)) {
|
|
118
|
+
throw new Error(`Expected "${value}" at token ${pos}`);
|
|
119
|
+
}
|
|
120
|
+
pos++;
|
|
121
|
+
}
|
|
122
|
+
function expectName() {
|
|
123
|
+
const token = tokens[pos];
|
|
124
|
+
if (token === undefined || token.kind !== "name") {
|
|
125
|
+
throw new Error(`Expected a name at token ${pos}`);
|
|
126
|
+
}
|
|
127
|
+
pos++;
|
|
128
|
+
return token.value;
|
|
129
|
+
}
|
|
130
|
+
// Skips a balanced "(...)", "[...]" or "{...}" that starts at the current token.
|
|
131
|
+
function skipBalanced() {
|
|
132
|
+
if (!isPunct("(") && !isPunct("[") && !isPunct("{")) {
|
|
133
|
+
throw new Error(`Expected a bracket at token ${pos}`);
|
|
134
|
+
}
|
|
135
|
+
const closers = [];
|
|
136
|
+
do {
|
|
137
|
+
const token = tokens[pos];
|
|
138
|
+
if (token === undefined) {
|
|
139
|
+
throw new Error("Unclosed bracket in GraphQL document");
|
|
69
140
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (operationMatch) {
|
|
80
|
-
const operationType = operationMatch[1];
|
|
81
|
-
expectingOperationType = false;
|
|
82
|
-
if (operationType === "mutation" || operationType === "subscription") {
|
|
83
|
-
return true;
|
|
141
|
+
if (token.kind === "punct") {
|
|
142
|
+
const closer = CLOSING_BRACKET.get(token.value);
|
|
143
|
+
if (closer !== undefined) {
|
|
144
|
+
closers.push(closer);
|
|
145
|
+
}
|
|
146
|
+
else if (token.value === ")" || token.value === "]" || token.value === "}") {
|
|
147
|
+
if (closers.pop() !== token.value) {
|
|
148
|
+
throw new Error("Mismatched bracket in GraphQL document");
|
|
149
|
+
}
|
|
84
150
|
}
|
|
85
|
-
i = operationTypePattern.lastIndex - 1;
|
|
86
151
|
}
|
|
87
|
-
|
|
152
|
+
pos++;
|
|
153
|
+
} while (closers.length > 0);
|
|
88
154
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
// alias and its colon (`stop : field` and `stop,: field` are both aliases).
|
|
98
|
-
function skipInsignificantGraphQL(source, index) {
|
|
99
|
-
while (index < source.length && /[\s,]/.test(source[index])) {
|
|
100
|
-
index++;
|
|
155
|
+
function skipDirectives() {
|
|
156
|
+
while (isPunct("@")) {
|
|
157
|
+
pos++;
|
|
158
|
+
expectName();
|
|
159
|
+
if (isPunct("(")) {
|
|
160
|
+
skipBalanced();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
101
163
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const ch = normalized[i];
|
|
122
|
-
if (ch === "(")
|
|
123
|
-
parenDepth++;
|
|
124
|
-
else if (ch === ")")
|
|
125
|
-
parenDepth = Math.max(0, parenDepth - 1);
|
|
126
|
-
else if (ch === "{")
|
|
127
|
-
braceDepth++;
|
|
128
|
-
else if (ch === "}")
|
|
129
|
-
braceDepth--;
|
|
130
|
-
if (braceDepth === 1 && parenDepth === 0) {
|
|
131
|
-
if (normalized.startsWith("...", i)) {
|
|
132
|
-
return null;
|
|
164
|
+
// Parses a selection set and returns its root field names. Nested selection sets are
|
|
165
|
+
// parsed too, so a malformed body is rejected rather than skipped.
|
|
166
|
+
function parseSelectionSet() {
|
|
167
|
+
expectPunct("{");
|
|
168
|
+
const fields = [];
|
|
169
|
+
let hasSpread = false;
|
|
170
|
+
let selections = 0;
|
|
171
|
+
while (!isPunct("}")) {
|
|
172
|
+
selections++;
|
|
173
|
+
if (isPunct("...")) {
|
|
174
|
+
hasSpread = true;
|
|
175
|
+
pos++;
|
|
176
|
+
if (isName("on")) {
|
|
177
|
+
pos++;
|
|
178
|
+
expectName();
|
|
179
|
+
}
|
|
180
|
+
else if (isName()) {
|
|
181
|
+
// Named fragment spread.
|
|
182
|
+
pos++;
|
|
133
183
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
continue;
|
|
184
|
+
skipDirectives();
|
|
185
|
+
if (isPunct("{")) {
|
|
186
|
+
parseSelectionSet();
|
|
138
187
|
}
|
|
139
188
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
189
|
+
else {
|
|
190
|
+
let field = expectName();
|
|
191
|
+
if (isPunct(":")) {
|
|
192
|
+
// An alias: the field name after the colon is what GitLab executes.
|
|
193
|
+
pos++;
|
|
194
|
+
field = expectName();
|
|
195
|
+
}
|
|
196
|
+
if (isPunct("(")) {
|
|
197
|
+
skipBalanced();
|
|
145
198
|
}
|
|
146
|
-
|
|
199
|
+
skipDirectives();
|
|
200
|
+
if (isPunct("{")) {
|
|
201
|
+
parseSelectionSet();
|
|
202
|
+
}
|
|
203
|
+
fields.push(field);
|
|
147
204
|
}
|
|
148
|
-
i++;
|
|
149
205
|
}
|
|
150
|
-
if (
|
|
151
|
-
|
|
206
|
+
if (selections === 0) {
|
|
207
|
+
throw new Error("Empty selection set in GraphQL document");
|
|
152
208
|
}
|
|
209
|
+
pos++;
|
|
210
|
+
return { fields, hasSpread };
|
|
153
211
|
}
|
|
154
|
-
|
|
212
|
+
function parseDefinition() {
|
|
213
|
+
if (isName("fragment")) {
|
|
214
|
+
pos++;
|
|
215
|
+
if (isName("on")) {
|
|
216
|
+
throw new Error("A fragment cannot be named on");
|
|
217
|
+
}
|
|
218
|
+
expectName();
|
|
219
|
+
if (!isName("on")) {
|
|
220
|
+
throw new Error("Expected a type condition on the fragment");
|
|
221
|
+
}
|
|
222
|
+
pos++;
|
|
223
|
+
expectName();
|
|
224
|
+
skipDirectives();
|
|
225
|
+
parseSelectionSet();
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
let type = "query";
|
|
229
|
+
if (!isPunct("{")) {
|
|
230
|
+
const keyword = expectName();
|
|
231
|
+
if (!OPERATION_TYPES.has(keyword)) {
|
|
232
|
+
throw new Error(`Unsupported GraphQL definition "${keyword}"`);
|
|
233
|
+
}
|
|
234
|
+
type = keyword;
|
|
235
|
+
if (isName()) {
|
|
236
|
+
// Operation name.
|
|
237
|
+
pos++;
|
|
238
|
+
}
|
|
239
|
+
if (isPunct("(")) {
|
|
240
|
+
skipBalanced();
|
|
241
|
+
}
|
|
242
|
+
skipDirectives();
|
|
243
|
+
}
|
|
244
|
+
const selection = parseSelectionSet();
|
|
245
|
+
operations.push({
|
|
246
|
+
type,
|
|
247
|
+
rootFields: selection.hasSpread ? null : selection.fields,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
while (pos < tokens.length) {
|
|
251
|
+
parseDefinition();
|
|
252
|
+
}
|
|
253
|
+
return operations;
|
|
155
254
|
}
|
|
255
|
+
// Returns true when the document contains a mutation or subscription. A document that
|
|
256
|
+
// cannot be parsed is treated as a write.
|
|
257
|
+
export function graphqlQueryContainsWriteOperation(query) {
|
|
258
|
+
let operations;
|
|
259
|
+
try {
|
|
260
|
+
operations = parseGraphQLOperations(query);
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
return operations.some(operation => operation.type !== "query");
|
|
266
|
+
}
|
|
267
|
+
// Verbs that mark a mutation as destructive for GITLAB_PERMISSION_MODE=modify.
|
|
268
|
+
// GitLab exposes many destructive mutations whose names do not contain "delete"
|
|
269
|
+
// (environmentStop, pipelineCancel, clusterAgentTokenRevoke, jobUnschedule, ...), so
|
|
270
|
+
// the ban covers teardown verbs as well as deletion verbs.
|
|
271
|
+
const DESTRUCTIVE_FIELD_PATTERN = /delete|destroy|remove|prune|purge|erase|revoke|cancel|stop|terminate|unprotect|disable|deactivate|drop|unschedule/i;
|
|
156
272
|
// Kept as `...DeleteOperation` for callers, but the guard now covers every
|
|
157
|
-
// destructive mutation verb, not only delete-named ones.
|
|
273
|
+
// destructive mutation verb, not only delete-named ones. Only the field name is tested,
|
|
274
|
+
// so an alias such as `stop: issueSetSeverity(...)` does not count as a destructive field.
|
|
158
275
|
export function graphqlQueryContainsDeleteOperation(query) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
// Fragment spread at mutation top level, or a mutation whose selection set
|
|
166
|
-
// could not be located (exotic syntax): be conservative and treat as delete
|
|
276
|
+
let operations;
|
|
277
|
+
try {
|
|
278
|
+
operations = parseGraphQLOperations(query);
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
// The document could hide a mutation, so it is blocked.
|
|
167
282
|
return true;
|
|
168
283
|
}
|
|
169
|
-
return
|
|
284
|
+
return operations.some(operation => {
|
|
285
|
+
if (operation.type !== "mutation") {
|
|
286
|
+
return false;
|
|
287
|
+
}
|
|
288
|
+
// A root fragment spread could hide any field, so it is blocked too.
|
|
289
|
+
return (operation.rootFields === null ||
|
|
290
|
+
operation.rootFields.some(field => DESTRUCTIVE_FIELD_PATTERN.test(field)));
|
|
291
|
+
});
|
|
170
292
|
}
|
package/package.json
CHANGED