@graphql-codegen/plugin-helpers 2.1.0-alpha-ae01a8c41.0 → 2.1.1
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/index.js +5 -4
- package/index.mjs +5 -4
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -10,7 +10,6 @@ const changeCaseAll = require('change-case-all');
|
|
|
10
10
|
const graphql = require('graphql');
|
|
11
11
|
const merge = _interopDefault(require('lodash/merge.js'));
|
|
12
12
|
const utils = require('@graphql-tools/utils');
|
|
13
|
-
const visitorPluginCommon = require('@graphql-codegen/visitor-plugin-common');
|
|
14
13
|
|
|
15
14
|
function resolveExternalModuleAndFn(pointer) {
|
|
16
15
|
if (typeof pointer === 'function') {
|
|
@@ -27,7 +26,9 @@ function resolveExternalModuleAndFn(pointer) {
|
|
|
27
26
|
loadedModule = changeCaseAll;
|
|
28
27
|
}
|
|
29
28
|
else {
|
|
30
|
-
|
|
29
|
+
// we have to use a path to a filename here (it does not need to exist.)
|
|
30
|
+
// https://github.com/dotansimha/graphql-code-generator/issues/6553
|
|
31
|
+
const cwdRequire = module$1.createRequire(process.cwd() + '/index.js');
|
|
31
32
|
loadedModule = cwdRequire(moduleName);
|
|
32
33
|
if (!(functionName in loadedModule) && typeof loadedModule !== 'function') {
|
|
33
34
|
throw new Error(`${functionName} couldn't be found in module ${moduleName}!`);
|
|
@@ -449,8 +450,8 @@ class ApolloFederation {
|
|
|
449
450
|
*/
|
|
450
451
|
function isFederationObjectType(node, schema) {
|
|
451
452
|
const { name: { value: name }, directives, } = graphql.isObjectType(node) ? utils.astFromObjectType(node, schema) : node;
|
|
452
|
-
const rootTypeNames =
|
|
453
|
-
const isNotRoot = !rootTypeNames.
|
|
453
|
+
const rootTypeNames = utils.getRootTypeNames(schema);
|
|
454
|
+
const isNotRoot = !rootTypeNames.has(name);
|
|
454
455
|
const isNotIntrospection = !name.startsWith('__');
|
|
455
456
|
const hasKeyDirective = directives.some(d => d.name.value === 'key');
|
|
456
457
|
return isNotRoot && isNotIntrospection && hasKeyDirective;
|
package/index.mjs
CHANGED
|
@@ -3,8 +3,7 @@ import { cwd } from 'process';
|
|
|
3
3
|
import * as changeCaseAll from 'change-case-all';
|
|
4
4
|
import { isListType, isNonNullType, visit, Kind, isObjectType, parse, GraphQLObjectType } from 'graphql';
|
|
5
5
|
import merge from 'lodash/merge.js';
|
|
6
|
-
import { mapSchema, MapperKind, astFromObjectType, getDocumentNodeFromSchema } from '@graphql-tools/utils';
|
|
7
|
-
import { getRootTypeNames } from '@graphql-codegen/visitor-plugin-common';
|
|
6
|
+
import { mapSchema, MapperKind, astFromObjectType, getRootTypeNames, getDocumentNodeFromSchema } from '@graphql-tools/utils';
|
|
8
7
|
|
|
9
8
|
function resolveExternalModuleAndFn(pointer) {
|
|
10
9
|
if (typeof pointer === 'function') {
|
|
@@ -21,7 +20,9 @@ function resolveExternalModuleAndFn(pointer) {
|
|
|
21
20
|
loadedModule = changeCaseAll;
|
|
22
21
|
}
|
|
23
22
|
else {
|
|
24
|
-
|
|
23
|
+
// we have to use a path to a filename here (it does not need to exist.)
|
|
24
|
+
// https://github.com/dotansimha/graphql-code-generator/issues/6553
|
|
25
|
+
const cwdRequire = createRequire(cwd() + '/index.js');
|
|
25
26
|
loadedModule = cwdRequire(moduleName);
|
|
26
27
|
if (!(functionName in loadedModule) && typeof loadedModule !== 'function') {
|
|
27
28
|
throw new Error(`${functionName} couldn't be found in module ${moduleName}!`);
|
|
@@ -444,7 +445,7 @@ class ApolloFederation {
|
|
|
444
445
|
function isFederationObjectType(node, schema) {
|
|
445
446
|
const { name: { value: name }, directives, } = isObjectType(node) ? astFromObjectType(node, schema) : node;
|
|
446
447
|
const rootTypeNames = getRootTypeNames(schema);
|
|
447
|
-
const isNotRoot = !rootTypeNames.
|
|
448
|
+
const isNotRoot = !rootTypeNames.has(name);
|
|
448
449
|
const isNotIntrospection = !name.startsWith('__');
|
|
449
450
|
const hasKeyDirective = directives.some(d => d.name.value === 'key');
|
|
450
451
|
return isNotRoot && isNotIntrospection && hasKeyDirective;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/plugin-helpers",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.1",
|
|
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"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@graphql-tools/utils": "^8.
|
|
9
|
+
"@graphql-tools/utils": "^8.1.1",
|
|
10
10
|
"change-case-all": "1.0.14",
|
|
11
11
|
"common-tags": "1.8.0",
|
|
12
12
|
"import-from": "4.0.0",
|