@graphql-codegen/visitor-plugin-common 4.1.2 → 5.0.0-rc-20240220170602-d141e5332d3177e34161adba33affe23df47aacc

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.
@@ -351,10 +351,15 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
351
351
  }
352
352
  createFieldContextTypeMap() {
353
353
  return this.config.fieldContextTypes.reduce((prev, fieldContextType) => {
354
+ const isScoped = fieldContextType.includes('\\#');
355
+ if (fieldContextType.includes('\\#')) {
356
+ fieldContextType = fieldContextType.replace('\\#', '');
357
+ }
354
358
  const items = fieldContextType.split('#');
355
359
  if (items.length === 3) {
356
360
  const [path, source, contextTypeName] = items;
357
- return { ...prev, [path]: (0, mappers_js_1.parseMapper)(`${source}#${contextTypeName}`) };
361
+ const sourceStr = isScoped ? `\\#${source}` : source;
362
+ return { ...prev, [path]: (0, mappers_js_1.parseMapper)(`${sourceStr}#${contextTypeName}`) };
358
363
  }
359
364
  const [path, contextType] = items;
360
365
  return { ...prev, [path]: (0, mappers_js_1.parseMapper)(contextType) };
@@ -362,10 +367,15 @@ class BaseResolversVisitor extends base_visitor_js_1.BaseVisitor {
362
367
  }
363
368
  createDirectivedContextType() {
364
369
  return this.config.directiveContextTypes.reduce((prev, fieldContextType) => {
370
+ const isScoped = fieldContextType.includes('\\#');
371
+ if (fieldContextType.includes('\\#')) {
372
+ fieldContextType = fieldContextType.replace('\\#', '');
373
+ }
365
374
  const items = fieldContextType.split('#');
366
375
  if (items.length === 3) {
367
376
  const [path, source, contextTypeName] = items;
368
- return { ...prev, [path]: (0, mappers_js_1.parseMapper)(`${source}#${contextTypeName}`) };
377
+ const sourceStr = isScoped ? `\\#${source}` : source;
378
+ return { ...prev, [path]: (0, mappers_js_1.parseMapper)(`${sourceStr}#${contextTypeName}`) };
369
379
  }
370
380
  const [path, contextType] = items;
371
381
  return { ...prev, [path]: (0, mappers_js_1.parseMapper)(contextType) };
package/cjs/mappers.js CHANGED
@@ -12,10 +12,16 @@ var MapperKind;
12
12
  MapperKind[MapperKind["Regular"] = 2] = "Regular";
13
13
  })(MapperKind || (MapperKind = {}));
14
14
  function prepareLegacy(mapper) {
15
+ const isScoped = mapper.includes('\\#');
16
+ if (mapper.includes('\\#')) {
17
+ mapper = mapper.replace('\\#', '');
18
+ }
15
19
  const items = mapper.split('#');
16
20
  const isNamespace = items.length === 3;
17
21
  const isDefault = items[1].trim() === 'default' || items[1].startsWith('default ');
18
22
  const hasAlias = items[1].includes(' as ');
23
+ const source = isScoped ? `#${items[0]}` : items[0];
24
+ items[0] = source;
19
25
  return {
20
26
  items,
21
27
  isDefault,
@@ -24,10 +30,15 @@ function prepareLegacy(mapper) {
24
30
  };
25
31
  }
26
32
  function prepare(mapper) {
27
- const [source, path] = mapper.split('#');
33
+ const isScoped = mapper.includes('\\#');
34
+ if (mapper.includes('\\#')) {
35
+ mapper = mapper.replace('\\#', '');
36
+ }
37
+ let [source, path] = mapper.split('#');
28
38
  const isNamespace = path.includes('.');
29
39
  const isDefault = path.trim() === 'default' || path.startsWith('default ');
30
40
  const hasAlias = path.includes(' as ');
41
+ source = isScoped ? `#${source}` : source;
31
42
  return {
32
43
  items: isNamespace ? [source, ...path.split('.')] : [source, path],
33
44
  isDefault,
@@ -36,6 +47,9 @@ function prepare(mapper) {
36
47
  };
37
48
  }
38
49
  function isLegacyMode(mapper) {
50
+ if (mapper.includes('\\#')) {
51
+ mapper = mapper.replace('\\#', '');
52
+ }
39
53
  return mapper.split('#').length === 3;
40
54
  }
41
55
  function parseMapper(mapper, gqlTypeName = null, suffix) {
@@ -347,10 +347,15 @@ export class BaseResolversVisitor extends BaseVisitor {
347
347
  }
348
348
  createFieldContextTypeMap() {
349
349
  return this.config.fieldContextTypes.reduce((prev, fieldContextType) => {
350
+ const isScoped = fieldContextType.includes('\\#');
351
+ if (fieldContextType.includes('\\#')) {
352
+ fieldContextType = fieldContextType.replace('\\#', '');
353
+ }
350
354
  const items = fieldContextType.split('#');
351
355
  if (items.length === 3) {
352
356
  const [path, source, contextTypeName] = items;
353
- return { ...prev, [path]: parseMapper(`${source}#${contextTypeName}`) };
357
+ const sourceStr = isScoped ? `\\#${source}` : source;
358
+ return { ...prev, [path]: parseMapper(`${sourceStr}#${contextTypeName}`) };
354
359
  }
355
360
  const [path, contextType] = items;
356
361
  return { ...prev, [path]: parseMapper(contextType) };
@@ -358,10 +363,15 @@ export class BaseResolversVisitor extends BaseVisitor {
358
363
  }
359
364
  createDirectivedContextType() {
360
365
  return this.config.directiveContextTypes.reduce((prev, fieldContextType) => {
366
+ const isScoped = fieldContextType.includes('\\#');
367
+ if (fieldContextType.includes('\\#')) {
368
+ fieldContextType = fieldContextType.replace('\\#', '');
369
+ }
361
370
  const items = fieldContextType.split('#');
362
371
  if (items.length === 3) {
363
372
  const [path, source, contextTypeName] = items;
364
- return { ...prev, [path]: parseMapper(`${source}#${contextTypeName}`) };
373
+ const sourceStr = isScoped ? `\\#${source}` : source;
374
+ return { ...prev, [path]: parseMapper(`${sourceStr}#${contextTypeName}`) };
365
375
  }
366
376
  const [path, contextType] = items;
367
377
  return { ...prev, [path]: parseMapper(contextType) };
package/esm/mappers.js CHANGED
@@ -8,10 +8,16 @@ var MapperKind;
8
8
  MapperKind[MapperKind["Regular"] = 2] = "Regular";
9
9
  })(MapperKind || (MapperKind = {}));
10
10
  function prepareLegacy(mapper) {
11
+ const isScoped = mapper.includes('\\#');
12
+ if (mapper.includes('\\#')) {
13
+ mapper = mapper.replace('\\#', '');
14
+ }
11
15
  const items = mapper.split('#');
12
16
  const isNamespace = items.length === 3;
13
17
  const isDefault = items[1].trim() === 'default' || items[1].startsWith('default ');
14
18
  const hasAlias = items[1].includes(' as ');
19
+ const source = isScoped ? `#${items[0]}` : items[0];
20
+ items[0] = source;
15
21
  return {
16
22
  items,
17
23
  isDefault,
@@ -20,10 +26,15 @@ function prepareLegacy(mapper) {
20
26
  };
21
27
  }
22
28
  function prepare(mapper) {
23
- const [source, path] = mapper.split('#');
29
+ const isScoped = mapper.includes('\\#');
30
+ if (mapper.includes('\\#')) {
31
+ mapper = mapper.replace('\\#', '');
32
+ }
33
+ let [source, path] = mapper.split('#');
24
34
  const isNamespace = path.includes('.');
25
35
  const isDefault = path.trim() === 'default' || path.startsWith('default ');
26
36
  const hasAlias = path.includes(' as ');
37
+ source = isScoped ? `#${source}` : source;
27
38
  return {
28
39
  items: isNamespace ? [source, ...path.split('.')] : [source, path],
29
40
  isDefault,
@@ -32,6 +43,9 @@ function prepare(mapper) {
32
43
  };
33
44
  }
34
45
  function isLegacyMode(mapper) {
46
+ if (mapper.includes('\\#')) {
47
+ mapper = mapper.replace('\\#', '');
48
+ }
35
49
  return mapper.split('#').length === 3;
36
50
  }
37
51
  export function parseMapper(mapper, gqlTypeName = null, suffix) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/visitor-plugin-common",
3
- "version": "4.1.2",
3
+ "version": "5.0.0-rc-20240220170602-d141e5332d3177e34161adba33affe23df47aacc",
4
4
  "peerDependencies": {
5
5
  "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
6
6
  },