@graphql-codegen/cli 2.7.0-alpha-7c50b8781.0 → 2.7.0-alpha-929a21bcb.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.
Files changed (4) hide show
  1. package/bin.js +10 -4
  2. package/index.js +10 -4
  3. package/index.mjs +12 -6
  4. package/package.json +5 -5
package/bin.js CHANGED
@@ -376,7 +376,12 @@ async function getPluginByName(name, pluginLoader) {
376
376
  }
377
377
 
378
378
  async function getPresetByName(name, loader) {
379
- const possibleNames = [`@graphql-codegen/${name}`, `@graphql-codegen/${name}-preset`, name];
379
+ const possibleNames = [
380
+ `@graphql-codegen/${name}`,
381
+ `@graphql-codegen/${name}-preset`,
382
+ name,
383
+ path.resolve(process.cwd(), name),
384
+ ];
380
385
  for (const moduleName of possibleNames) {
381
386
  try {
382
387
  const loaded = await loader(moduleName);
@@ -799,13 +804,14 @@ function hashContent(content) {
799
804
  return crypto.createHash('sha256').update(content).digest('hex');
800
805
  }
801
806
  function hashSchema(schema) {
802
- return hashContent(utils.printSchemaWithDirectives(schema, {
803
- assumeValid: true,
804
- }));
807
+ return hashContent(graphql.print(pluginHelpers.getCachedDocumentNodeFromSchema(schema)));
805
808
  }
806
809
  function addHashToSchema(schemaPromise) {
807
810
  return schemaPromise.then(schema => {
808
811
  // It's consumed later on. The general purpose is to use it for caching.
812
+ if (!schema.extensions) {
813
+ schema.extensions = {};
814
+ }
809
815
  schema.extensions['hash'] = hashSchema(schema);
810
816
  return schema;
811
817
  });
package/index.js CHANGED
@@ -294,7 +294,12 @@ async function getPluginByName(name, pluginLoader) {
294
294
  }
295
295
 
296
296
  async function getPresetByName(name, loader) {
297
- const possibleNames = [`@graphql-codegen/${name}`, `@graphql-codegen/${name}-preset`, name];
297
+ const possibleNames = [
298
+ `@graphql-codegen/${name}`,
299
+ `@graphql-codegen/${name}-preset`,
300
+ name,
301
+ path.resolve(process.cwd(), name),
302
+ ];
298
303
  for (const moduleName of possibleNames) {
299
304
  try {
300
305
  const loaded = await loader(moduleName);
@@ -717,13 +722,14 @@ function hashContent(content) {
717
722
  return crypto.createHash('sha256').update(content).digest('hex');
718
723
  }
719
724
  function hashSchema(schema) {
720
- return hashContent(utils.printSchemaWithDirectives(schema, {
721
- assumeValid: true,
722
- }));
725
+ return hashContent(graphql.print(pluginHelpers.getCachedDocumentNodeFromSchema(schema)));
723
726
  }
724
727
  function addHashToSchema(schemaPromise) {
725
728
  return schemaPromise.then(schema => {
726
729
  // It's consumed later on. The general purpose is to use it for caching.
730
+ if (!schema.extensions) {
731
+ schema.extensions = {};
732
+ }
727
733
  schema.extensions['hash'] = hashSchema(schema);
728
734
  return schema;
729
735
  });
package/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { isDetailedError, DetailedError, createNoopProfiler, createProfiler, normalizeInstanceOrArray, normalizeConfig, normalizeOutputParam, getCachedDocumentNodeFromSchema } from '@graphql-codegen/plugin-helpers';
1
+ import { isDetailedError, DetailedError, createNoopProfiler, createProfiler, getCachedDocumentNodeFromSchema, normalizeInstanceOrArray, normalizeConfig, normalizeOutputParam } from '@graphql-codegen/plugin-helpers';
2
2
  import { codegen } from '@graphql-codegen/core';
3
- import { printSchemaWithDirectives, AggregateError, isValidPath } from '@graphql-tools/utils';
3
+ import { AggregateError, isValidPath } from '@graphql-tools/utils';
4
4
  import chalk from 'chalk';
5
5
  import logSymbols from 'log-symbols';
6
6
  import ansiEscapes from 'ansi-escapes';
@@ -267,7 +267,12 @@ async function getPluginByName(name, pluginLoader) {
267
267
  }
268
268
 
269
269
  async function getPresetByName(name, loader) {
270
- const possibleNames = [`@graphql-codegen/${name}`, `@graphql-codegen/${name}-preset`, name];
270
+ const possibleNames = [
271
+ `@graphql-codegen/${name}`,
272
+ `@graphql-codegen/${name}-preset`,
273
+ name,
274
+ resolve(process.cwd(), name),
275
+ ];
271
276
  for (const moduleName of possibleNames) {
272
277
  try {
273
278
  const loaded = await loader(moduleName);
@@ -690,13 +695,14 @@ function hashContent(content) {
690
695
  return createHash('sha256').update(content).digest('hex');
691
696
  }
692
697
  function hashSchema(schema) {
693
- return hashContent(printSchemaWithDirectives(schema, {
694
- assumeValid: true,
695
- }));
698
+ return hashContent(print(getCachedDocumentNodeFromSchema(schema)));
696
699
  }
697
700
  function addHashToSchema(schemaPromise) {
698
701
  return schemaPromise.then(schema => {
699
702
  // It's consumed later on. The general purpose is to use it for caching.
703
+ if (!schema.extensions) {
704
+ schema.extensions = {};
705
+ }
700
706
  schema.extensions['hash'] = hashSchema(schema);
701
707
  return schema;
702
708
  });
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@graphql-codegen/cli",
3
- "version": "2.7.0-alpha-7c50b8781.0",
3
+ "version": "2.7.0-alpha-929a21bcb.0",
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/core": "2.6.0-alpha-7c50b8781.0",
9
- "@graphql-codegen/plugin-helpers": "2.5.0-alpha-7c50b8781.0",
8
+ "@graphql-codegen/core": "2.5.1",
9
+ "@graphql-codegen/plugin-helpers": "^2.4.1",
10
10
  "@graphql-tools/apollo-engine-loader": "^7.0.5",
11
- "@graphql-tools/code-file-loader": "^7.0.6",
11
+ "@graphql-tools/code-file-loader": "^7.2.10",
12
12
  "@graphql-tools/git-loader": "^7.0.5",
13
13
  "@graphql-tools/github-loader": "^7.0.5",
14
14
  "@graphql-tools/graphql-file-loader": "^7.0.5",
@@ -36,7 +36,7 @@
36
36
  "listr": "^0.14.3",
37
37
  "listr-update-renderer": "^0.5.0",
38
38
  "log-symbols": "^4.0.0",
39
- "minimatch": "^3.0.4",
39
+ "minimatch": "^5.0.0",
40
40
  "mkdirp": "^1.0.4",
41
41
  "string-env-interpolation": "^1.0.1",
42
42
  "ts-log": "^2.2.3",