@graphitation/supermassive 3.0.0-alpha.5 → 3.0.0-alpha.7
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/.eslintcache +1 -1
- package/CHANGELOG.md +18 -2
- package/lib/benchmarks/index.js.map +2 -2
- package/lib/benchmarks/index.mjs.map +2 -2
- package/lib/collectFields.d.ts.map +1 -1
- package/lib/collectFields.js +6 -5
- package/lib/collectFields.js.map +2 -2
- package/lib/collectFields.mjs +6 -5
- package/lib/collectFields.mjs.map +2 -2
- package/lib/executeWithoutSchema.d.ts +1 -3
- package/lib/executeWithoutSchema.d.ts.map +1 -1
- package/lib/executeWithoutSchema.js +153 -69
- package/lib/executeWithoutSchema.js.map +2 -2
- package/lib/executeWithoutSchema.mjs +143 -71
- package/lib/executeWithoutSchema.mjs.map +2 -2
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +2 -2
- package/lib/index.mjs +10 -2
- package/lib/index.mjs.map +2 -2
- package/lib/schema/definition.d.ts +43 -33
- package/lib/schema/definition.d.ts.map +1 -1
- package/lib/schema/definition.js +284 -9
- package/lib/schema/definition.js.map +2 -2
- package/lib/schema/definition.mjs +284 -55
- package/lib/schema/definition.mjs.map +3 -3
- package/lib/schema/directives.d.ts.map +1 -1
- package/lib/schema/directives.js +3 -3
- package/lib/schema/directives.js.map +2 -2
- package/lib/schema/directives.mjs +4 -4
- package/lib/schema/directives.mjs.map +2 -2
- package/lib/schema/reference.d.ts +3 -1
- package/lib/schema/reference.d.ts.map +1 -1
- package/lib/schema/reference.js.map +2 -2
- package/lib/schema/reference.mjs.map +2 -2
- package/lib/schema/resolvers.d.ts +10 -4
- package/lib/schema/resolvers.d.ts.map +1 -1
- package/lib/schema/resolvers.js +92 -9
- package/lib/schema/resolvers.js.map +2 -2
- package/lib/schema/resolvers.mjs +99 -9
- package/lib/schema/resolvers.mjs.map +2 -2
- package/lib/types.d.ts +25 -2
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utilities/coerceInputValue.d.ts +3 -3
- package/lib/utilities/coerceInputValue.d.ts.map +1 -1
- package/lib/utilities/coerceInputValue.js +17 -12
- package/lib/utilities/coerceInputValue.js.map +2 -2
- package/lib/utilities/coerceInputValue.mjs +22 -12
- package/lib/utilities/coerceInputValue.mjs.map +2 -2
- package/lib/utilities/decodeASTSchema.d.ts.map +1 -1
- package/lib/utilities/decodeASTSchema.js +32 -40
- package/lib/utilities/decodeASTSchema.js.map +2 -2
- package/lib/utilities/decodeASTSchema.mjs +51 -49
- package/lib/utilities/decodeASTSchema.mjs.map +2 -2
- package/lib/utilities/encodeASTSchema.d.ts.map +1 -1
- package/lib/utilities/encodeASTSchema.js +16 -20
- package/lib/utilities/encodeASTSchema.js.map +2 -2
- package/lib/utilities/encodeASTSchema.mjs +22 -21
- package/lib/utilities/encodeASTSchema.mjs.map +2 -2
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.d.ts.map +1 -1
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js +20 -22
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.js.map +2 -2
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs +35 -29
- package/lib/utilities/extractMinimalViableSchemaForRequestDocument.mjs.map +2 -2
- package/lib/utilities/mergeResolvers.js +1 -2
- package/lib/utilities/mergeResolvers.js.map +2 -2
- package/lib/utilities/mergeResolvers.mjs +1 -2
- package/lib/utilities/mergeResolvers.mjs.map +2 -2
- package/lib/utilities/mergeSchemaDefinitions.d.ts.map +1 -1
- package/lib/utilities/mergeSchemaDefinitions.js +18 -28
- package/lib/utilities/mergeSchemaDefinitions.js.map +2 -2
- package/lib/utilities/mergeSchemaDefinitions.mjs +28 -34
- package/lib/utilities/mergeSchemaDefinitions.mjs.map +2 -2
- package/lib/utilities/valueFromAST.d.ts +3 -3
- package/lib/utilities/valueFromAST.d.ts.map +1 -1
- package/lib/utilities/valueFromAST.js +23 -10
- package/lib/utilities/valueFromAST.js.map +2 -2
- package/lib/utilities/valueFromAST.mjs +13 -10
- package/lib/utilities/valueFromAST.mjs.map +2 -2
- package/lib/values.d.ts +2 -2
- package/lib/values.d.ts.map +1 -1
- package/lib/values.js +14 -14
- package/lib/values.js.map +2 -2
- package/lib/values.mjs +21 -14
- package/lib/values.mjs.map +2 -2
- package/package.json +1 -1
- package/lib/schema/fragment.d.ts +0 -63
- package/lib/schema/fragment.d.ts.map +0 -1
- package/lib/schema/fragment.js +0 -295
- package/lib/schema/fragment.js.map +0 -7
- package/lib/schema/fragment.mjs +0 -292
- package/lib/schema/fragment.mjs.map +0 -7
package/lib/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export {\n executeWithoutSchema,\n isTotalExecutionResult,\n isIncrementalExecutionResult,\n} from \"./executeWithoutSchema\";\nexport { executeWithSchema } from \"./executeWithSchema\";\nexport { subscribeWithSchema } from \"./subscribeWithSchema\";\nexport { subscribeWithoutSchema } from \"./subscribeWithoutSchema\";\nexport { encodeASTSchema } from \"./utilities/encodeASTSchema\";\nexport { decodeASTSchema } from \"./utilities/decodeASTSchema\";\nexport { mergeSchemaDefinitions } from \"./utilities/mergeSchemaDefinitions\";\nexport { mergeResolvers } from \"./utilities/mergeResolvers\";\nexport { annotateDocumentGraphQLTransform } from \"./utilities/annotateDocumentGraphQLTransform\";\nexport {\n addMinimalViableSchemaToRequestDocument,\n addMinimalViableSchemaToExecutableDefinitionNode,\n} from \"./utilities/addMinimalViableSchemaToRequestDocument\";\nexport { extractMinimalViableSchemaForRequestDocument } from \"./utilities/extractMinimalViableSchemaForRequestDocument\";\nexport { specifiedScalarResolvers } from \"./schema/resolvers\";\nexport {\n typeNameFromReference,\n typeReferenceFromName,\n typeReferenceFromNode,\n} from \"./schema/reference\";\n\nexport type { ExtractMinimalViableSchemaResult } from \"./utilities/extractMinimalViableSchemaForRequestDocument\";\nexport type {\n AddMinimalViableSchemaToRequestDocumentOptions,\n ExecutableDefinitionNodeWithInlinedSchema,\n} from \"./utilities/addMinimalViableSchemaToRequestDocument\";\nexport type {\n SchemaDefinitions,\n OperationTypes,\n TypeDefinitionsRecord,\n TypeDefinitionTuple,\n
|
|
5
|
-
"mappings": ";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AACpC,SAAS,8BAA8B;AACvC,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,8BAA8B;AACvC,SAAS,sBAAsB;AAC/B,SAAS,wCAAwC;AACjD;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,oDAAoD;AAC7D,SAAS,gCAAgC;AACzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
4
|
+
"sourcesContent": ["export {\n executeWithoutSchema,\n isTotalExecutionResult,\n isIncrementalExecutionResult,\n} from \"./executeWithoutSchema\";\nexport { executeWithSchema } from \"./executeWithSchema\";\nexport { subscribeWithSchema } from \"./subscribeWithSchema\";\nexport { subscribeWithoutSchema } from \"./subscribeWithoutSchema\";\nexport { encodeASTSchema } from \"./utilities/encodeASTSchema\";\nexport { decodeASTSchema } from \"./utilities/decodeASTSchema\";\nexport { mergeSchemaDefinitions } from \"./utilities/mergeSchemaDefinitions\";\nexport { mergeResolvers } from \"./utilities/mergeResolvers\";\nexport { annotateDocumentGraphQLTransform } from \"./utilities/annotateDocumentGraphQLTransform\";\nexport {\n addMinimalViableSchemaToRequestDocument,\n addMinimalViableSchemaToExecutableDefinitionNode,\n} from \"./utilities/addMinimalViableSchemaToRequestDocument\";\nexport { extractMinimalViableSchemaForRequestDocument } from \"./utilities/extractMinimalViableSchemaForRequestDocument\";\nexport { specifiedScalarResolvers } from \"./schema/resolvers\";\nexport {\n typeNameFromReference,\n typeReferenceFromName,\n typeReferenceFromNode,\n isNonNullType,\n isListType,\n unwrap,\n unwrapAll,\n} from \"./schema/reference\";\nexport type {\n TypeReference,\n TypeName,\n SpecTypeIndex,\n} from \"./schema/reference\";\n\nexport type { ExtractMinimalViableSchemaResult } from \"./utilities/extractMinimalViableSchemaForRequestDocument\";\nexport type {\n AddMinimalViableSchemaToRequestDocumentOptions,\n ExecutableDefinitionNodeWithInlinedSchema,\n} from \"./utilities/addMinimalViableSchemaToRequestDocument\";\nexport type {\n SchemaDefinitions,\n OperationTypes,\n TypeDefinitionsRecord,\n TypeDefinitionTuple,\n DirectiveDefinitionTuple,\n InterfaceTypeDefinitionTuple,\n ObjectTypeDefinitionTuple,\n InputValueDefinition,\n InputValueDefinitionRecord,\n UnionTypeDefinitionTuple,\n EnumTypeDefinitionTuple,\n ScalarTypeDefinitionTuple,\n InputObjectTypeDefinitionTuple,\n FieldDefinition,\n FieldDefinitionTuple,\n CompositeTypeTuple,\n FieldDefinitionRecord,\n InputValueDefinitionTuple,\n DirectiveTuple,\n InterfaceImplementationsRecord,\n DirectiveName,\n} from \"./schema/definition\";\n\nexport type {\n ObjectTypeResolver,\n ScalarTypeResolver,\n EnumTypeResolver,\n FunctionFieldResolver,\n Resolvers,\n UserResolvers,\n ResolveInfo,\n TotalExecutionResult,\n ExecutionResult,\n SubscriptionExecutionResult,\n IncrementalExecutionResult,\n SchemaFragment,\n SchemaFragmentLoader,\n SchemaFragmentLoaderResult,\n SchemaFragmentRequest,\n SchemaFragmentForReturnTypeRequest,\n SchemaFragmentForRuntimeTypeRequest,\n} from \"./types\";\n\nexport type { PromiseOrValue } from \"./jsutils/PromiseOrValue\";\n\nexport type {\n NameNode,\n DocumentNode,\n OperationDefinitionNode,\n VariableDefinitionNode,\n VariableNode,\n SelectionSetNode,\n FieldNode,\n ArgumentNode,\n FragmentSpreadNode,\n InlineFragmentNode,\n FragmentDefinitionNode,\n IntValueNode,\n FloatValueNode,\n StringValueNode,\n BooleanValueNode,\n NullValueNode,\n EnumValueNode,\n ListValueNode,\n ObjectValueNode,\n ObjectFieldNode,\n DirectiveNode,\n NamedTypeNode,\n ListTypeNode,\n NonNullTypeNode,\n SchemaDefinitionNode,\n OperationTypeDefinitionNode,\n ScalarTypeDefinitionNode,\n ObjectTypeDefinitionNode,\n FieldDefinitionNode,\n InputValueDefinitionNode,\n InterfaceTypeDefinitionNode,\n UnionTypeDefinitionNode,\n EnumTypeDefinitionNode,\n EnumValueDefinitionNode,\n InputObjectTypeDefinitionNode,\n DirectiveDefinitionNode,\n SchemaExtensionNode,\n ScalarTypeExtensionNode,\n ObjectTypeExtensionNode,\n InterfaceTypeExtensionNode,\n UnionTypeExtensionNode,\n EnumTypeExtensionNode,\n InputObjectTypeExtensionNode,\n} from \"graphql\";\n\nexport type {\n BeforeFieldResolveHookArgs,\n AfterFieldResolveHookArgs,\n AfterFieldCompleteHookArgs,\n BeforeFieldResolveHook,\n AfterFieldResolveHook,\n AfterFieldCompleteHook,\n ExecutionHooks,\n} from \"./hooks/types\";\n"],
|
|
5
|
+
"mappings": ";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAAS,2BAA2B;AACpC,SAAS,8BAA8B;AACvC,SAAS,uBAAuB;AAChC,SAAS,uBAAuB;AAChC,SAAS,8BAA8B;AACvC,SAAS,sBAAsB;AAC/B,SAAS,wCAAwC;AACjD;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,oDAAoD;AAC7D,SAAS,gCAAgC;AACzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type TypeReference = string | SpecTypeIndex;
|
|
4
|
-
export declare const enum TypeKind {
|
|
1
|
+
import { TypeName, TypeReference } from "./reference";
|
|
2
|
+
declare const enum TypeKind {
|
|
5
3
|
SCALAR = 1,
|
|
6
4
|
OBJECT = 2,
|
|
7
5
|
INTERFACE = 3,
|
|
@@ -17,60 +15,35 @@ export type ObjectTypeDefinitionTuple = [
|
|
|
17
15
|
fields: FieldDefinitionRecord,
|
|
18
16
|
interfaces?: TypeName[]
|
|
19
17
|
];
|
|
20
|
-
export declare const enum ObjectKeys {
|
|
21
|
-
fields = 1,
|
|
22
|
-
interfaces = 2
|
|
23
|
-
}
|
|
24
18
|
export type InterfaceTypeDefinitionTuple = [
|
|
25
19
|
kind: TypeKind.INTERFACE,
|
|
26
20
|
fields: FieldDefinitionRecord,
|
|
27
21
|
interfaces?: TypeName[]
|
|
28
22
|
];
|
|
29
|
-
export declare const enum InterfaceKeys {
|
|
30
|
-
fields = 1,
|
|
31
|
-
interfaces = 2
|
|
32
|
-
}
|
|
33
23
|
export type UnionTypeDefinitionTuple = [
|
|
34
24
|
kind: TypeKind.UNION,
|
|
35
25
|
types: TypeName[]
|
|
36
26
|
];
|
|
37
|
-
export declare const enum UnionKeys {
|
|
38
|
-
types = 1
|
|
39
|
-
}
|
|
40
27
|
export type EnumTypeDefinitionTuple = [
|
|
41
28
|
kind: TypeKind.ENUM,
|
|
42
29
|
values: string[]
|
|
43
30
|
];
|
|
44
|
-
export declare const enum EnumKeys {
|
|
45
|
-
values = 1
|
|
46
|
-
}
|
|
47
31
|
export type InputObjectTypeDefinitionTuple = [
|
|
48
32
|
kind: TypeKind.INPUT,
|
|
49
33
|
fields: InputValueDefinitionRecord
|
|
50
34
|
];
|
|
51
|
-
export declare const enum InputObjectKeys {
|
|
52
|
-
fields = 1
|
|
53
|
-
}
|
|
54
35
|
export type TypeDefinitionTuple = ScalarTypeDefinitionTuple | ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple | UnionTypeDefinitionTuple | EnumTypeDefinitionTuple | InputObjectTypeDefinitionTuple;
|
|
55
36
|
export type CompositeTypeTuple = ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple | UnionTypeDefinitionTuple;
|
|
56
37
|
export type FieldDefinitionTuple = [
|
|
57
38
|
type: TypeReference,
|
|
58
39
|
arguments: InputValueDefinitionRecord
|
|
59
40
|
];
|
|
60
|
-
export declare const enum FieldKeys {
|
|
61
|
-
type = 0,
|
|
62
|
-
arguments = 1
|
|
63
|
-
}
|
|
64
41
|
export type FieldDefinition = TypeReference | FieldDefinitionTuple;
|
|
65
42
|
export type FieldDefinitionRecord = Record<string, FieldDefinition>;
|
|
66
43
|
export type InputValueDefinitionTuple = [
|
|
67
44
|
type: TypeReference,
|
|
68
45
|
defaultValue: unknown
|
|
69
46
|
];
|
|
70
|
-
export declare const enum InputValueKeys {
|
|
71
|
-
type = 0,
|
|
72
|
-
defaultValue = 1
|
|
73
|
-
}
|
|
74
47
|
export type InputValueDefinition = TypeReference | InputValueDefinitionTuple;
|
|
75
48
|
export type InputValueDefinitionRecord = Record<string, InputValueDefinition>;
|
|
76
49
|
export type DirectiveName = string;
|
|
@@ -82,10 +55,6 @@ export type DirectiveDefinitionTuple = [
|
|
|
82
55
|
name: DirectiveName,
|
|
83
56
|
arguments?: InputValueDefinitionRecord
|
|
84
57
|
];
|
|
85
|
-
export declare const enum DirectiveKeys {
|
|
86
|
-
name = 0,
|
|
87
|
-
arguments = 1
|
|
88
|
-
}
|
|
89
58
|
export type TypeDefinitionsRecord = Record<TypeName, TypeDefinitionTuple>;
|
|
90
59
|
export type InterfaceImplementationsRecord = Record<TypeName, TypeName[]>;
|
|
91
60
|
export type OperationTypes = {
|
|
@@ -97,4 +66,45 @@ export type SchemaDefinitions = {
|
|
|
97
66
|
types: TypeDefinitionsRecord;
|
|
98
67
|
directives?: DirectiveDefinitionTuple[];
|
|
99
68
|
};
|
|
69
|
+
export declare function findObjectType(defs: SchemaDefinitions, typeName: TypeName): ObjectTypeDefinitionTuple | undefined;
|
|
70
|
+
export declare function getObjectFields(def: ObjectTypeDefinitionTuple): FieldDefinitionRecord;
|
|
71
|
+
export declare function addInterfaceImplementation(defs: SchemaDefinitions, interfaceType: TypeName, objectType: TypeName): void;
|
|
72
|
+
export declare function getField(defs: SchemaDefinitions, typeName: TypeName, fieldName: string): FieldDefinition | undefined;
|
|
73
|
+
export declare function getInputObjectType(defs: SchemaDefinitions, typeRef: TypeReference): InputObjectTypeDefinitionTuple | undefined;
|
|
74
|
+
export declare function getLeafType(defs: SchemaDefinitions, typeRef: TypeReference): EnumTypeDefinitionTuple | ScalarTypeDefinitionTuple | undefined;
|
|
75
|
+
export declare function isDefined(defs: SchemaDefinitions, typeRef: TypeReference): boolean;
|
|
76
|
+
export declare function isInputType(defs: SchemaDefinitions, typeRef: TypeReference): boolean;
|
|
77
|
+
export declare function isObjectType(defs: SchemaDefinitions, typeRef: TypeReference): boolean;
|
|
78
|
+
export declare function isAbstractType(defs: SchemaDefinitions, typeRef: TypeReference): boolean;
|
|
79
|
+
export declare function getUnionType(defs: SchemaDefinitions, typeRef: TypeReference): UnionTypeDefinitionTuple | undefined;
|
|
80
|
+
export declare function getInterfaceType(defs: SchemaDefinitions, typeRef: TypeReference): InterfaceTypeDefinitionTuple | undefined;
|
|
81
|
+
export declare function isSubType(defs: SchemaDefinitions, abstractTypeName: TypeName, maybeSubTypeName: TypeName): boolean;
|
|
82
|
+
export declare function getDirectiveName(tuple: DirectiveDefinitionTuple): string;
|
|
83
|
+
export declare function isObjectTypeDefinition(type: TypeDefinitionTuple): type is ObjectTypeDefinitionTuple;
|
|
84
|
+
export declare function isUnionTypeDefinition(type: TypeDefinitionTuple): type is UnionTypeDefinitionTuple;
|
|
85
|
+
export declare function isInterfaceTypeDefinition(type: TypeDefinitionTuple): type is InterfaceTypeDefinitionTuple;
|
|
86
|
+
export declare function isEnumTypeDefinition(type: TypeDefinitionTuple): type is EnumTypeDefinitionTuple;
|
|
87
|
+
export declare function isScalarTypeDefinition(type: TypeDefinitionTuple): type is ScalarTypeDefinitionTuple;
|
|
88
|
+
export declare function isInputObjectTypeDefinition(type: TypeDefinitionTuple): type is InputObjectTypeDefinitionTuple;
|
|
89
|
+
export declare function getInputValueTypeReference(inputValue: InputValueDefinition): TypeReference;
|
|
90
|
+
export declare function getInputObjectFields(obj: InputObjectTypeDefinitionTuple): InputValueDefinitionRecord;
|
|
91
|
+
export declare function getInputDefaultValue(inputValue: InputValueDefinition): unknown | undefined;
|
|
92
|
+
export declare function getFields(def: ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple): FieldDefinitionRecord;
|
|
93
|
+
export declare function getFieldTypeReference(field: FieldDefinition): TypeReference;
|
|
94
|
+
export declare function getFieldArgs(field: FieldDefinition): InputValueDefinitionRecord | undefined;
|
|
95
|
+
export declare function setFieldArgs(field: FieldDefinitionTuple, args: InputValueDefinitionRecord): InputValueDefinitionRecord;
|
|
96
|
+
export declare function getEnumValues(tuple: EnumTypeDefinitionTuple): string[];
|
|
97
|
+
export declare function getDirectiveDefinitionArgs(directive: DirectiveDefinitionTuple): InputValueDefinitionRecord | undefined;
|
|
98
|
+
export declare function setDirectiveDefinitionArgs(directive: DirectiveDefinitionTuple, args: InputValueDefinitionRecord): InputValueDefinitionRecord;
|
|
99
|
+
export declare function createUnionTypeDefinition(types: TypeName[]): UnionTypeDefinitionTuple;
|
|
100
|
+
export declare function createInterfaceTypeDefinition(fields: FieldDefinitionRecord, interfaces?: TypeName[]): InterfaceTypeDefinitionTuple;
|
|
101
|
+
export declare function createObjectTypeDefinition(fields: FieldDefinitionRecord, interfaces?: TypeName[]): ObjectTypeDefinitionTuple;
|
|
102
|
+
export declare function createInputObjectTypeDefinition(fields: InputValueDefinitionRecord): InputObjectTypeDefinitionTuple;
|
|
103
|
+
export declare function createEnumTypeDefinition(values: string[]): EnumTypeDefinitionTuple;
|
|
104
|
+
export declare function createScalarTypeDefinition(): ScalarTypeDefinitionTuple;
|
|
105
|
+
export declare function getObjectTypeInterfaces(def: ObjectTypeDefinitionTuple): TypeName[];
|
|
106
|
+
export declare function getInterfaceTypeInterfaces(def: InterfaceTypeDefinitionTuple): TypeName[];
|
|
107
|
+
export declare function getUnionTypeMembers(tuple: UnionTypeDefinitionTuple): TypeName[];
|
|
108
|
+
export declare function getDefinitionArguments(def: FieldDefinition | DirectiveDefinitionTuple): InputValueDefinitionRecord | undefined;
|
|
109
|
+
export {};
|
|
100
110
|
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/schema/definition.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/schema/definition.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAyB,MAAM,aAAa,CAAC;AAI7E,mBAAW,QAAQ;IACjB,MAAM,IAAI;IACV,MAAM,IAAI;IACV,SAAS,IAAI;IACb,KAAK,IAAI;IACT,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AAED,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,QAAQ,CAAC,MAAM;CAEtB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,QAAQ,CAAC,MAAM;IACrB,MAAM,EAAE,qBAAqB;IAC7B,UAAU,CAAC,EAAE,QAAQ,EAAE;CAExB,CAAC;AAMF,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,QAAQ,CAAC,SAAS;IACxB,MAAM,EAAE,qBAAqB;IAC7B,UAAU,CAAC,EAAE,QAAQ,EAAE;CAExB,CAAC;AAMF,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,QAAQ,CAAC,KAAK;IACpB,KAAK,EAAE,QAAQ,EAAE;CAElB,CAAC;AAKF,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,QAAQ,CAAC,IAAI;IACnB,MAAM,EAAE,MAAM,EAAE;CAEjB,CAAC;AAKF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}
|
package/lib/schema/definition.js
CHANGED
|
@@ -18,17 +18,50 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var definition_exports = {};
|
|
20
20
|
__export(definition_exports, {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
addInterfaceImplementation: () => addInterfaceImplementation,
|
|
22
|
+
createEnumTypeDefinition: () => createEnumTypeDefinition,
|
|
23
|
+
createInputObjectTypeDefinition: () => createInputObjectTypeDefinition,
|
|
24
|
+
createInterfaceTypeDefinition: () => createInterfaceTypeDefinition,
|
|
25
|
+
createObjectTypeDefinition: () => createObjectTypeDefinition,
|
|
26
|
+
createScalarTypeDefinition: () => createScalarTypeDefinition,
|
|
27
|
+
createUnionTypeDefinition: () => createUnionTypeDefinition,
|
|
28
|
+
findObjectType: () => findObjectType,
|
|
29
|
+
getDefinitionArguments: () => getDefinitionArguments,
|
|
30
|
+
getDirectiveDefinitionArgs: () => getDirectiveDefinitionArgs,
|
|
31
|
+
getDirectiveName: () => getDirectiveName,
|
|
32
|
+
getEnumValues: () => getEnumValues,
|
|
33
|
+
getField: () => getField,
|
|
34
|
+
getFieldArgs: () => getFieldArgs,
|
|
35
|
+
getFieldTypeReference: () => getFieldTypeReference,
|
|
36
|
+
getFields: () => getFields,
|
|
37
|
+
getInputDefaultValue: () => getInputDefaultValue,
|
|
38
|
+
getInputObjectFields: () => getInputObjectFields,
|
|
39
|
+
getInputObjectType: () => getInputObjectType,
|
|
40
|
+
getInputValueTypeReference: () => getInputValueTypeReference,
|
|
41
|
+
getInterfaceType: () => getInterfaceType,
|
|
42
|
+
getInterfaceTypeInterfaces: () => getInterfaceTypeInterfaces,
|
|
43
|
+
getLeafType: () => getLeafType,
|
|
44
|
+
getObjectFields: () => getObjectFields,
|
|
45
|
+
getObjectTypeInterfaces: () => getObjectTypeInterfaces,
|
|
46
|
+
getUnionType: () => getUnionType,
|
|
47
|
+
getUnionTypeMembers: () => getUnionTypeMembers,
|
|
48
|
+
isAbstractType: () => isAbstractType,
|
|
49
|
+
isDefined: () => isDefined,
|
|
50
|
+
isEnumTypeDefinition: () => isEnumTypeDefinition,
|
|
51
|
+
isInputObjectTypeDefinition: () => isInputObjectTypeDefinition,
|
|
52
|
+
isInputType: () => isInputType,
|
|
53
|
+
isInterfaceTypeDefinition: () => isInterfaceTypeDefinition,
|
|
54
|
+
isObjectType: () => isObjectType,
|
|
55
|
+
isObjectTypeDefinition: () => isObjectTypeDefinition,
|
|
56
|
+
isScalarTypeDefinition: () => isScalarTypeDefinition,
|
|
57
|
+
isSubType: () => isSubType,
|
|
58
|
+
isUnionTypeDefinition: () => isUnionTypeDefinition,
|
|
59
|
+
setDirectiveDefinitionArgs: () => setDirectiveDefinitionArgs,
|
|
60
|
+
setFieldArgs: () => setFieldArgs
|
|
30
61
|
});
|
|
31
62
|
module.exports = __toCommonJS(definition_exports);
|
|
63
|
+
var import_resolvers = require("./resolvers");
|
|
64
|
+
var import_reference = require("./reference");
|
|
32
65
|
var TypeKind = /* @__PURE__ */ ((TypeKind2) => {
|
|
33
66
|
TypeKind2[TypeKind2["SCALAR"] = 1] = "SCALAR";
|
|
34
67
|
TypeKind2[TypeKind2["OBJECT"] = 2] = "OBJECT";
|
|
@@ -75,3 +108,245 @@ var DirectiveKeys = /* @__PURE__ */ ((DirectiveKeys2) => {
|
|
|
75
108
|
DirectiveKeys2[DirectiveKeys2["arguments"] = 1] = "arguments";
|
|
76
109
|
return DirectiveKeys2;
|
|
77
110
|
})(DirectiveKeys || {});
|
|
111
|
+
const typeNameMetaFieldDef = "String";
|
|
112
|
+
const specifiedScalarDefinition = [1 /* SCALAR */];
|
|
113
|
+
function findObjectType(defs, typeName) {
|
|
114
|
+
const type = defs.types[typeName];
|
|
115
|
+
return (type == null ? void 0 : type[0]) === 2 /* OBJECT */ ? type : void 0;
|
|
116
|
+
}
|
|
117
|
+
function getObjectFields(def) {
|
|
118
|
+
return def[1 /* fields */];
|
|
119
|
+
}
|
|
120
|
+
function addInterfaceImplementation(defs, interfaceType, objectType) {
|
|
121
|
+
const iface = getInterfaceType(defs, interfaceType);
|
|
122
|
+
const type = defs.types[objectType];
|
|
123
|
+
if (!iface) {
|
|
124
|
+
throw new Error(
|
|
125
|
+
`Type ${interfaceType} either doesn't exist or is not an interface`
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
if (type && !isObjectTypeDefinition(type)) {
|
|
129
|
+
throw new Error(`Type ${objectType} is not an object type`);
|
|
130
|
+
}
|
|
131
|
+
if (!type) {
|
|
132
|
+
defs.types[objectType] = [
|
|
133
|
+
2 /* OBJECT */,
|
|
134
|
+
/* @__PURE__ */ Object.create(null),
|
|
135
|
+
[interfaceType]
|
|
136
|
+
];
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
let knownInterfaces = type[2 /* interfaces */];
|
|
140
|
+
if (!knownInterfaces) {
|
|
141
|
+
knownInterfaces = [];
|
|
142
|
+
type[2 /* interfaces */] = knownInterfaces;
|
|
143
|
+
}
|
|
144
|
+
if (!knownInterfaces.includes(interfaceType)) {
|
|
145
|
+
knownInterfaces.push(interfaceType);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function getField(defs, typeName, fieldName) {
|
|
149
|
+
var _a;
|
|
150
|
+
if (fieldName === "__typename") {
|
|
151
|
+
return typeNameMetaFieldDef;
|
|
152
|
+
}
|
|
153
|
+
return (_a = getOwnField(defs, typeName, fieldName)) != null ? _a : findInterfaceField(defs, typeName, fieldName);
|
|
154
|
+
}
|
|
155
|
+
function getOwnField(defs, typeName, fieldName) {
|
|
156
|
+
var _a, _b;
|
|
157
|
+
const type = defs.types[typeName];
|
|
158
|
+
if (!type) {
|
|
159
|
+
return void 0;
|
|
160
|
+
}
|
|
161
|
+
if (type[0] === 2 /* OBJECT */) {
|
|
162
|
+
return (_a = type[1 /* fields */]) == null ? void 0 : _a[fieldName];
|
|
163
|
+
}
|
|
164
|
+
if (type[0] === 3 /* INTERFACE */) {
|
|
165
|
+
return (_b = type[1 /* fields */]) == null ? void 0 : _b[fieldName];
|
|
166
|
+
}
|
|
167
|
+
return void 0;
|
|
168
|
+
}
|
|
169
|
+
function findInterfaceField(defs, typeName, fieldName) {
|
|
170
|
+
const type = defs.types[typeName];
|
|
171
|
+
if (!type) {
|
|
172
|
+
return void 0;
|
|
173
|
+
}
|
|
174
|
+
if (type[0] === 2 /* OBJECT */ && type[2 /* interfaces */]) {
|
|
175
|
+
return findField(defs, type[2 /* interfaces */], fieldName);
|
|
176
|
+
}
|
|
177
|
+
if (type[0] === 3 /* INTERFACE */ && type[2 /* interfaces */]) {
|
|
178
|
+
return findField(defs, type[2 /* interfaces */], fieldName);
|
|
179
|
+
}
|
|
180
|
+
return void 0;
|
|
181
|
+
}
|
|
182
|
+
function findField(defs, interfaceTypes, fieldName) {
|
|
183
|
+
for (const interfaceName of interfaceTypes) {
|
|
184
|
+
const ownField = getOwnField(defs, interfaceName, fieldName);
|
|
185
|
+
if (ownField !== void 0) {
|
|
186
|
+
return ownField;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return void 0;
|
|
190
|
+
}
|
|
191
|
+
function getInputObjectType(defs, typeRef) {
|
|
192
|
+
const type = defs.types[(0, import_reference.typeNameFromReference)(typeRef)];
|
|
193
|
+
return (type == null ? void 0 : type[0]) === 6 /* INPUT */ ? type : void 0;
|
|
194
|
+
}
|
|
195
|
+
function getLeafType(defs, typeRef) {
|
|
196
|
+
const typeName = (0, import_reference.typeNameFromReference)(typeRef);
|
|
197
|
+
if ((0, import_resolvers.isSpecifiedScalarType)(typeName)) {
|
|
198
|
+
return specifiedScalarDefinition;
|
|
199
|
+
}
|
|
200
|
+
const type = defs.types[typeName];
|
|
201
|
+
if ((type == null ? void 0 : type[0]) !== 5 /* ENUM */ && (type == null ? void 0 : type[0]) !== 1 /* SCALAR */) {
|
|
202
|
+
return void 0;
|
|
203
|
+
}
|
|
204
|
+
return type;
|
|
205
|
+
}
|
|
206
|
+
function isDefined(defs, typeRef) {
|
|
207
|
+
if (typeof typeRef === "number") {
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
const types = defs.types;
|
|
211
|
+
const typeName = (0, import_reference.typeNameFromReference)(typeRef);
|
|
212
|
+
return !!types[typeName] || (0, import_resolvers.isSpecifiedScalarType)(typeName);
|
|
213
|
+
}
|
|
214
|
+
function isInputType(defs, typeRef) {
|
|
215
|
+
var _a;
|
|
216
|
+
if (typeof typeRef === "number") {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
const typeName = (0, import_reference.typeNameFromReference)(typeRef);
|
|
220
|
+
const kind = (_a = defs.types[typeName]) == null ? void 0 : _a[0];
|
|
221
|
+
return (0, import_resolvers.isSpecifiedScalarType)(typeName) || kind === 5 /* ENUM */ || kind === 6 /* INPUT */ || kind === 1 /* SCALAR */;
|
|
222
|
+
}
|
|
223
|
+
function isObjectType(defs, typeRef) {
|
|
224
|
+
var _a;
|
|
225
|
+
if (typeof typeRef === "number") {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
const types = defs.types;
|
|
229
|
+
const type = (_a = types[typeRef]) != null ? _a : types[(0, import_reference.typeNameFromReference)(typeRef)];
|
|
230
|
+
return (type == null ? void 0 : type[0]) === 2 /* OBJECT */;
|
|
231
|
+
}
|
|
232
|
+
function isAbstractType(defs, typeRef) {
|
|
233
|
+
var _a;
|
|
234
|
+
if (typeof typeRef === "number") {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
const type = (_a = defs.types[typeRef]) != null ? _a : defs.types[(0, import_reference.typeNameFromReference)(typeRef)];
|
|
238
|
+
return (type == null ? void 0 : type[0]) === 4 /* UNION */ || (type == null ? void 0 : type[0]) === 3 /* INTERFACE */;
|
|
239
|
+
}
|
|
240
|
+
function getUnionType(defs, typeRef) {
|
|
241
|
+
var _a;
|
|
242
|
+
const types = defs.types;
|
|
243
|
+
const type = (_a = types[typeRef]) != null ? _a : types[(0, import_reference.typeNameFromReference)(typeRef)];
|
|
244
|
+
return (type == null ? void 0 : type[0]) === 4 /* UNION */ ? type : void 0;
|
|
245
|
+
}
|
|
246
|
+
function getInterfaceType(defs, typeRef) {
|
|
247
|
+
var _a;
|
|
248
|
+
const types = defs.types;
|
|
249
|
+
const type = (_a = types[typeRef]) != null ? _a : types[(0, import_reference.typeNameFromReference)(typeRef)];
|
|
250
|
+
return (type == null ? void 0 : type[0]) === 3 /* INTERFACE */ ? type : void 0;
|
|
251
|
+
}
|
|
252
|
+
function isSubType(defs, abstractTypeName, maybeSubTypeName) {
|
|
253
|
+
var _a, _b;
|
|
254
|
+
const union = getUnionType(defs, abstractTypeName);
|
|
255
|
+
if (union) {
|
|
256
|
+
return union[1 /* types */].includes(maybeSubTypeName);
|
|
257
|
+
}
|
|
258
|
+
const object = findObjectType(defs, maybeSubTypeName);
|
|
259
|
+
if (object) {
|
|
260
|
+
return !!((_a = object[2 /* interfaces */]) == null ? void 0 : _a.includes(abstractTypeName));
|
|
261
|
+
}
|
|
262
|
+
const iface = getInterfaceType(defs, maybeSubTypeName);
|
|
263
|
+
if (iface) {
|
|
264
|
+
return !!((_b = iface[2 /* interfaces */]) == null ? void 0 : _b.includes(abstractTypeName));
|
|
265
|
+
}
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
function getDirectiveName(tuple) {
|
|
269
|
+
return tuple[0 /* name */];
|
|
270
|
+
}
|
|
271
|
+
function isObjectTypeDefinition(type) {
|
|
272
|
+
return type[0] === 2 /* OBJECT */;
|
|
273
|
+
}
|
|
274
|
+
function isUnionTypeDefinition(type) {
|
|
275
|
+
return type[0] === 4 /* UNION */;
|
|
276
|
+
}
|
|
277
|
+
function isInterfaceTypeDefinition(type) {
|
|
278
|
+
return type[0] === 3 /* INTERFACE */;
|
|
279
|
+
}
|
|
280
|
+
function isEnumTypeDefinition(type) {
|
|
281
|
+
return type[0] === 5 /* ENUM */;
|
|
282
|
+
}
|
|
283
|
+
function isScalarTypeDefinition(type) {
|
|
284
|
+
return type[0] === 1 /* SCALAR */;
|
|
285
|
+
}
|
|
286
|
+
function isInputObjectTypeDefinition(type) {
|
|
287
|
+
return type[0] === 6 /* INPUT */;
|
|
288
|
+
}
|
|
289
|
+
function getInputValueTypeReference(inputValue) {
|
|
290
|
+
return Array.isArray(inputValue) ? inputValue[0 /* type */] : inputValue;
|
|
291
|
+
}
|
|
292
|
+
function getInputObjectFields(obj) {
|
|
293
|
+
return obj[1 /* fields */];
|
|
294
|
+
}
|
|
295
|
+
function getInputDefaultValue(inputValue) {
|
|
296
|
+
return Array.isArray(inputValue) ? inputValue[1 /* defaultValue */] : void 0;
|
|
297
|
+
}
|
|
298
|
+
function getFields(def) {
|
|
299
|
+
return def[0] === 2 /* OBJECT */ ? def[1 /* fields */] : def[1 /* fields */];
|
|
300
|
+
}
|
|
301
|
+
function getFieldTypeReference(field) {
|
|
302
|
+
return Array.isArray(field) ? field[0 /* type */] : field;
|
|
303
|
+
}
|
|
304
|
+
function getFieldArgs(field) {
|
|
305
|
+
return Array.isArray(field) ? field[1 /* arguments */] : void 0;
|
|
306
|
+
}
|
|
307
|
+
function setFieldArgs(field, args) {
|
|
308
|
+
field[1 /* arguments */] = args;
|
|
309
|
+
return args;
|
|
310
|
+
}
|
|
311
|
+
function getEnumValues(tuple) {
|
|
312
|
+
return tuple[1 /* values */];
|
|
313
|
+
}
|
|
314
|
+
function getDirectiveDefinitionArgs(directive) {
|
|
315
|
+
return directive[1 /* arguments */];
|
|
316
|
+
}
|
|
317
|
+
function setDirectiveDefinitionArgs(directive, args) {
|
|
318
|
+
directive[1 /* arguments */] = args;
|
|
319
|
+
return args;
|
|
320
|
+
}
|
|
321
|
+
function createUnionTypeDefinition(types) {
|
|
322
|
+
return [4 /* UNION */, types];
|
|
323
|
+
}
|
|
324
|
+
function createInterfaceTypeDefinition(fields, interfaces) {
|
|
325
|
+
return (interfaces == null ? void 0 : interfaces.length) ? [3 /* INTERFACE */, fields, interfaces] : [3 /* INTERFACE */, fields];
|
|
326
|
+
}
|
|
327
|
+
function createObjectTypeDefinition(fields, interfaces) {
|
|
328
|
+
return (interfaces == null ? void 0 : interfaces.length) ? [2 /* OBJECT */, fields, interfaces] : [2 /* OBJECT */, fields];
|
|
329
|
+
}
|
|
330
|
+
function createInputObjectTypeDefinition(fields) {
|
|
331
|
+
return [6 /* INPUT */, fields];
|
|
332
|
+
}
|
|
333
|
+
function createEnumTypeDefinition(values) {
|
|
334
|
+
return [5 /* ENUM */, values];
|
|
335
|
+
}
|
|
336
|
+
function createScalarTypeDefinition() {
|
|
337
|
+
return [1 /* SCALAR */];
|
|
338
|
+
}
|
|
339
|
+
function getObjectTypeInterfaces(def) {
|
|
340
|
+
var _a;
|
|
341
|
+
return (_a = def[2 /* interfaces */]) != null ? _a : [];
|
|
342
|
+
}
|
|
343
|
+
function getInterfaceTypeInterfaces(def) {
|
|
344
|
+
var _a;
|
|
345
|
+
return (_a = def[2 /* interfaces */]) != null ? _a : [];
|
|
346
|
+
}
|
|
347
|
+
function getUnionTypeMembers(tuple) {
|
|
348
|
+
return tuple[1 /* types */];
|
|
349
|
+
}
|
|
350
|
+
function getDefinitionArguments(def) {
|
|
351
|
+
return Array.isArray(def) ? def[1 /* arguments */] : void 0;
|
|
352
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/schema/definition.ts"],
|
|
4
|
-
"sourcesContent": ["export type TypeName = string; // name without wrappers, i.e. \"MyType\", but not \"[MyType]\"\nexport type SpecTypeIndex = number;\nexport type TypeReference = string | SpecTypeIndex; // e.g. \"ComplexType\" | \"ComplexType!\" | \"[ComplexType!]\" | 4 (i.e. \"ID\")\n\n// Perf: const enums are inlined in the build (+small integers are stored on the stack in v8)\nexport const enum TypeKind {\n SCALAR = 1,\n OBJECT = 2,\n INTERFACE = 3,\n UNION = 4,\n ENUM = 5,\n INPUT = 6,\n}\n\nexport type ScalarTypeDefinitionTuple = [\n kind: TypeKind.SCALAR,\n // directives?: DirectiveTuple[], // TODO ?\n];\n\nexport type ObjectTypeDefinitionTuple = [\n kind: TypeKind.OBJECT,\n fields: FieldDefinitionRecord,\n interfaces?: TypeName[],\n // directives?: DirectiveTuple[],\n];\nexport const enum ObjectKeys {\n fields = 1,\n interfaces = 2,\n}\n\nexport type InterfaceTypeDefinitionTuple = [\n kind: TypeKind.INTERFACE,\n fields: FieldDefinitionRecord,\n interfaces?: TypeName[],\n // directives?: DirectiveTuple[],\n];\nexport const enum InterfaceKeys {\n fields = 1,\n interfaces = 2,\n}\n\nexport type UnionTypeDefinitionTuple = [\n kind: TypeKind.UNION,\n types: TypeName[],\n // directives?: DirectiveTuple[],\n];\nexport const enum UnionKeys {\n types = 1,\n}\n\nexport type EnumTypeDefinitionTuple = [\n kind: TypeKind.ENUM,\n values: string[],\n // directives?: DirectiveTuple[],\n];\nexport const enum EnumKeys {\n values = 1,\n}\n\nexport type InputObjectTypeDefinitionTuple = [\n kind: TypeKind.INPUT,\n fields: InputValueDefinitionRecord,\n // directives?: DirectiveTuple[],\n];\nexport const enum InputObjectKeys {\n fields = 1,\n}\n\nexport type TypeDefinitionTuple =\n | ScalarTypeDefinitionTuple\n | ObjectTypeDefinitionTuple\n | InterfaceTypeDefinitionTuple\n | UnionTypeDefinitionTuple\n | EnumTypeDefinitionTuple\n | InputObjectTypeDefinitionTuple;\n\nexport type CompositeTypeTuple =\n | ObjectTypeDefinitionTuple\n | InterfaceTypeDefinitionTuple\n | UnionTypeDefinitionTuple;\n\nexport type FieldDefinitionTuple = [\n type: TypeReference,\n arguments: InputValueDefinitionRecord,\n // directives?: DirectiveTuple[],\n];\nexport const enum FieldKeys {\n type = 0,\n arguments = 1,\n}\nexport type FieldDefinition = TypeReference | FieldDefinitionTuple;\nexport type FieldDefinitionRecord = Record<string, FieldDefinition>;\n\nexport type InputValueDefinitionTuple = [\n type: TypeReference,\n defaultValue: unknown,\n // directives?: DirectiveTuple[],\n];\nexport const enum InputValueKeys {\n type = 0,\n defaultValue = 1,\n}\nexport type InputValueDefinition = TypeReference | InputValueDefinitionTuple;\nexport type InputValueDefinitionRecord = Record<string, InputValueDefinition>;\n\nexport type DirectiveName = string;\nexport type DirectiveTuple = [\n name: DirectiveName,\n arguments?: Record<string, unknown>, // JS values (cannot be a variable inside schema definition, so it is fine)\n];\nexport type DirectiveDefinitionTuple = [\n name: DirectiveName,\n arguments?: InputValueDefinitionRecord,\n];\nexport const enum DirectiveKeys {\n name = 0,\n arguments = 1,\n}\n\nexport type TypeDefinitionsRecord = Record<TypeName, TypeDefinitionTuple>;\nexport type InterfaceImplementationsRecord = Record<TypeName, TypeName[]>;\n\nexport type OperationTypes = {\n query?: TypeName;\n mutation?: TypeName;\n subscription?: TypeName;\n};\n\nexport type SchemaDefinitions = {\n types: TypeDefinitionsRecord;\n directives?: DirectiveDefinitionTuple[];\n // implementations?: InterfaceImplementationsRecord; // TODO?\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { isSpecifiedScalarType } from \"./resolvers\";\nimport { TypeName, TypeReference, typeNameFromReference } from \"./reference\";\n\n// Perf: const enums are inlined in the build (+small integers are stored on the stack in v8)\n// IMPORTANT: const enums MUST NOT be exported, otherwise esbuild struggles to inline them: use exported functions\nconst enum TypeKind {\n SCALAR = 1,\n OBJECT = 2,\n INTERFACE = 3,\n UNION = 4,\n ENUM = 5,\n INPUT = 6,\n}\n\nexport type ScalarTypeDefinitionTuple = [\n kind: TypeKind.SCALAR,\n // directives?: DirectiveTuple[], // TODO ?\n];\n\nexport type ObjectTypeDefinitionTuple = [\n kind: TypeKind.OBJECT,\n fields: FieldDefinitionRecord,\n interfaces?: TypeName[],\n // directives?: DirectiveTuple[],\n];\nconst enum ObjectKeys {\n fields = 1,\n interfaces = 2,\n}\n\nexport type InterfaceTypeDefinitionTuple = [\n kind: TypeKind.INTERFACE,\n fields: FieldDefinitionRecord,\n interfaces?: TypeName[],\n // directives?: DirectiveTuple[],\n];\nconst enum InterfaceKeys {\n fields = 1,\n interfaces = 2,\n}\n\nexport type UnionTypeDefinitionTuple = [\n kind: TypeKind.UNION,\n types: TypeName[],\n // directives?: DirectiveTuple[],\n];\nconst enum UnionKeys {\n types = 1,\n}\n\nexport type EnumTypeDefinitionTuple = [\n kind: TypeKind.ENUM,\n values: string[],\n // directives?: DirectiveTuple[],\n];\nconst enum EnumKeys {\n values = 1,\n}\n\nexport type InputObjectTypeDefinitionTuple = [\n kind: TypeKind.INPUT,\n fields: InputValueDefinitionRecord,\n // directives?: DirectiveTuple[],\n];\nconst enum InputObjectKeys {\n fields = 1,\n}\n\nexport type TypeDefinitionTuple =\n | ScalarTypeDefinitionTuple\n | ObjectTypeDefinitionTuple\n | InterfaceTypeDefinitionTuple\n | UnionTypeDefinitionTuple\n | EnumTypeDefinitionTuple\n | InputObjectTypeDefinitionTuple;\n\nexport type CompositeTypeTuple =\n | ObjectTypeDefinitionTuple\n | InterfaceTypeDefinitionTuple\n | UnionTypeDefinitionTuple;\n\nexport type FieldDefinitionTuple = [\n type: TypeReference,\n arguments: InputValueDefinitionRecord,\n // directives?: DirectiveTuple[],\n];\nconst enum FieldKeys {\n type = 0,\n arguments = 1,\n}\nexport type FieldDefinition = TypeReference | FieldDefinitionTuple;\nexport type FieldDefinitionRecord = Record<string, FieldDefinition>;\n\nexport type InputValueDefinitionTuple = [\n type: TypeReference,\n defaultValue: unknown,\n // directives?: DirectiveTuple[],\n];\nconst enum InputValueKeys {\n type = 0,\n defaultValue = 1,\n}\nexport type InputValueDefinition = TypeReference | InputValueDefinitionTuple;\nexport type InputValueDefinitionRecord = Record<string, InputValueDefinition>;\n\nexport type DirectiveName = string;\nexport type DirectiveTuple = [\n name: DirectiveName,\n arguments?: Record<string, unknown>, // JS values (cannot be a variable inside schema definition, so it is fine)\n];\nexport type DirectiveDefinitionTuple = [\n name: DirectiveName,\n arguments?: InputValueDefinitionRecord,\n];\nconst enum DirectiveKeys {\n name = 0,\n arguments = 1,\n}\n\nexport type TypeDefinitionsRecord = Record<TypeName, TypeDefinitionTuple>;\nexport type InterfaceImplementationsRecord = Record<TypeName, TypeName[]>;\n\nexport type OperationTypes = {\n query?: TypeName;\n mutation?: TypeName;\n subscription?: TypeName;\n};\n\nexport type SchemaDefinitions = {\n types: TypeDefinitionsRecord;\n directives?: DirectiveDefinitionTuple[];\n // implementations?: InterfaceImplementationsRecord; // TODO?\n};\n\nconst typeNameMetaFieldDef: FieldDefinition = \"String\";\nconst specifiedScalarDefinition: ScalarTypeDefinitionTuple = [TypeKind.SCALAR];\n\nexport function findObjectType(\n defs: SchemaDefinitions,\n typeName: TypeName,\n): ObjectTypeDefinitionTuple | undefined {\n const type = defs.types[typeName];\n return type?.[0] === TypeKind.OBJECT ? type : undefined;\n}\n\nexport function getObjectFields(\n def: ObjectTypeDefinitionTuple,\n): FieldDefinitionRecord {\n return def[ObjectKeys.fields];\n}\n\nexport function addInterfaceImplementation(\n defs: SchemaDefinitions,\n interfaceType: TypeName,\n objectType: TypeName,\n) {\n const iface = getInterfaceType(defs, interfaceType);\n const type = defs.types[objectType];\n\n if (!iface) {\n throw new Error(\n `Type ${interfaceType} either doesn't exist or is not an interface`,\n );\n }\n if (type && !isObjectTypeDefinition(type)) {\n throw new Error(`Type ${objectType} is not an object type`);\n }\n if (!type) {\n defs.types[objectType] = [\n TypeKind.OBJECT,\n Object.create(null),\n [interfaceType],\n ];\n return;\n }\n let knownInterfaces = type[ObjectKeys.interfaces];\n if (!knownInterfaces) {\n knownInterfaces = [];\n type[ObjectKeys.interfaces] = knownInterfaces;\n }\n if (!knownInterfaces.includes(interfaceType)) {\n knownInterfaces.push(interfaceType);\n }\n}\n\nexport function getField(\n defs: SchemaDefinitions,\n typeName: TypeName,\n fieldName: string,\n) {\n if (fieldName === \"__typename\") {\n return typeNameMetaFieldDef;\n }\n return (\n getOwnField(defs, typeName, fieldName) ??\n findInterfaceField(defs, typeName, fieldName)\n );\n}\n\nfunction getOwnField(\n defs: SchemaDefinitions,\n typeName: TypeName,\n fieldName: string,\n): FieldDefinition | undefined {\n const type = defs.types[typeName];\n if (!type) {\n return undefined;\n }\n if (type[0] === TypeKind.OBJECT) {\n return type[ObjectKeys.fields]?.[fieldName];\n }\n if (type[0] === TypeKind.INTERFACE) {\n return type[InterfaceKeys.fields]?.[fieldName];\n }\n return undefined;\n}\n\nfunction findInterfaceField(\n defs: SchemaDefinitions,\n typeName: TypeName,\n fieldName: string,\n) {\n const type = defs.types[typeName];\n if (!type) {\n return undefined;\n }\n if (type[0] === TypeKind.OBJECT && type[ObjectKeys.interfaces]) {\n return findField(defs, type[ObjectKeys.interfaces], fieldName);\n }\n if (type[0] === TypeKind.INTERFACE && type[InterfaceKeys.interfaces]) {\n return findField(defs, type[InterfaceKeys.interfaces], fieldName);\n }\n return undefined;\n}\n\nfunction findField(\n defs: SchemaDefinitions,\n interfaceTypes: TypeName[],\n fieldName: string,\n) {\n // TODO: merge field definition from all interface types to ensure all necessary arguments are present\n // (or maybe instead always encode all arguments in the schema fragment for simplicity?)\n for (const interfaceName of interfaceTypes) {\n const ownField = getOwnField(defs, interfaceName, fieldName);\n if (ownField !== undefined) {\n return ownField;\n }\n }\n return undefined;\n}\n\nexport function getInputObjectType(\n defs: SchemaDefinitions,\n typeRef: TypeReference,\n): InputObjectTypeDefinitionTuple | undefined {\n const type = defs.types[typeNameFromReference(typeRef)];\n return type?.[0] === TypeKind.INPUT ? type : undefined;\n}\n\nexport function getLeafType(\n defs: SchemaDefinitions,\n typeRef: TypeReference,\n): EnumTypeDefinitionTuple | ScalarTypeDefinitionTuple | undefined {\n const typeName = typeNameFromReference(typeRef);\n\n if (isSpecifiedScalarType(typeName)) {\n return specifiedScalarDefinition;\n }\n const type = defs.types[typeName];\n if (type?.[0] !== TypeKind.ENUM && type?.[0] !== TypeKind.SCALAR) {\n return undefined;\n }\n return type;\n}\n\nexport function isDefined(\n defs: SchemaDefinitions,\n typeRef: TypeReference,\n): boolean {\n if (typeof typeRef === \"number\") {\n // Fast-path: spec type\n return true;\n }\n const types = defs.types;\n const typeName = typeNameFromReference(typeRef);\n return !!types[typeName] || isSpecifiedScalarType(typeName);\n}\n\nexport function isInputType(\n defs: SchemaDefinitions,\n typeRef: TypeReference,\n): boolean {\n if (typeof typeRef === \"number\") {\n // Fast-path: all spec types are input types\n return true;\n }\n const typeName = typeNameFromReference(typeRef);\n const kind = defs.types[typeName]?.[0];\n return (\n isSpecifiedScalarType(typeName) ||\n kind === TypeKind.ENUM ||\n kind === TypeKind.INPUT ||\n kind === TypeKind.SCALAR\n );\n}\n\nexport function isObjectType(\n defs: SchemaDefinitions,\n typeRef: TypeReference,\n): boolean {\n if (typeof typeRef === \"number\") {\n // Fast-path: all spec types are scalars\n return false;\n }\n const types = defs.types;\n const type = types[typeRef] ?? types[typeNameFromReference(typeRef)];\n return type?.[0] === TypeKind.OBJECT;\n}\n\nexport function isAbstractType(\n defs: SchemaDefinitions,\n typeRef: TypeReference,\n): boolean {\n if (typeof typeRef === \"number\") {\n // Fast-path: all spec types are scalars\n return false;\n }\n const type =\n defs.types[typeRef] ?? defs.types[typeNameFromReference(typeRef)];\n return type?.[0] === TypeKind.UNION || type?.[0] === TypeKind.INTERFACE;\n}\n\nexport function getUnionType(\n defs: SchemaDefinitions,\n typeRef: TypeReference,\n): UnionTypeDefinitionTuple | undefined {\n const types = defs.types;\n const type = types[typeRef] ?? types[typeNameFromReference(typeRef)];\n return type?.[0] === TypeKind.UNION ? type : undefined;\n}\n\nexport function getInterfaceType(\n defs: SchemaDefinitions,\n typeRef: TypeReference,\n): InterfaceTypeDefinitionTuple | undefined {\n const types = defs.types;\n const type = types[typeRef] ?? types[typeNameFromReference(typeRef)];\n return type?.[0] === TypeKind.INTERFACE ? type : undefined;\n}\n\nexport function isSubType(\n defs: SchemaDefinitions,\n abstractTypeName: TypeName,\n maybeSubTypeName: TypeName,\n): boolean {\n const union = getUnionType(defs, abstractTypeName);\n if (union) {\n return union[UnionKeys.types].includes(maybeSubTypeName);\n }\n const object = findObjectType(defs, maybeSubTypeName);\n if (object) {\n return !!object[ObjectKeys.interfaces]?.includes(abstractTypeName);\n }\n const iface = getInterfaceType(defs, maybeSubTypeName);\n if (iface) {\n return !!iface[InterfaceKeys.interfaces]?.includes(abstractTypeName);\n }\n return false;\n}\n\nexport function getDirectiveName(tuple: DirectiveDefinitionTuple): string {\n return tuple[DirectiveKeys.name];\n}\n\nexport function isObjectTypeDefinition(\n type: TypeDefinitionTuple,\n): type is ObjectTypeDefinitionTuple {\n return type[0] === TypeKind.OBJECT;\n}\n\nexport function isUnionTypeDefinition(\n type: TypeDefinitionTuple,\n): type is UnionTypeDefinitionTuple {\n return type[0] === TypeKind.UNION;\n}\n\nexport function isInterfaceTypeDefinition(\n type: TypeDefinitionTuple,\n): type is InterfaceTypeDefinitionTuple {\n return type[0] === TypeKind.INTERFACE;\n}\n\nexport function isEnumTypeDefinition(\n type: TypeDefinitionTuple,\n): type is EnumTypeDefinitionTuple {\n return type[0] === TypeKind.ENUM;\n}\n\nexport function isScalarTypeDefinition(\n type: TypeDefinitionTuple,\n): type is ScalarTypeDefinitionTuple {\n return type[0] === TypeKind.SCALAR;\n}\n\nexport function isInputObjectTypeDefinition(\n type: TypeDefinitionTuple,\n): type is InputObjectTypeDefinitionTuple {\n return type[0] === TypeKind.INPUT;\n}\n\nexport function getInputValueTypeReference(\n inputValue: InputValueDefinition,\n): TypeReference {\n return Array.isArray(inputValue)\n ? inputValue[InputValueKeys.type]\n : inputValue;\n}\n\nexport function getInputObjectFields(\n obj: InputObjectTypeDefinitionTuple,\n): InputValueDefinitionRecord {\n return obj[InputObjectKeys.fields];\n}\n\nexport function getInputDefaultValue(\n inputValue: InputValueDefinition,\n): unknown | undefined {\n return Array.isArray(inputValue)\n ? inputValue[InputValueKeys.defaultValue]\n : undefined;\n}\n\nexport function getFields(\n def: ObjectTypeDefinitionTuple | InterfaceTypeDefinitionTuple,\n): FieldDefinitionRecord {\n return def[0] === TypeKind.OBJECT\n ? def[ObjectKeys.fields]\n : def[InterfaceKeys.fields];\n}\n\nexport function getFieldTypeReference(field: FieldDefinition): TypeReference {\n return Array.isArray(field) ? field[FieldKeys.type] : field;\n}\n\nexport function getFieldArgs(\n field: FieldDefinition,\n): InputValueDefinitionRecord | undefined {\n return Array.isArray(field) ? field[FieldKeys.arguments] : undefined;\n}\n\nexport function setFieldArgs(\n field: FieldDefinitionTuple,\n args: InputValueDefinitionRecord,\n): InputValueDefinitionRecord {\n field[FieldKeys.arguments] = args;\n return args;\n}\n\nexport function getEnumValues(tuple: EnumTypeDefinitionTuple): string[] {\n return tuple[EnumKeys.values];\n}\n\nexport function getDirectiveDefinitionArgs(\n directive: DirectiveDefinitionTuple,\n): InputValueDefinitionRecord | undefined {\n return directive[DirectiveKeys.arguments];\n}\n\nexport function setDirectiveDefinitionArgs(\n directive: DirectiveDefinitionTuple,\n args: InputValueDefinitionRecord,\n): InputValueDefinitionRecord {\n directive[DirectiveKeys.arguments] = args;\n return args;\n}\n\nexport function createUnionTypeDefinition(\n types: TypeName[],\n): UnionTypeDefinitionTuple {\n return [TypeKind.UNION, types];\n}\n\nexport function createInterfaceTypeDefinition(\n fields: FieldDefinitionRecord,\n interfaces?: TypeName[],\n): InterfaceTypeDefinitionTuple {\n return interfaces?.length\n ? [TypeKind.INTERFACE, fields, interfaces]\n : [TypeKind.INTERFACE, fields];\n}\n\nexport function createObjectTypeDefinition(\n fields: FieldDefinitionRecord,\n interfaces?: TypeName[],\n): ObjectTypeDefinitionTuple {\n return interfaces?.length\n ? [TypeKind.OBJECT, fields, interfaces]\n : [TypeKind.OBJECT, fields];\n}\n\nexport function createInputObjectTypeDefinition(\n fields: InputValueDefinitionRecord,\n): InputObjectTypeDefinitionTuple {\n return [TypeKind.INPUT, fields];\n}\n\nexport function createEnumTypeDefinition(\n values: string[],\n): EnumTypeDefinitionTuple {\n return [TypeKind.ENUM, values];\n}\n\nexport function createScalarTypeDefinition(): ScalarTypeDefinitionTuple {\n return [TypeKind.SCALAR];\n}\n\nexport function getObjectTypeInterfaces(\n def: ObjectTypeDefinitionTuple,\n): TypeName[] {\n return def[ObjectKeys.interfaces] ?? [];\n}\n\nexport function getInterfaceTypeInterfaces(\n def: InterfaceTypeDefinitionTuple,\n): TypeName[] {\n return def[InterfaceKeys.interfaces] ?? [];\n}\n\nexport function getUnionTypeMembers(\n tuple: UnionTypeDefinitionTuple,\n): TypeName[] {\n return tuple[UnionKeys.types];\n}\n\nexport function getDefinitionArguments(\n def: FieldDefinition | DirectiveDefinitionTuple,\n): InputValueDefinitionRecord | undefined {\n // Note: both FieldDefinition and DirectiveDefinition store arguments at the same position\n return Array.isArray(def) ? def[FieldKeys.arguments] : undefined;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAsC;AACtC,uBAA+D;AAI/D,IAAW,WAAX,kBAAWA,cAAX;AACE,EAAAA,oBAAA,YAAS,KAAT;AACA,EAAAA,oBAAA,YAAS,KAAT;AACA,EAAAA,oBAAA,eAAY,KAAZ;AACA,EAAAA,oBAAA,WAAQ,KAAR;AACA,EAAAA,oBAAA,UAAO,KAAP;AACA,EAAAA,oBAAA,WAAQ,K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