@graphql-mesh/transform-prefix 0.9.8 → 0.10.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/barePrefix.d.ts +1 -0
- package/index.js +15 -7
- package/index.mjs +15 -7
- package/package.json +4 -4
package/barePrefix.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export default class BarePrefix implements MeshTransform {
|
|
|
4
4
|
noWrap: boolean;
|
|
5
5
|
private ignoreList;
|
|
6
6
|
private includeRootOperations;
|
|
7
|
+
private includeTypes;
|
|
7
8
|
private prefix;
|
|
8
9
|
constructor(options: MeshTransformOptions<YamlConfig.PrefixTransformConfig>);
|
|
9
10
|
transformSchema(schema: GraphQLSchema): GraphQLSchema;
|
package/index.js
CHANGED
|
@@ -20,8 +20,12 @@ class WrapPrefix {
|
|
|
20
20
|
throw new Error(`Transform 'prefix' has missing config: prefix`);
|
|
21
21
|
}
|
|
22
22
|
const ignoreList = config.ignore || [];
|
|
23
|
-
|
|
24
|
-
if (
|
|
23
|
+
const includeTypes = config.includeTypes !== false;
|
|
24
|
+
if (includeTypes) {
|
|
25
|
+
this.transforms.push(new wrap.RenameTypes(typeName => (ignoreList.includes(typeName) ? typeName : `${prefix}${typeName}`)));
|
|
26
|
+
}
|
|
27
|
+
const includeRootOperations = config.includeRootOperations === true;
|
|
28
|
+
if (includeRootOperations) {
|
|
25
29
|
this.transforms.push(new wrap.RenameRootFields((typeName, fieldName) => ignoreList.includes(typeName) || ignoreList.includes(`${typeName}.${fieldName}`)
|
|
26
30
|
? fieldName
|
|
27
31
|
: `${prefix}${fieldName}`));
|
|
@@ -44,7 +48,8 @@ class BarePrefix {
|
|
|
44
48
|
this.noWrap = true;
|
|
45
49
|
const { apiName, config } = options;
|
|
46
50
|
this.ignoreList = config.ignore || [];
|
|
47
|
-
this.includeRootOperations = config.includeRootOperations;
|
|
51
|
+
this.includeRootOperations = config.includeRootOperations === true;
|
|
52
|
+
this.includeTypes = config.includeTypes !== false;
|
|
48
53
|
this.prefix = null;
|
|
49
54
|
if (config.value) {
|
|
50
55
|
this.prefix = config.value;
|
|
@@ -59,10 +64,13 @@ class BarePrefix {
|
|
|
59
64
|
transformSchema(schema) {
|
|
60
65
|
return utils$1.mapSchema(schema, {
|
|
61
66
|
[utils$1.MapperKind.TYPE]: (type) => {
|
|
62
|
-
if (graphql.isSpecifiedScalarType(type))
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
if (this.includeTypes && !graphql.isSpecifiedScalarType(type)) {
|
|
68
|
+
const currentName = type.name;
|
|
69
|
+
if (!this.ignoreList.includes(currentName)) {
|
|
70
|
+
return utils$1.renameType(type, this.prefix + currentName);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return undefined;
|
|
66
74
|
},
|
|
67
75
|
[utils$1.MapperKind.ROOT_OBJECT]() {
|
|
68
76
|
return undefined;
|
package/index.mjs
CHANGED
|
@@ -18,8 +18,12 @@ class WrapPrefix {
|
|
|
18
18
|
throw new Error(`Transform 'prefix' has missing config: prefix`);
|
|
19
19
|
}
|
|
20
20
|
const ignoreList = config.ignore || [];
|
|
21
|
-
|
|
22
|
-
if (
|
|
21
|
+
const includeTypes = config.includeTypes !== false;
|
|
22
|
+
if (includeTypes) {
|
|
23
|
+
this.transforms.push(new RenameTypes(typeName => (ignoreList.includes(typeName) ? typeName : `${prefix}${typeName}`)));
|
|
24
|
+
}
|
|
25
|
+
const includeRootOperations = config.includeRootOperations === true;
|
|
26
|
+
if (includeRootOperations) {
|
|
23
27
|
this.transforms.push(new RenameRootFields((typeName, fieldName) => ignoreList.includes(typeName) || ignoreList.includes(`${typeName}.${fieldName}`)
|
|
24
28
|
? fieldName
|
|
25
29
|
: `${prefix}${fieldName}`));
|
|
@@ -42,7 +46,8 @@ class BarePrefix {
|
|
|
42
46
|
this.noWrap = true;
|
|
43
47
|
const { apiName, config } = options;
|
|
44
48
|
this.ignoreList = config.ignore || [];
|
|
45
|
-
this.includeRootOperations = config.includeRootOperations;
|
|
49
|
+
this.includeRootOperations = config.includeRootOperations === true;
|
|
50
|
+
this.includeTypes = config.includeTypes !== false;
|
|
46
51
|
this.prefix = null;
|
|
47
52
|
if (config.value) {
|
|
48
53
|
this.prefix = config.value;
|
|
@@ -57,10 +62,13 @@ class BarePrefix {
|
|
|
57
62
|
transformSchema(schema) {
|
|
58
63
|
return mapSchema(schema, {
|
|
59
64
|
[MapperKind.TYPE]: (type) => {
|
|
60
|
-
if (isSpecifiedScalarType(type))
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
if (this.includeTypes && !isSpecifiedScalarType(type)) {
|
|
66
|
+
const currentName = type.name;
|
|
67
|
+
if (!this.ignoreList.includes(currentName)) {
|
|
68
|
+
return renameType(type, this.prefix + currentName);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
64
72
|
},
|
|
65
73
|
[MapperKind.ROOT_OBJECT]() {
|
|
66
74
|
return undefined;
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/transform-prefix",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "*"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@graphql-mesh/types": "0.
|
|
10
|
-
"@graphql-mesh/utils": "0.26.
|
|
9
|
+
"@graphql-mesh/types": "0.58.0",
|
|
10
|
+
"@graphql-mesh/utils": "0.26.1",
|
|
11
11
|
"@graphql-tools/delegate": "8.4.3",
|
|
12
|
-
"@graphql-tools/utils": "8.6.
|
|
12
|
+
"@graphql-tools/utils": "8.6.1",
|
|
13
13
|
"@graphql-tools/wrap": "8.3.3"
|
|
14
14
|
},
|
|
15
15
|
"license": "MIT",
|