@graphql-inspector/patch 0.0.1 → 0.1.0-alpha-20251210011837-ed57c921c80feafc1e499b3e92955f7a79b551ee
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/cjs/patches/schema.js +57 -36
- package/esm/patches/schema.js +57 -36
- package/package.json +1 -1
package/cjs/patches/schema.js
CHANGED
|
@@ -11,25 +11,32 @@ function schemaMutationTypeChanged(change, schemaNodes, config, _context) {
|
|
|
11
11
|
for (const schemaNode of schemaNodes) {
|
|
12
12
|
const mutation = schemaNode.operationTypes?.find(({ operation }) => operation === graphql_1.OperationTypeNode.MUTATION);
|
|
13
13
|
if (!mutation) {
|
|
14
|
-
if (change.meta.oldMutationTypeName !==
|
|
15
|
-
config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldMutationTypeName,
|
|
14
|
+
if (change.meta.oldMutationTypeName !== null) {
|
|
15
|
+
config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldMutationTypeName, null), change);
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
if (change.meta.newMutationTypeName) {
|
|
18
|
+
schemaNode.operationTypes = [
|
|
19
|
+
...(schemaNode.operationTypes ?? []),
|
|
20
|
+
{
|
|
21
|
+
kind: graphql_1.Kind.OPERATION_TYPE_DEFINITION,
|
|
22
|
+
operation: graphql_1.OperationTypeNode.MUTATION,
|
|
23
|
+
type: {
|
|
24
|
+
kind: graphql_1.Kind.NAMED_TYPE,
|
|
25
|
+
name: (0, node_templates_js_1.nameNode)(change.meta.newMutationTypeName),
|
|
26
|
+
},
|
|
25
27
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
];
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
31
|
else {
|
|
30
32
|
if (mutation.type.name.value !== change.meta.oldMutationTypeName) {
|
|
31
33
|
config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldMutationTypeName, mutation?.type.name.value), change);
|
|
32
34
|
}
|
|
35
|
+
if (change.meta.newMutationTypeName === null) {
|
|
36
|
+
schemaNode.operationTypes =
|
|
37
|
+
schemaNode.operationTypes?.filter(({ operation }) => operation !== graphql_1.OperationTypeNode.MUTATION);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
33
40
|
mutation.type.name = (0, node_templates_js_1.nameNode)(change.meta.newMutationTypeName);
|
|
34
41
|
}
|
|
35
42
|
}
|
|
@@ -38,25 +45,32 @@ function schemaQueryTypeChanged(change, schemaNodes, config, _context) {
|
|
|
38
45
|
for (const schemaNode of schemaNodes) {
|
|
39
46
|
const query = schemaNode.operationTypes?.find(({ operation }) => operation === graphql_1.OperationTypeNode.MUTATION);
|
|
40
47
|
if (!query) {
|
|
41
|
-
if (change.meta.oldQueryTypeName !==
|
|
42
|
-
config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldQueryTypeName,
|
|
48
|
+
if (change.meta.oldQueryTypeName !== null) {
|
|
49
|
+
config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldQueryTypeName, null), change);
|
|
43
50
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
if (change.meta.newQueryTypeName) {
|
|
52
|
+
schemaNode.operationTypes = [
|
|
53
|
+
...(schemaNode.operationTypes ?? []),
|
|
54
|
+
{
|
|
55
|
+
kind: graphql_1.Kind.OPERATION_TYPE_DEFINITION,
|
|
56
|
+
operation: graphql_1.OperationTypeNode.QUERY,
|
|
57
|
+
type: {
|
|
58
|
+
kind: graphql_1.Kind.NAMED_TYPE,
|
|
59
|
+
name: (0, node_templates_js_1.nameNode)(change.meta.newQueryTypeName),
|
|
60
|
+
},
|
|
52
61
|
},
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
];
|
|
63
|
+
}
|
|
55
64
|
}
|
|
56
65
|
else {
|
|
57
66
|
if (query.type.name.value !== change.meta.oldQueryTypeName) {
|
|
58
67
|
config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldQueryTypeName, query?.type.name.value), change);
|
|
59
68
|
}
|
|
69
|
+
if (change.meta.newQueryTypeName === null) {
|
|
70
|
+
schemaNode.operationTypes =
|
|
71
|
+
schemaNode.operationTypes?.filter(({ operation }) => operation !== graphql_1.OperationTypeNode.QUERY);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
60
74
|
query.type.name = (0, node_templates_js_1.nameNode)(change.meta.newQueryTypeName);
|
|
61
75
|
}
|
|
62
76
|
}
|
|
@@ -65,25 +79,32 @@ function schemaSubscriptionTypeChanged(change, schemaNodes, config, _context) {
|
|
|
65
79
|
for (const schemaNode of schemaNodes) {
|
|
66
80
|
const sub = schemaNode.operationTypes?.find(({ operation }) => operation === graphql_1.OperationTypeNode.SUBSCRIPTION);
|
|
67
81
|
if (!sub) {
|
|
68
|
-
if (change.meta.oldSubscriptionTypeName !==
|
|
69
|
-
config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldSubscriptionTypeName,
|
|
82
|
+
if (change.meta.oldSubscriptionTypeName !== null) {
|
|
83
|
+
config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldSubscriptionTypeName, null), change);
|
|
70
84
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
if (change.meta.newSubscriptionTypeName) {
|
|
86
|
+
schemaNode.operationTypes = [
|
|
87
|
+
...(schemaNode.operationTypes ?? []),
|
|
88
|
+
{
|
|
89
|
+
kind: graphql_1.Kind.OPERATION_TYPE_DEFINITION,
|
|
90
|
+
operation: graphql_1.OperationTypeNode.QUERY,
|
|
91
|
+
type: {
|
|
92
|
+
kind: graphql_1.Kind.NAMED_TYPE,
|
|
93
|
+
name: (0, node_templates_js_1.nameNode)(change.meta.newSubscriptionTypeName),
|
|
94
|
+
},
|
|
79
95
|
},
|
|
80
|
-
|
|
81
|
-
|
|
96
|
+
];
|
|
97
|
+
}
|
|
82
98
|
}
|
|
83
99
|
else {
|
|
84
100
|
if (sub.type.name.value !== change.meta.oldSubscriptionTypeName) {
|
|
85
101
|
config.onError(new errors_js_1.ValueMismatchError(graphql_1.Kind.SCHEMA_DEFINITION, change.meta.oldSubscriptionTypeName, sub?.type.name.value), change);
|
|
86
102
|
}
|
|
103
|
+
if (change.meta.newSubscriptionTypeName === null) {
|
|
104
|
+
schemaNode.operationTypes =
|
|
105
|
+
schemaNode.operationTypes?.filter(({ operation }) => operation !== graphql_1.OperationTypeNode.SUBSCRIPTION);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
87
108
|
sub.type.name = (0, node_templates_js_1.nameNode)(change.meta.newSubscriptionTypeName);
|
|
88
109
|
}
|
|
89
110
|
}
|
package/esm/patches/schema.js
CHANGED
|
@@ -6,25 +6,32 @@ export function schemaMutationTypeChanged(change, schemaNodes, config, _context)
|
|
|
6
6
|
for (const schemaNode of schemaNodes) {
|
|
7
7
|
const mutation = schemaNode.operationTypes?.find(({ operation }) => operation === OperationTypeNode.MUTATION);
|
|
8
8
|
if (!mutation) {
|
|
9
|
-
if (change.meta.oldMutationTypeName !==
|
|
10
|
-
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldMutationTypeName,
|
|
9
|
+
if (change.meta.oldMutationTypeName !== null) {
|
|
10
|
+
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldMutationTypeName, null), change);
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
if (change.meta.newMutationTypeName) {
|
|
13
|
+
schemaNode.operationTypes = [
|
|
14
|
+
...(schemaNode.operationTypes ?? []),
|
|
15
|
+
{
|
|
16
|
+
kind: Kind.OPERATION_TYPE_DEFINITION,
|
|
17
|
+
operation: OperationTypeNode.MUTATION,
|
|
18
|
+
type: {
|
|
19
|
+
kind: Kind.NAMED_TYPE,
|
|
20
|
+
name: nameNode(change.meta.newMutationTypeName),
|
|
21
|
+
},
|
|
20
22
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
];
|
|
24
|
+
}
|
|
23
25
|
}
|
|
24
26
|
else {
|
|
25
27
|
if (mutation.type.name.value !== change.meta.oldMutationTypeName) {
|
|
26
28
|
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldMutationTypeName, mutation?.type.name.value), change);
|
|
27
29
|
}
|
|
30
|
+
if (change.meta.newMutationTypeName === null) {
|
|
31
|
+
schemaNode.operationTypes =
|
|
32
|
+
schemaNode.operationTypes?.filter(({ operation }) => operation !== OperationTypeNode.MUTATION);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
28
35
|
mutation.type.name = nameNode(change.meta.newMutationTypeName);
|
|
29
36
|
}
|
|
30
37
|
}
|
|
@@ -33,25 +40,32 @@ export function schemaQueryTypeChanged(change, schemaNodes, config, _context) {
|
|
|
33
40
|
for (const schemaNode of schemaNodes) {
|
|
34
41
|
const query = schemaNode.operationTypes?.find(({ operation }) => operation === OperationTypeNode.MUTATION);
|
|
35
42
|
if (!query) {
|
|
36
|
-
if (change.meta.oldQueryTypeName !==
|
|
37
|
-
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldQueryTypeName,
|
|
43
|
+
if (change.meta.oldQueryTypeName !== null) {
|
|
44
|
+
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldQueryTypeName, null), change);
|
|
38
45
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
if (change.meta.newQueryTypeName) {
|
|
47
|
+
schemaNode.operationTypes = [
|
|
48
|
+
...(schemaNode.operationTypes ?? []),
|
|
49
|
+
{
|
|
50
|
+
kind: Kind.OPERATION_TYPE_DEFINITION,
|
|
51
|
+
operation: OperationTypeNode.QUERY,
|
|
52
|
+
type: {
|
|
53
|
+
kind: Kind.NAMED_TYPE,
|
|
54
|
+
name: nameNode(change.meta.newQueryTypeName),
|
|
55
|
+
},
|
|
47
56
|
},
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
];
|
|
58
|
+
}
|
|
50
59
|
}
|
|
51
60
|
else {
|
|
52
61
|
if (query.type.name.value !== change.meta.oldQueryTypeName) {
|
|
53
62
|
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldQueryTypeName, query?.type.name.value), change);
|
|
54
63
|
}
|
|
64
|
+
if (change.meta.newQueryTypeName === null) {
|
|
65
|
+
schemaNode.operationTypes =
|
|
66
|
+
schemaNode.operationTypes?.filter(({ operation }) => operation !== OperationTypeNode.QUERY);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
55
69
|
query.type.name = nameNode(change.meta.newQueryTypeName);
|
|
56
70
|
}
|
|
57
71
|
}
|
|
@@ -60,25 +74,32 @@ export function schemaSubscriptionTypeChanged(change, schemaNodes, config, _cont
|
|
|
60
74
|
for (const schemaNode of schemaNodes) {
|
|
61
75
|
const sub = schemaNode.operationTypes?.find(({ operation }) => operation === OperationTypeNode.SUBSCRIPTION);
|
|
62
76
|
if (!sub) {
|
|
63
|
-
if (change.meta.oldSubscriptionTypeName !==
|
|
64
|
-
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldSubscriptionTypeName,
|
|
77
|
+
if (change.meta.oldSubscriptionTypeName !== null) {
|
|
78
|
+
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldSubscriptionTypeName, null), change);
|
|
65
79
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
80
|
+
if (change.meta.newSubscriptionTypeName) {
|
|
81
|
+
schemaNode.operationTypes = [
|
|
82
|
+
...(schemaNode.operationTypes ?? []),
|
|
83
|
+
{
|
|
84
|
+
kind: Kind.OPERATION_TYPE_DEFINITION,
|
|
85
|
+
operation: OperationTypeNode.QUERY,
|
|
86
|
+
type: {
|
|
87
|
+
kind: Kind.NAMED_TYPE,
|
|
88
|
+
name: nameNode(change.meta.newSubscriptionTypeName),
|
|
89
|
+
},
|
|
74
90
|
},
|
|
75
|
-
|
|
76
|
-
|
|
91
|
+
];
|
|
92
|
+
}
|
|
77
93
|
}
|
|
78
94
|
else {
|
|
79
95
|
if (sub.type.name.value !== change.meta.oldSubscriptionTypeName) {
|
|
80
96
|
config.onError(new ValueMismatchError(Kind.SCHEMA_DEFINITION, change.meta.oldSubscriptionTypeName, sub?.type.name.value), change);
|
|
81
97
|
}
|
|
98
|
+
if (change.meta.newSubscriptionTypeName === null) {
|
|
99
|
+
schemaNode.operationTypes =
|
|
100
|
+
schemaNode.operationTypes?.filter(({ operation }) => operation !== OperationTypeNode.SUBSCRIPTION);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
82
103
|
sub.type.name = nameNode(change.meta.newSubscriptionTypeName);
|
|
83
104
|
}
|
|
84
105
|
}
|
package/package.json
CHANGED