@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 +6 -7
- package/cjs/index.js +5 -5
- package/cjs/oldVisit.js +2 -2
- package/cjs/resolve-external-module-and-fn.js +0 -1
- package/cjs/types.js +1 -1
- package/esm/federation.js +7 -8
- package/esm/helpers.js +1 -1
- package/esm/index.js +4 -4
- package/esm/oldVisit.js +2 -2
- package/esm/resolve-external-module-and-fn.js +0 -1
- package/esm/types.js +1 -1
- package/package.json +1 -1
- package/typings/federation.d.cts +1 -1
- package/typings/federation.d.ts +1 -1
- package/typings/helpers.d.cts +1 -1
- package/typings/helpers.d.ts +1 -1
- package/typings/index.d.cts +4 -4
- package/typings/index.d.ts +4 -4
- package/typings/types.d.cts +6 -6
- package/typings/types.d.ts +6 -6
- package/typings/utils.d.cts +1 -1
- package/typings/utils.d.ts +1 -1
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
|
|
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
|
|
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
|
-
|
|
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]
|
|
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]
|
|
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' &&
|
|
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 {
|
|
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
|
|
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
|
|
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
|
-
|
|
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 {
|
|
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]
|
|
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]
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/plugin-helpers",
|
|
3
|
-
"version": "3.1.
|
|
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"
|
package/typings/federation.d.cts
CHANGED
package/typings/federation.d.ts
CHANGED
package/typings/helpers.d.cts
CHANGED
|
@@ -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;
|
package/typings/helpers.d.ts
CHANGED
|
@@ -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;
|
package/typings/index.d.cts
CHANGED
|
@@ -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';
|
package/typings/index.d.ts
CHANGED
|
@@ -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';
|
package/typings/types.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
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://
|
|
216
|
-
* Need a custom plugin? read this: https://
|
|
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://
|
|
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
|
-
|
|
467
|
+
gqlMagicComment?: string;
|
|
468
468
|
/**
|
|
469
469
|
* @description Overrides the name of the default GraphQL name identifier.
|
|
470
470
|
*/
|
package/typings/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
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://
|
|
216
|
-
* Need a custom plugin? read this: https://
|
|
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://
|
|
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
|
-
|
|
467
|
+
gqlMagicComment?: string;
|
|
468
468
|
/**
|
|
469
469
|
* @description Overrides the name of the default GraphQL name identifier.
|
|
470
470
|
*/
|
package/typings/utils.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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>;
|
package/typings/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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>;
|