@graphql-codegen/plugin-helpers 3.1.2 → 3.1.3-alpha-20230131004821-8a76a405d

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/federation.js CHANGED
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApolloFederation = exports.removeFederation = exports.addFederationReferencesToSchema = exports.federationSpec = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ const utils_1 = require("@graphql-tools/utils");
5
6
  const graphql_1 = require("graphql");
6
7
  const merge_js_1 = tslib_1.__importDefault(require("lodash/merge.js"));
7
- const utils_js_1 = require("./utils.js");
8
- const utils_1 = require("@graphql-tools/utils");
9
8
  const index_js_1 = require("./index.js");
9
+ const utils_js_1 = require("./utils.js");
10
10
  /**
11
11
  * Federation Spec
12
12
  */
@@ -158,7 +158,7 @@ class ApolloFederation {
158
158
  }
159
159
  hasProvides(objectType, node) {
160
160
  const fields = this.providesMap[(0, graphql_1.isObjectType)(objectType) ? objectType.name : objectType.name.value];
161
- if (fields && fields.length) {
161
+ if (fields === null || fields === void 0 ? void 0 : fields.length) {
162
162
  return fields.includes(node.name.value);
163
163
  }
164
164
  return false;
@@ -180,7 +180,7 @@ class ApolloFederation {
180
180
  Field(node) {
181
181
  return {
182
182
  name: node.name.value,
183
- selection: node.selectionSet ? node.selectionSet : true,
183
+ selection: node.selectionSet || true,
184
184
  };
185
185
  },
186
186
  Document(node) {
@@ -203,13 +203,12 @@ class ApolloFederation {
203
203
  const objectType = this.schema.getType(typename);
204
204
  if ((0, graphql_1.isObjectType)(objectType)) {
205
205
  Object.values(objectType.getFields()).forEach(field => {
206
+ var _a;
206
207
  const provides = getDirectivesByName('provides', field.astNode)
207
208
  .map(this.extractProvidesFieldSet)
208
209
  .reduce((prev, curr) => [...prev, ...curr], []);
209
210
  const ofType = (0, utils_js_1.getBaseType)(field.type);
210
- if (!providesMap[ofType.name]) {
211
- providesMap[ofType.name] = [];
212
- }
211
+ providesMap[_a = ofType.name] || (providesMap[_a] = []);
213
212
  providesMap[ofType.name].push(...provides);
214
213
  });
215
214
  }
package/cjs/index.js CHANGED
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveExternalModuleAndFn = void 0;
4
4
  const tslib_1 = require("tslib");
5
- var resolve_external_module_and_fn_js_1 = require("./resolve-external-module-and-fn.js");
6
- Object.defineProperty(exports, "resolveExternalModuleAndFn", { enumerable: true, get: function () { return resolve_external_module_and_fn_js_1.resolveExternalModuleAndFn; } });
7
- tslib_1.__exportStar(require("./types.js"), exports);
8
- tslib_1.__exportStar(require("./utils.js"), exports);
9
- tslib_1.__exportStar(require("./helpers.js"), exports);
10
5
  tslib_1.__exportStar(require("./federation.js"), exports);
11
6
  tslib_1.__exportStar(require("./getCachedDocumentNodeFromSchema.js"), exports);
7
+ tslib_1.__exportStar(require("./helpers.js"), exports);
12
8
  tslib_1.__exportStar(require("./oldVisit.js"), exports);
13
9
  tslib_1.__exportStar(require("./profiler.js"), exports);
10
+ var resolve_external_module_and_fn_js_1 = require("./resolve-external-module-and-fn.js");
11
+ Object.defineProperty(exports, "resolveExternalModuleAndFn", { enumerable: true, get: function () { return resolve_external_module_and_fn_js_1.resolveExternalModuleAndFn; } });
12
+ tslib_1.__exportStar(require("./types.js"), exports);
13
+ tslib_1.__exportStar(require("./utils.js"), exports);
package/cjs/oldVisit.js CHANGED
@@ -5,13 +5,13 @@ const graphql_1 = require("graphql");
5
5
  function oldVisit(root, { enter: enterVisitors, leave: leaveVisitors, ...newVisitor }) {
6
6
  if (typeof enterVisitors === 'object') {
7
7
  for (const key in enterVisitors) {
8
- newVisitor[key] = newVisitor[key] || {};
8
+ newVisitor[key] || (newVisitor[key] = {});
9
9
  newVisitor[key].enter = enterVisitors[key];
10
10
  }
11
11
  }
12
12
  if (typeof leaveVisitors === 'object') {
13
13
  for (const key in leaveVisitors) {
14
- newVisitor[key] = newVisitor[key] || {};
14
+ newVisitor[key] || (newVisitor[key] = {});
15
15
  newVisitor[key].leave = leaveVisitors[key];
16
16
  }
17
17
  }
@@ -9,7 +9,6 @@ function resolveExternalModuleAndFn(pointer) {
9
9
  if (typeof pointer === 'function') {
10
10
  return pointer;
11
11
  }
12
- // eslint-disable-next-line prefer-const
13
12
  let [moduleName, functionName] = pointer.split('#');
14
13
  // Temp workaround until v2
15
14
  if (moduleName === 'change-case') {
package/cjs/types.js CHANGED
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isComplexPluginOutput = void 0;
4
4
  function isComplexPluginOutput(obj) {
5
- return typeof obj === 'object' && obj.hasOwnProperty('content');
5
+ return typeof obj === 'object' && Object.prototype.hasOwnProperty.call(obj, 'content');
6
6
  }
7
7
  exports.isComplexPluginOutput = isComplexPluginOutput;
package/esm/federation.js CHANGED
@@ -1,8 +1,8 @@
1
- import { parse, GraphQLObjectType, isObjectType, } from 'graphql';
1
+ import { astFromObjectType, getRootTypeNames, MapperKind, mapSchema } from '@graphql-tools/utils';
2
+ import { GraphQLObjectType, isObjectType, parse, } from 'graphql';
2
3
  import merge from 'lodash/merge.js';
3
- import { getBaseType } from './utils.js';
4
- import { MapperKind, mapSchema, astFromObjectType, getRootTypeNames } from '@graphql-tools/utils';
5
4
  import { oldVisit } from './index.js';
5
+ import { getBaseType } from './utils.js';
6
6
  /**
7
7
  * Federation Spec
8
8
  */
@@ -152,7 +152,7 @@ export class ApolloFederation {
152
152
  }
153
153
  hasProvides(objectType, node) {
154
154
  const fields = this.providesMap[isObjectType(objectType) ? objectType.name : objectType.name.value];
155
- if (fields && fields.length) {
155
+ if (fields === null || fields === void 0 ? void 0 : fields.length) {
156
156
  return fields.includes(node.name.value);
157
157
  }
158
158
  return false;
@@ -174,7 +174,7 @@ export class ApolloFederation {
174
174
  Field(node) {
175
175
  return {
176
176
  name: node.name.value,
177
- selection: node.selectionSet ? node.selectionSet : true,
177
+ selection: node.selectionSet || true,
178
178
  };
179
179
  },
180
180
  Document(node) {
@@ -197,13 +197,12 @@ export class ApolloFederation {
197
197
  const objectType = this.schema.getType(typename);
198
198
  if (isObjectType(objectType)) {
199
199
  Object.values(objectType.getFields()).forEach(field => {
200
+ var _a;
200
201
  const provides = getDirectivesByName('provides', field.astNode)
201
202
  .map(this.extractProvidesFieldSet)
202
203
  .reduce((prev, curr) => [...prev, ...curr], []);
203
204
  const ofType = getBaseType(field.type);
204
- if (!providesMap[ofType.name]) {
205
- providesMap[ofType.name] = [];
206
- }
205
+ providesMap[_a = ofType.name] || (providesMap[_a] = []);
207
206
  providesMap[ofType.name].push(...provides);
208
207
  });
209
208
  }
package/esm/helpers.js CHANGED
@@ -1,4 +1,4 @@
1
- import { visit, isListType, isObjectType, Kind, isNonNullType, } from 'graphql';
1
+ import { isListType, isNonNullType, isObjectType, Kind, visit, } from 'graphql';
2
2
  import { getBaseType } from './utils.js';
3
3
  export function isOutputConfigArray(type) {
4
4
  return Array.isArray(type);
package/esm/index.js CHANGED
@@ -1,8 +1,8 @@
1
- export { resolveExternalModuleAndFn } from './resolve-external-module-and-fn.js';
2
- export * from './types.js';
3
- export * from './utils.js';
4
- export * from './helpers.js';
5
1
  export * from './federation.js';
6
2
  export * from './getCachedDocumentNodeFromSchema.js';
3
+ export * from './helpers.js';
7
4
  export * from './oldVisit.js';
8
5
  export * from './profiler.js';
6
+ export { resolveExternalModuleAndFn } from './resolve-external-module-and-fn.js';
7
+ export * from './types.js';
8
+ export * from './utils.js';
package/esm/oldVisit.js CHANGED
@@ -2,13 +2,13 @@ import { visit } from 'graphql';
2
2
  export function oldVisit(root, { enter: enterVisitors, leave: leaveVisitors, ...newVisitor }) {
3
3
  if (typeof enterVisitors === 'object') {
4
4
  for (const key in enterVisitors) {
5
- newVisitor[key] = newVisitor[key] || {};
5
+ newVisitor[key] || (newVisitor[key] = {});
6
6
  newVisitor[key].enter = enterVisitors[key];
7
7
  }
8
8
  }
9
9
  if (typeof leaveVisitors === 'object') {
10
10
  for (const key in leaveVisitors) {
11
- newVisitor[key] = newVisitor[key] || {};
11
+ newVisitor[key] || (newVisitor[key] = {});
12
12
  newVisitor[key].leave = leaveVisitors[key];
13
13
  }
14
14
  }
@@ -5,7 +5,6 @@ export function resolveExternalModuleAndFn(pointer) {
5
5
  if (typeof pointer === 'function') {
6
6
  return pointer;
7
7
  }
8
- // eslint-disable-next-line prefer-const
9
8
  let [moduleName, functionName] = pointer.split('#');
10
9
  // Temp workaround until v2
11
10
  if (moduleName === 'change-case') {
package/esm/types.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export function isComplexPluginOutput(obj) {
2
- return typeof obj === 'object' && obj.hasOwnProperty('content');
2
+ return typeof obj === 'object' && Object.prototype.hasOwnProperty.call(obj, 'content');
3
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/plugin-helpers",
3
- "version": "3.1.2",
3
+ "version": "3.1.3-alpha-20230131004821-8a76a405d",
4
4
  "description": "GraphQL Code Generator common utils and types",
5
5
  "peerDependencies": {
6
6
  "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"
@@ -1,4 +1,4 @@
1
- import { GraphQLSchema, FieldDefinitionNode, GraphQLNamedType } from 'graphql';
1
+ import { FieldDefinitionNode, GraphQLNamedType, GraphQLSchema } from 'graphql';
2
2
  /**
3
3
  * Federation Spec
4
4
  */
@@ -1,4 +1,4 @@
1
- import { GraphQLSchema, FieldDefinitionNode, GraphQLNamedType } from 'graphql';
1
+ import { FieldDefinitionNode, GraphQLNamedType, GraphQLSchema } from 'graphql';
2
2
  /**
3
3
  * Federation Spec
4
4
  */
@@ -1,5 +1,5 @@
1
+ import { DocumentNode, GraphQLOutputType, GraphQLSchema } from 'graphql';
1
2
  import { Types } from './types.cjs';
2
- import { DocumentNode, GraphQLSchema, GraphQLOutputType } from 'graphql';
3
3
  export declare function isOutputConfigArray(type: any): type is Types.OutputConfig[];
4
4
  export declare function isConfiguredOutput(type: any): type is Types.ConfiguredOutput;
5
5
  export declare function normalizeOutputParam(config: Types.OutputConfig | Types.ConfiguredPlugin[] | Types.ConfiguredOutput): Types.ConfiguredOutput;
@@ -1,5 +1,5 @@
1
+ import { DocumentNode, GraphQLOutputType, GraphQLSchema } from 'graphql';
1
2
  import { Types } from './types.js';
2
- import { DocumentNode, GraphQLSchema, GraphQLOutputType } from 'graphql';
3
3
  export declare function isOutputConfigArray(type: any): type is Types.OutputConfig[];
4
4
  export declare function isConfiguredOutput(type: any): type is Types.ConfiguredOutput;
5
5
  export declare function normalizeOutputParam(config: Types.OutputConfig | Types.ConfiguredPlugin[] | Types.ConfiguredOutput): Types.ConfiguredOutput;
@@ -1,9 +1,9 @@
1
- export { resolveExternalModuleAndFn } from './resolve-external-module-and-fn.cjs';
2
- export * from './types.cjs';
3
- export * from './utils.cjs';
4
- export * from './helpers.cjs';
5
1
  export * from './federation.cjs';
6
2
  export * from './getCachedDocumentNodeFromSchema.cjs';
3
+ export * from './helpers.cjs';
7
4
  export * from './oldVisit.cjs';
8
5
  export * from './profiler.cjs';
6
+ export { resolveExternalModuleAndFn } from './resolve-external-module-and-fn.cjs';
7
+ export * from './types.cjs';
9
8
  export { Types } from './types.cjs';
9
+ export * from './utils.cjs';
@@ -1,9 +1,9 @@
1
- export { resolveExternalModuleAndFn } from './resolve-external-module-and-fn.js';
2
- export * from './types.js';
3
- export * from './utils.js';
4
- export * from './helpers.js';
5
1
  export * from './federation.js';
6
2
  export * from './getCachedDocumentNodeFromSchema.js';
3
+ export * from './helpers.js';
7
4
  export * from './oldVisit.js';
8
5
  export * from './profiler.js';
6
+ export { resolveExternalModuleAndFn } from './resolve-external-module-and-fn.js';
7
+ export * from './types.js';
9
8
  export { Types } from './types.js';
9
+ export * from './utils.js';
@@ -1,7 +1,7 @@
1
- import { GraphQLSchema, DocumentNode } from 'graphql';
1
+ import type { ApolloEngineOptions } from '@graphql-tools/apollo-engine-loader';
2
2
  import { Source } from '@graphql-tools/utils';
3
+ import { DocumentNode, GraphQLSchema } from 'graphql';
3
4
  import type { Profiler } from './profiler.cjs';
4
- import type { ApolloEngineOptions } from '@graphql-tools/apollo-engine-loader';
5
5
  export declare namespace Types {
6
6
  interface GenerateOptions {
7
7
  filename: string;
@@ -212,14 +212,14 @@ export declare namespace Types {
212
212
  *
213
213
  * You can either specify plugins from the community using the NPM package name (after you installed it in your project), or you can use a path to a local file for custom plugins.
214
214
  *
215
- * You can find a list of available plugins here: https://graphql-code-generator.com/docs/plugins/index
216
- * Need a custom plugin? read this: https://graphql-code-generator.com/docs/custom-codegen/index
215
+ * You can find a list of available plugins here: https://the-guild.dev/graphql/codegen/docs/plugins/index
216
+ * Need a custom plugin? read this: https://the-guild.dev/graphql/codegen/docs/custom-codegen/index
217
217
  */
218
218
  plugins: OutputConfig[];
219
219
  /**
220
220
  * @description If your setup uses Preset to have a more dynamic setup and output, set the name of your preset here.
221
221
  *
222
- * Presets are a way to have more than one file output, for example: https://graphql-code-generator.com/docs/presets/near-operation-file
222
+ * Presets are a way to have more than one file output, for example: https://the-guild.dev/graphql/codegen/docs/presets/near-operation-file
223
223
  *
224
224
  * You can either specify a preset from the community using the NPM package name (after you installed it in your project), or you can use a path to a local file for a custom preset.
225
225
  *
@@ -464,7 +464,7 @@ export declare namespace Types {
464
464
  /**
465
465
  * @description Configures the magic GraphQL comments to look for. The default is `GraphQL`.
466
466
  */
467
- magicComment?: string;
467
+ gqlMagicComment?: string;
468
468
  /**
469
469
  * @description Overrides the name of the default GraphQL name identifier.
470
470
  */
@@ -1,7 +1,7 @@
1
- import { GraphQLSchema, DocumentNode } from 'graphql';
1
+ import type { ApolloEngineOptions } from '@graphql-tools/apollo-engine-loader';
2
2
  import { Source } from '@graphql-tools/utils';
3
+ import { DocumentNode, GraphQLSchema } from 'graphql';
3
4
  import type { Profiler } from './profiler.js';
4
- import type { ApolloEngineOptions } from '@graphql-tools/apollo-engine-loader';
5
5
  export declare namespace Types {
6
6
  interface GenerateOptions {
7
7
  filename: string;
@@ -212,14 +212,14 @@ export declare namespace Types {
212
212
  *
213
213
  * You can either specify plugins from the community using the NPM package name (after you installed it in your project), or you can use a path to a local file for custom plugins.
214
214
  *
215
- * You can find a list of available plugins here: https://graphql-code-generator.com/docs/plugins/index
216
- * Need a custom plugin? read this: https://graphql-code-generator.com/docs/custom-codegen/index
215
+ * You can find a list of available plugins here: https://the-guild.dev/graphql/codegen/docs/plugins/index
216
+ * Need a custom plugin? read this: https://the-guild.dev/graphql/codegen/docs/custom-codegen/index
217
217
  */
218
218
  plugins: OutputConfig[];
219
219
  /**
220
220
  * @description If your setup uses Preset to have a more dynamic setup and output, set the name of your preset here.
221
221
  *
222
- * Presets are a way to have more than one file output, for example: https://graphql-code-generator.com/docs/presets/near-operation-file
222
+ * Presets are a way to have more than one file output, for example: https://the-guild.dev/graphql/codegen/docs/presets/near-operation-file
223
223
  *
224
224
  * You can either specify a preset from the community using the NPM package name (after you installed it in your project), or you can use a path to a local file for a custom preset.
225
225
  *
@@ -464,7 +464,7 @@ export declare namespace Types {
464
464
  /**
465
465
  * @description Configures the magic GraphQL comments to look for. The default is `GraphQL`.
466
466
  */
467
- magicComment?: string;
467
+ gqlMagicComment?: string;
468
468
  /**
469
469
  * @description Overrides the name of the default GraphQL name identifier.
470
470
  */
@@ -1,4 +1,4 @@
1
- import { GraphQLOutputType, GraphQLNamedType, GraphQLNonNull, GraphQLList } from 'graphql';
1
+ import { GraphQLList, GraphQLNamedType, GraphQLNonNull, GraphQLOutputType } from 'graphql';
2
2
  import { Types } from './types.cjs';
3
3
  export declare function mergeOutputs(content: Types.PluginOutput | Array<Types.PluginOutput>): string;
4
4
  export declare function isWrapperType(t: GraphQLOutputType): t is GraphQLNonNull<any> | GraphQLList<any>;
@@ -1,4 +1,4 @@
1
- import { GraphQLOutputType, GraphQLNamedType, GraphQLNonNull, GraphQLList } from 'graphql';
1
+ import { GraphQLList, GraphQLNamedType, GraphQLNonNull, GraphQLOutputType } from 'graphql';
2
2
  import { Types } from './types.js';
3
3
  export declare function mergeOutputs(content: Types.PluginOutput | Array<Types.PluginOutput>): string;
4
4
  export declare function isWrapperType(t: GraphQLOutputType): t is GraphQLNonNull<any> | GraphQLList<any>;