@graphql-codegen/typescript-apollo-client-helpers 2.1.21 → 2.2.0-alpha-bd464a586.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.
package/cjs/config.js
ADDED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const path = require('path');
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validate = exports.plugin = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
const path_1 = require("path");
|
|
8
6
|
const plugin = (schema, documents, config) => {
|
|
9
7
|
const results = [];
|
|
10
8
|
results.push(generateTypePoliciesSignature(schema, config));
|
|
@@ -14,13 +12,14 @@ const plugin = (schema, documents, config) => {
|
|
|
14
12
|
content: results.map(r => r.content).join('\n'),
|
|
15
13
|
};
|
|
16
14
|
};
|
|
15
|
+
exports.plugin = plugin;
|
|
17
16
|
function generateTypePoliciesSignature(schema, config) {
|
|
18
17
|
var _a, _b, _c;
|
|
19
18
|
const typeMap = schema.getTypeMap();
|
|
20
19
|
const perTypePolicies = [];
|
|
21
20
|
const typedTypePolicies = Object.keys(typeMap).reduce((prev, typeName) => {
|
|
22
21
|
const type = typeMap[typeName];
|
|
23
|
-
if (!typeName.startsWith('__') && (
|
|
22
|
+
if (!typeName.startsWith('__') && ((0, graphql_1.isObjectType)(type) || (0, graphql_1.isInterfaceType)(type))) {
|
|
24
23
|
const fieldsNames = Object.keys(type.getFields()).filter(f => !f.startsWith('__'));
|
|
25
24
|
const keySpecifierVarName = `${typeName}KeySpecifier`;
|
|
26
25
|
const fieldPolicyVarName = `${typeName}FieldPolicy`;
|
|
@@ -59,10 +58,8 @@ ${fieldsNames.map(fieldName => `\t${fieldName}?: FieldPolicy<any> | FieldReadFun
|
|
|
59
58
|
};
|
|
60
59
|
}
|
|
61
60
|
const validate = async (schema, documents, config, outputFile) => {
|
|
62
|
-
if (
|
|
61
|
+
if ((0, path_1.extname)(outputFile) !== '.ts' && (0, path_1.extname)(outputFile) !== '.tsx') {
|
|
63
62
|
throw new Error(`Plugin "apollo-client-helpers" requires extension to be ".ts" or ".tsx"!`);
|
|
64
63
|
}
|
|
65
64
|
};
|
|
66
|
-
|
|
67
|
-
exports.plugin = plugin;
|
|
68
65
|
exports.validate = validate;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
package/esm/config.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isInterfaceType, isObjectType } from 'graphql';
|
|
2
2
|
import { extname } from 'path';
|
|
3
|
-
|
|
4
|
-
const plugin = (schema, documents, config) => {
|
|
3
|
+
export const plugin = (schema, documents, config) => {
|
|
5
4
|
const results = [];
|
|
6
5
|
results.push(generateTypePoliciesSignature(schema, config));
|
|
7
6
|
return {
|
|
@@ -54,10 +53,8 @@ ${fieldsNames.map(fieldName => `\t${fieldName}?: FieldPolicy<any> | FieldReadFun
|
|
|
54
53
|
content: [...perTypePolicies, rootContent].join('\n'),
|
|
55
54
|
};
|
|
56
55
|
}
|
|
57
|
-
const validate = async (schema, documents, config, outputFile) => {
|
|
56
|
+
export const validate = async (schema, documents, config, outputFile) => {
|
|
58
57
|
if (extname(outputFile) !== '.ts' && extname(outputFile) !== '.tsx') {
|
|
59
58
|
throw new Error(`Plugin "apollo-client-helpers" requires extension to be ".ts" or ".tsx"!`);
|
|
60
59
|
}
|
|
61
60
|
};
|
|
62
|
-
|
|
63
|
-
export { plugin, validate };
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript-apollo-client-helpers",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-alpha-bd464a586.0",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating TypeScript helpers for Apollo Client > 3",
|
|
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.0",
|
|
10
|
-
"@graphql-codegen/visitor-plugin-common": "2.10.0",
|
|
11
|
-
"auto-bind": "~4.0.0",
|
|
12
9
|
"change-case-all": "1.0.14",
|
|
10
|
+
"@graphql-codegen/plugin-helpers": "^2.5.0-alpha-bd464a586.0",
|
|
11
|
+
"@graphql-codegen/visitor-plugin-common": "2.11.0-alpha-bd464a586.0",
|
|
12
|
+
"auto-bind": "~4.0.0",
|
|
13
13
|
"tslib": "~2.4.0"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
@@ -18,21 +18,28 @@
|
|
|
18
18
|
"directory": "packages/plugins/typescript/apollo-client-helpers"
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
|
-
"main": "index.js",
|
|
22
|
-
"module": "index.
|
|
23
|
-
"typings": "index.d.ts",
|
|
21
|
+
"main": "cjs/index.js",
|
|
22
|
+
"module": "esm/index.js",
|
|
23
|
+
"typings": "typings/index.d.ts",
|
|
24
24
|
"typescript": {
|
|
25
|
-
"definition": "index.d.ts"
|
|
25
|
+
"definition": "typings/index.d.ts"
|
|
26
26
|
},
|
|
27
|
+
"type": "module",
|
|
27
28
|
"exports": {
|
|
28
|
-
"./package.json": "./package.json",
|
|
29
29
|
".": {
|
|
30
|
-
"require":
|
|
31
|
-
|
|
30
|
+
"require": {
|
|
31
|
+
"types": "./typings/index.d.ts",
|
|
32
|
+
"default": "./cjs/index.js"
|
|
33
|
+
},
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./typings/index.d.ts",
|
|
36
|
+
"default": "./esm/index.js"
|
|
37
|
+
},
|
|
38
|
+
"default": {
|
|
39
|
+
"types": "./typings/index.d.ts",
|
|
40
|
+
"default": "./esm/index.js"
|
|
41
|
+
}
|
|
32
42
|
},
|
|
33
|
-
"
|
|
34
|
-
"require": "./*.js",
|
|
35
|
-
"import": "./*.mjs"
|
|
36
|
-
}
|
|
43
|
+
"./package.json": "./package.json"
|
|
37
44
|
}
|
|
38
|
-
}
|
|
45
|
+
}
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { PluginValidateFn, PluginFunction } from '@graphql-codegen/plugin-helpers';
|
|
2
|
-
import { ApolloClientHelpersConfig } from './config';
|
|
2
|
+
import { ApolloClientHelpersConfig } from './config.js';
|
|
3
3
|
export declare const plugin: PluginFunction<ApolloClientHelpersConfig>;
|
|
4
4
|
export declare const validate: PluginValidateFn<ApolloClientHelpersConfig>;
|