@0no-co/graphql.web 0.1.0 → 0.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/LICENSE.md +21 -0
- package/dist/graphql.web.d.ts +250 -0
- package/dist/graphql.web.js +798 -0
- package/dist/graphql.web.js.map +1 -0
- package/dist/graphql.web.mjs +786 -0
- package/dist/graphql.web.mjs.map +1 -0
- package/package.json +6 -1
- package/.changeset/README.md +0 -8
- package/.changeset/config.json +0 -7
- package/.gitattributes +0 -1
- package/.github/workflows/ci.yml +0 -57
- package/.github/workflows/release.yml +0 -63
- package/benchmark/kitchen_sink.graphql +0 -69
- package/benchmark/package.json +0 -14
- package/benchmark/suite.js +0 -26
- package/pnpm-workspace.yaml +0 -2
- package/scripts/changelog.js +0 -125
- package/scripts/eslint-preset.js +0 -54
- package/scripts/prepare.js +0 -18
- package/scripts/rollup.config.mjs +0 -160
- package/src/__tests__/__snapshots__/parser.test.ts.snap +0 -779
- package/src/__tests__/parser.test.ts +0 -11
- package/src/ast.ts +0 -251
- package/src/error.ts +0 -51
- package/src/index.ts +0 -6
- package/src/kind.ts +0 -32
- package/src/parser.ts +0 -480
- package/src/printer.ts +0 -132
- package/src/types.ts +0 -5
- package/src/visitor.ts +0 -136
- package/tsconfig.json +0 -24
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { readFileSync } from 'fs';
|
|
3
|
-
|
|
4
|
-
import { parse } from '../parser';
|
|
5
|
-
|
|
6
|
-
describe('parse', () => {
|
|
7
|
-
it('parses the kitchen sink query', () => {
|
|
8
|
-
const sink = readFileSync(__dirname + '/../../benchmark/kitchen_sink.graphql', { encoding: 'utf8' });
|
|
9
|
-
expect(parse(sink)).toMatchSnapshot();
|
|
10
|
-
})
|
|
11
|
-
});
|
package/src/ast.ts
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import type { Kind } from './kind';
|
|
2
|
-
|
|
3
|
-
export interface Location {
|
|
4
|
-
readonly start: number;
|
|
5
|
-
readonly end: number;
|
|
6
|
-
readonly source: Source;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface Source {
|
|
10
|
-
body: string;
|
|
11
|
-
name: string;
|
|
12
|
-
locationOffset: {
|
|
13
|
-
line: number;
|
|
14
|
-
column: number;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export declare type ASTNode =
|
|
19
|
-
| NameNode
|
|
20
|
-
| DocumentNode
|
|
21
|
-
| OperationDefinitionNode
|
|
22
|
-
| VariableDefinitionNode
|
|
23
|
-
| VariableNode
|
|
24
|
-
| SelectionSetNode
|
|
25
|
-
| FieldNode
|
|
26
|
-
| ArgumentNode
|
|
27
|
-
| FragmentSpreadNode
|
|
28
|
-
| InlineFragmentNode
|
|
29
|
-
| FragmentDefinitionNode
|
|
30
|
-
| IntValueNode
|
|
31
|
-
| FloatValueNode
|
|
32
|
-
| StringValueNode
|
|
33
|
-
| BooleanValueNode
|
|
34
|
-
| NullValueNode
|
|
35
|
-
| EnumValueNode
|
|
36
|
-
| ListValueNode
|
|
37
|
-
| ObjectValueNode
|
|
38
|
-
| ObjectFieldNode
|
|
39
|
-
| DirectiveNode
|
|
40
|
-
| NamedTypeNode
|
|
41
|
-
| ListTypeNode
|
|
42
|
-
| NonNullTypeNode;
|
|
43
|
-
|
|
44
|
-
export interface NameNode {
|
|
45
|
-
readonly kind: Kind.NAME;
|
|
46
|
-
readonly value: string;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface DocumentNode {
|
|
50
|
-
readonly kind: Kind.DOCUMENT;
|
|
51
|
-
readonly definitions: ReadonlyArray<ExecutableDefinitionNode>;
|
|
52
|
-
readonly loc?: Location;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export type DefinitionNode =
|
|
56
|
-
| OperationDefinitionNode
|
|
57
|
-
| FragmentDefinitionNode;
|
|
58
|
-
export type ExecutableDefinitionNode =
|
|
59
|
-
| OperationDefinitionNode
|
|
60
|
-
| FragmentDefinitionNode;
|
|
61
|
-
|
|
62
|
-
export interface OperationDefinitionNode {
|
|
63
|
-
readonly kind: Kind.OPERATION_DEFINITION;
|
|
64
|
-
readonly operation: OperationTypeNode;
|
|
65
|
-
readonly name?: NameNode;
|
|
66
|
-
readonly variableDefinitions?: ReadonlyArray<VariableDefinitionNode>;
|
|
67
|
-
readonly directives?: ReadonlyArray<DirectiveNode>;
|
|
68
|
-
readonly selectionSet: SelectionSetNode;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export const enum OperationTypeNode {
|
|
72
|
-
QUERY = 'query',
|
|
73
|
-
MUTATION = 'mutation',
|
|
74
|
-
SUBSCRIPTION = 'subscription',
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface VariableDefinitionNode {
|
|
78
|
-
readonly kind: Kind.VARIABLE_DEFINITION;
|
|
79
|
-
readonly variable: VariableNode;
|
|
80
|
-
readonly type: TypeNode;
|
|
81
|
-
readonly defaultValue?: ConstValueNode;
|
|
82
|
-
readonly directives?: ReadonlyArray<ConstDirectiveNode>;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export interface VariableNode {
|
|
86
|
-
readonly kind: Kind.VARIABLE;
|
|
87
|
-
readonly name: NameNode;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export interface SelectionSetNode {
|
|
91
|
-
kind: Kind.SELECTION_SET;
|
|
92
|
-
selections: ReadonlyArray<SelectionNode>;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export declare type SelectionNode =
|
|
96
|
-
| FieldNode
|
|
97
|
-
| FragmentSpreadNode
|
|
98
|
-
| InlineFragmentNode;
|
|
99
|
-
|
|
100
|
-
export interface FieldNode {
|
|
101
|
-
readonly kind: Kind.FIELD;
|
|
102
|
-
readonly alias?: NameNode;
|
|
103
|
-
readonly name: NameNode;
|
|
104
|
-
readonly arguments?: ReadonlyArray<ArgumentNode>;
|
|
105
|
-
readonly directives?: ReadonlyArray<DirectiveNode>;
|
|
106
|
-
readonly selectionSet?: SelectionSetNode;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface ArgumentNode {
|
|
110
|
-
readonly kind: Kind.ARGUMENT;
|
|
111
|
-
readonly name: NameNode;
|
|
112
|
-
readonly value: ValueNode;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export interface ConstArgumentNode {
|
|
116
|
-
readonly kind: Kind.ARGUMENT;
|
|
117
|
-
readonly name: NameNode;
|
|
118
|
-
readonly value: ConstValueNode;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export interface FragmentSpreadNode {
|
|
122
|
-
readonly kind: Kind.FRAGMENT_SPREAD;
|
|
123
|
-
readonly name: NameNode;
|
|
124
|
-
readonly directives?: ReadonlyArray<DirectiveNode>;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export interface InlineFragmentNode {
|
|
128
|
-
readonly kind: Kind.INLINE_FRAGMENT;
|
|
129
|
-
readonly typeCondition?: NamedTypeNode;
|
|
130
|
-
readonly directives?: ReadonlyArray<DirectiveNode>;
|
|
131
|
-
readonly selectionSet: SelectionSetNode;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export interface FragmentDefinitionNode {
|
|
135
|
-
readonly kind: Kind.FRAGMENT_DEFINITION;
|
|
136
|
-
readonly name: NameNode;
|
|
137
|
-
readonly typeCondition: NamedTypeNode;
|
|
138
|
-
readonly directives?: ReadonlyArray<DirectiveNode>;
|
|
139
|
-
readonly selectionSet: SelectionSetNode;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export type ValueNode =
|
|
143
|
-
| VariableNode
|
|
144
|
-
| IntValueNode
|
|
145
|
-
| FloatValueNode
|
|
146
|
-
| StringValueNode
|
|
147
|
-
| BooleanValueNode
|
|
148
|
-
| NullValueNode
|
|
149
|
-
| EnumValueNode
|
|
150
|
-
| ListValueNode
|
|
151
|
-
| ObjectValueNode;
|
|
152
|
-
|
|
153
|
-
export type ConstValueNode =
|
|
154
|
-
| IntValueNode
|
|
155
|
-
| FloatValueNode
|
|
156
|
-
| StringValueNode
|
|
157
|
-
| BooleanValueNode
|
|
158
|
-
| NullValueNode
|
|
159
|
-
| EnumValueNode
|
|
160
|
-
| ConstListValueNode
|
|
161
|
-
| ConstObjectValueNode;
|
|
162
|
-
|
|
163
|
-
export interface IntValueNode {
|
|
164
|
-
readonly kind: Kind.INT;
|
|
165
|
-
readonly value: string;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export interface FloatValueNode {
|
|
169
|
-
readonly kind: Kind.FLOAT;
|
|
170
|
-
readonly value: string;
|
|
171
|
-
}
|
|
172
|
-
export interface StringValueNode {
|
|
173
|
-
readonly kind: Kind.STRING;
|
|
174
|
-
readonly value: string;
|
|
175
|
-
readonly block?: boolean;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export interface BooleanValueNode {
|
|
179
|
-
readonly kind: Kind.BOOLEAN;
|
|
180
|
-
readonly value: boolean;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export interface NullValueNode {
|
|
184
|
-
readonly kind: Kind.NULL;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export interface EnumValueNode {
|
|
188
|
-
readonly kind: Kind.ENUM;
|
|
189
|
-
readonly value: string;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export interface ListValueNode {
|
|
193
|
-
readonly kind: Kind.LIST;
|
|
194
|
-
readonly values: ReadonlyArray<ValueNode>;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export interface ConstListValueNode {
|
|
198
|
-
readonly kind: Kind.LIST;
|
|
199
|
-
readonly values: ReadonlyArray<ConstValueNode>;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export interface ObjectValueNode {
|
|
203
|
-
readonly kind: Kind.OBJECT;
|
|
204
|
-
readonly fields: ReadonlyArray<ObjectFieldNode>;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export interface ConstObjectValueNode {
|
|
208
|
-
readonly kind: Kind.OBJECT;
|
|
209
|
-
readonly fields: ReadonlyArray<ConstObjectFieldNode>;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export interface ObjectFieldNode {
|
|
213
|
-
readonly kind: Kind.OBJECT_FIELD;
|
|
214
|
-
readonly name: NameNode;
|
|
215
|
-
readonly value: ValueNode;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export interface ConstObjectFieldNode {
|
|
219
|
-
readonly kind: Kind.OBJECT_FIELD;
|
|
220
|
-
readonly name: NameNode;
|
|
221
|
-
readonly value: ConstValueNode;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export interface DirectiveNode {
|
|
225
|
-
readonly kind: Kind.DIRECTIVE;
|
|
226
|
-
readonly name: NameNode;
|
|
227
|
-
readonly arguments?: ReadonlyArray<ArgumentNode>;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
export interface ConstDirectiveNode {
|
|
231
|
-
readonly kind: Kind.DIRECTIVE;
|
|
232
|
-
readonly name: NameNode;
|
|
233
|
-
readonly arguments?: ReadonlyArray<ConstArgumentNode>;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export declare type TypeNode = NamedTypeNode | ListTypeNode | NonNullTypeNode;
|
|
237
|
-
|
|
238
|
-
export interface NamedTypeNode {
|
|
239
|
-
readonly kind: Kind.NAMED_TYPE;
|
|
240
|
-
readonly name: NameNode;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
export interface ListTypeNode {
|
|
244
|
-
readonly kind: Kind.LIST_TYPE;
|
|
245
|
-
readonly type: TypeNode;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export interface NonNullTypeNode {
|
|
249
|
-
readonly kind: Kind.NON_NULL_TYPE;
|
|
250
|
-
readonly type: NamedTypeNode | ListTypeNode;
|
|
251
|
-
}
|
package/src/error.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Maybe, Extensions } from './types';
|
|
2
|
-
import { ASTNode, Source } from './ast';
|
|
3
|
-
|
|
4
|
-
export class GraphQLError extends Error {
|
|
5
|
-
readonly locations: undefined;
|
|
6
|
-
readonly path: ReadonlyArray<string | number> | undefined;
|
|
7
|
-
readonly nodes: ReadonlyArray<ASTNode> | undefined;
|
|
8
|
-
readonly source: Source | undefined;
|
|
9
|
-
readonly positions: ReadonlyArray<number> | undefined;
|
|
10
|
-
readonly originalError: Error | undefined;
|
|
11
|
-
readonly extensions: Extensions;
|
|
12
|
-
|
|
13
|
-
constructor(
|
|
14
|
-
message: string,
|
|
15
|
-
nodes?: ReadonlyArray<ASTNode> | ASTNode | null,
|
|
16
|
-
source?: Maybe<Source>,
|
|
17
|
-
positions?: Maybe<ReadonlyArray<number>>,
|
|
18
|
-
path?: Maybe<ReadonlyArray<string | number>>,
|
|
19
|
-
originalError?: Maybe<Error>,
|
|
20
|
-
extensions?: Maybe<Extensions>,
|
|
21
|
-
) {
|
|
22
|
-
super(message);
|
|
23
|
-
|
|
24
|
-
this.name = 'GraphQLError';
|
|
25
|
-
this.message = message;
|
|
26
|
-
|
|
27
|
-
if (path) this.path = path;
|
|
28
|
-
if (nodes) this.nodes = (Array.isArray(nodes) ? nodes : [nodes]) as ASTNode[];
|
|
29
|
-
if (source) this.source = source;
|
|
30
|
-
if (positions) this.positions = positions;
|
|
31
|
-
if (originalError) this.originalError = originalError;
|
|
32
|
-
|
|
33
|
-
let _extensions = extensions;
|
|
34
|
-
if (!_extensions && originalError) {
|
|
35
|
-
const originalExtensions = (originalError as any).extensions;
|
|
36
|
-
if (originalExtensions && typeof originalExtensions === 'object') {
|
|
37
|
-
_extensions = originalExtensions;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
this.extensions = extensions || {};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
toJSON() {
|
|
45
|
-
return { ...this };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
toString() {
|
|
49
|
-
return this.message;
|
|
50
|
-
}
|
|
51
|
-
}
|
package/src/index.ts
DELETED
package/src/kind.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export enum Kind {
|
|
2
|
-
/** Name */
|
|
3
|
-
NAME = 'Name',
|
|
4
|
-
/** Document */
|
|
5
|
-
DOCUMENT = 'Document',
|
|
6
|
-
OPERATION_DEFINITION = 'OperationDefinition',
|
|
7
|
-
VARIABLE_DEFINITION = 'VariableDefinition',
|
|
8
|
-
SELECTION_SET = 'SelectionSet',
|
|
9
|
-
FIELD = 'Field',
|
|
10
|
-
ARGUMENT = 'Argument',
|
|
11
|
-
/** Fragments */
|
|
12
|
-
FRAGMENT_SPREAD = 'FragmentSpread',
|
|
13
|
-
INLINE_FRAGMENT = 'InlineFragment',
|
|
14
|
-
FRAGMENT_DEFINITION = 'FragmentDefinition',
|
|
15
|
-
/** Values */
|
|
16
|
-
VARIABLE = 'Variable',
|
|
17
|
-
INT = 'IntValue',
|
|
18
|
-
FLOAT = 'FloatValue',
|
|
19
|
-
STRING = 'StringValue',
|
|
20
|
-
BOOLEAN = 'BooleanValue',
|
|
21
|
-
NULL = 'NullValue',
|
|
22
|
-
ENUM = 'EnumValue',
|
|
23
|
-
LIST = 'ListValue',
|
|
24
|
-
OBJECT = 'ObjectValue',
|
|
25
|
-
OBJECT_FIELD = 'ObjectField',
|
|
26
|
-
/** Directives */
|
|
27
|
-
DIRECTIVE = 'Directive',
|
|
28
|
-
/** Types */
|
|
29
|
-
NAMED_TYPE = 'NamedType',
|
|
30
|
-
LIST_TYPE = 'ListType',
|
|
31
|
-
NON_NULL_TYPE = 'NonNullType',
|
|
32
|
-
}
|