@0no-co/graphql.web
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -1,40 +0,6 @@ | ||
declare enum Kind { | ||
/** Name */ | ||
NAME = "Name", | ||
/** Document */ | ||
DOCUMENT = "Document", | ||
OPERATION_DEFINITION = "OperationDefinition", | ||
VARIABLE_DEFINITION = "VariableDefinition", | ||
SELECTION_SET = "SelectionSet", | ||
FIELD = "Field", | ||
ARGUMENT = "Argument", | ||
/** Fragments */ | ||
FRAGMENT_SPREAD = "FragmentSpread", | ||
INLINE_FRAGMENT = "InlineFragment", | ||
FRAGMENT_DEFINITION = "FragmentDefinition", | ||
/** Values */ | ||
VARIABLE = "Variable", | ||
INT = "IntValue", | ||
FLOAT = "FloatValue", | ||
STRING = "StringValue", | ||
BOOLEAN = "BooleanValue", | ||
NULL = "NullValue", | ||
ENUM = "EnumValue", | ||
LIST = "ListValue", | ||
OBJECT = "ObjectValue", | ||
OBJECT_FIELD = "ObjectField", | ||
/** Directives */ | ||
DIRECTIVE = "Directive", | ||
/** Types */ | ||
NAMED_TYPE = "NamedType", | ||
LIST_TYPE = "ListType", | ||
NON_NULL_TYPE = "NonNullType" | ||
type Maybe<T> = T | undefined | null; | ||
interface Extensions { | ||
[extension: string]: unknown; | ||
} | ||
interface Location { | ||
readonly start: number; | ||
readonly end: number; | ||
readonly source: Source; | ||
} | ||
interface Source { | ||
type Source = any | { | ||
body: string; | ||
@@ -46,14 +12,239 @@ name: string; | ||
}; | ||
}; | ||
type Location = any | { | ||
start: number; | ||
end: number; | ||
source: Source; | ||
}; | ||
declare enum Kind { | ||
/** Name */ | ||
NAME = 'Name', | ||
/** Document */ | ||
DOCUMENT = 'Document', | ||
OPERATION_DEFINITION = 'OperationDefinition', | ||
VARIABLE_DEFINITION = 'VariableDefinition', | ||
SELECTION_SET = 'SelectionSet', | ||
FIELD = 'Field', | ||
ARGUMENT = 'Argument', | ||
/** Fragments */ | ||
FRAGMENT_SPREAD = 'FragmentSpread', | ||
INLINE_FRAGMENT = 'InlineFragment', | ||
FRAGMENT_DEFINITION = 'FragmentDefinition', | ||
/** Values */ | ||
VARIABLE = 'Variable', | ||
INT = 'IntValue', | ||
FLOAT = 'FloatValue', | ||
STRING = 'StringValue', | ||
BOOLEAN = 'BooleanValue', | ||
NULL = 'NullValue', | ||
ENUM = 'EnumValue', | ||
LIST = 'ListValue', | ||
OBJECT = 'ObjectValue', | ||
OBJECT_FIELD = 'ObjectField', | ||
/** Directives */ | ||
DIRECTIVE = 'Directive', | ||
/** Types */ | ||
NAMED_TYPE = 'NamedType', | ||
LIST_TYPE = 'ListType', | ||
NON_NULL_TYPE = 'NonNullType', | ||
/** Type System Definitions */ | ||
SCHEMA_DEFINITION = 'SchemaDefinition', | ||
OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition', | ||
/** Type Definitions */ | ||
SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition', | ||
OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition', | ||
FIELD_DEFINITION = 'FieldDefinition', | ||
INPUT_VALUE_DEFINITION = 'InputValueDefinition', | ||
INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition', | ||
UNION_TYPE_DEFINITION = 'UnionTypeDefinition', | ||
ENUM_TYPE_DEFINITION = 'EnumTypeDefinition', | ||
ENUM_VALUE_DEFINITION = 'EnumValueDefinition', | ||
INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition', | ||
/** Directive Definitions */ | ||
DIRECTIVE_DEFINITION = 'DirectiveDefinition', | ||
/** Type System Extensions */ | ||
SCHEMA_EXTENSION = 'SchemaExtension', | ||
/** Type Extensions */ | ||
SCALAR_TYPE_EXTENSION = 'ScalarTypeExtension', | ||
OBJECT_TYPE_EXTENSION = 'ObjectTypeExtension', | ||
INTERFACE_TYPE_EXTENSION = 'InterfaceTypeExtension', | ||
UNION_TYPE_EXTENSION = 'UnionTypeExtension', | ||
ENUM_TYPE_EXTENSION = 'EnumTypeExtension', | ||
INPUT_OBJECT_TYPE_EXTENSION = 'InputObjectTypeExtension', | ||
} | ||
declare type ASTNode = NameNode | DocumentNode | OperationDefinitionNode | VariableDefinitionNode | VariableNode | SelectionSetNode | FieldNode | ArgumentNode | FragmentSpreadNode | InlineFragmentNode | FragmentDefinitionNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode | ObjectFieldNode | DirectiveNode | NamedTypeNode | ListTypeNode | NonNullTypeNode; | ||
declare enum OperationTypeNode { | ||
QUERY = 'query', | ||
MUTATION = 'mutation', | ||
SUBSCRIPTION = 'subscription', | ||
} | ||
/** Type System Definition */ | ||
declare type TypeSystemDefinitionNode = SchemaDefinitionNode | TypeDefinitionNode | DirectiveDefinitionNode; | ||
interface SchemaDefinitionNode { | ||
readonly kind: Kind.SCHEMA_DEFINITION; | ||
readonly loc?: Location; | ||
readonly description?: StringValueNode; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
readonly operationTypes: ReadonlyArray<OperationTypeDefinitionNode>; | ||
} | ||
interface OperationTypeDefinitionNode { | ||
readonly kind: Kind.OPERATION_TYPE_DEFINITION; | ||
readonly loc?: Location; | ||
readonly operation: OperationTypeNode; | ||
readonly type: NamedTypeNode; | ||
} | ||
/** Type Definition */ | ||
declare type TypeDefinitionNode = ScalarTypeDefinitionNode | ObjectTypeDefinitionNode | InterfaceTypeDefinitionNode | UnionTypeDefinitionNode | EnumTypeDefinitionNode | InputObjectTypeDefinitionNode; | ||
interface ScalarTypeDefinitionNode { | ||
readonly kind: Kind.SCALAR_TYPE_DEFINITION; | ||
readonly loc?: Location; | ||
readonly description?: StringValueNode; | ||
readonly name: NameNode; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
} | ||
interface ObjectTypeDefinitionNode { | ||
readonly kind: Kind.OBJECT_TYPE_DEFINITION; | ||
readonly loc?: Location; | ||
readonly description?: StringValueNode; | ||
readonly name: NameNode; | ||
readonly interfaces?: ReadonlyArray<NamedTypeNode>; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
readonly fields?: ReadonlyArray<FieldDefinitionNode>; | ||
} | ||
interface FieldDefinitionNode { | ||
readonly kind: Kind.FIELD_DEFINITION; | ||
readonly loc?: Location; | ||
readonly description?: StringValueNode; | ||
readonly name: NameNode; | ||
readonly arguments?: ReadonlyArray<InputValueDefinitionNode>; | ||
readonly type: TypeNode; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
} | ||
interface InputValueDefinitionNode { | ||
readonly kind: Kind.INPUT_VALUE_DEFINITION; | ||
readonly loc?: Location; | ||
readonly description?: StringValueNode; | ||
readonly name: NameNode; | ||
readonly type: TypeNode; | ||
readonly defaultValue?: ConstValueNode; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
} | ||
interface InterfaceTypeDefinitionNode { | ||
readonly kind: Kind.INTERFACE_TYPE_DEFINITION; | ||
readonly loc?: Location; | ||
readonly description?: StringValueNode; | ||
readonly name: NameNode; | ||
readonly interfaces?: ReadonlyArray<NamedTypeNode>; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
readonly fields?: ReadonlyArray<FieldDefinitionNode>; | ||
} | ||
interface UnionTypeDefinitionNode { | ||
readonly kind: Kind.UNION_TYPE_DEFINITION; | ||
readonly loc?: Location; | ||
readonly description?: StringValueNode; | ||
readonly name: NameNode; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
readonly types?: ReadonlyArray<NamedTypeNode>; | ||
} | ||
interface EnumTypeDefinitionNode { | ||
readonly kind: Kind.ENUM_TYPE_DEFINITION; | ||
readonly loc?: Location; | ||
readonly description?: StringValueNode; | ||
readonly name: NameNode; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
readonly values?: ReadonlyArray<EnumValueDefinitionNode>; | ||
} | ||
interface EnumValueDefinitionNode { | ||
readonly kind: Kind.ENUM_VALUE_DEFINITION; | ||
readonly loc?: Location; | ||
readonly description?: StringValueNode; | ||
readonly name: NameNode; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
} | ||
interface InputObjectTypeDefinitionNode { | ||
readonly kind: Kind.INPUT_OBJECT_TYPE_DEFINITION; | ||
readonly loc?: Location; | ||
readonly description?: StringValueNode; | ||
readonly name: NameNode; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
readonly fields?: ReadonlyArray<InputValueDefinitionNode>; | ||
} | ||
/** Directive Definitions */ | ||
interface DirectiveDefinitionNode { | ||
readonly kind: Kind.DIRECTIVE_DEFINITION; | ||
readonly loc?: Location; | ||
readonly description?: StringValueNode; | ||
readonly name: NameNode; | ||
readonly arguments?: ReadonlyArray<InputValueDefinitionNode>; | ||
readonly repeatable: boolean; | ||
readonly locations: ReadonlyArray<NameNode>; | ||
} | ||
/** Type System Extensions */ | ||
declare type TypeSystemExtensionNode = SchemaExtensionNode | TypeExtensionNode; | ||
interface SchemaExtensionNode { | ||
readonly kind: Kind.SCHEMA_EXTENSION; | ||
readonly loc?: Location; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
readonly operationTypes?: ReadonlyArray<OperationTypeDefinitionNode>; | ||
} | ||
/** Type Extensions */ | ||
declare type TypeExtensionNode = ScalarTypeExtensionNode | ObjectTypeExtensionNode | InterfaceTypeExtensionNode | UnionTypeExtensionNode | EnumTypeExtensionNode | InputObjectTypeExtensionNode; | ||
interface ScalarTypeExtensionNode { | ||
readonly kind: Kind.SCALAR_TYPE_EXTENSION; | ||
readonly loc?: Location; | ||
readonly name: NameNode; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
} | ||
interface ObjectTypeExtensionNode { | ||
readonly kind: Kind.OBJECT_TYPE_EXTENSION; | ||
readonly loc?: Location; | ||
readonly name: NameNode; | ||
readonly interfaces?: ReadonlyArray<NamedTypeNode>; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
readonly fields?: ReadonlyArray<FieldDefinitionNode>; | ||
} | ||
interface InterfaceTypeExtensionNode { | ||
readonly kind: Kind.INTERFACE_TYPE_EXTENSION; | ||
readonly loc?: Location; | ||
readonly name: NameNode; | ||
readonly interfaces?: ReadonlyArray<NamedTypeNode>; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
readonly fields?: ReadonlyArray<FieldDefinitionNode>; | ||
} | ||
interface UnionTypeExtensionNode { | ||
readonly kind: Kind.UNION_TYPE_EXTENSION; | ||
readonly loc?: Location; | ||
readonly name: NameNode; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
readonly types?: ReadonlyArray<NamedTypeNode>; | ||
} | ||
interface EnumTypeExtensionNode { | ||
readonly kind: Kind.ENUM_TYPE_EXTENSION; | ||
readonly loc?: Location; | ||
readonly name: NameNode; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
readonly values?: ReadonlyArray<EnumValueDefinitionNode>; | ||
} | ||
interface InputObjectTypeExtensionNode { | ||
readonly kind: Kind.INPUT_OBJECT_TYPE_EXTENSION; | ||
readonly loc?: Location; | ||
readonly name: NameNode; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
readonly fields?: ReadonlyArray<InputValueDefinitionNode>; | ||
} | ||
type ASTNode = NameNode | DocumentNode | OperationDefinitionNode | VariableDefinitionNode | VariableNode | SelectionSetNode | FieldNode | ArgumentNode | FragmentSpreadNode | InlineFragmentNode | FragmentDefinitionNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode | ObjectFieldNode | DirectiveNode | NamedTypeNode | ListTypeNode | NonNullTypeNode | SchemaDefinitionNode | OperationTypeDefinitionNode | ScalarTypeDefinitionNode | ObjectTypeDefinitionNode | FieldDefinitionNode | InputValueDefinitionNode | InterfaceTypeDefinitionNode | UnionTypeDefinitionNode | EnumTypeDefinitionNode | EnumValueDefinitionNode | InputObjectTypeDefinitionNode | DirectiveDefinitionNode | SchemaExtensionNode | ScalarTypeExtensionNode | ObjectTypeExtensionNode | InterfaceTypeExtensionNode | UnionTypeExtensionNode | EnumTypeExtensionNode | InputObjectTypeExtensionNode; | ||
interface NameNode { | ||
readonly kind: Kind.NAME; | ||
readonly value: string; | ||
readonly loc?: Location; | ||
} | ||
interface DocumentNode { | ||
readonly kind: Kind.DOCUMENT; | ||
readonly definitions: ReadonlyArray<ExecutableDefinitionNode>; | ||
readonly definitions: ReadonlyArray<DefinitionNode>; | ||
readonly loc?: Location; | ||
} | ||
type DefinitionNode = OperationDefinitionNode | FragmentDefinitionNode; | ||
type DefinitionNode = ExecutableDefinitionNode | TypeSystemDefinitionNode | TypeSystemExtensionNode; | ||
type ExecutableDefinitionNode = OperationDefinitionNode | FragmentDefinitionNode; | ||
@@ -67,8 +258,4 @@ interface OperationDefinitionNode { | ||
readonly selectionSet: SelectionSetNode; | ||
readonly loc?: Location; | ||
} | ||
declare const enum OperationTypeNode { | ||
QUERY = "query", | ||
MUTATION = "mutation", | ||
SUBSCRIPTION = "subscription" | ||
} | ||
interface VariableDefinitionNode { | ||
@@ -80,2 +267,3 @@ readonly kind: Kind.VARIABLE_DEFINITION; | ||
readonly directives?: ReadonlyArray<ConstDirectiveNode>; | ||
readonly loc?: Location; | ||
} | ||
@@ -85,6 +273,8 @@ interface VariableNode { | ||
readonly name: NameNode; | ||
readonly loc?: Location; | ||
} | ||
interface SelectionSetNode { | ||
kind: Kind.SELECTION_SET; | ||
selections: ReadonlyArray<SelectionNode>; | ||
readonly kind: Kind.SELECTION_SET; | ||
readonly selections: ReadonlyArray<SelectionNode>; | ||
readonly loc?: Location; | ||
} | ||
@@ -99,2 +289,3 @@ declare type SelectionNode = FieldNode | FragmentSpreadNode | InlineFragmentNode; | ||
readonly selectionSet?: SelectionSetNode; | ||
readonly loc?: Location; | ||
} | ||
@@ -105,2 +296,3 @@ interface ArgumentNode { | ||
readonly value: ValueNode; | ||
readonly loc?: Location; | ||
} | ||
@@ -111,2 +303,3 @@ interface ConstArgumentNode { | ||
readonly value: ConstValueNode; | ||
readonly loc?: Location; | ||
} | ||
@@ -117,2 +310,3 @@ interface FragmentSpreadNode { | ||
readonly directives?: ReadonlyArray<DirectiveNode>; | ||
readonly loc?: Location; | ||
} | ||
@@ -124,2 +318,3 @@ interface InlineFragmentNode { | ||
readonly selectionSet: SelectionSetNode; | ||
readonly loc?: Location; | ||
} | ||
@@ -132,2 +327,3 @@ interface FragmentDefinitionNode { | ||
readonly selectionSet: SelectionSetNode; | ||
readonly loc?: Location; | ||
} | ||
@@ -139,2 +335,3 @@ type ValueNode = VariableNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode; | ||
readonly value: string; | ||
readonly loc?: Location; | ||
} | ||
@@ -144,2 +341,3 @@ interface FloatValueNode { | ||
readonly value: string; | ||
readonly loc?: Location; | ||
} | ||
@@ -150,2 +348,3 @@ interface StringValueNode { | ||
readonly block?: boolean; | ||
readonly loc?: Location; | ||
} | ||
@@ -155,5 +354,7 @@ interface BooleanValueNode { | ||
readonly value: boolean; | ||
readonly loc?: Location; | ||
} | ||
interface NullValueNode { | ||
readonly kind: Kind.NULL; | ||
readonly loc?: Location; | ||
} | ||
@@ -163,2 +364,3 @@ interface EnumValueNode { | ||
readonly value: string; | ||
readonly loc?: Location; | ||
} | ||
@@ -168,2 +370,3 @@ interface ListValueNode { | ||
readonly values: ReadonlyArray<ValueNode>; | ||
readonly loc?: Location; | ||
} | ||
@@ -173,2 +376,3 @@ interface ConstListValueNode { | ||
readonly values: ReadonlyArray<ConstValueNode>; | ||
readonly loc?: Location; | ||
} | ||
@@ -178,2 +382,3 @@ interface ObjectValueNode { | ||
readonly fields: ReadonlyArray<ObjectFieldNode>; | ||
readonly loc?: Location; | ||
} | ||
@@ -183,2 +388,3 @@ interface ConstObjectValueNode { | ||
readonly fields: ReadonlyArray<ConstObjectFieldNode>; | ||
readonly loc?: Location; | ||
} | ||
@@ -189,2 +395,3 @@ interface ObjectFieldNode { | ||
readonly value: ValueNode; | ||
readonly loc?: Location; | ||
} | ||
@@ -195,2 +402,3 @@ interface ConstObjectFieldNode { | ||
readonly value: ConstValueNode; | ||
readonly loc?: Location; | ||
} | ||
@@ -201,2 +409,3 @@ interface DirectiveNode { | ||
readonly arguments?: ReadonlyArray<ArgumentNode>; | ||
readonly loc?: Location; | ||
} | ||
@@ -207,2 +416,3 @@ interface ConstDirectiveNode { | ||
readonly arguments?: ReadonlyArray<ConstArgumentNode>; | ||
readonly loc?: Location; | ||
} | ||
@@ -213,2 +423,3 @@ declare type TypeNode = NamedTypeNode | ListTypeNode | NonNullTypeNode; | ||
readonly name: NameNode; | ||
readonly loc?: Location; | ||
} | ||
@@ -218,2 +429,3 @@ interface ListTypeNode { | ||
readonly type: TypeNode; | ||
readonly loc?: Location; | ||
} | ||
@@ -223,13 +435,9 @@ interface NonNullTypeNode { | ||
readonly type: NamedTypeNode | ListTypeNode; | ||
readonly loc?: Location; | ||
} | ||
type Maybe<T> = T | undefined | null; | ||
interface Extensions { | ||
[extension: string]: unknown; | ||
} | ||
declare class GraphQLError extends Error { | ||
readonly locations: undefined; | ||
readonly locations: ReadonlyArray<any> | undefined; | ||
readonly path: ReadonlyArray<string | number> | undefined; | ||
readonly nodes: ReadonlyArray<ASTNode> | undefined; | ||
readonly nodes: ReadonlyArray<any> | undefined; | ||
readonly source: Source | undefined; | ||
@@ -240,10 +448,14 @@ readonly positions: ReadonlyArray<number> | undefined; | ||
constructor(message: string, nodes?: ReadonlyArray<ASTNode> | ASTNode | null, source?: Maybe<Source>, positions?: Maybe<ReadonlyArray<number>>, path?: Maybe<ReadonlyArray<string | number>>, originalError?: Maybe<Error>, extensions?: Maybe<Extensions>); | ||
toJSON(): this; | ||
toJSON(): any; | ||
toString(): string; | ||
get [Symbol.toStringTag](): string; | ||
} | ||
declare function blockString(string: string): string; | ||
declare function parse(string: string): DocumentNode; | ||
declare function parseValue(string: string): ValueNode | undefined; | ||
declare function parseType(string: string): TypeNode | undefined; | ||
type ParseOptions = { | ||
[option: string]: any; | ||
}; | ||
declare function parse(string: string | Source, _options?: ParseOptions | undefined): DocumentNode; | ||
declare function parseValue(string: string | Source, _options?: ParseOptions | undefined): ValueNode; | ||
declare function parseType(string: string | Source, _options?: ParseOptions | undefined): TypeNode; | ||
@@ -280,2 +492,2 @@ declare const BREAK: {}; | ||
export { ASTNode, ASTReducer, ASTVisitFn, ASTVisitor, ArgumentNode, BREAK, BooleanValueNode, ConstArgumentNode, ConstDirectiveNode, ConstListValueNode, ConstObjectFieldNode, ConstObjectValueNode, ConstValueNode, DefinitionNode, DirectiveNode, DocumentNode, EnumValueNode, ExecutableDefinitionNode, FieldNode, FloatValueNode, FragmentDefinitionNode, FragmentSpreadNode, GraphQLError, InlineFragmentNode, IntValueNode, Kind, ListTypeNode, ListValueNode, Location, NameNode, NamedTypeNode, NonNullTypeNode, NullValueNode, ObjectFieldNode, ObjectValueNode, OperationDefinitionNode, OperationTypeNode, SelectionNode, SelectionSetNode, Source, StringValueNode, TypeNode, ValueNode, VariableDefinitionNode, VariableNode, blockString, parse, parseType, parseValue, print, printBlockString, printString, valueFromASTUntyped, valueFromTypeNode, visit }; | ||
export { ASTNode, ASTReducer, ASTVisitFn, ASTVisitor, ArgumentNode, BREAK, BooleanValueNode, ConstArgumentNode, ConstDirectiveNode, ConstListValueNode, ConstObjectFieldNode, ConstObjectValueNode, ConstValueNode, DefinitionNode, DirectiveDefinitionNode, DirectiveNode, DocumentNode, EnumTypeDefinitionNode, EnumTypeExtensionNode, EnumValueDefinitionNode, EnumValueNode, ExecutableDefinitionNode, FieldDefinitionNode, FieldNode, FloatValueNode, FragmentDefinitionNode, FragmentSpreadNode, GraphQLError, InlineFragmentNode, InputObjectTypeDefinitionNode, InputObjectTypeExtensionNode, InputValueDefinitionNode, IntValueNode, InterfaceTypeDefinitionNode, InterfaceTypeExtensionNode, Kind, ListTypeNode, ListValueNode, Location, NameNode, NamedTypeNode, NonNullTypeNode, NullValueNode, ObjectFieldNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode, ObjectValueNode, OperationDefinitionNode, OperationTypeDefinitionNode, OperationTypeNode, ScalarTypeDefinitionNode, ScalarTypeExtensionNode, SchemaDefinitionNode, SchemaExtensionNode, SelectionNode, SelectionSetNode, Source, StringValueNode, TypeDefinitionNode, TypeExtensionNode, TypeNode, TypeSystemDefinitionNode, TypeSystemExtensionNode, UnionTypeDefinitionNode, UnionTypeExtensionNode, ValueNode, VariableDefinitionNode, VariableNode, blockString, parse, parseType, parseValue, print, printBlockString, printString, valueFromASTUntyped, valueFromTypeNode, visit }; |
@@ -5,41 +5,4 @@ Object.defineProperty(exports, "__esModule", { | ||
exports.OperationTypeNode = void 0; | ||
!function(e) { | ||
e.QUERY = "query"; | ||
e.MUTATION = "mutation"; | ||
e.SUBSCRIPTION = "subscription"; | ||
}(exports.OperationTypeNode || (exports.OperationTypeNode = {})); | ||
exports.Kind = void 0; | ||
!function(e) { | ||
e.NAME = "Name"; | ||
e.DOCUMENT = "Document"; | ||
e.OPERATION_DEFINITION = "OperationDefinition"; | ||
e.VARIABLE_DEFINITION = "VariableDefinition"; | ||
e.SELECTION_SET = "SelectionSet"; | ||
e.FIELD = "Field"; | ||
e.ARGUMENT = "Argument"; | ||
e.FRAGMENT_SPREAD = "FragmentSpread"; | ||
e.INLINE_FRAGMENT = "InlineFragment"; | ||
e.FRAGMENT_DEFINITION = "FragmentDefinition"; | ||
e.VARIABLE = "Variable"; | ||
e.INT = "IntValue"; | ||
e.FLOAT = "FloatValue"; | ||
e.STRING = "StringValue"; | ||
e.BOOLEAN = "BooleanValue"; | ||
e.NULL = "NullValue"; | ||
e.ENUM = "EnumValue"; | ||
e.LIST = "ListValue"; | ||
e.OBJECT = "ObjectValue"; | ||
e.OBJECT_FIELD = "ObjectField"; | ||
e.DIRECTIVE = "Directive"; | ||
e.NAMED_TYPE = "NamedType"; | ||
e.LIST_TYPE = "ListType"; | ||
e.NON_NULL_TYPE = "NonNullType"; | ||
}(exports.Kind || (exports.Kind = {})); | ||
class GraphQLError extends Error { | ||
constructor(e, r, n, i, t, o, a) { | ||
constructor(e, r, i, n, t, a, o) { | ||
super(e); | ||
@@ -54,18 +17,18 @@ this.name = "GraphQLError"; | ||
} | ||
if (i) { | ||
this.source = i; | ||
} | ||
if (n) { | ||
this.source = n; | ||
this.positions = n; | ||
} | ||
if (i) { | ||
this.positions = i; | ||
if (a) { | ||
this.originalError = a; | ||
} | ||
if (o) { | ||
this.originalError = o; | ||
} | ||
if (!a && o) { | ||
var s = o.extensions; | ||
if (s && "object" == typeof s) { | ||
s; | ||
if (!o && a) { | ||
var l = a.extensions; | ||
if (l && "object" == typeof l) { | ||
l; | ||
} | ||
} | ||
this.extensions = a || {}; | ||
this.extensions = o || {}; | ||
} | ||
@@ -80,2 +43,5 @@ toJSON() { | ||
} | ||
get [Symbol.toStringTag]() { | ||
return "GraphQLError"; | ||
} | ||
} | ||
@@ -91,32 +57,32 @@ | ||
function advance(n) { | ||
n.lastIndex = r; | ||
if (n.test(e)) { | ||
return e.slice(r, r = n.lastIndex); | ||
function advance(i) { | ||
i.lastIndex = r; | ||
if (i.test(e)) { | ||
return e.slice(r, r = i.lastIndex); | ||
} | ||
} | ||
var n = / +(?=[^\s])/y; | ||
var i = / +(?=[^\s])/y; | ||
function blockString(e) { | ||
var r = ""; | ||
var i = 0; | ||
var n = 0; | ||
var t = 0; | ||
var o = -1; | ||
var a = e.split("\n"); | ||
for (var s = 0; s < a.length; s++) { | ||
n.lastIndex = 0; | ||
if (n.test(a[s])) { | ||
if (s && (!i || n.lastIndex < i)) { | ||
i = n.lastIndex; | ||
var a = -1; | ||
var o = e.split("\n"); | ||
for (var l = 0; l < o.length; l++) { | ||
i.lastIndex = 0; | ||
if (i.test(o[l])) { | ||
if (l && (!n || i.lastIndex < n)) { | ||
n = i.lastIndex; | ||
} | ||
t = t || s; | ||
o = s; | ||
t = t || l; | ||
a = l; | ||
} | ||
} | ||
for (var d = t; d <= o; d++) { | ||
if (d !== t) { | ||
for (var u = t; u <= a; u++) { | ||
if (u !== t) { | ||
r += "\n"; | ||
} | ||
r += a[d].slice(i).replace(/\\"""/g, '"""'); | ||
r += o[u].slice(n).replace(/\\"""/g, '"""'); | ||
} | ||
@@ -126,8 +92,8 @@ return r; | ||
var i = /(?:[\s,]*|#[^\n\r]*)*/y; | ||
var n = /(?:[\s,]*|#[^\n\r]*)*/y; | ||
function ignored() { | ||
i.lastIndex = r; | ||
i.test(e); | ||
r = i.lastIndex; | ||
n.lastIndex = r; | ||
n.test(e); | ||
r = n.lastIndex; | ||
} | ||
@@ -141,3 +107,3 @@ | ||
return { | ||
kind: exports.Kind.NAME, | ||
kind: "Name", | ||
value: e | ||
@@ -148,56 +114,52 @@ }; | ||
var o = /null/y; | ||
var a = /null|true|false/y; | ||
var a = /true|false/y; | ||
var o = /\$[_\w][_\d\w]*/y; | ||
var s = /\$[_\w][_\d\w]*/y; | ||
var l = /[-]?\d+/y; | ||
var d = /[-]?\d+/y; | ||
var u = /(?:[-]?\d+)?(?:\.\d+)(?:[eE][+-]?\d+)?/y; | ||
var p = /(?:[-]?\d+)?(?:\.\d+)(?:[eE][+-]?\d+)?/y; | ||
var s = /\\/g; | ||
var u = /\\/g; | ||
var d = /"""(?:[\s\S]+(?="""))?"""/y; | ||
var l = /"""(?:[\s\S]+(?="""))?"""/y; | ||
var v = /"(?:[^"\r\n]+)?"/y; | ||
function value(n) { | ||
var i; | ||
function value(i) { | ||
var n; | ||
var c; | ||
if (advance(o)) { | ||
i = { | ||
kind: exports.Kind.NULL | ||
}; | ||
} else if (c = advance(a)) { | ||
i = { | ||
kind: exports.Kind.BOOLEAN, | ||
if (c = advance(a)) { | ||
n = "null" === c ? { | ||
kind: "NullValue" | ||
} : { | ||
kind: "BooleanValue", | ||
value: "true" === c | ||
}; | ||
} else if (!n && (c = advance(s))) { | ||
i = { | ||
kind: exports.Kind.VARIABLE, | ||
} else if (!i && (c = advance(o))) { | ||
n = { | ||
kind: "Variable", | ||
name: { | ||
kind: exports.Kind.NAME, | ||
kind: "Name", | ||
value: c.slice(1) | ||
} | ||
}; | ||
} else if (c = advance(p)) { | ||
i = { | ||
kind: exports.Kind.FLOAT, | ||
} else if (c = advance(u)) { | ||
n = { | ||
kind: "FloatValue", | ||
value: c | ||
}; | ||
} else if (c = advance(d)) { | ||
i = { | ||
kind: exports.Kind.INT, | ||
} else if (c = advance(l)) { | ||
n = { | ||
kind: "IntValue", | ||
value: c | ||
}; | ||
} else if (c = advance(t)) { | ||
i = { | ||
kind: exports.Kind.ENUM, | ||
n = { | ||
kind: "EnumValue", | ||
value: c | ||
}; | ||
} else if (c = advance(l)) { | ||
i = { | ||
kind: exports.Kind.STRING, | ||
} else if (c = advance(d)) { | ||
n = { | ||
kind: "StringValue", | ||
value: blockString(c.slice(3, -3)), | ||
@@ -207,9 +169,9 @@ block: !0 | ||
} else if (c = advance(v)) { | ||
i = { | ||
kind: exports.Kind.STRING, | ||
value: u.test(c) ? JSON.parse(c) : c.slice(1, -1), | ||
n = { | ||
kind: "StringValue", | ||
value: s.test(c) ? JSON.parse(c) : c.slice(1, -1), | ||
block: !1 | ||
}; | ||
} else if (i = function list(n) { | ||
var i; | ||
} else if (n = function list(i) { | ||
var n; | ||
if (91 === e.charCodeAt(r)) { | ||
@@ -219,19 +181,19 @@ r++; | ||
var t = []; | ||
while (i = value(n)) { | ||
t.push(i); | ||
while (n = value(i)) { | ||
t.push(n); | ||
} | ||
if (93 !== e.charCodeAt(r++)) { | ||
throw error(exports.Kind.LIST); | ||
throw error("ListValue"); | ||
} | ||
ignored(); | ||
return { | ||
kind: exports.Kind.LIST, | ||
kind: "ListValue", | ||
values: t | ||
}; | ||
} | ||
}(n) || function object(n) { | ||
}(i) || function object(i) { | ||
if (123 === e.charCodeAt(r)) { | ||
r++; | ||
ignored(); | ||
var i = []; | ||
var n = []; | ||
var t; | ||
@@ -241,33 +203,33 @@ while (t = name()) { | ||
if (58 !== e.charCodeAt(r++)) { | ||
throw error(exports.Kind.OBJECT_FIELD); | ||
throw error("ObjectField"); | ||
} | ||
ignored(); | ||
var o = value(n); | ||
if (!o) { | ||
throw error(exports.Kind.OBJECT_FIELD); | ||
var a = value(i); | ||
if (!a) { | ||
throw error("ObjectField"); | ||
} | ||
i.push({ | ||
kind: exports.Kind.OBJECT_FIELD, | ||
n.push({ | ||
kind: "ObjectField", | ||
name: t, | ||
value: o | ||
value: a | ||
}); | ||
} | ||
if (125 !== e.charCodeAt(r++)) { | ||
throw error(exports.Kind.OBJECT); | ||
throw error("ObjectValue"); | ||
} | ||
ignored(); | ||
return { | ||
kind: exports.Kind.OBJECT, | ||
fields: i | ||
kind: "ObjectValue", | ||
fields: n | ||
}; | ||
} | ||
}(n)) { | ||
return i; | ||
}(i)) { | ||
return n; | ||
} | ||
ignored(); | ||
return i; | ||
return n; | ||
} | ||
function arguments_(n) { | ||
var i = []; | ||
function arguments_(i) { | ||
var n = []; | ||
ignored(); | ||
@@ -281,25 +243,25 @@ if (40 === e.charCodeAt(r)) { | ||
if (58 !== e.charCodeAt(r++)) { | ||
throw error(exports.Kind.ARGUMENT); | ||
throw error("Argument"); | ||
} | ||
ignored(); | ||
var o = value(n); | ||
if (!o) { | ||
throw error(exports.Kind.ARGUMENT); | ||
var a = value(i); | ||
if (!a) { | ||
throw error("Argument"); | ||
} | ||
i.push({ | ||
kind: exports.Kind.ARGUMENT, | ||
n.push({ | ||
kind: "Argument", | ||
name: t, | ||
value: o | ||
value: a | ||
}); | ||
} | ||
if (!i.length || 41 !== e.charCodeAt(r++)) { | ||
throw error(exports.Kind.ARGUMENT); | ||
if (!n.length || 41 !== e.charCodeAt(r++)) { | ||
throw error("Argument"); | ||
} | ||
ignored(); | ||
} | ||
return i; | ||
return n; | ||
} | ||
function directives(n) { | ||
var i = []; | ||
function directives(i) { | ||
var n = []; | ||
ignored(); | ||
@@ -310,12 +272,12 @@ while (64 === e.charCodeAt(r)) { | ||
if (!t) { | ||
throw error(exports.Kind.DIRECTIVE); | ||
throw error("Directive"); | ||
} | ||
ignored(); | ||
i.push({ | ||
kind: exports.Kind.DIRECTIVE, | ||
n.push({ | ||
kind: "Directive", | ||
name: t, | ||
arguments: arguments_(n) | ||
arguments: arguments_(i) | ||
}); | ||
} | ||
return i; | ||
return n; | ||
} | ||
@@ -325,12 +287,12 @@ | ||
ignored(); | ||
var n = name(); | ||
if (n) { | ||
var i = name(); | ||
if (i) { | ||
ignored(); | ||
var i; | ||
var n; | ||
if (58 === e.charCodeAt(r)) { | ||
r++; | ||
ignored(); | ||
i = n; | ||
if (!(n = name())) { | ||
throw error(exports.Kind.FIELD); | ||
n = i; | ||
if (!(i = name())) { | ||
throw error("Field"); | ||
} | ||
@@ -340,5 +302,5 @@ ignored(); | ||
return { | ||
kind: exports.Kind.FIELD, | ||
alias: i, | ||
name: n, | ||
kind: "Field", | ||
alias: n, | ||
name: i, | ||
arguments: arguments_(!1), | ||
@@ -352,3 +314,3 @@ directives: directives(!1), | ||
function type() { | ||
var n; | ||
var i; | ||
ignored(); | ||
@@ -358,17 +320,17 @@ if (91 === e.charCodeAt(r)) { | ||
ignored(); | ||
var i = type(); | ||
if (!i || 93 !== e.charCodeAt(r++)) { | ||
throw error(exports.Kind.LIST_TYPE); | ||
var n = type(); | ||
if (!n || 93 !== e.charCodeAt(r++)) { | ||
throw error("ListType"); | ||
} | ||
n = { | ||
kind: exports.Kind.LIST_TYPE, | ||
type: i | ||
i = { | ||
kind: "ListType", | ||
type: n | ||
}; | ||
} else if (n = name()) { | ||
n = { | ||
kind: exports.Kind.NAMED_TYPE, | ||
name: n | ||
} else if (i = name()) { | ||
i = { | ||
kind: "NamedType", | ||
name: i | ||
}; | ||
} else { | ||
throw error(exports.Kind.NAMED_TYPE); | ||
throw error("NamedType"); | ||
} | ||
@@ -380,7 +342,7 @@ ignored(); | ||
return { | ||
kind: exports.Kind.NON_NULL_TYPE, | ||
type: n | ||
kind: "NonNullType", | ||
type: i | ||
}; | ||
} else { | ||
return n; | ||
return i; | ||
} | ||
@@ -396,7 +358,7 @@ } | ||
if (!e) { | ||
throw error(exports.Kind.NAMED_TYPE); | ||
throw error("NamedType"); | ||
} | ||
ignored(); | ||
return { | ||
kind: exports.Kind.NAMED_TYPE, | ||
kind: "NamedType", | ||
name: e | ||
@@ -414,7 +376,7 @@ }; | ||
var e = r; | ||
var n; | ||
if ((n = name()) && "on" !== n.value) { | ||
var i; | ||
if ((i = name()) && "on" !== i.value) { | ||
return { | ||
kind: exports.Kind.FRAGMENT_SPREAD, | ||
name: n, | ||
kind: "FragmentSpread", | ||
name: i, | ||
directives: directives(!1) | ||
@@ -424,13 +386,13 @@ }; | ||
r = e; | ||
var i = typeCondition(); | ||
var n = typeCondition(); | ||
var t = directives(!1); | ||
var o = selectionSet(); | ||
if (!o) { | ||
throw error(exports.Kind.INLINE_FRAGMENT); | ||
var a = selectionSet(); | ||
if (!a) { | ||
throw error("InlineFragment"); | ||
} | ||
return { | ||
kind: exports.Kind.INLINE_FRAGMENT, | ||
typeCondition: i, | ||
kind: "InlineFragment", | ||
typeCondition: n, | ||
directives: t, | ||
selectionSet: o | ||
selectionSet: a | ||
}; | ||
@@ -442,3 +404,3 @@ } | ||
function selectionSet() { | ||
var n; | ||
var i; | ||
ignored(); | ||
@@ -448,13 +410,13 @@ if (123 === e.charCodeAt(r)) { | ||
ignored(); | ||
var i = []; | ||
while (n = fragmentSpread() || field()) { | ||
i.push(n); | ||
var n = []; | ||
while (i = fragmentSpread() || field()) { | ||
n.push(i); | ||
} | ||
if (!i.length || 125 !== e.charCodeAt(r++)) { | ||
throw error(exports.Kind.SELECTION_SET); | ||
if (!n.length || 125 !== e.charCodeAt(r++)) { | ||
throw error("SelectionSet"); | ||
} | ||
ignored(); | ||
return { | ||
kind: exports.Kind.SELECTION_SET, | ||
selections: i | ||
kind: "SelectionSet", | ||
selections: n | ||
}; | ||
@@ -464,10 +426,10 @@ } | ||
var E = /fragment/y; | ||
var p = /fragment/y; | ||
function fragmentDefinition() { | ||
if (advance(E)) { | ||
if (advance(p)) { | ||
ignored(); | ||
var e = name(); | ||
if (!e) { | ||
throw error(exports.Kind.FRAGMENT_DEFINITION); | ||
throw error("FragmentDefinition"); | ||
} | ||
@@ -477,15 +439,15 @@ ignored(); | ||
if (!r) { | ||
throw error(exports.Kind.FRAGMENT_DEFINITION); | ||
throw error("FragmentDefinition"); | ||
} | ||
var n = directives(!1); | ||
var i = selectionSet(); | ||
if (!i) { | ||
throw error(exports.Kind.FRAGMENT_DEFINITION); | ||
var i = directives(!1); | ||
var n = selectionSet(); | ||
if (!n) { | ||
throw error("FragmentDefinition"); | ||
} | ||
return { | ||
kind: exports.Kind.FRAGMENT_DEFINITION, | ||
kind: "FragmentDefinition", | ||
name: e, | ||
typeCondition: r, | ||
directives: n, | ||
selectionSet: i | ||
directives: i, | ||
selectionSet: n | ||
}; | ||
@@ -495,15 +457,15 @@ } | ||
var N = /query|mutation|subscription/y; | ||
var m = /query|mutation|subscription/y; | ||
function operationDefinition() { | ||
var i; | ||
var n; | ||
var i; | ||
var t = []; | ||
var o = []; | ||
if (n = advance(N)) { | ||
var a = []; | ||
if (i = advance(m)) { | ||
ignored(); | ||
i = name(); | ||
n = name(); | ||
t = function variableDefinitions() { | ||
var n; | ||
var i = []; | ||
var i; | ||
var n = []; | ||
ignored(); | ||
@@ -513,31 +475,31 @@ if (40 === e.charCodeAt(r)) { | ||
ignored(); | ||
while (n = advance(s)) { | ||
while (i = advance(o)) { | ||
ignored(); | ||
if (58 !== e.charCodeAt(r++)) { | ||
throw error(exports.Kind.VARIABLE_DEFINITION); | ||
throw error("VariableDefinition"); | ||
} | ||
var t = type(); | ||
if (!t) { | ||
throw error(exports.Kind.VARIABLE_DEFINITION); | ||
throw error("VariableDefinition"); | ||
} | ||
var o = void 0; | ||
var a = void 0; | ||
if (61 === e.charCodeAt(r)) { | ||
r++; | ||
ignored(); | ||
if (!(o = value(!0))) { | ||
throw error(exports.Kind.VARIABLE_DEFINITION); | ||
if (!(a = value(!0))) { | ||
throw error("VariableDefinition"); | ||
} | ||
} | ||
ignored(); | ||
i.push({ | ||
kind: exports.Kind.VARIABLE_DEFINITION, | ||
n.push({ | ||
kind: "VariableDefinition", | ||
variable: { | ||
kind: exports.Kind.VARIABLE, | ||
kind: "Variable", | ||
name: { | ||
kind: exports.Kind.NAME, | ||
value: n.slice(1) | ||
kind: "Name", | ||
value: i.slice(1) | ||
} | ||
}, | ||
type: t, | ||
defaultValue: o, | ||
defaultValue: a, | ||
directives: directives(!0) | ||
@@ -547,19 +509,19 @@ }); | ||
if (41 !== e.charCodeAt(r++)) { | ||
throw error(exports.Kind.VARIABLE_DEFINITION); | ||
throw error("VariableDefinition"); | ||
} | ||
ignored(); | ||
} | ||
return i; | ||
return n; | ||
}(); | ||
o = directives(!1); | ||
a = directives(!1); | ||
} | ||
var a = selectionSet(); | ||
if (a) { | ||
var l = selectionSet(); | ||
if (l) { | ||
return { | ||
kind: exports.Kind.OPERATION_DEFINITION, | ||
operation: n || "query", | ||
name: i, | ||
kind: "OperationDefinition", | ||
operation: i || "query", | ||
name: n, | ||
variableDefinitions: t, | ||
directives: o, | ||
selectionSet: a | ||
directives: a, | ||
selectionSet: l | ||
}; | ||
@@ -569,3 +531,3 @@ } | ||
var I = {}; | ||
var g = {}; | ||
@@ -582,36 +544,36 @@ function printString(e) { | ||
var T = 80; | ||
var h = 80; | ||
function valueFromASTUntyped(e, r) { | ||
switch (e.kind) { | ||
case exports.Kind.NULL: | ||
case "NullValue": | ||
return null; | ||
case exports.Kind.INT: | ||
case "IntValue": | ||
return parseInt(e.value, 10); | ||
case exports.Kind.FLOAT: | ||
case "FloatValue": | ||
return parseFloat(e.value); | ||
case exports.Kind.STRING: | ||
case exports.Kind.ENUM: | ||
case exports.Kind.BOOLEAN: | ||
case "StringValue": | ||
case "EnumValue": | ||
case "BooleanValue": | ||
return e.value; | ||
case exports.Kind.LIST: | ||
var n = []; | ||
for (var i = 0, t = e.values; i < t.length; i += 1) { | ||
n.push(valueFromASTUntyped(t[i], r)); | ||
case "ListValue": | ||
var i = []; | ||
for (var n = 0, t = e.values; n < t.length; n += 1) { | ||
i.push(valueFromASTUntyped(t[n], r)); | ||
} | ||
return n; | ||
return i; | ||
case exports.Kind.OBJECT: | ||
var o = Object.create(null); | ||
for (var a = 0, s = e.fields; a < s.length; a += 1) { | ||
var d = s[a]; | ||
o[d.name.value] = valueFromASTUntyped(d.value, r); | ||
case "ObjectValue": | ||
var a = Object.create(null); | ||
for (var o = 0, l = e.fields; o < l.length; o += 1) { | ||
var u = l[o]; | ||
a[u.name.value] = valueFromASTUntyped(u.value, r); | ||
} | ||
return o; | ||
return a; | ||
case exports.Kind.VARIABLE: | ||
case "Variable": | ||
return r && r[e.name.value]; | ||
@@ -621,24 +583,50 @@ } | ||
exports.BREAK = I; | ||
exports.BREAK = g; | ||
exports.GraphQLError = GraphQLError; | ||
exports.Kind = { | ||
NAME: "Name", | ||
DOCUMENT: "Document", | ||
OPERATION_DEFINITION: "OperationDefinition", | ||
VARIABLE_DEFINITION: "VariableDefinition", | ||
SELECTION_SET: "SelectionSet", | ||
FIELD: "Field", | ||
ARGUMENT: "Argument", | ||
FRAGMENT_SPREAD: "FragmentSpread", | ||
INLINE_FRAGMENT: "InlineFragment", | ||
FRAGMENT_DEFINITION: "FragmentDefinition", | ||
VARIABLE: "Variable", | ||
OBJECT: "ObjectValue", | ||
OBJECT_FIELD: "ObjectField", | ||
DIRECTIVE: "Directive", | ||
NAMED_TYPE: "NamedType", | ||
LIST_TYPE: "ListType", | ||
NON_NULL_TYPE: "NonNullType" | ||
}; | ||
exports.OperationTypeNode = { | ||
QUERY: "query", | ||
MUTATION: "mutation", | ||
SUBSCRIPTION: "subscription" | ||
}; | ||
exports.blockString = blockString; | ||
exports.parse = function parse(n) { | ||
e = n; | ||
exports.parse = function parse(i, n) { | ||
e = "string" == typeof i.body ? i.body : i; | ||
r = 0; | ||
return function document() { | ||
var n; | ||
var i; | ||
ignored(); | ||
var i = []; | ||
while (n = fragmentDefinition() || operationDefinition()) { | ||
i.push(n); | ||
var n = []; | ||
while (i = fragmentDefinition() || operationDefinition()) { | ||
n.push(i); | ||
} | ||
if (r !== e.length) { | ||
throw error(exports.Kind.DOCUMENT); | ||
throw error("Document"); | ||
} | ||
return { | ||
kind: exports.Kind.DOCUMENT, | ||
definitions: i | ||
kind: "Document", | ||
definitions: n | ||
}; | ||
@@ -648,13 +636,21 @@ }(); | ||
exports.parseType = function parseType(n) { | ||
e = n; | ||
exports.parseType = function parseType(i, n) { | ||
e = "string" == typeof i.body ? i.body : i; | ||
r = 0; | ||
return type(); | ||
var t = type(); | ||
if (!t) { | ||
throw error("TypeNode"); | ||
} | ||
return t; | ||
}; | ||
exports.parseValue = function parseValue(n) { | ||
e = n; | ||
exports.parseValue = function parseValue(i, n) { | ||
e = "string" == typeof i.body ? i.body : i; | ||
r = 0; | ||
ignored(); | ||
return value(!1); | ||
var t = value(!1); | ||
if (!t) { | ||
throw error("ValueNode"); | ||
} | ||
return t; | ||
}; | ||
@@ -665,3 +661,3 @@ | ||
switch (e.kind) { | ||
case exports.Kind.OPERATION_DEFINITION: | ||
case "OperationDefinition": | ||
if ("query" === e.operation && !e.name && !hasItems(e.variableDefinitions) && !hasItems(e.directives)) { | ||
@@ -685,3 +681,3 @@ return print(e.selectionSet); | ||
case exports.Kind.VARIABLE_DEFINITION: | ||
case "VariableDefinition": | ||
r = print(e.variable) + ": " + print(e.type); | ||
@@ -696,8 +692,8 @@ if (e.defaultValue) { | ||
case exports.Kind.FIELD: | ||
case "Field": | ||
r = (e.alias ? print(e.alias) + ": " : "") + e.name.value; | ||
if (hasItems(e.arguments)) { | ||
var n = e.arguments.map(print); | ||
var i = r + "(" + n.join(", ") + ")"; | ||
r = i.length > T ? r + "(\n " + n.join("\n").replace(/\n/g, "\n ") + "\n)" : i; | ||
var i = e.arguments.map(print); | ||
var n = r + "(" + i.join(", ") + ")"; | ||
r = n.length > h ? r + "(\n " + i.join("\n").replace(/\n/g, "\n ") + "\n)" : n; | ||
} | ||
@@ -709,39 +705,37 @@ if (hasItems(e.directives)) { | ||
case exports.Kind.STRING: | ||
case "StringValue": | ||
return e.block ? printBlockString(e.value) : printString(e.value); | ||
case exports.Kind.BOOLEAN: | ||
case "BooleanValue": | ||
return "" + e.value; | ||
case exports.Kind.NULL: | ||
case "NullValue": | ||
return "null"; | ||
case exports.Kind.INT: | ||
case exports.Kind.FLOAT: | ||
case exports.Kind.ENUM: | ||
case exports.Kind.NAME: | ||
case "IntValue": | ||
case "FloatValue": | ||
case "EnumValue": | ||
case "Name": | ||
return e.value; | ||
case exports.Kind.LIST: | ||
case "ListValue": | ||
return "[" + e.values.map(print).join(", ") + "]"; | ||
case exports.Kind.OBJECT: | ||
case "ObjectValue": | ||
return "{" + e.fields.map(print).join(", ") + "}"; | ||
case exports.Kind.OBJECT_FIELD: | ||
case "ObjectField": | ||
case "Argument": | ||
return e.name.value + ": " + print(e.value); | ||
case exports.Kind.VARIABLE: | ||
case "Variable": | ||
return "$" + e.name.value; | ||
case exports.Kind.DOCUMENT: | ||
case "Document": | ||
return hasItems(e.definitions) ? e.definitions.map(print).join("\n\n") : ""; | ||
case exports.Kind.SELECTION_SET: | ||
case "SelectionSet": | ||
return "{\n " + e.selections.map(print).join("\n").replace(/\n/g, "\n ") + "\n}"; | ||
case exports.Kind.ARGUMENT: | ||
return e.name.value + ": " + print(e.value); | ||
case exports.Kind.FRAGMENT_SPREAD: | ||
case "FragmentSpread": | ||
r = "..." + e.name.value; | ||
@@ -753,3 +747,3 @@ if (hasItems(e.directives)) { | ||
case exports.Kind.INLINE_FRAGMENT: | ||
case "InlineFragment": | ||
r = "..."; | ||
@@ -764,3 +758,3 @@ if (e.typeCondition) { | ||
case exports.Kind.FRAGMENT_DEFINITION: | ||
case "FragmentDefinition": | ||
r = "fragment " + e.name.value; | ||
@@ -773,3 +767,3 @@ r += " on " + e.typeCondition.name.value; | ||
case exports.Kind.DIRECTIVE: | ||
case "Directive": | ||
r = "@" + e.name.value; | ||
@@ -781,10 +775,13 @@ if (hasItems(e.arguments)) { | ||
case exports.Kind.NAMED_TYPE: | ||
case "NamedType": | ||
return e.name.value; | ||
case exports.Kind.LIST_TYPE: | ||
case "ListType": | ||
return "[" + print(e.type) + "]"; | ||
case exports.Kind.NON_NULL_TYPE: | ||
case "NonNullType": | ||
return print(e.type) + "!"; | ||
default: | ||
return ""; | ||
} | ||
@@ -799,23 +796,23 @@ }; | ||
exports.valueFromTypeNode = function valueFromTypeNode(e, r, n) { | ||
if (e.kind === exports.Kind.VARIABLE) { | ||
return n ? valueFromTypeNode(n[e.name.value], r, n) : void 0; | ||
} else if (r.kind === exports.Kind.NON_NULL_TYPE) { | ||
return e.kind !== exports.Kind.NULL ? valueFromTypeNode(e, r, n) : void 0; | ||
} else if (e.kind === exports.Kind.NULL) { | ||
exports.valueFromTypeNode = function valueFromTypeNode(e, r, i) { | ||
if ("Variable" === e.kind) { | ||
return i ? valueFromTypeNode(i[e.name.value], r, i) : void 0; | ||
} else if ("NonNullType" === r.kind) { | ||
return "NullValue" !== e.kind ? valueFromTypeNode(e, r, i) : void 0; | ||
} else if ("NullValue" === e.kind) { | ||
return null; | ||
} else if (r.kind === exports.Kind.LIST_TYPE) { | ||
if (e.kind === exports.Kind.LIST) { | ||
var i = []; | ||
for (var t = 0, o = e.values; t < o.length; t += 1) { | ||
var a = valueFromTypeNode(o[t], r.type, n); | ||
if (void 0 === a) { | ||
} else if ("ListType" === r.kind) { | ||
if ("ListValue" === e.kind) { | ||
var n = []; | ||
for (var t = 0, a = e.values; t < a.length; t += 1) { | ||
var o = valueFromTypeNode(a[t], r.type, i); | ||
if (void 0 === o) { | ||
return; | ||
} else { | ||
i.push(a); | ||
n.push(o); | ||
} | ||
} | ||
return i; | ||
return n; | ||
} | ||
} else if (r.kind === exports.Kind.NAMED_TYPE) { | ||
} else if ("NamedType" === r.kind) { | ||
switch (r.name.value) { | ||
@@ -826,6 +823,6 @@ case "Int": | ||
case "Bool": | ||
return r.name.value + "Value" === e.kind ? valueFromASTUntyped(e, n) : void 0; | ||
return r.name.value + "Value" === e.kind ? valueFromASTUntyped(e, i) : void 0; | ||
default: | ||
return valueFromASTUntyped(e, n); | ||
return valueFromASTUntyped(e, i); | ||
} | ||
@@ -836,73 +833,73 @@ } | ||
exports.visit = function visit(e, r) { | ||
var i = []; | ||
var n = []; | ||
var i = []; | ||
try { | ||
var t = function traverse(e, t, o) { | ||
var a = !1; | ||
var s = r[e.kind] && r[e.kind].enter || r[e.kind]; | ||
var d = s && s.call(r, e, t, o, i, n); | ||
if (!1 === d) { | ||
var t = function traverse(e, t, a) { | ||
var o = !1; | ||
var l = r[e.kind] && r[e.kind].enter || r[e.kind]; | ||
var u = l && l.call(r, e, t, a, n, i); | ||
if (!1 === u) { | ||
return e; | ||
} else if (null === d) { | ||
} else if (null === u) { | ||
return null; | ||
} else if (d === I) { | ||
throw I; | ||
} else if (d && "string" == typeof d.kind) { | ||
a = d !== e; | ||
e = d; | ||
} else if (u === g) { | ||
throw g; | ||
} else if (u && "string" == typeof u.kind) { | ||
o = u !== e; | ||
e = u; | ||
} | ||
if (o) { | ||
n.push(o); | ||
if (a) { | ||
i.push(a); | ||
} | ||
var p; | ||
var u = { | ||
var s; | ||
var d = { | ||
...e | ||
}; | ||
for (var l in e) { | ||
i.push(l); | ||
var v = e[l]; | ||
if (Array.isArray(v)) { | ||
var c = []; | ||
for (var f = 0; f < v.length; f++) { | ||
if (null != v[f] && "string" == typeof v[f].kind) { | ||
n.push(e); | ||
i.push(f); | ||
p = traverse(v[f], f, v); | ||
for (var v in e) { | ||
n.push(v); | ||
var c = e[v]; | ||
if (Array.isArray(c)) { | ||
var f = []; | ||
for (var p = 0; p < c.length; p++) { | ||
if (null != c[p] && "string" == typeof c[p].kind) { | ||
i.push(e); | ||
n.push(p); | ||
s = traverse(c[p], p, c); | ||
n.pop(); | ||
i.pop(); | ||
n.pop(); | ||
if (void 0 === p) { | ||
c.push(v[f]); | ||
} else if (null === p) { | ||
a = !0; | ||
if (void 0 === s) { | ||
f.push(c[p]); | ||
} else if (null === s) { | ||
o = !0; | ||
} else { | ||
a = a || p !== v[f]; | ||
c.push(p); | ||
o = o || s !== c[p]; | ||
f.push(s); | ||
} | ||
} | ||
} | ||
v = c; | ||
} else if (null != v && "string" == typeof v.kind) { | ||
if (void 0 !== (p = traverse(v, l, e))) { | ||
a = a || v !== p; | ||
v = p; | ||
c = f; | ||
} else if (null != c && "string" == typeof c.kind) { | ||
if (void 0 !== (s = traverse(c, v, e))) { | ||
o = o || c !== s; | ||
c = s; | ||
} | ||
} | ||
i.pop(); | ||
if (a) { | ||
u[l] = v; | ||
n.pop(); | ||
if (o) { | ||
d[v] = c; | ||
} | ||
} | ||
if (o) { | ||
n.pop(); | ||
if (a) { | ||
i.pop(); | ||
} | ||
var E = r[e.kind] && r[e.kind].leave; | ||
var N = E && E.call(r, e, t, o, i, n); | ||
if (N === I) { | ||
throw I; | ||
} else if (void 0 !== N) { | ||
return N; | ||
} else if (void 0 !== d) { | ||
return a ? u : d; | ||
var m = r[e.kind] && r[e.kind].leave; | ||
var h = m && m.call(r, e, t, a, n, i); | ||
if (h === g) { | ||
throw g; | ||
} else if (void 0 !== h) { | ||
return h; | ||
} else if (void 0 !== u) { | ||
return o ? d : u; | ||
} else { | ||
return a ? u : e; | ||
return o ? d : e; | ||
} | ||
@@ -912,3 +909,3 @@ }(e); | ||
} catch (r) { | ||
if (r !== I) { | ||
if (r !== g) { | ||
throw r; | ||
@@ -915,0 +912,0 @@ } |
{ | ||
"name": "@0no-co/graphql.web", | ||
"description": "A spec-compliant client-side GraphQL implementation", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"author": "0no.co <hi@0no.co>", | ||
@@ -67,2 +67,3 @@ "source": "./src/index.ts", | ||
"@typescript-eslint/parser": "^5.55.0", | ||
"dotenv": "^16.0.3", | ||
"eslint": "^8.36.0", | ||
@@ -89,3 +90,3 @@ "eslint-config-prettier": "^8.7.0", | ||
"scripts": { | ||
"test": "vitest", | ||
"test": "vitest run", | ||
"check": "tsc", | ||
@@ -92,0 +93,0 @@ "lint": "eslint --ext=js,ts .", |
@@ -34,3 +34,3 @@ <div align="center"> | ||
### API | ||
### API | ||
@@ -37,0 +37,0 @@ Currently, only a select few exports are provided — namely, the ones listed here |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2043
146190
26