@graphql-eslint/eslint-plugin 4.2.2-alpha-20241204102535-3afae251e645e69192a088b7f57a2e67e04485b4 → 4.3.0-alpha-20241204113935-074a093b359d2947f263679eac8596958876a3b6

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 CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});const version = "4.2.2-alpha-20241204102535-3afae251e645e69192a088b7f57a2e67e04485b4";
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});const version = "4.3.0-alpha-20241204113935-074a093b359d2947f263679eac8596958876a3b6";
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 schema = project.loadSchemaSync(project.schema, "GraphQLSchema", {
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/index.d.ts CHANGED
@@ -49,12 +49,12 @@ declare const _default: {
49
49
  };
50
50
  rules: {
51
51
  alphabetize: GraphQLESLintRule<{
52
- definitions?: boolean | undefined;
53
- selections?: ("OperationDefinition" | "FragmentDefinition")[] | undefined;
54
- arguments?: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[] | undefined;
55
52
  values?: boolean | undefined;
56
- fields?: ("ObjectTypeDefinition" | "InterfaceTypeDefinition" | "InputObjectTypeDefinition")[] | undefined;
53
+ definitions?: boolean | undefined;
54
+ fields?: ("InputObjectTypeDefinition" | "InterfaceTypeDefinition" | "ObjectTypeDefinition")[] | undefined;
55
+ selections?: ("FragmentDefinition" | "OperationDefinition")[] | undefined;
57
56
  variables?: boolean | undefined;
57
+ arguments?: ("Directive" | "DirectiveDefinition" | "Field" | "FieldDefinition")[] | undefined;
58
58
  groups?: string[] | undefined;
59
59
  }[]>;
60
60
  'description-style': GraphQLESLintRule<{
@@ -67,7 +67,7 @@ declare const _default: {
67
67
  checkMutations?: boolean | undefined;
68
68
  }[]>;
69
69
  'lone-executable-definition': GraphQLESLintRule<{
70
- ignore?: (graphql.OperationTypeNode | "fragment")[] | undefined;
70
+ ignore?: ("fragment" | graphql.OperationTypeNode)[] | undefined;
71
71
  }[]>;
72
72
  'match-document-filename': GraphQLESLintRule<{
73
73
  fragment?: (CaseStyle | "matchDocumentStyle") | {
@@ -75,6 +75,7 @@ declare const _default: {
75
75
  suffix?: string | undefined;
76
76
  prefix?: string | undefined;
77
77
  } | undefined;
78
+ fileExtension?: ".gql" | ".graphql" | undefined;
78
79
  query?: (CaseStyle | "matchDocumentStyle") | {
79
80
  style?: (CaseStyle | "matchDocumentStyle") | undefined;
80
81
  suffix?: string | undefined;
@@ -90,10 +91,11 @@ declare const _default: {
90
91
  suffix?: string | undefined;
91
92
  prefix?: string | undefined;
92
93
  } | undefined;
93
- fileExtension?: ".gql" | ".graphql" | undefined;
94
94
  }[]>;
95
95
  'naming-convention': GraphQLESLintRule<{
96
96
  [x: string]: unknown;
97
+ allowLeadingUnderscore?: boolean | undefined;
98
+ allowTrailingUnderscore?: boolean | undefined;
97
99
  types?: ("camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE") | {
98
100
  style?: ("camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE") | undefined;
99
101
  suffix?: string | undefined;
@@ -110,8 +112,6 @@ declare const _default: {
110
112
  requiredSuffixes?: string[] | undefined;
111
113
  ignorePattern?: string | undefined;
112
114
  } | undefined;
113
- allowLeadingUnderscore?: boolean | undefined;
114
- allowTrailingUnderscore?: boolean | undefined;
115
115
  }[]>;
116
116
  'no-anonymous-operations': GraphQLESLintRule;
117
117
  'no-deprecated': GraphQLESLintRule<[], true>;
package/esm/meta.js CHANGED
@@ -1,4 +1,4 @@
1
- const version = "4.2.2-alpha-20241204102535-3afae251e645e69192a088b7f57a2e67e04485b4";
1
+ const version = "4.3.0-alpha-20241204113935-074a093b359d2947f263679eac8596958876a3b6";
2
2
  export {
3
3
  version
4
4
  };
@@ -19,7 +19,7 @@ declare const schema: {
19
19
  readonly properties: {
20
20
  readonly fields: {
21
21
  readonly items: {
22
- readonly enum: ("ObjectTypeDefinition" | "InterfaceTypeDefinition" | "InputObjectTypeDefinition")[];
22
+ readonly enum: ("InputObjectTypeDefinition" | "InterfaceTypeDefinition" | "ObjectTypeDefinition")[];
23
23
  };
24
24
  readonly description: "Fields of `type`, `interface`, and `input`.";
25
25
  readonly type: "array";
@@ -32,7 +32,7 @@ declare const schema: {
32
32
  };
33
33
  readonly selections: {
34
34
  readonly items: {
35
- readonly enum: ("OperationDefinition" | "FragmentDefinition")[];
35
+ readonly enum: ("FragmentDefinition" | "OperationDefinition")[];
36
36
  };
37
37
  readonly description: "Selections of `fragment` and operations `query`, `mutation` and `subscription`.";
38
38
  readonly type: "array";
@@ -45,7 +45,7 @@ declare const schema: {
45
45
  };
46
46
  readonly arguments: {
47
47
  readonly items: {
48
- readonly enum: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[];
48
+ readonly enum: ("Directive" | "DirectiveDefinition" | "Field" | "FieldDefinition")[];
49
49
  };
50
50
  readonly description: "Arguments of fields and directives.";
51
51
  readonly type: "array";
@@ -12,12 +12,12 @@ import 'json-schema-to-ts';
12
12
 
13
13
  declare const rules: {
14
14
  alphabetize: GraphQLESLintRule<{
15
- definitions?: boolean | undefined;
16
- selections?: ("OperationDefinition" | "FragmentDefinition")[] | undefined;
17
- arguments?: ("Field" | "Directive" | "FieldDefinition" | "DirectiveDefinition")[] | undefined;
18
15
  values?: boolean | undefined;
19
- fields?: ("ObjectTypeDefinition" | "InterfaceTypeDefinition" | "InputObjectTypeDefinition")[] | undefined;
16
+ definitions?: boolean | undefined;
17
+ fields?: ("InputObjectTypeDefinition" | "InterfaceTypeDefinition" | "ObjectTypeDefinition")[] | undefined;
18
+ selections?: ("FragmentDefinition" | "OperationDefinition")[] | undefined;
20
19
  variables?: boolean | undefined;
20
+ arguments?: ("Directive" | "DirectiveDefinition" | "Field" | "FieldDefinition")[] | undefined;
21
21
  groups?: string[] | undefined;
22
22
  }[]>;
23
23
  'description-style': GraphQLESLintRule<{
@@ -30,7 +30,7 @@ declare const rules: {
30
30
  checkMutations?: boolean | undefined;
31
31
  }[]>;
32
32
  'lone-executable-definition': GraphQLESLintRule<{
33
- ignore?: (graphql.OperationTypeNode | "fragment")[] | undefined;
33
+ ignore?: ("fragment" | graphql.OperationTypeNode)[] | undefined;
34
34
  }[]>;
35
35
  'match-document-filename': GraphQLESLintRule<{
36
36
  fragment?: (CaseStyle | "matchDocumentStyle") | {
@@ -38,6 +38,7 @@ declare const rules: {
38
38
  suffix?: string | undefined;
39
39
  prefix?: string | undefined;
40
40
  } | undefined;
41
+ fileExtension?: ".gql" | ".graphql" | undefined;
41
42
  query?: (CaseStyle | "matchDocumentStyle") | {
42
43
  style?: (CaseStyle | "matchDocumentStyle") | undefined;
43
44
  suffix?: string | undefined;
@@ -53,10 +54,11 @@ declare const rules: {
53
54
  suffix?: string | undefined;
54
55
  prefix?: string | undefined;
55
56
  } | undefined;
56
- fileExtension?: ".gql" | ".graphql" | undefined;
57
57
  }[]>;
58
58
  'naming-convention': GraphQLESLintRule<{
59
59
  [x: string]: unknown;
60
+ allowLeadingUnderscore?: boolean | undefined;
61
+ allowTrailingUnderscore?: boolean | undefined;
60
62
  types?: ("camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE") | {
61
63
  style?: ("camelCase" | "PascalCase" | "snake_case" | "UPPER_CASE") | undefined;
62
64
  suffix?: string | undefined;
@@ -73,8 +75,6 @@ declare const rules: {
73
75
  requiredSuffixes?: string[] | undefined;
74
76
  ignorePattern?: string | undefined;
75
77
  } | undefined;
76
- allowLeadingUnderscore?: boolean | undefined;
77
- allowTrailingUnderscore?: boolean | undefined;
78
78
  }[]>;
79
79
  'no-anonymous-operations': GraphQLESLintRule;
80
80
  'no-deprecated': GraphQLESLintRule<[], true>;
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 schema = project.loadSchemaSync(project.schema, "GraphQLSchema", {
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.2.2-alpha-20241204102535-3afae251e645e69192a088b7f57a2e67e04485b4";
153
+ var version = "4.3.0-alpha-20241204113935-074a093b359d2947f263679eac8596958876a3b6";
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.2.2-alpha-20241204102535-3afae251e645e69192a088b7f57a2e67e04485b4",
3
+ "version": "4.3.0-alpha-20241204113935-074a093b359d2947f263679eac8596958876a3b6",
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.4",
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",