@graphql-codegen/core 2.6.7 → 2.6.9-alpha-20230130231142-decc5d741

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.md CHANGED
@@ -4,6 +4,6 @@
4
4
  <img src="https://github.com/dotansimha/graphql-code-generator/blob/master/logo.png?raw=true" />
5
5
  </p>
6
6
 
7
- Live demo and full documentation: [graphql-code-generator.com](https://graphql-code-generator.com)
7
+ Live demo and full documentation: [the-guild.dev/graphql/codegen](https://the-guild.dev/graphql/codegen)
8
8
 
9
9
  Project repository: [graphql-code-generator](https://github.com/dotansimha/graphql-code-generator)
package/cjs/codegen.js CHANGED
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sortPrependValues = exports.codegen = void 0;
4
4
  const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
5
+ const schema_1 = require("@graphql-tools/schema");
6
+ const utils_1 = require("@graphql-tools/utils");
5
7
  const graphql_1 = require("graphql");
6
8
  const execute_plugin_js_1 = require("./execute-plugin.js");
7
- const utils_1 = require("@graphql-tools/utils");
8
- const schema_1 = require("@graphql-tools/schema");
9
9
  const utils_js_1 = require("./utils.js");
10
10
  async function codegen(options) {
11
11
  var _a;
@@ -79,12 +79,7 @@ async function codegen(options) {
79
79
  const name = Object.keys(plugin)[0];
80
80
  const pluginPackage = options.pluginMap[name];
81
81
  const pluginConfig = plugin[name] || {};
82
- const execConfig = typeof pluginConfig !== 'object'
83
- ? pluginConfig
84
- : {
85
- ...options.config,
86
- ...pluginConfig,
87
- };
82
+ const execConfig = typeof pluginConfig === 'object' ? { ...options.config, ...pluginConfig } : pluginConfig;
88
83
  const result = await profiler.run(() => (0, execute_plugin_js_1.executePlugin)({
89
84
  name,
90
85
  config: execConfig,
@@ -155,16 +150,13 @@ function validateDuplicateDocuments(files) {
155
150
  // duplicated names
156
151
  const definitionMap = {};
157
152
  function addDefinition(file, node, deduplicatedDefinitions) {
153
+ var _a, _b, _c;
158
154
  if (typeof node.name !== 'undefined') {
159
- if (!definitionMap[node.kind]) {
160
- definitionMap[node.kind] = {};
161
- }
162
- if (!definitionMap[node.kind][node.name.value]) {
163
- definitionMap[node.kind][node.name.value] = {
164
- paths: new Set(),
165
- contents: new Set(),
166
- };
167
- }
155
+ definitionMap[_a = node.kind] || (definitionMap[_a] = {});
156
+ (_b = definitionMap[node.kind])[_c = node.name.value] || (_b[_c] = {
157
+ paths: new Set(),
158
+ contents: new Set(),
159
+ });
168
160
  const definitionKindMap = definitionMap[node.kind];
169
161
  const length = definitionKindMap[node.name.value].contents.size;
170
162
  definitionKindMap[node.name.value].paths.add(file.location);
@@ -5,7 +5,7 @@ const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
5
5
  const graphql_1 = require("graphql");
6
6
  async function executePlugin(options, plugin) {
7
7
  var _a;
8
- if (!plugin || !plugin.plugin || typeof plugin.plugin !== 'function') {
8
+ if (!(plugin === null || plugin === void 0 ? void 0 : plugin.plugin) || typeof plugin.plugin !== 'function') {
9
9
  throw new Error(`Invalid Custom Plugin "${options.name}" \n
10
10
  Plugin ${options.name} does not export a valid JS object with "plugin" function.
11
11
 
package/cjs/utils.js CHANGED
@@ -71,9 +71,7 @@ function hasFederationSpec(schemaOrAST) {
71
71
  exports.hasFederationSpec = hasFederationSpec;
72
72
  function extractHashFromSchema(schema) {
73
73
  var _a;
74
- if (!schema.extensions) {
75
- schema.extensions = {};
76
- }
74
+ schema.extensions || (schema.extensions = {});
77
75
  return (_a = schema.extensions['hash']) !== null && _a !== void 0 ? _a : null;
78
76
  }
79
77
  exports.extractHashFromSchema = extractHashFromSchema;
package/esm/codegen.js CHANGED
@@ -1,8 +1,8 @@
1
- import { isComplexPluginOutput, federationSpec, getCachedDocumentNodeFromSchema, createNoopProfiler, } from '@graphql-codegen/plugin-helpers';
2
- import { visit, Kind, print, specifiedRules } from 'graphql';
3
- import { executePlugin } from './execute-plugin.js';
4
- import { validateGraphQlDocuments, asArray } from '@graphql-tools/utils';
1
+ import { createNoopProfiler, federationSpec, getCachedDocumentNodeFromSchema, isComplexPluginOutput, } from '@graphql-codegen/plugin-helpers';
5
2
  import { mergeSchemas } from '@graphql-tools/schema';
3
+ import { asArray, validateGraphQlDocuments } from '@graphql-tools/utils';
4
+ import { Kind, print, specifiedRules, visit } from 'graphql';
5
+ import { executePlugin } from './execute-plugin.js';
6
6
  import { extractHashFromSchema, getSkipDocumentsValidationOption, hasFederationSpec, pickFlag, prioritize, shouldValidateDocumentsAgainstSchema, shouldValidateDuplicateDocuments, } from './utils.js';
7
7
  export async function codegen(options) {
8
8
  var _a;
@@ -76,12 +76,7 @@ export async function codegen(options) {
76
76
  const name = Object.keys(plugin)[0];
77
77
  const pluginPackage = options.pluginMap[name];
78
78
  const pluginConfig = plugin[name] || {};
79
- const execConfig = typeof pluginConfig !== 'object'
80
- ? pluginConfig
81
- : {
82
- ...options.config,
83
- ...pluginConfig,
84
- };
79
+ const execConfig = typeof pluginConfig === 'object' ? { ...options.config, ...pluginConfig } : pluginConfig;
85
80
  const result = await profiler.run(() => executePlugin({
86
81
  name,
87
82
  config: execConfig,
@@ -150,16 +145,13 @@ function validateDuplicateDocuments(files) {
150
145
  // duplicated names
151
146
  const definitionMap = {};
152
147
  function addDefinition(file, node, deduplicatedDefinitions) {
148
+ var _a, _b, _c;
153
149
  if (typeof node.name !== 'undefined') {
154
- if (!definitionMap[node.kind]) {
155
- definitionMap[node.kind] = {};
156
- }
157
- if (!definitionMap[node.kind][node.name.value]) {
158
- definitionMap[node.kind][node.name.value] = {
159
- paths: new Set(),
160
- contents: new Set(),
161
- };
162
- }
150
+ definitionMap[_a = node.kind] || (definitionMap[_a] = {});
151
+ (_b = definitionMap[node.kind])[_c = node.name.value] || (_b[_c] = {
152
+ paths: new Set(),
153
+ contents: new Set(),
154
+ });
163
155
  const definitionKindMap = definitionMap[node.kind];
164
156
  const length = definitionKindMap[node.name.value].contents.size;
165
157
  definitionKindMap[node.name.value].paths.add(file.location);
@@ -2,7 +2,7 @@ import { createNoopProfiler } from '@graphql-codegen/plugin-helpers';
2
2
  import { buildASTSchema } from 'graphql';
3
3
  export async function executePlugin(options, plugin) {
4
4
  var _a;
5
- if (!plugin || !plugin.plugin || typeof plugin.plugin !== 'function') {
5
+ if (!(plugin === null || plugin === void 0 ? void 0 : plugin.plugin) || typeof plugin.plugin !== 'function') {
6
6
  throw new Error(`Invalid Custom Plugin "${options.name}" \n
7
7
  Plugin ${options.name} does not export a valid JS object with "plugin" function.
8
8
 
package/esm/utils.js CHANGED
@@ -61,8 +61,6 @@ export function hasFederationSpec(schemaOrAST) {
61
61
  }
62
62
  export function extractHashFromSchema(schema) {
63
63
  var _a;
64
- if (!schema.extensions) {
65
- schema.extensions = {};
66
- }
64
+ schema.extensions || (schema.extensions = {});
67
65
  return (_a = schema.extensions['hash']) !== null && _a !== void 0 ? _a : null;
68
66
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@graphql-codegen/core",
3
- "version": "2.6.7",
3
+ "version": "2.6.9-alpha-20230130231142-decc5d741",
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
  },
7
7
  "dependencies": {
8
- "@graphql-codegen/plugin-helpers": "^3.0.0",
8
+ "@graphql-codegen/plugin-helpers": "3.1.3-alpha-20230130231142-decc5d741",
9
9
  "@graphql-tools/schema": "^9.0.0",
10
10
  "@graphql-tools/utils": "^9.1.1",
11
11
  "tslib": "~2.4.0"
@@ -1,4 +1,4 @@
1
- import { Types, CodegenPlugin, Profiler } from '@graphql-codegen/plugin-helpers';
1
+ import { CodegenPlugin, Profiler, Types } from '@graphql-codegen/plugin-helpers';
2
2
  import { DocumentNode, GraphQLSchema } from 'graphql';
3
3
  export interface ExecutePluginOptions {
4
4
  name: string;
@@ -1,4 +1,4 @@
1
- import { Types, CodegenPlugin, Profiler } from '@graphql-codegen/plugin-helpers';
1
+ import { CodegenPlugin, Profiler, Types } from '@graphql-codegen/plugin-helpers';
2
2
  import { DocumentNode, GraphQLSchema } from 'graphql';
3
3
  export interface ExecutePluginOptions {
4
4
  name: string;