@graphql-codegen/fragment-matcher 3.2.2-alpha-714e0efe9.0 → 3.3.0-alpha-2fbcdb6d3.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.
@@ -1,11 +1,9 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const path = require('path');
6
- const pluginHelpers = require('@graphql-codegen/plugin-helpers');
7
- const graphql = require('graphql');
8
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validate = exports.plugin = void 0;
4
+ const path_1 = require("path");
5
+ const plugin_helpers_1 = require("@graphql-codegen/plugin-helpers");
6
+ const graphql_1 = require("graphql");
9
7
  const extensions = {
10
8
  ts: ['.ts', '.tsx'],
11
9
  js: ['.js', '.jsx'],
@@ -20,11 +18,11 @@ const plugin = async (schema, _documents, pluginConfig, info) => {
20
18
  ...pluginConfig,
21
19
  };
22
20
  const apolloClientVersion = parseInt(config.apolloClientVersion);
23
- const cleanSchema = config.federation ? pluginHelpers.removeFederation(schema) : schema;
24
- const useExplicitTyping = config.useExplicitTyping;
25
- const introspection = (await graphql.execute({
21
+ const cleanSchema = config.federation ? (0, plugin_helpers_1.removeFederation)(schema) : schema;
22
+ const { useExplicitTyping } = config;
23
+ const introspection = (await (0, graphql_1.execute)({
26
24
  schema: cleanSchema,
27
- document: graphql.parse(`
25
+ document: (0, graphql_1.parse)(`
28
26
  {
29
27
  __schema {
30
28
  types {
@@ -38,7 +36,7 @@ const plugin = async (schema, _documents, pluginConfig, info) => {
38
36
  }
39
37
  `),
40
38
  }));
41
- const ext = path.extname(info.outputFile).toLowerCase();
39
+ const ext = (0, path_1.extname)(info.outputFile).toLowerCase();
42
40
  if (!introspection.data) {
43
41
  throw new Error(`Plugin "fragment-matcher" couldn't introspect the schema`);
44
42
  }
@@ -108,8 +106,9 @@ const plugin = async (schema, _documents, pluginConfig, info) => {
108
106
  }
109
107
  throw new Error(`Extension ${ext} is not supported`);
110
108
  };
109
+ exports.plugin = plugin;
111
110
  const validate = async (_schema, _documents, config, outputFile) => {
112
- const ext = path.extname(outputFile).toLowerCase();
111
+ const ext = (0, path_1.extname)(outputFile).toLowerCase();
113
112
  const all = Object.values(extensions).reduce((acc, exts) => [...acc, ...exts], []);
114
113
  if (!all.includes(ext)) {
115
114
  throw new Error(`Plugin "fragment-matcher" requires extension to be one of ${all.map(val => val.replace('.', '')).join(', ')}!`);
@@ -118,6 +117,4 @@ const validate = async (_schema, _documents, config, outputFile) => {
118
117
  throw new Error(`Plugin "fragment-matcher" doesn't support commonjs modules combined with TypeScript!`);
119
118
  }
120
119
  };
121
-
122
- exports.plugin = plugin;
123
120
  exports.validate = validate;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -1,13 +1,12 @@
1
1
  import { extname } from 'path';
2
2
  import { removeFederation } from '@graphql-codegen/plugin-helpers';
3
3
  import { execute, parse } from 'graphql';
4
-
5
4
  const extensions = {
6
5
  ts: ['.ts', '.tsx'],
7
6
  js: ['.js', '.jsx'],
8
7
  json: ['.json'],
9
8
  };
10
- const plugin = async (schema, _documents, pluginConfig, info) => {
9
+ export const plugin = async (schema, _documents, pluginConfig, info) => {
11
10
  const config = {
12
11
  module: 'es2015',
13
12
  federation: false,
@@ -17,7 +16,7 @@ const plugin = async (schema, _documents, pluginConfig, info) => {
17
16
  };
18
17
  const apolloClientVersion = parseInt(config.apolloClientVersion);
19
18
  const cleanSchema = config.federation ? removeFederation(schema) : schema;
20
- const useExplicitTyping = config.useExplicitTyping;
19
+ const { useExplicitTyping } = config;
21
20
  const introspection = (await execute({
22
21
  schema: cleanSchema,
23
22
  document: parse(`
@@ -104,7 +103,7 @@ const plugin = async (schema, _documents, pluginConfig, info) => {
104
103
  }
105
104
  throw new Error(`Extension ${ext} is not supported`);
106
105
  };
107
- const validate = async (_schema, _documents, config, outputFile) => {
106
+ export const validate = async (_schema, _documents, config, outputFile) => {
108
107
  const ext = extname(outputFile).toLowerCase();
109
108
  const all = Object.values(extensions).reduce((acc, exts) => [...acc, ...exts], []);
110
109
  if (!all.includes(ext)) {
@@ -114,5 +113,3 @@ const validate = async (_schema, _documents, config, outputFile) => {
114
113
  throw new Error(`Plugin "fragment-matcher" doesn't support commonjs modules combined with TypeScript!`);
115
114
  }
116
115
  };
117
-
118
- export { plugin, validate };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@graphql-codegen/fragment-matcher",
3
- "version": "3.2.2-alpha-714e0efe9.0",
3
+ "version": "3.3.0-alpha-2fbcdb6d3.0",
4
4
  "description": "graphql-code-generate plugin for generating fragments matcher introspection file",
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"
7
7
  },
8
8
  "dependencies": {
9
- "@graphql-codegen/plugin-helpers": "2.4.2-alpha-714e0efe9.0",
10
- "tslib": "~2.3.0"
9
+ "@graphql-codegen/plugin-helpers": "^2.5.0-alpha-2fbcdb6d3.0",
10
+ "tslib": "~2.4.0"
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
@@ -15,21 +15,28 @@
15
15
  "directory": "packages/plugins/other/fragment-matcher"
16
16
  },
17
17
  "license": "MIT",
18
- "main": "index.js",
19
- "module": "index.mjs",
20
- "typings": "index.d.ts",
18
+ "main": "cjs/index.js",
19
+ "module": "esm/index.js",
20
+ "typings": "typings/index.d.ts",
21
21
  "typescript": {
22
- "definition": "index.d.ts"
22
+ "definition": "typings/index.d.ts"
23
23
  },
24
+ "type": "module",
24
25
  "exports": {
25
- "./package.json": "./package.json",
26
26
  ".": {
27
- "require": "./index.js",
28
- "import": "./index.mjs"
27
+ "require": {
28
+ "types": "./typings/index.d.ts",
29
+ "default": "./cjs/index.js"
30
+ },
31
+ "import": {
32
+ "types": "./typings/index.d.ts",
33
+ "default": "./esm/index.js"
34
+ },
35
+ "default": {
36
+ "types": "./typings/index.d.ts",
37
+ "default": "./esm/index.js"
38
+ }
29
39
  },
30
- "./*": {
31
- "require": "./*.js",
32
- "import": "./*.mjs"
33
- }
40
+ "./package.json": "./package.json"
34
41
  }
35
- }
42
+ }
@@ -18,7 +18,7 @@ export interface FragmentMatcherConfig {
18
18
  * @default es2015
19
19
  *
20
20
  * @exampleMarkdown
21
- * ```yml
21
+ * ```yaml
22
22
  * generates:
23
23
  * path/to/file.json:
24
24
  * plugins:
@@ -33,7 +33,7 @@ export interface FragmentMatcherConfig {
33
33
  * @default 3
34
34
  *
35
35
  * @exampleMarkdown
36
- * ```yml
36
+ * ```yaml
37
37
  * generates:
38
38
  * path/to/file.ts:
39
39
  * plugins:
@@ -48,7 +48,7 @@ export interface FragmentMatcherConfig {
48
48
  * @default false
49
49
  *
50
50
  * @exampleMarkdown
51
- * ```yml
51
+ * ```yaml
52
52
  * generates:
53
53
  * path/to/file.ts:
54
54
  * plugins: