@graphql-eslint/eslint-plugin 4.2.2-alpha-20241204114819-5991c18e49604d2797fb52011a661193e55f2a51 → 4.3.0-alpha-20241204114257-e01dcddc96c4363da10e4e9df8ad7e8de0849073
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/meta.js +1 -1
- package/cjs/schema.js +19 -2
- package/esm/meta.js +1 -1
- package/esm/schema.js +21 -3
- package/index.browser.js +1 -1
- package/package.json +6 -2
package/cjs/meta.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});const version = "4.
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});const version = "4.3.0-alpha-20241204114257-e01dcddc96c4363da10e4e9df8ad7e8de0849073";
|
2
2
|
|
3
3
|
|
4
4
|
exports.version = version;
|
package/cjs/schema.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _debug = require('debug'); var _debug2 = _interopRequireDefault(_debug);
|
2
2
|
var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob);
|
3
3
|
var _graphql = require('graphql');
|
4
4
|
var _cachejs = require('./cache.js');
|
@@ -11,9 +11,26 @@ function getSchema(project) {
|
|
11
11
|
if (cache)
|
12
12
|
return cache;
|
13
13
|
debug("Loading schema from %o", project.schema);
|
14
|
-
const
|
14
|
+
const opts = {
|
15
15
|
pluckConfig: project.extensions.pluckConfig
|
16
|
+
}, typeDefs = project.loadSchemaSync(project.schema, "DocumentNode", opts);
|
17
|
+
let isFederation = !1;
|
18
|
+
_graphql.visit.call(void 0, typeDefs, {
|
19
|
+
SchemaExtension(node) {
|
20
|
+
const linkDirective = _optionalChain([node, 'access', _ => _.directives, 'optionalAccess', _2 => _2.find, 'call', _3 => _3((d) => d.name.value === "link")]);
|
21
|
+
if (!linkDirective) return _graphql.BREAK;
|
22
|
+
const urlArgument = _optionalChain([linkDirective, 'access', _4 => _4.arguments, 'optionalAccess', _5 => _5.find, 'call', _6 => _6((a) => a.name.value === "url")]);
|
23
|
+
if (!urlArgument) return _graphql.BREAK;
|
24
|
+
if (urlArgument.value.kind !== "StringValue") return _graphql.BREAK;
|
25
|
+
isFederation = urlArgument.value.value.includes("/federation/");
|
26
|
+
}
|
16
27
|
});
|
28
|
+
let schema;
|
29
|
+
if (isFederation) {
|
30
|
+
const { buildSubgraphSchema } = require("@apollo/subgraph");
|
31
|
+
schema = buildSubgraphSchema({ typeDefs });
|
32
|
+
} else
|
33
|
+
schema = project.loadSchemaSync(project.schema, "GraphQLSchema", opts);
|
17
34
|
if (debug.enabled) {
|
18
35
|
debug("Schema loaded: %o", schema instanceof _graphql.GraphQLSchema);
|
19
36
|
const schemaPaths = _fastglob2.default.sync(project.schema, { absolute: !0 });
|
package/esm/meta.js
CHANGED
package/esm/schema.js
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
import { createRequire } from "module";
|
1
2
|
import debugFactory from "debug";
|
2
3
|
import fg from "fast-glob";
|
3
|
-
import { GraphQLSchema } from "graphql";
|
4
|
+
import { BREAK, GraphQLSchema, visit } from "graphql";
|
4
5
|
import { ModuleCache } from "./cache.js";
|
5
|
-
const schemaCache = new ModuleCache(), debug = debugFactory("graphql-eslint:schema");
|
6
|
+
const schemaCache = new ModuleCache(), debug = debugFactory("graphql-eslint:schema"), require2 = createRequire(import.meta.url);
|
6
7
|
function getSchema(project) {
|
7
8
|
const schemaKey = project.schema;
|
8
9
|
if (!schemaKey)
|
@@ -11,9 +12,26 @@ function getSchema(project) {
|
|
11
12
|
if (cache)
|
12
13
|
return cache;
|
13
14
|
debug("Loading schema from %o", project.schema);
|
14
|
-
const
|
15
|
+
const opts = {
|
15
16
|
pluckConfig: project.extensions.pluckConfig
|
17
|
+
}, typeDefs = project.loadSchemaSync(project.schema, "DocumentNode", opts);
|
18
|
+
let isFederation = !1;
|
19
|
+
visit(typeDefs, {
|
20
|
+
SchemaExtension(node) {
|
21
|
+
const linkDirective = node.directives?.find((d) => d.name.value === "link");
|
22
|
+
if (!linkDirective) return BREAK;
|
23
|
+
const urlArgument = linkDirective.arguments?.find((a) => a.name.value === "url");
|
24
|
+
if (!urlArgument) return BREAK;
|
25
|
+
if (urlArgument.value.kind !== "StringValue") return BREAK;
|
26
|
+
isFederation = urlArgument.value.value.includes("/federation/");
|
27
|
+
}
|
16
28
|
});
|
29
|
+
let schema;
|
30
|
+
if (isFederation) {
|
31
|
+
const { buildSubgraphSchema } = require2("@apollo/subgraph");
|
32
|
+
schema = buildSubgraphSchema({ typeDefs });
|
33
|
+
} else
|
34
|
+
schema = project.loadSchemaSync(project.schema, "GraphQLSchema", opts);
|
17
35
|
if (debug.enabled) {
|
18
36
|
debug("Schema loaded: %o", schema instanceof GraphQLSchema);
|
19
37
|
const schemaPaths = fg.sync(project.schema, { absolute: !0 });
|
package/index.browser.js
CHANGED
@@ -150,7 +150,7 @@ function convertToESTree(node, schema16) {
|
|
150
150
|
}
|
151
151
|
|
152
152
|
// src/meta.ts
|
153
|
-
var version = "4.
|
153
|
+
var version = "4.3.0-alpha-20241204114257-e01dcddc96c4363da10e4e9df8ad7e8de0849073";
|
154
154
|
|
155
155
|
// src/siblings.ts
|
156
156
|
import {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@graphql-eslint/eslint-plugin",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.3.0-alpha-20241204114257-e01dcddc96c4363da10e4e9df8ad7e8de0849073",
|
4
4
|
"type": "module",
|
5
5
|
"description": "GraphQL plugin for ESLint",
|
6
6
|
"repository": "https://github.com/dimaMachina/graphql-eslint",
|
@@ -30,18 +30,22 @@
|
|
30
30
|
"graphql"
|
31
31
|
],
|
32
32
|
"peerDependencies": {
|
33
|
+
"@apollo/subgraph": "^2",
|
33
34
|
"eslint": ">=8.44.0",
|
34
35
|
"graphql": "^16",
|
35
36
|
"json-schema-to-ts": "^3"
|
36
37
|
},
|
37
38
|
"peerDependenciesMeta": {
|
39
|
+
"@apollo/subgraph": {
|
40
|
+
"optional": true
|
41
|
+
},
|
38
42
|
"json-schema-to-ts": {
|
39
43
|
"optional": true
|
40
44
|
}
|
41
45
|
},
|
42
46
|
"dependencies": {
|
43
47
|
"@graphql-tools/code-file-loader": "^8.0.0",
|
44
|
-
"@graphql-tools/graphql-tag-pluck": "8.3.
|
48
|
+
"@graphql-tools/graphql-tag-pluck": "^8.3.4",
|
45
49
|
"@graphql-tools/utils": "^10.0.0",
|
46
50
|
"debug": "^4.3.4",
|
47
51
|
"fast-glob": "^3.2.12",
|