@soda-gql/core 0.10.2 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{index-Cbo0WJHs.d.ts → index-DPtgl2f4.d.ts} +231 -228
- package/dist/index-DPtgl2f4.d.ts.map +1 -0
- package/dist/{index-gHe-Lwi7.d.cts → index-IMOOkvQf.d.cts} +231 -228
- package/dist/index-IMOOkvQf.d.cts.map +1 -0
- package/dist/index.cjs +113 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +113 -87
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.cts +1 -1
- package/dist/runtime.d.ts +1 -1
- package/package.json +1 -1
- package/dist/index-Cbo0WJHs.d.ts.map +0 -1
- package/dist/index-gHe-Lwi7.d.cts.map +0 -1
|
@@ -14,10 +14,18 @@ import { TypedDocumentNode } from "@graphql-typed-document-node/core";
|
|
|
14
14
|
* @module
|
|
15
15
|
*/
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
* Subset of GraphQL DirectiveLocation enum relevant for soda-gql.
|
|
17
|
+
* Executable directive locations (used in operations/fragments).
|
|
19
18
|
*/
|
|
20
|
-
type
|
|
19
|
+
type ExecutableDirectiveLocation = "QUERY" | "MUTATION" | "SUBSCRIPTION" | "FIELD" | "FRAGMENT_DEFINITION" | "FRAGMENT_SPREAD" | "INLINE_FRAGMENT" | "VARIABLE_DEFINITION";
|
|
20
|
+
/**
|
|
21
|
+
* Type system directive locations (used in schema definitions).
|
|
22
|
+
*/
|
|
23
|
+
type TypeSystemDirectiveLocation = "SCHEMA" | "SCALAR" | "OBJECT" | "FIELD_DEFINITION" | "ARGUMENT_DEFINITION" | "INTERFACE" | "UNION" | "ENUM" | "ENUM_VALUE" | "INPUT_OBJECT" | "INPUT_FIELD_DEFINITION";
|
|
24
|
+
/**
|
|
25
|
+
* All valid locations where a directive can be applied.
|
|
26
|
+
* Matches GraphQL specification DirectiveLocation enum.
|
|
27
|
+
*/
|
|
28
|
+
type DirectiveLocation = ExecutableDirectiveLocation | TypeSystemDirectiveLocation;
|
|
21
29
|
/**
|
|
22
30
|
* Brand interface for DirectiveRef type information.
|
|
23
31
|
* Contains the directive name and valid locations.
|
|
@@ -26,14 +34,28 @@ interface AnyDirectiveRefBrand {
|
|
|
26
34
|
readonly directiveName: string;
|
|
27
35
|
readonly locations: readonly DirectiveLocation[];
|
|
28
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Type specifier for a directive argument.
|
|
39
|
+
* Used to enable enum detection when building directive arguments.
|
|
40
|
+
*/
|
|
41
|
+
type DirectiveArgumentSpecifier = {
|
|
42
|
+
readonly kind: "scalar" | "enum" | "input";
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly modifier: string;
|
|
45
|
+
};
|
|
29
46
|
/**
|
|
30
47
|
* Internal structure of a DirectiveRef.
|
|
31
|
-
* Contains the directive name, arguments, and
|
|
48
|
+
* Contains the directive name, arguments, valid locations, and optional argument specifiers.
|
|
32
49
|
*/
|
|
33
50
|
type DirectiveRefInner = {
|
|
34
51
|
readonly name: string;
|
|
35
52
|
readonly arguments: Readonly<Record<string, unknown>>;
|
|
36
53
|
readonly locations: readonly DirectiveLocation[];
|
|
54
|
+
/**
|
|
55
|
+
* Type specifiers for arguments, enabling enum detection.
|
|
56
|
+
* Generated by codegen for typed directives.
|
|
57
|
+
*/
|
|
58
|
+
readonly argumentSpecs?: Readonly<Record<string, DirectiveArgumentSpecifier>>;
|
|
37
59
|
};
|
|
38
60
|
declare const __DIRECTIVE_REF_BRAND__: unique symbol;
|
|
39
61
|
/**
|
|
@@ -225,7 +247,7 @@ type FieldSelectionTemplateOf<TSchema extends AnyGraphqlSchema, TTypeName$1 exte
|
|
|
225
247
|
union: AnyNestedUnion;
|
|
226
248
|
} : never)> : never;
|
|
227
249
|
/** Resolve the data shape produced by a set of field selections. */
|
|
228
|
-
type InferFields<TSchema extends AnyGraphqlSchema, TFields
|
|
250
|
+
type InferFields<TSchema extends AnyGraphqlSchema, TFields extends AnyFields> = { [_ in TSchema["label"]]: { [TAliasName in keyof TFields]: InferField<TSchema, TFields[TAliasName]> } & {} }[TSchema["label"]];
|
|
229
251
|
/** Resolve the data shape for a single field reference, including nested objects/unions. */
|
|
230
252
|
type InferField<TSchema extends AnyGraphqlSchema, TSelection extends AnyFieldSelection> = (TSelection extends {
|
|
231
253
|
type: infer TSpecifier extends OutputObjectSpecifier;
|
|
@@ -238,20 +260,37 @@ type InferField<TSchema extends AnyGraphqlSchema, TSelection extends AnyFieldSel
|
|
|
238
260
|
} ? GetModifiedType<InferOutputProfile<TSchema, TSpecifier>, TSpecifier["modifier"]> : never);
|
|
239
261
|
//#endregion
|
|
240
262
|
//#region packages/core/src/composer/build-document.d.ts
|
|
263
|
+
/**
|
|
264
|
+
* Context for determining if a value should be output as an enum.
|
|
265
|
+
* Contains the schema for looking up nested input types and the current type specifier.
|
|
266
|
+
*/
|
|
267
|
+
type EnumLookup = {
|
|
268
|
+
schema: AnyGraphqlSchema;
|
|
269
|
+
/** Type specifier for the current value. null means enum detection is skipped. */
|
|
270
|
+
typeSpecifier: InputTypeSpecifier | null;
|
|
271
|
+
};
|
|
241
272
|
/**
|
|
242
273
|
* Converts an assignable input value to a GraphQL AST ValueNode.
|
|
243
274
|
*
|
|
244
275
|
* Handles primitives, arrays, objects, and variable references.
|
|
245
276
|
* Returns null for undefined values (field is omitted).
|
|
277
|
+
*
|
|
278
|
+
* @param value - The value to convert
|
|
279
|
+
* @param enumLookup - Context for enum detection. String values will be output
|
|
280
|
+
* as Kind.ENUM if typeSpecifier indicates an enum type.
|
|
246
281
|
*/
|
|
247
|
-
declare const buildArgumentValue: (value: AnyAssignableInputValue) => ValueNode | null;
|
|
282
|
+
declare const buildArgumentValue: (value: AnyAssignableInputValue, enumLookup: EnumLookup) => ValueNode | null;
|
|
248
283
|
/**
|
|
249
284
|
* Converts a constant value to a GraphQL AST ConstValueNode.
|
|
250
285
|
*
|
|
251
286
|
* Unlike `buildArgumentValue`, this only handles literal values
|
|
252
287
|
* (no variable references). Used for default values.
|
|
288
|
+
*
|
|
289
|
+
* @param value - The constant value to convert
|
|
290
|
+
* @param enumLookup - Context for enum detection. String values will be output
|
|
291
|
+
* as Kind.ENUM if typeSpecifier indicates an enum type.
|
|
253
292
|
*/
|
|
254
|
-
declare const buildConstValueNode: (value: ConstValue) => ConstValueNode | null;
|
|
293
|
+
declare const buildConstValueNode: (value: ConstValue, enumLookup: EnumLookup) => ConstValueNode | null;
|
|
255
294
|
/**
|
|
256
295
|
* Wraps a named type with modifiers (non-null, list).
|
|
257
296
|
*
|
|
@@ -276,15 +315,16 @@ declare const buildOperationTypeNode: (operation: OperationType) => OperationTyp
|
|
|
276
315
|
* a GraphQL document AST. The result can be used with any GraphQL
|
|
277
316
|
* client that supports TypedDocumentNode.
|
|
278
317
|
*
|
|
279
|
-
* @param options - Operation configuration (name, type, variables, fields)
|
|
318
|
+
* @param options - Operation configuration (name, type, variables, fields, schema)
|
|
280
319
|
* @returns TypedDocumentNode with inferred input/output types
|
|
281
320
|
*/
|
|
282
|
-
declare const buildDocument: <TSchema extends AnyGraphqlSchema, TFields
|
|
321
|
+
declare const buildDocument: <TSchema extends AnyGraphqlSchema, TFields extends AnyFields, TVarDefinitions extends InputTypeSpecifiers>(options: {
|
|
283
322
|
operationName: string;
|
|
284
323
|
operationType: OperationType;
|
|
285
324
|
variables: TVarDefinitions;
|
|
286
|
-
fields: TFields
|
|
287
|
-
|
|
325
|
+
fields: TFields;
|
|
326
|
+
schema: TSchema;
|
|
327
|
+
}) => TypedDocumentNode<InferFields<TSchema, TFields>, ConstAssignableInput<TSchema, TVarDefinitions>>;
|
|
288
328
|
//#endregion
|
|
289
329
|
//#region packages/core/src/utils/type-utils.d.ts
|
|
290
330
|
type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends ((x: infer I) => void) ? I : never;
|
|
@@ -387,6 +427,36 @@ declare const createDirectiveMethod: <TDirectiveName extends string, const TLoca
|
|
|
387
427
|
directiveName: TDirectiveName;
|
|
388
428
|
locations: TLocations;
|
|
389
429
|
}>);
|
|
430
|
+
/**
|
|
431
|
+
* Type for directive argument specifiers.
|
|
432
|
+
* Maps argument names to their type information.
|
|
433
|
+
*/
|
|
434
|
+
type DirectiveArgumentSpecifiers = {
|
|
435
|
+
readonly [argName: string]: DirectiveArgumentSpecifier;
|
|
436
|
+
};
|
|
437
|
+
/**
|
|
438
|
+
* Creates a typed directive method with argument type specifiers.
|
|
439
|
+
* Enables enum value output in directive arguments.
|
|
440
|
+
*
|
|
441
|
+
* @param name - The directive name (without @)
|
|
442
|
+
* @param locations - Valid locations where the directive can be applied
|
|
443
|
+
* @param argSpecs - Type specifiers for directive arguments
|
|
444
|
+
* @returns A function that creates DirectiveRef instances with argument type info
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* ```typescript
|
|
448
|
+
* const authMethod = createTypedDirectiveMethod(
|
|
449
|
+
* "auth",
|
|
450
|
+
* ["FIELD"] as const,
|
|
451
|
+
* { role: { kind: "enum", name: "Role", modifier: "!" } }
|
|
452
|
+
* );
|
|
453
|
+
* const authDirective = authMethod({ role: "ADMIN" });
|
|
454
|
+
* ```
|
|
455
|
+
*/
|
|
456
|
+
declare const createTypedDirectiveMethod: <TDirectiveName extends string, const TLocations extends readonly DirectiveLocation[], const TArgSpecs extends DirectiveArgumentSpecifiers>(name: TDirectiveName, locations: TLocations, argSpecs: TArgSpecs) => (<TArgs extends Record<string, unknown>>(args: TArgs) => DirectiveRef<{
|
|
457
|
+
directiveName: TDirectiveName;
|
|
458
|
+
locations: TLocations;
|
|
459
|
+
}>);
|
|
390
460
|
/**
|
|
391
461
|
* Creates the standard GraphQL directives (@skip, @include).
|
|
392
462
|
* These are always available regardless of schema definition.
|
|
@@ -479,7 +549,7 @@ declare const empty: () => EmptyObject;
|
|
|
479
549
|
* tooling `f`/`fields`/`_` aliases provide ergonomic access to GraphQL fields
|
|
480
550
|
* while preserving the original schema information for inference.
|
|
481
551
|
*/
|
|
482
|
-
type FieldsBuilder<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"] & string, TVariableDefinitions extends InputTypeSpecifiers, TFields
|
|
552
|
+
type FieldsBuilder<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"] & string, TVariableDefinitions extends InputTypeSpecifiers, TFields extends AnyFields> = (tools: NoInfer<FieldsBuilderTools<TSchema, TTypeName$1, TVariableDefinitions>>) => TFields;
|
|
483
553
|
/**
|
|
484
554
|
* Tools provided to field builder callbacks.
|
|
485
555
|
* - `f`: Field selection factories for the current type
|
|
@@ -493,7 +563,7 @@ type FieldsBuilderTools<TSchema extends AnyGraphqlSchema, TTypeName$1 extends ke
|
|
|
493
563
|
* Builder for nested object field selections.
|
|
494
564
|
* Used when a field returns an object type requiring sub-selections.
|
|
495
565
|
*/
|
|
496
|
-
type NestedObjectFieldsBuilder<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"] & string, TFields
|
|
566
|
+
type NestedObjectFieldsBuilder<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"] & string, TFields extends AnyNestedObject> = (tools: NoInfer<NestedObjectFieldsBuilderTools<TSchema, TTypeName$1>>) => TFields;
|
|
497
567
|
/**
|
|
498
568
|
* Tools for nested object builders (no variable access).
|
|
499
569
|
* @internal
|
|
@@ -651,7 +721,7 @@ declare abstract class GqlElement<TDefinition extends object, TInfer extends obj
|
|
|
651
721
|
/**
|
|
652
722
|
* Type alias for any Fragment instance.
|
|
653
723
|
*/
|
|
654
|
-
type AnyFragment = Fragment<string, any, AnyFields, any
|
|
724
|
+
type AnyFragment = Fragment<string, any, AnyFields, any>;
|
|
655
725
|
/**
|
|
656
726
|
* Type inference metadata for fragments.
|
|
657
727
|
* Access via `typeof fragment.$infer`.
|
|
@@ -664,12 +734,12 @@ type FragmentInferMeta<TVariables, TOutput extends object> = {
|
|
|
664
734
|
* Internal artifact shape produced by fragment evaluation.
|
|
665
735
|
* @internal
|
|
666
736
|
*/
|
|
667
|
-
interface FragmentArtifact<TTypeName$1 extends string, TVariables extends Partial<AnyAssignableInput> | void, TFields
|
|
737
|
+
interface FragmentArtifact<TTypeName$1 extends string, TVariables extends Partial<AnyAssignableInput> | void, TFields extends Partial<AnyFields>> {
|
|
668
738
|
readonly typename: TTypeName$1;
|
|
669
|
-
readonly key:
|
|
739
|
+
readonly key: string | undefined;
|
|
670
740
|
readonly schemaLabel: string;
|
|
671
741
|
readonly variableDefinitions: InputTypeSpecifiers;
|
|
672
|
-
readonly spread: (variables: TVariables) => TFields
|
|
742
|
+
readonly spread: (variables: TVariables) => TFields;
|
|
673
743
|
}
|
|
674
744
|
declare const __FRAGMENT_BRAND__: unique symbol;
|
|
675
745
|
/**
|
|
@@ -682,15 +752,14 @@ declare const __FRAGMENT_BRAND__: unique symbol;
|
|
|
682
752
|
* @template TVariables - Variables required when spreading
|
|
683
753
|
* @template TFields - The selected fields structure
|
|
684
754
|
* @template TOutput - Inferred output type from selected fields
|
|
685
|
-
* @template TKey - Optional unique key for prebuilt type lookup
|
|
686
755
|
*/
|
|
687
|
-
declare class Fragment<TTypeName$1 extends string, TVariables extends Partial<AnyAssignableInput> | void, TFields
|
|
756
|
+
declare class Fragment<TTypeName$1 extends string, TVariables extends Partial<AnyAssignableInput> | void, TFields extends Partial<AnyFields>, TOutput extends object> extends GqlElement<FragmentArtifact<TTypeName$1, TVariables, TFields>, FragmentInferMeta<TVariables, TOutput>> implements FragmentArtifact<TTypeName$1, TVariables, TFields> {
|
|
688
757
|
private readonly [__FRAGMENT_BRAND__];
|
|
689
758
|
private constructor();
|
|
690
759
|
/** The GraphQL type name this fragment selects from. */
|
|
691
760
|
get typename(): TTypeName$1;
|
|
692
761
|
/** Optional unique key for prebuilt type lookup. */
|
|
693
|
-
get key():
|
|
762
|
+
get key(): string | undefined;
|
|
694
763
|
/** The schema label this fragment belongs to. */
|
|
695
764
|
get schemaLabel(): string;
|
|
696
765
|
/** Variable definitions for this fragment. */
|
|
@@ -699,23 +768,23 @@ declare class Fragment<TTypeName$1 extends string, TVariables extends Partial<An
|
|
|
699
768
|
* Spreads this fragment's fields into a parent selection.
|
|
700
769
|
* Pass variables if the fragment defines any.
|
|
701
770
|
*/
|
|
702
|
-
get spread(): (variables: TVariables) => TFields
|
|
771
|
+
get spread(): (variables: TVariables) => TFields;
|
|
703
772
|
/**
|
|
704
773
|
* Creates a new Fragment instance.
|
|
705
774
|
* Prefer using the `gql(({ fragment }) => ...)` API instead.
|
|
706
775
|
* @internal
|
|
707
776
|
*/
|
|
708
|
-
static create<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"] & string, TVariableDefinitions extends InputTypeSpecifiers, TFields
|
|
777
|
+
static create<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"] & string, TVariableDefinitions extends InputTypeSpecifiers, TFields extends AnyFields>(define: () => {
|
|
709
778
|
typename: TTypeName$1;
|
|
710
|
-
key:
|
|
779
|
+
key: string | undefined;
|
|
711
780
|
schemaLabel: TSchema["label"];
|
|
712
781
|
variableDefinitions: TVariableDefinitions;
|
|
713
|
-
spread: (variables: OptionalArg<AssignableInput<TSchema, TVariableDefinitions>>) => TFields
|
|
714
|
-
}): Fragment<TTypeName$1, OptionalArg<AssignableInput<TSchema, TVariableDefinitions>>, TFields
|
|
782
|
+
spread: (variables: OptionalArg<AssignableInput<TSchema, TVariableDefinitions>>) => TFields;
|
|
783
|
+
}): Fragment<TTypeName$1, OptionalArg<AssignableInput<TSchema, TVariableDefinitions>>, TFields & {
|
|
715
784
|
[key: symbol]: never;
|
|
716
|
-
}, InferFields<TSchema, TFields
|
|
785
|
+
}, InferFields<TSchema, TFields> & {
|
|
717
786
|
[key: symbol]: never;
|
|
718
|
-
}
|
|
787
|
+
}>;
|
|
719
788
|
}
|
|
720
789
|
//#endregion
|
|
721
790
|
//#region packages/core/src/types/element/operation.d.ts
|
|
@@ -726,7 +795,7 @@ type AnyOperation = AnyOperationOf<"query"> | AnyOperationOf<"mutation"> | AnyOp
|
|
|
726
795
|
/**
|
|
727
796
|
* Type alias for an Operation of a specific type.
|
|
728
797
|
*/
|
|
729
|
-
type AnyOperationOf<TOperationType
|
|
798
|
+
type AnyOperationOf<TOperationType extends OperationType> = Operation<TOperationType, string, string[], any, AnyFields, any>;
|
|
730
799
|
/**
|
|
731
800
|
* Type inference metadata for operations.
|
|
732
801
|
* Access via `typeof operation.$infer`.
|
|
@@ -740,12 +809,12 @@ declare const __OPERATION_BRAND__: unique symbol;
|
|
|
740
809
|
* Internal artifact shape produced by operation evaluation.
|
|
741
810
|
* @internal
|
|
742
811
|
*/
|
|
743
|
-
type OperationArtifact<TOperationType
|
|
744
|
-
readonly operationType: TOperationType
|
|
745
|
-
readonly operationName: TOperationName
|
|
812
|
+
type OperationArtifact<TOperationType extends OperationType, TOperationName extends string, TVariableNames extends string[], TVariables extends AnyConstAssignableInput, TFields extends Partial<AnyFields>, TData extends object> = {
|
|
813
|
+
readonly operationType: TOperationType;
|
|
814
|
+
readonly operationName: TOperationName;
|
|
746
815
|
readonly schemaLabel: string;
|
|
747
|
-
readonly variableNames: TVariableNames
|
|
748
|
-
readonly documentSource: () => TFields
|
|
816
|
+
readonly variableNames: TVariableNames;
|
|
817
|
+
readonly documentSource: () => TFields;
|
|
749
818
|
readonly document: TypedDocumentNode<TData, TVariables>;
|
|
750
819
|
readonly metadata?: unknown;
|
|
751
820
|
};
|
|
@@ -762,22 +831,22 @@ type OperationArtifact<TOperationType$1 extends OperationType, TOperationName$1
|
|
|
762
831
|
* @template TFields - Selected fields structure
|
|
763
832
|
* @template TData - Inferred response data type
|
|
764
833
|
*/
|
|
765
|
-
declare class Operation<TOperationType
|
|
834
|
+
declare class Operation<TOperationType extends OperationType, TOperationName extends string, TVariableNames extends string[], TVariables extends AnyConstAssignableInput, TFields extends Partial<AnyFields>, TData extends object> extends GqlElement<OperationArtifact<TOperationType, TOperationName, TVariableNames, TVariables, TFields, TData>, OperationInferMeta<TVariables, TData>> implements OperationArtifact<TOperationType, TOperationName, TVariableNames, TVariables, TFields, TData> {
|
|
766
835
|
private readonly [__OPERATION_BRAND__];
|
|
767
836
|
private constructor();
|
|
768
837
|
/** The operation type: 'query', 'mutation', or 'subscription'. */
|
|
769
|
-
get operationType(): TOperationType
|
|
838
|
+
get operationType(): TOperationType;
|
|
770
839
|
/** The unique name of this operation. */
|
|
771
|
-
get operationName(): TOperationName
|
|
840
|
+
get operationName(): TOperationName;
|
|
772
841
|
/** The schema label this operation belongs to. */
|
|
773
842
|
get schemaLabel(): string;
|
|
774
843
|
/** List of variable names defined for this operation. */
|
|
775
|
-
get variableNames(): TVariableNames
|
|
844
|
+
get variableNames(): TVariableNames;
|
|
776
845
|
/**
|
|
777
846
|
* Returns the field selections. Used for document reconstruction.
|
|
778
847
|
* @internal
|
|
779
848
|
*/
|
|
780
|
-
get documentSource(): () => TFields
|
|
849
|
+
get documentSource(): () => TFields;
|
|
781
850
|
/** The TypedDocumentNode for use with GraphQL clients. */
|
|
782
851
|
get document(): TypedDocumentNode<TData, TVariables>;
|
|
783
852
|
/** Custom metadata attached to this operation, if any. */
|
|
@@ -787,23 +856,23 @@ declare class Operation<TOperationType$1 extends OperationType, TOperationName$1
|
|
|
787
856
|
* Prefer using the `gql(({ query }) => ...)` API instead.
|
|
788
857
|
* @internal
|
|
789
858
|
*/
|
|
790
|
-
static create<TSchema extends AnyGraphqlSchema, TOperationType
|
|
791
|
-
operationType: TOperationType
|
|
792
|
-
operationName: TOperationName
|
|
859
|
+
static create<TSchema extends AnyGraphqlSchema, TOperationType extends OperationType, TOperationName extends string, TVariableDefinitions extends InputTypeSpecifiers, TFields extends AnyFields>(define: (context: GqlElementContext | null) => {
|
|
860
|
+
operationType: TOperationType;
|
|
861
|
+
operationName: TOperationName;
|
|
793
862
|
schemaLabel: TSchema["label"];
|
|
794
863
|
variableNames: (keyof TVariableDefinitions & string)[];
|
|
795
|
-
documentSource: () => TFields
|
|
796
|
-
document: TypedDocumentNode<InferFields<TSchema, TFields
|
|
864
|
+
documentSource: () => TFields;
|
|
865
|
+
document: TypedDocumentNode<InferFields<TSchema, TFields>, ConstAssignableInput<TSchema, TVariableDefinitions>>;
|
|
797
866
|
metadata?: unknown;
|
|
798
867
|
} | Promise<{
|
|
799
|
-
operationType: TOperationType
|
|
800
|
-
operationName: TOperationName
|
|
868
|
+
operationType: TOperationType;
|
|
869
|
+
operationName: TOperationName;
|
|
801
870
|
schemaLabel: TSchema["label"];
|
|
802
871
|
variableNames: (keyof TVariableDefinitions & string)[];
|
|
803
|
-
documentSource: () => TFields
|
|
804
|
-
document: TypedDocumentNode<InferFields<TSchema, TFields
|
|
872
|
+
documentSource: () => TFields;
|
|
873
|
+
document: TypedDocumentNode<InferFields<TSchema, TFields>, ConstAssignableInput<TSchema, TVariableDefinitions>>;
|
|
805
874
|
metadata?: unknown;
|
|
806
|
-
}>): Operation<TOperationType
|
|
875
|
+
}>): Operation<TOperationType, TOperationName, (keyof TVariableDefinitions & string)[], ConstAssignableInput<TSchema, TVariableDefinitions>, TFields, InferFields<TSchema, TFields>>;
|
|
807
876
|
}
|
|
808
877
|
//#endregion
|
|
809
878
|
//#region packages/core/src/composer/fields-builder.d.ts
|
|
@@ -851,13 +920,13 @@ declare const createVarRefs: <TSchema extends AnyGraphqlSchema, TVarDefinitions
|
|
|
851
920
|
* Used by codegen to generate explicit fragment builder types instead of
|
|
852
921
|
* expensive mapped types. This improves IDE performance for large schemas.
|
|
853
922
|
*/
|
|
854
|
-
type FragmentBuilderFor<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"] & string, TAdapter extends AnyMetadataAdapter = DefaultMetadataAdapter> = <TFields
|
|
923
|
+
type FragmentBuilderFor<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"] & string, TAdapter extends AnyMetadataAdapter = DefaultMetadataAdapter> = <TFields extends AnyFields, TVarDefinitions extends InputTypeSpecifiers = {}>(options: {
|
|
855
924
|
/** Optional unique key for prebuilt type lookup. */
|
|
856
|
-
key?:
|
|
925
|
+
key?: string;
|
|
857
926
|
variables?: TVarDefinitions;
|
|
858
927
|
metadata?: FragmentMetadataBuilder<ReturnType<typeof createVarRefs<TSchema, TVarDefinitions>>, ExtractAdapterTypes<TAdapter>["fragmentMetadata"]>;
|
|
859
|
-
fields: FieldsBuilder<TSchema, TTypeName$1, TVarDefinitions, TFields
|
|
860
|
-
}) => ReturnType<typeof Fragment.create<TSchema, TTypeName$1, TVarDefinitions, TFields
|
|
928
|
+
fields: FieldsBuilder<TSchema, TTypeName$1, TVarDefinitions, TFields>;
|
|
929
|
+
}) => ReturnType<typeof Fragment.create<TSchema, TTypeName$1, TVarDefinitions, TFields>>;
|
|
861
930
|
/**
|
|
862
931
|
* Creates fragment builder functions for all object types in the schema.
|
|
863
932
|
*
|
|
@@ -870,16 +939,16 @@ type FragmentBuilderFor<TSchema extends AnyGraphqlSchema, TTypeName$1 extends ke
|
|
|
870
939
|
*
|
|
871
940
|
* @internal Used by `createGqlElementComposer`
|
|
872
941
|
*/
|
|
873
|
-
declare const createGqlFragmentComposers: <TSchema extends AnyGraphqlSchema, TAdapter extends AnyMetadataAdapter = DefaultMetadataAdapter>(schema: NoInfer<TSchema>, _adapter?: TAdapter) => { readonly [TTypeName in keyof TSchema["object"]]: TTypeName extends string ? <TFields
|
|
874
|
-
key?:
|
|
942
|
+
declare const createGqlFragmentComposers: <TSchema extends AnyGraphqlSchema, TAdapter extends AnyMetadataAdapter = DefaultMetadataAdapter>(schema: NoInfer<TSchema>, _adapter?: TAdapter) => { readonly [TTypeName in keyof TSchema["object"]]: TTypeName extends string ? <TFields extends AnyFields, TVarDefinitions extends InputTypeSpecifiers = {}>(options: {
|
|
943
|
+
key?: string;
|
|
875
944
|
variables?: TVarDefinitions | undefined;
|
|
876
945
|
metadata?: FragmentMetadataBuilder<DeclaredVariables<TSchema, TVarDefinitions>, ExtractAdapterTypes<TAdapter>["fragmentMetadata"]> | undefined;
|
|
877
|
-
fields: FieldsBuilder<TSchema, TTypeName, TVarDefinitions, TFields
|
|
878
|
-
}) => Fragment<TTypeName, OptionalArg<AssignableInput<TSchema, TVarDefinitions>>, TFields
|
|
946
|
+
fields: FieldsBuilder<TSchema, TTypeName, TVarDefinitions, TFields>;
|
|
947
|
+
}) => Fragment<TTypeName, OptionalArg<AssignableInput<TSchema, TVarDefinitions>>, TFields & {
|
|
879
948
|
[key: symbol]: never;
|
|
880
|
-
}, InferFields<TSchema, TFields
|
|
949
|
+
}, InferFields<TSchema, TFields> & {
|
|
881
950
|
[key: symbol]: never;
|
|
882
|
-
}
|
|
951
|
+
}> : never };
|
|
883
952
|
//#endregion
|
|
884
953
|
//#region packages/core/src/composer/fragment-usage-context.d.ts
|
|
885
954
|
/**
|
|
@@ -1174,31 +1243,31 @@ type GqlElementComposerOptions<TSchema extends AnyGraphqlSchema, TDirectiveMetho
|
|
|
1174
1243
|
declare const createGqlElementComposer: <TSchema extends AnyGraphqlSchema, TFragmentBuilders, TDirectiveMethods extends StandardDirectives, TAdapter extends AnyAdapter = DefaultAdapter>(schema: NoInfer<TSchema>, options: GqlElementComposerOptions<NoInfer<TSchema>, NoInfer<TDirectiveMethods>, NoInfer<TAdapter>>) => GqlElementComposerWithSchema<{
|
|
1175
1244
|
fragment: TFragmentBuilders;
|
|
1176
1245
|
query: {
|
|
1177
|
-
operation: <TOperationName
|
|
1178
|
-
name: TOperationName
|
|
1246
|
+
operation: <TOperationName extends string, TFields extends AnyFields, TVarDefinitions extends InputTypeSpecifiers = {}, TOperationMetadata = unknown>(options: {
|
|
1247
|
+
name: TOperationName;
|
|
1179
1248
|
variables?: TVarDefinitions | undefined;
|
|
1180
1249
|
metadata?: MetadataBuilder<DeclaredVariables<TSchema, TVarDefinitions>, TOperationMetadata, ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["aggregatedFragmentMetadata"], ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["schemaLevel"]> | undefined;
|
|
1181
|
-
fields: FieldsBuilder<TSchema, TSchema["operations"]["query"] & keyof TSchema["object"] & string, TVarDefinitions, TFields
|
|
1250
|
+
fields: FieldsBuilder<TSchema, TSchema["operations"]["query"] & keyof TSchema["object"] & string, TVarDefinitions, TFields>;
|
|
1182
1251
|
transformDocument?: OperationDocumentTransformer<TOperationMetadata> | undefined;
|
|
1183
|
-
}) => Operation<"query", TOperationName
|
|
1252
|
+
}) => Operation<"query", TOperationName, (keyof TVarDefinitions & string)[], ConstAssignableInput<TSchema, TVarDefinitions>, TFields, InferFields<TSchema, TFields>>;
|
|
1184
1253
|
};
|
|
1185
1254
|
mutation: {
|
|
1186
|
-
operation: <TOperationName
|
|
1187
|
-
name: TOperationName
|
|
1255
|
+
operation: <TOperationName extends string, TFields extends AnyFields, TVarDefinitions extends InputTypeSpecifiers = {}, TOperationMetadata = unknown>(options: {
|
|
1256
|
+
name: TOperationName;
|
|
1188
1257
|
variables?: TVarDefinitions | undefined;
|
|
1189
1258
|
metadata?: MetadataBuilder<DeclaredVariables<TSchema, TVarDefinitions>, TOperationMetadata, ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["aggregatedFragmentMetadata"], ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["schemaLevel"]> | undefined;
|
|
1190
|
-
fields: FieldsBuilder<TSchema, TSchema["operations"]["mutation"] & keyof TSchema["object"] & string, TVarDefinitions, TFields
|
|
1259
|
+
fields: FieldsBuilder<TSchema, TSchema["operations"]["mutation"] & keyof TSchema["object"] & string, TVarDefinitions, TFields>;
|
|
1191
1260
|
transformDocument?: OperationDocumentTransformer<TOperationMetadata> | undefined;
|
|
1192
|
-
}) => Operation<"mutation", TOperationName
|
|
1261
|
+
}) => Operation<"mutation", TOperationName, (keyof TVarDefinitions & string)[], ConstAssignableInput<TSchema, TVarDefinitions>, TFields, InferFields<TSchema, TFields>>;
|
|
1193
1262
|
};
|
|
1194
1263
|
subscription: {
|
|
1195
|
-
operation: <TOperationName
|
|
1196
|
-
name: TOperationName
|
|
1264
|
+
operation: <TOperationName extends string, TFields extends AnyFields, TVarDefinitions extends InputTypeSpecifiers = {}, TOperationMetadata = unknown>(options: {
|
|
1265
|
+
name: TOperationName;
|
|
1197
1266
|
variables?: TVarDefinitions | undefined;
|
|
1198
1267
|
metadata?: MetadataBuilder<DeclaredVariables<TSchema, TVarDefinitions>, TOperationMetadata, ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["aggregatedFragmentMetadata"], ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["schemaLevel"]> | undefined;
|
|
1199
|
-
fields: FieldsBuilder<TSchema, TSchema["operations"]["subscription"] & keyof TSchema["object"] & string, TVarDefinitions, TFields
|
|
1268
|
+
fields: FieldsBuilder<TSchema, TSchema["operations"]["subscription"] & keyof TSchema["object"] & string, TVarDefinitions, TFields>;
|
|
1200
1269
|
transformDocument?: OperationDocumentTransformer<TOperationMetadata> | undefined;
|
|
1201
|
-
}) => Operation<"subscription", TOperationName
|
|
1270
|
+
}) => Operation<"subscription", TOperationName, (keyof TVarDefinitions & string)[], ConstAssignableInput<TSchema, TVarDefinitions>, TFields, InferFields<TSchema, TFields>>;
|
|
1202
1271
|
};
|
|
1203
1272
|
$var: VarBuilder<TSchema>;
|
|
1204
1273
|
$dir: TDirectiveMethods;
|
|
@@ -1247,165 +1316,13 @@ type AnyGqlContext = {
|
|
|
1247
1316
|
*
|
|
1248
1317
|
* @internal Used by `createGqlElementComposer`
|
|
1249
1318
|
*/
|
|
1250
|
-
declare const createOperationComposerFactory: <TSchema extends AnyGraphqlSchema, TAdapter extends AnyMetadataAdapter = DefaultMetadataAdapter>(schema: NoInfer<TSchema>, adapter?: TAdapter, transformDocument?: DocumentTransformer<ExtractAdapterTypes<TAdapter>["schemaLevel"], ExtractAdapterTypes<TAdapter>["aggregatedFragmentMetadata"]>) => <TOperationType
|
|
1251
|
-
name: TOperationName
|
|
1319
|
+
declare const createOperationComposerFactory: <TSchema extends AnyGraphqlSchema, TAdapter extends AnyMetadataAdapter = DefaultMetadataAdapter>(schema: NoInfer<TSchema>, adapter?: TAdapter, transformDocument?: DocumentTransformer<ExtractAdapterTypes<TAdapter>["schemaLevel"], ExtractAdapterTypes<TAdapter>["aggregatedFragmentMetadata"]>) => <TOperationType extends OperationType>(operationType: TOperationType) => <TOperationName extends string, TFields extends AnyFields, TVarDefinitions extends InputTypeSpecifiers = {}, TOperationMetadata = unknown>(options: {
|
|
1320
|
+
name: TOperationName;
|
|
1252
1321
|
variables?: TVarDefinitions;
|
|
1253
1322
|
metadata?: MetadataBuilder<ReturnType<typeof createVarRefs<TSchema, TVarDefinitions>>, TOperationMetadata, ExtractAdapterTypes<TAdapter>["aggregatedFragmentMetadata"], ExtractAdapterTypes<TAdapter>["schemaLevel"]>;
|
|
1254
|
-
fields: FieldsBuilder<TSchema, TSchema["operations"][TOperationType
|
|
1323
|
+
fields: FieldsBuilder<TSchema, TSchema["operations"][TOperationType] & keyof TSchema["object"] & string, TVarDefinitions, TFields>;
|
|
1255
1324
|
transformDocument?: OperationDocumentTransformer<TOperationMetadata>;
|
|
1256
|
-
}) => Operation<TOperationType
|
|
1257
|
-
//#endregion
|
|
1258
|
-
//#region packages/core/src/prebuilt/types.d.ts
|
|
1259
|
-
/**
|
|
1260
|
-
* Type definitions for prebuilt type system.
|
|
1261
|
-
*
|
|
1262
|
-
* These types enable looking up pre-computed types from a registry
|
|
1263
|
-
* instead of relying on complex type inference that may be lost
|
|
1264
|
-
* when bundling with tools like tsdown.
|
|
1265
|
-
*
|
|
1266
|
-
* @module
|
|
1267
|
-
*/
|
|
1268
|
-
/**
|
|
1269
|
-
* Registry mapping fragment/operation keys to their inferred types.
|
|
1270
|
-
* Generated by the builder and used by prebuilt composers.
|
|
1271
|
-
*/
|
|
1272
|
-
type PrebuiltTypeRegistry = {
|
|
1273
|
-
readonly fragments: {
|
|
1274
|
-
readonly [key: string]: {
|
|
1275
|
-
readonly input: unknown;
|
|
1276
|
-
readonly output: object;
|
|
1277
|
-
};
|
|
1278
|
-
};
|
|
1279
|
-
readonly operations: {
|
|
1280
|
-
readonly [key: string]: {
|
|
1281
|
-
readonly input: object;
|
|
1282
|
-
readonly output: object;
|
|
1283
|
-
};
|
|
1284
|
-
};
|
|
1285
|
-
};
|
|
1286
|
-
/**
|
|
1287
|
-
* Empty registry type for when no prebuilt types are available.
|
|
1288
|
-
*/
|
|
1289
|
-
type EmptyPrebuiltTypeRegistry = {
|
|
1290
|
-
readonly fragments: Record<string, never>;
|
|
1291
|
-
readonly operations: Record<string, never>;
|
|
1292
|
-
};
|
|
1293
|
-
/**
|
|
1294
|
-
* Extract the input type for a fragment from the registry.
|
|
1295
|
-
*/
|
|
1296
|
-
type PrebuiltFragmentInput<TRegistry extends PrebuiltTypeRegistry, TKey$1 extends keyof TRegistry["fragments"] & string> = TRegistry["fragments"][TKey$1]["input"];
|
|
1297
|
-
/**
|
|
1298
|
-
* Extract the output type for a fragment from the registry.
|
|
1299
|
-
*/
|
|
1300
|
-
type PrebuiltFragmentOutput<TRegistry extends PrebuiltTypeRegistry, TKey$1 extends keyof TRegistry["fragments"] & string> = TRegistry["fragments"][TKey$1]["output"];
|
|
1301
|
-
/**
|
|
1302
|
-
* Extract the input type for an operation from the registry.
|
|
1303
|
-
*/
|
|
1304
|
-
type PrebuiltOperationInput<TRegistry extends PrebuiltTypeRegistry, TKey$1 extends keyof TRegistry["operations"] & string> = TRegistry["operations"][TKey$1]["input"];
|
|
1305
|
-
/**
|
|
1306
|
-
* Extract the output type for an operation from the registry.
|
|
1307
|
-
*/
|
|
1308
|
-
type PrebuiltOperationOutput<TRegistry extends PrebuiltTypeRegistry, TKey$1 extends keyof TRegistry["operations"] & string> = TRegistry["operations"][TKey$1]["output"];
|
|
1309
|
-
/**
|
|
1310
|
-
* Check if a key exists in the fragment registry.
|
|
1311
|
-
*/
|
|
1312
|
-
type HasPrebuiltFragment<TRegistry extends PrebuiltTypeRegistry, TKey$1 extends string> = TKey$1 extends keyof TRegistry["fragments"] ? true : false;
|
|
1313
|
-
/**
|
|
1314
|
-
* Check if a key exists in the operation registry.
|
|
1315
|
-
*/
|
|
1316
|
-
type HasPrebuiltOperation<TRegistry extends PrebuiltTypeRegistry, TKey$1 extends string> = TKey$1 extends keyof TRegistry["operations"] ? true : false;
|
|
1317
|
-
/**
|
|
1318
|
-
* Branded error type for missing prebuilt registry entries.
|
|
1319
|
-
*
|
|
1320
|
-
* This type intentionally produces a clear error message at compile time
|
|
1321
|
-
* when an operation or fragment is not found in the PrebuiltTypeRegistry.
|
|
1322
|
-
* Instead of silently falling back to inferred types, this forces users
|
|
1323
|
-
* to ensure all elements are properly registered via typegen.
|
|
1324
|
-
*/
|
|
1325
|
-
type PrebuiltEntryNotFound<TKey$1 extends string, TKind extends "fragment" | "operation"> = {
|
|
1326
|
-
readonly __error: "PREBUILT_ENTRY_NOT_FOUND";
|
|
1327
|
-
readonly __message: `${TKind} "${TKey$1}" not found in PrebuiltTypeRegistry. Run 'soda-gql typegen' to generate prebuilt types.`;
|
|
1328
|
-
readonly __key: TKey$1;
|
|
1329
|
-
readonly __kind: TKind;
|
|
1330
|
-
};
|
|
1331
|
-
/**
|
|
1332
|
-
* Branded error type for unrecognized element types in prebuilt resolution.
|
|
1333
|
-
*
|
|
1334
|
-
* This type is returned when ResolvePrebuiltElement receives a type that
|
|
1335
|
-
* is neither Operation nor Fragment. This should not happen in normal usage,
|
|
1336
|
-
* but provides a clear error message for debugging if it does.
|
|
1337
|
-
*/
|
|
1338
|
-
type PrebuiltUnknownElement<TElement> = {
|
|
1339
|
-
readonly __error: "PREBUILT_UNKNOWN_ELEMENT";
|
|
1340
|
-
readonly __message: "Element type not recognized. Expected Operation or Fragment.";
|
|
1341
|
-
readonly __element: TElement;
|
|
1342
|
-
};
|
|
1343
|
-
//#endregion
|
|
1344
|
-
//#region packages/core/src/composer/prebuilt-composer.d.ts
|
|
1345
|
-
/**
|
|
1346
|
-
* Resolves the output type for a prebuilt element (strict mode).
|
|
1347
|
-
*
|
|
1348
|
-
* For Operations: Looks up by operation name in the registry
|
|
1349
|
-
* For Fragments: Looks up by fragment key in the registry
|
|
1350
|
-
*
|
|
1351
|
-
* Returns `PrebuiltEntryNotFound` error type if the element is not found
|
|
1352
|
-
* in the registry, forcing users to ensure all elements are properly
|
|
1353
|
-
* registered via typegen.
|
|
1354
|
-
*/
|
|
1355
|
-
type ResolvePrebuiltElement<TElement, TPrebuilt extends PrebuiltTypeRegistry> = TElement extends Operation<infer TOperationType extends OperationType, infer TOperationName extends string, infer TVariableNames extends string[], any, infer TFields extends Partial<AnyFields>, any> ? TOperationName extends keyof TPrebuilt["operations"] ? Operation<TOperationType, TOperationName, TVariableNames, TPrebuilt["operations"][TOperationName]["input"] & AnyConstAssignableInput, TFields, TPrebuilt["operations"][TOperationName]["output"] & object> : Operation<TOperationType, TOperationName, TVariableNames, PrebuiltEntryNotFound<TOperationName, "operation">, TFields, PrebuiltEntryNotFound<TOperationName, "operation">> : TElement extends Fragment<infer TTypeName extends string, any, infer TFields extends Partial<AnyFields>, any, infer TKey extends string | undefined> ? TKey extends string ? TKey extends keyof TPrebuilt["fragments"] ? Fragment<TTypeName, TPrebuilt["fragments"][TKey]["input"] extends infer TInput ? TInput extends AnyAssignableInput ? Partial<TInput> : void : void, TFields, TPrebuilt["fragments"][TKey]["output"] & object, TKey> : Fragment<TTypeName, PrebuiltEntryNotFound<TKey, "fragment">, TFields, PrebuiltEntryNotFound<TKey, "fragment">, TKey> : Fragment<TTypeName, PrebuiltEntryNotFound<"(undefined)", "fragment">, TFields, PrebuiltEntryNotFound<"(undefined)", "fragment">, TKey> : PrebuiltUnknownElement<TElement>;
|
|
1356
|
-
/**
|
|
1357
|
-
* Prebuilt element composer that resolves types from a registry.
|
|
1358
|
-
*/
|
|
1359
|
-
type PrebuiltGqlElementComposer<TContext, TPrebuilt extends PrebuiltTypeRegistry> = <TResult extends AnyFragment | Operation<OperationType, string, string[], AnyConstAssignableInput, AnyFields, object>>(composeElement: (context: TContext) => TResult) => ResolvePrebuiltElement<TResult, TPrebuilt>;
|
|
1360
|
-
/**
|
|
1361
|
-
* Prebuilt element composer with schema access.
|
|
1362
|
-
*
|
|
1363
|
-
* Extends the prebuilt composer function with a `$schema` property that provides
|
|
1364
|
-
* runtime access to the schema definition.
|
|
1365
|
-
*/
|
|
1366
|
-
type PrebuiltGqlElementComposerWithSchema<TContext, TPrebuilt extends PrebuiltTypeRegistry, TSchema extends AnyGraphqlSchema> = PrebuiltGqlElementComposer<TContext, TPrebuilt> & {
|
|
1367
|
-
/**
|
|
1368
|
-
* The GraphQL schema definition used by this composer.
|
|
1369
|
-
*/
|
|
1370
|
-
readonly $schema: TSchema;
|
|
1371
|
-
};
|
|
1372
|
-
/**
|
|
1373
|
-
* Creates a prebuilt GQL element composer for a given schema.
|
|
1374
|
-
*
|
|
1375
|
-
* This composer has the same runtime behavior as `createGqlElementComposer`,
|
|
1376
|
-
* but the returned elements have their types resolved from the PrebuiltTypeRegistry
|
|
1377
|
-
* instead of using complex type inference.
|
|
1378
|
-
*
|
|
1379
|
-
* Use this when bundling with tools like tsdown that may lose type information.
|
|
1380
|
-
*
|
|
1381
|
-
* @param schema - The GraphQL schema definition
|
|
1382
|
-
* @param options - Configuration including input type methods and optional adapter
|
|
1383
|
-
* @returns Prebuilt element composer function
|
|
1384
|
-
*
|
|
1385
|
-
* @example
|
|
1386
|
-
* ```typescript
|
|
1387
|
-
* // Generated by codegen in prebuilt/index.ts
|
|
1388
|
-
* import type { PrebuiltTypes } from "./types";
|
|
1389
|
-
*
|
|
1390
|
-
* const gql = createPrebuiltGqlElementComposer<
|
|
1391
|
-
* Schema,
|
|
1392
|
-
* PrebuiltTypes,
|
|
1393
|
-
* FragmentBuilders,
|
|
1394
|
-
* DirectiveMethods,
|
|
1395
|
-
* Context
|
|
1396
|
-
* >(schema, { inputTypeMethods });
|
|
1397
|
-
*
|
|
1398
|
-
* // Types are resolved from PrebuiltTypes registry
|
|
1399
|
-
* const GetUser = gql(({ query }) =>
|
|
1400
|
-
* query.operation({
|
|
1401
|
-
* name: "GetUser",
|
|
1402
|
-
* fields: ({ f }) => ({ ...f.user({ id: "1" })(({ f }) => ({ ...f.id() })) }),
|
|
1403
|
-
* })
|
|
1404
|
-
* );
|
|
1405
|
-
* // GetUser.$infer.output is PrebuiltTypes["operations"]["GetUser"]["output"]
|
|
1406
|
-
* ```
|
|
1407
|
-
*/
|
|
1408
|
-
declare const createPrebuiltGqlElementComposer: <TSchema extends AnyGraphqlSchema, TPrebuilt extends PrebuiltTypeRegistry, TFragmentBuilders, TDirectiveMethods extends StandardDirectives, TContext, TAdapter extends AnyAdapter = DefaultAdapter>(schema: NoInfer<TSchema>, options: GqlElementComposerOptions<NoInfer<TSchema>, NoInfer<TDirectiveMethods>, NoInfer<TAdapter>>) => PrebuiltGqlElementComposerWithSchema<TContext, TPrebuilt, TSchema>;
|
|
1325
|
+
}) => Operation<TOperationType, TOperationName, (keyof TVarDefinitions & string)[], ConstAssignableInput<TSchema, TVarDefinitions>, TFields, InferFields<TSchema, TFields>>;
|
|
1409
1326
|
//#endregion
|
|
1410
1327
|
//#region packages/core/src/prebuilt/type-calculator.d.ts
|
|
1411
1328
|
/**
|
|
@@ -1545,6 +1462,92 @@ declare const generateInputType: (schema: AnyGraphqlSchema, variableDefinitions:
|
|
|
1545
1462
|
*/
|
|
1546
1463
|
declare const generateInputTypeFromSpecifiers: (schema: AnyGraphqlSchema, specifiers: InputTypeSpecifiers, options?: GenerateInputObjectTypeOptions) => string;
|
|
1547
1464
|
//#endregion
|
|
1465
|
+
//#region packages/core/src/prebuilt/types.d.ts
|
|
1466
|
+
/**
|
|
1467
|
+
* Type definitions for prebuilt type system.
|
|
1468
|
+
*
|
|
1469
|
+
* These types enable looking up pre-computed types from a registry
|
|
1470
|
+
* instead of relying on complex type inference that may be lost
|
|
1471
|
+
* when bundling with tools like tsdown.
|
|
1472
|
+
*
|
|
1473
|
+
* @module
|
|
1474
|
+
*/
|
|
1475
|
+
/**
|
|
1476
|
+
* Registry mapping fragment/operation keys to their inferred types.
|
|
1477
|
+
* Generated by the builder and used by prebuilt composers.
|
|
1478
|
+
*/
|
|
1479
|
+
type PrebuiltTypeRegistry = {
|
|
1480
|
+
readonly fragments: {
|
|
1481
|
+
readonly [key: string]: {
|
|
1482
|
+
readonly input: unknown;
|
|
1483
|
+
readonly output: object;
|
|
1484
|
+
};
|
|
1485
|
+
};
|
|
1486
|
+
readonly operations: {
|
|
1487
|
+
readonly [key: string]: {
|
|
1488
|
+
readonly input: object;
|
|
1489
|
+
readonly output: object;
|
|
1490
|
+
};
|
|
1491
|
+
};
|
|
1492
|
+
};
|
|
1493
|
+
/**
|
|
1494
|
+
* Empty registry type for when no prebuilt types are available.
|
|
1495
|
+
*/
|
|
1496
|
+
type EmptyPrebuiltTypeRegistry = {
|
|
1497
|
+
readonly fragments: Record<string, never>;
|
|
1498
|
+
readonly operations: Record<string, never>;
|
|
1499
|
+
};
|
|
1500
|
+
/**
|
|
1501
|
+
* Extract the input type for a fragment from the registry.
|
|
1502
|
+
*/
|
|
1503
|
+
type PrebuiltFragmentInput<TRegistry extends PrebuiltTypeRegistry, TKey extends keyof TRegistry["fragments"] & string> = TRegistry["fragments"][TKey]["input"];
|
|
1504
|
+
/**
|
|
1505
|
+
* Extract the output type for a fragment from the registry.
|
|
1506
|
+
*/
|
|
1507
|
+
type PrebuiltFragmentOutput<TRegistry extends PrebuiltTypeRegistry, TKey extends keyof TRegistry["fragments"] & string> = TRegistry["fragments"][TKey]["output"];
|
|
1508
|
+
/**
|
|
1509
|
+
* Extract the input type for an operation from the registry.
|
|
1510
|
+
*/
|
|
1511
|
+
type PrebuiltOperationInput<TRegistry extends PrebuiltTypeRegistry, TKey extends keyof TRegistry["operations"] & string> = TRegistry["operations"][TKey]["input"];
|
|
1512
|
+
/**
|
|
1513
|
+
* Extract the output type for an operation from the registry.
|
|
1514
|
+
*/
|
|
1515
|
+
type PrebuiltOperationOutput<TRegistry extends PrebuiltTypeRegistry, TKey extends keyof TRegistry["operations"] & string> = TRegistry["operations"][TKey]["output"];
|
|
1516
|
+
/**
|
|
1517
|
+
* Check if a key exists in the fragment registry.
|
|
1518
|
+
*/
|
|
1519
|
+
type HasPrebuiltFragment<TRegistry extends PrebuiltTypeRegistry, TKey extends string> = TKey extends keyof TRegistry["fragments"] ? true : false;
|
|
1520
|
+
/**
|
|
1521
|
+
* Check if a key exists in the operation registry.
|
|
1522
|
+
*/
|
|
1523
|
+
type HasPrebuiltOperation<TRegistry extends PrebuiltTypeRegistry, TKey extends string> = TKey extends keyof TRegistry["operations"] ? true : false;
|
|
1524
|
+
/**
|
|
1525
|
+
* Branded error type for missing prebuilt registry entries.
|
|
1526
|
+
*
|
|
1527
|
+
* This type intentionally produces a clear error message at compile time
|
|
1528
|
+
* when an operation or fragment is not found in the PrebuiltTypeRegistry.
|
|
1529
|
+
* Instead of silently falling back to inferred types, this forces users
|
|
1530
|
+
* to ensure all elements are properly registered via typegen.
|
|
1531
|
+
*/
|
|
1532
|
+
type PrebuiltEntryNotFound<TKey extends string, TKind extends "fragment" | "operation"> = {
|
|
1533
|
+
readonly __error: "PREBUILT_ENTRY_NOT_FOUND";
|
|
1534
|
+
readonly __message: `${TKind} "${TKey}" not found in PrebuiltTypeRegistry. Run 'soda-gql typegen' to generate prebuilt types.`;
|
|
1535
|
+
readonly __key: TKey;
|
|
1536
|
+
readonly __kind: TKind;
|
|
1537
|
+
};
|
|
1538
|
+
/**
|
|
1539
|
+
* Branded error type for unrecognized element types in prebuilt resolution.
|
|
1540
|
+
*
|
|
1541
|
+
* This type is returned when ResolvePrebuiltElement receives a type that
|
|
1542
|
+
* is neither Operation nor Fragment. This should not happen in normal usage,
|
|
1543
|
+
* but provides a clear error message for debugging if it does.
|
|
1544
|
+
*/
|
|
1545
|
+
type PrebuiltUnknownElement<TElement> = {
|
|
1546
|
+
readonly __error: "PREBUILT_UNKNOWN_ELEMENT";
|
|
1547
|
+
readonly __message: "Element type not recognized. Expected Operation or Fragment.";
|
|
1548
|
+
readonly __element: TElement;
|
|
1549
|
+
};
|
|
1550
|
+
//#endregion
|
|
1548
1551
|
//#region packages/core/src/utils/hidden.d.ts
|
|
1549
1552
|
declare const hidden: <T>() => (() => T);
|
|
1550
1553
|
type Hidden<T> = () => T;
|
|
@@ -1552,5 +1555,5 @@ type Hidden<T> = () => T;
|
|
|
1552
1555
|
//#region packages/core/src/utils/wrap-by-key.d.ts
|
|
1553
1556
|
declare function wrapByKey<TName$1 extends string, TValue$1>(name: TName$1, value: TValue$1): { [K in TName$1]: TValue$1 };
|
|
1554
1557
|
//#endregion
|
|
1555
|
-
export {
|
|
1556
|
-
//# sourceMappingURL=index-
|
|
1558
|
+
export { AnyOperation as $, buildConstValueNode as $t, GqlElementComposer as A, DirectiveRefInner as An, AttachmentToProperty as At, VarBuilderMethods as B, createStandardDirectives as Bt, getScalarInputType as C, ConstAssignableInputValue as Cn, NestedUnionFieldsBuilder as Ct, AnyGqlContext as D, DirectiveArgumentSpecifier as Dn, SwitchIfOmittable as Dt, createOperationComposerFactory as E, AnyDirectiveRefBrand as En, OptionalArg as Et, InputTypeMethods as F, DirectiveBuilder as Ft, FragmentUsageRecord as G, ColocatedFields as Gt, createVarBuilder as H, isDirectiveRef as Ht, ResolveTypeFromMeta as I, DirectiveMethod as It, FragmentBuilderFor as J, StripSymbols as Jt, recordFragmentUsage as K, createColocateHelper as Kt, SchemaAwareGetNameAt as L, StandardDirectives as Lt, GqlElementComposerWithSchema as M, TypeSystemDirectiveLocation as Mn, AnyDirectiveMethod as Mt, createGqlElementComposer as N, DirectiveArgValue as Nt, ExtractMetadataAdapter as O, DirectiveLocation as On, empty as Ot, InputTypeMethod as P, DirectiveArgumentSpecifiers as Pt, createFieldFactories as Q, buildArgumentValue as Qt, SchemaAwareGetValueAt as R, createDirectiveBuilder as Rt, getEnumType as S, ConstAssignableInput as Sn, NestedObjectFieldsBuilderTools as St, graphqlTypeToTypeScript as T, AnyDirectiveRef as Tn, IfOmittable as Tt, createVarMethod as U, ColocateHelper as Ut, VarSpecifier as V, createTypedDirectiveMethod as Vt, createVarMethodFactory as W, ColocatedEntries as Wt, createVarAssignments as X, UnionToIntersection as Xt, createGqlFragmentComposers as Y, Tuple as Yt, createVarRefs as Z, EnumLookup as Zt, calculateFieldType as _, DeclaredVariables as _n, FieldSelectionFactoryReturn as _t, HasPrebuiltFragment as a, AnyFields as an, FragmentInferMeta as at, generateInputType as b, AnyConstAssignableInput as bn, FieldsBuilderTools as bt, PrebuiltFragmentInput as c, FieldSelectionTemplateOf as cn, GqlElementContext as ct, PrebuiltOperationOutput as d, AnyDirectiveAttachments as dn, AnyFieldSelectionFactoryReturn as dt, buildDocument as en, AnyOperationOf as et, PrebuiltTypeRegistry as f, AnyAssignableInput as fn, FieldSelectionFactories as ft, applyTypeModifier as g, AssignableInputByFieldName as gn, FieldSelectionFactoryPrimitiveReturn as gt, TypeFormatters as h, AssignableInput as hn, FieldSelectionFactoryObjectReturn as ht, EmptyPrebuiltTypeRegistry as i, AnyFieldSelection as in, Fragment as it, GqlElementComposerOptions as j, ExecutableDirectiveLocation as jn, AttachmentsTupleToIntersection as jt, FragmentBuildersAll as k, DirectiveRef as kn, AttachmentShape as kt, PrebuiltFragmentOutput as l, InferField as ln, GqlElementDefinitionFactory as lt, GenerateInputObjectTypeOptions as m, AnyAssigningInput as mn, FieldSelectionFactoryFieldArguments as mt, Hidden as n, buildWithTypeModifier as nn, OperationInferMeta as nt, HasPrebuiltOperation as o, AnyNestedObject as on, GqlElement as ot, PrebuiltUnknownElement as p, AnyAssignableInputValue as pn, FieldSelectionFactory as pt, withFragmentUsageCollection as q, StripFunctions as qt, hidden as r, AbstractFieldSelection as rn, AnyFragment as rt, PrebuiltEntryNotFound as s, AnyNestedUnion as sn, GqlElementAttachment as st, wrapByKey as t, buildOperationTypeNode as tn, Operation as tt, PrebuiltOperationInput as u, InferFields as un, AnyFieldSelectionFactory as ut, calculateFieldsType as v, FieldArgumentValue as vn, FieldSelectionFactoryUnionReturn as vt, getScalarOutputType as w, GetAssignableType as wn, EmptyObject as wt, generateInputTypeFromSpecifiers as x, AnyConstAssignableInputValue as xn, NestedObjectFieldsBuilder as xt, generateInputObjectType as y, AnyConstDirectiveAttachments as yn, FieldsBuilder as yt, VarBuilder as z, createDirectiveMethod as zt };
|
|
1559
|
+
//# sourceMappingURL=index-DPtgl2f4.d.ts.map
|