@envelop/fragment-arguments 1.0.6 → 1.1.0-alpha-ed2d5ef.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.
@@ -1,18 +1,23 @@
1
- import { Parser } from 'graphql/language/parser.js';
1
+ import { ParseOptions, Parser } from 'graphql/language/parser.js';
2
+ import type { Lexer } from 'graphql/language/lexer.js';
3
+ import { Token, Location } from 'graphql';
2
4
  export declare class FragmentArgumentCompatibleParser extends Parser {
5
+ getLexer(): Lexer;
6
+ getOptions(): ParseOptions;
7
+ loc(startToken: Token): Location | undefined;
3
8
  parseFragment(): {
4
9
  kind: "FragmentSpread";
5
10
  name: import("graphql").NameNode;
6
11
  arguments: import("graphql").ArgumentNode[];
7
12
  directives: import("graphql").DirectiveNode[];
8
- loc: import("graphql").Location | undefined;
13
+ loc: Location | undefined;
9
14
  typeCondition?: undefined;
10
15
  selectionSet?: undefined;
11
16
  } | {
12
17
  kind: "FragmentSpread";
13
18
  name: import("graphql").NameNode;
14
19
  directives: import("graphql").DirectiveNode[];
15
- loc: import("graphql").Location | undefined;
20
+ loc: Location | undefined;
16
21
  arguments?: undefined;
17
22
  typeCondition?: undefined;
18
23
  selectionSet?: undefined;
@@ -21,7 +26,7 @@ export declare class FragmentArgumentCompatibleParser extends Parser {
21
26
  typeCondition: import("graphql").NamedTypeNode | undefined;
22
27
  directives: import("graphql").DirectiveNode[];
23
28
  selectionSet: import("graphql").SelectionSetNode;
24
- loc: import("graphql").Location | undefined;
29
+ loc: Location | undefined;
25
30
  name?: undefined;
26
31
  arguments?: undefined;
27
32
  };
@@ -32,14 +37,14 @@ export declare class FragmentArgumentCompatibleParser extends Parser {
32
37
  typeCondition: import("graphql").NamedTypeNode;
33
38
  directives: import("graphql").DirectiveNode[];
34
39
  selectionSet: import("graphql").SelectionSetNode;
35
- loc: import("graphql").Location | undefined;
40
+ loc: Location | undefined;
36
41
  } | {
37
42
  kind: "FragmentDefinition";
38
43
  name: import("graphql").NameNode;
39
44
  typeCondition: import("graphql").NamedTypeNode;
40
45
  directives: import("graphql").DirectiveNode[];
41
46
  selectionSet: import("graphql").SelectionSetNode;
42
- loc: import("graphql").Location | undefined;
47
+ loc: Location | undefined;
43
48
  variableDefinitions?: undefined;
44
49
  };
45
50
  }
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Plugin } from '@envelop/types';
2
- import { ParseOptions } from 'graphql/language/parser';
3
- import { Source, DocumentNode } from 'graphql';
1
+ import type { Plugin } from '@envelop/types';
2
+ import type { ParseOptions } from 'graphql/language/parser';
3
+ import type { Source, DocumentNode } from 'graphql';
4
4
  export declare function parseWithFragmentArguments(source: string | Source, options?: ParseOptions): DocumentNode;
5
5
  export declare const useFragmentArguments: () => Plugin;
package/index.js CHANGED
@@ -7,8 +7,25 @@ const graphql = require('graphql');
7
7
 
8
8
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
9
9
  class FragmentArgumentCompatibleParser extends parser_js.Parser {
10
+ // see https://github.com/graphql/graphql-js/pull/3248
11
+ getLexer() {
12
+ return this._lexer;
13
+ }
14
+ // see https://github.com/graphql/graphql-js/pull/3248
15
+ getOptions() {
16
+ return this._options;
17
+ }
18
+ // for backwards-compat with v15, this api was removed in v16 in favor of the this.node API.
19
+ loc(startToken) {
20
+ var _a;
21
+ if (((_a = this.getOptions()) === null || _a === void 0 ? void 0 : _a.noLocation) !== true) {
22
+ const lexer = this.getLexer();
23
+ return new graphql.Location(startToken, lexer.lastToken, lexer.source);
24
+ }
25
+ return undefined;
26
+ }
10
27
  parseFragment() {
11
- const start = this._lexer.token;
28
+ const start = this.getLexer().token;
12
29
  this.expectToken(graphql.TokenKind.SPREAD);
13
30
  const hasTypeCondition = this.expectOptionalKeyword('on');
14
31
  if (!hasTypeCondition && this.peek(graphql.TokenKind.NAME)) {
@@ -38,7 +55,7 @@ class FragmentArgumentCompatibleParser extends parser_js.Parser {
38
55
  };
39
56
  }
40
57
  parseFragmentDefinition() {
41
- const start = this._lexer.token;
58
+ const start = this.getLexer().token;
42
59
  this.expectKeyword('fragment');
43
60
  const name = this.parseFragmentName();
44
61
  if (this.peek(graphql.TokenKind.PAREN_L)) {
package/index.mjs CHANGED
@@ -1,10 +1,27 @@
1
1
  import { Parser } from 'graphql/language/parser.js';
2
- import { TokenKind, Kind, visit } from 'graphql';
2
+ import { Location, TokenKind, Kind, visit } from 'graphql';
3
3
 
4
4
  /* eslint-disable @typescript-eslint/explicit-module-boundary-types */
5
5
  class FragmentArgumentCompatibleParser extends Parser {
6
+ // see https://github.com/graphql/graphql-js/pull/3248
7
+ getLexer() {
8
+ return this._lexer;
9
+ }
10
+ // see https://github.com/graphql/graphql-js/pull/3248
11
+ getOptions() {
12
+ return this._options;
13
+ }
14
+ // for backwards-compat with v15, this api was removed in v16 in favor of the this.node API.
15
+ loc(startToken) {
16
+ var _a;
17
+ if (((_a = this.getOptions()) === null || _a === void 0 ? void 0 : _a.noLocation) !== true) {
18
+ const lexer = this.getLexer();
19
+ return new Location(startToken, lexer.lastToken, lexer.source);
20
+ }
21
+ return undefined;
22
+ }
6
23
  parseFragment() {
7
- const start = this._lexer.token;
24
+ const start = this.getLexer().token;
8
25
  this.expectToken(TokenKind.SPREAD);
9
26
  const hasTypeCondition = this.expectOptionalKeyword('on');
10
27
  if (!hasTypeCondition && this.peek(TokenKind.NAME)) {
@@ -34,7 +51,7 @@ class FragmentArgumentCompatibleParser extends Parser {
34
51
  };
35
52
  }
36
53
  parseFragmentDefinition() {
37
- const start = this._lexer.token;
54
+ const start = this.getLexer().token;
38
55
  this.expectKeyword('fragment');
39
56
  const name = this.parseFragmentName();
40
57
  if (this.peek(TokenKind.PAREN_L)) {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@envelop/fragment-arguments",
3
- "version": "1.0.6",
3
+ "version": "1.1.0-alpha-ed2d5ef.0",
4
4
  "peerDependencies": {
5
- "graphql": "^14.0.0 || ^15.0.0"
5
+ "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
6
6
  },
7
7
  "dependencies": {
8
- "@envelop/types": "1.2.0"
8
+ "@envelop/types": "1.3.0-alpha-ed2d5ef.0"
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",