@soda-gql/core 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/adapter.cjs +1 -1
  2. package/dist/adapter.d.cts +2 -2
  3. package/dist/adapter.d.ts +2 -2
  4. package/dist/adapter.js +1 -1
  5. package/dist/{index-rBHv6RJz.d.ts → index-Ib9pb2Si.d.cts} +565 -35
  6. package/dist/index-Ib9pb2Si.d.cts.map +1 -0
  7. package/dist/{index-x4fr7bdv.d.cts → index-wkJ6KSwK.d.ts} +565 -35
  8. package/dist/index-wkJ6KSwK.d.ts.map +1 -0
  9. package/dist/index.cjs +428 -35
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +43 -4
  12. package/dist/index.d.cts.map +1 -1
  13. package/dist/index.d.ts +43 -4
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +425 -36
  16. package/dist/index.js.map +1 -1
  17. package/dist/runtime.cjs +16 -10
  18. package/dist/runtime.cjs.map +1 -1
  19. package/dist/runtime.d.cts +2 -2
  20. package/dist/runtime.d.ts +2 -2
  21. package/dist/runtime.js +16 -10
  22. package/dist/runtime.js.map +1 -1
  23. package/dist/{schema-CFMmSBhl.d.ts → schema-2qqtKss4.d.ts} +39 -37
  24. package/dist/schema-2qqtKss4.d.ts.map +1 -0
  25. package/dist/{schema-BbCrsNkQ.js → schema-BiYcVVvm.js} +86 -1
  26. package/dist/schema-BiYcVVvm.js.map +1 -0
  27. package/dist/{schema-C1lnWj-m.d.cts → schema-CPTxQbTv.d.cts} +39 -37
  28. package/dist/schema-CPTxQbTv.d.cts.map +1 -0
  29. package/dist/{schema-DuWaRhdp.cjs → schema-D2MW4DOF.cjs} +86 -1
  30. package/dist/schema-D2MW4DOF.cjs.map +1 -0
  31. package/dist/schema-builder-BYJd50o2.d.cts +97 -0
  32. package/dist/schema-builder-BYJd50o2.d.cts.map +1 -0
  33. package/dist/schema-builder-Dhss2O1I.d.ts +97 -0
  34. package/dist/schema-builder-Dhss2O1I.d.ts.map +1 -0
  35. package/package.json +1 -1
  36. package/dist/index-rBHv6RJz.d.ts.map +0 -1
  37. package/dist/index-x4fr7bdv.d.cts.map +0 -1
  38. package/dist/schema-BbCrsNkQ.js.map +0 -1
  39. package/dist/schema-C1lnWj-m.d.cts.map +0 -1
  40. package/dist/schema-CFMmSBhl.d.ts.map +0 -1
  41. package/dist/schema-DuWaRhdp.cjs.map +0 -1
  42. package/dist/schema-builder-CQa-dOw9.d.ts +0 -40
  43. package/dist/schema-builder-CQa-dOw9.d.ts.map +0 -1
  44. package/dist/schema-builder-QkY6hZn6.d.cts +0 -40
  45. package/dist/schema-builder-QkY6hZn6.d.cts.map +0 -1
@@ -1,11 +1,77 @@
1
- import { C as ObjectTypeProfile, Ct as GetSignature, Et as ConstValue, F as AnyMetadataAdapter, G as FragmentMetadataBuilder, I as DefaultAdapter, L as DefaultMetadataAdapter, N as Adapter, Ot as FieldPath, P as AnyAdapter, R as ExtractAdapterTypes, S as GetModifiedType, St as ApplyTypeModifier, T as TypeProfile, X as AnyVarRef, Z as AnyVarRefBrand, bt as OutputTypenameSpecifier, c as InferOutputProfile, dt as InputTypeSpecifier, et as VarRef, f as ObjectFieldRecord, ft as InputTypeSpecifiers, g as ResolveInputProfileFromMeta, gt as OutputScalarSpecifier, h as PickTypeSpecifierByFieldName, ht as OutputObjectSpecifier, i as AnyTypeName, it as AnyDefaultValue, m as OperationType, mt as OutputInferrableTypeSpecifier, n as AnyFieldName, o as InferInputKind, pt as OutputEnumSpecifier, q as MetadataBuilder, r as AnyGraphqlSchema, s as InferInputProfile, t as AllInputTypeNames, ut as InputTypeKind, vt as OutputTypeSpecifier, w as PrimitiveTypeProfile, wt as TypeModifier, x as GetConstAssignableType, xt as OutputUnionSpecifier, y as UnionMemberName } from "./schema-C1lnWj-m.cjs";
1
+ import { C as ObjectTypeProfile, Ct as GetSignature, Et as ConstValue, F as AnyMetadataAdapter, G as FragmentMetadataBuilder, I as DefaultAdapter, L as DefaultMetadataAdapter, N as Adapter, Ot as FieldPath, P as AnyAdapter, R as ExtractAdapterTypes, S as GetModifiedType, St as ApplyTypeModifier, T as TypeProfile, X as AnyVarRef, Z as AnyVarRefBrand, bt as OutputTypenameSpecifier, c as InferOutputProfile, dt as InputTypeSpecifier, et as VarRef, f as ObjectFieldRecord, ft as InputTypeSpecifiers, g as ResolveInputProfileFromMeta, gt as OutputScalarSpecifier, h as PickTypeSpecifierByFieldName, ht as OutputObjectSpecifier, i as AnyTypeName, it as AnyDefaultValue, m as OperationType, mt as OutputInferrableTypeSpecifier, n as AnyFieldName, o as InferInputKind, pt as OutputEnumSpecifier, q as MetadataBuilder, r as AnyGraphqlSchema, s as InferInputProfile, t as AllInputTypeNames, ut as InputTypeKind, vt as OutputTypeSpecifier, w as PrimitiveTypeProfile, wt as TypeModifier, x as GetConstAssignableType, xt as OutputUnionSpecifier, y as UnionMemberName } from "./schema-2qqtKss4.js";
2
2
  import { ConstValueNode, NamedTypeNode, OperationTypeNode, TypeNode, ValueNode } from "graphql";
3
3
  import { TypedDocumentNode } from "@graphql-typed-document-node/core";
4
4
 
5
+ //#region packages/core/src/types/type-foundation/directive-ref.d.ts
6
+
7
+ /**
8
+ * DirectiveRef type for representing field-level directives.
9
+ *
10
+ * Similar to VarRef, DirectiveRef uses a branded type pattern to carry
11
+ * type information about the directive (name, locations, arguments) while
12
+ * allowing relaxed type checking at the field builder level.
13
+ *
14
+ * @module
15
+ */
16
+ /**
17
+ * Valid locations where a directive can be applied.
18
+ * Subset of GraphQL DirectiveLocation enum relevant for soda-gql.
19
+ */
20
+ type DirectiveLocation = "QUERY" | "MUTATION" | "SUBSCRIPTION" | "FIELD" | "FRAGMENT_DEFINITION" | "FRAGMENT_SPREAD" | "INLINE_FRAGMENT" | "VARIABLE_DEFINITION";
21
+ /**
22
+ * Brand interface for DirectiveRef type information.
23
+ * Contains the directive name and valid locations.
24
+ */
25
+ interface AnyDirectiveRefBrand {
26
+ readonly directiveName: string;
27
+ readonly locations: readonly DirectiveLocation[];
28
+ }
29
+ /**
30
+ * Internal structure of a DirectiveRef.
31
+ * Contains the directive name, arguments, and valid locations.
32
+ */
33
+ type DirectiveRefInner = {
34
+ readonly name: string;
35
+ readonly arguments: Readonly<Record<string, unknown>>;
36
+ readonly locations: readonly DirectiveLocation[];
37
+ };
38
+ declare const __DIRECTIVE_REF_BRAND__: unique symbol;
39
+ /**
40
+ * A reference to a directive that can be applied to fields.
41
+ *
42
+ * DirectiveRef carries type information about the directive via the TBrand
43
+ * type parameter, but this information is only used for type inference,
44
+ * not for runtime validation.
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const skipDirective = new DirectiveRef({
49
+ * name: "skip",
50
+ * arguments: { if: true },
51
+ * locations: ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"],
52
+ * });
53
+ * ```
54
+ */
55
+ declare class DirectiveRef<TBrand extends AnyDirectiveRefBrand> {
56
+ private readonly inner;
57
+ readonly [__DIRECTIVE_REF_BRAND__]: TBrand;
58
+ constructor(inner: DirectiveRefInner);
59
+ /**
60
+ * Extracts the inner structure from a DirectiveRef.
61
+ * Used by build-document.ts to generate DirectiveNode.
62
+ */
63
+ static getInner(ref: AnyDirectiveRef): DirectiveRefInner;
64
+ }
65
+ /**
66
+ * Type-erased DirectiveRef for use in contexts where
67
+ * the specific directive type is not needed.
68
+ */
69
+ type AnyDirectiveRef = DirectiveRef<AnyDirectiveRefBrand>;
70
+ //#endregion
5
71
  //#region packages/core/src/types/type-foundation/type-modifier-extension.generated.d.ts
6
72
  type Op_0<T> = T[];
7
73
  type Op_1<T> = T[] | null | undefined;
8
- type Ref<T extends TypeProfile, M$1 extends string> = VarRef<TypeProfile.VarRefBrand<T, GetSignature<M$1>>>;
74
+ type Ref<T extends TypeProfile, M$1 extends string> = VarRef<TypeProfile.ExpectedVariableType<T, GetSignature<M$1>>>;
9
75
  type IsOptionalProfile<TField extends TypeProfile.WithMeta> = TField[1] extends `${string}?` ? true : TField[2] extends TypeProfile.WITH_DEFAULT_INPUT ? true : false;
10
76
  type OptionalProfileKeys<TProfileObject extends {
11
77
  readonly [key: string]: TypeProfile.WithMeta;
@@ -83,19 +149,27 @@ type AnyAssigningInput = {
83
149
  readonly [key: string]: AnyVarRef;
84
150
  };
85
151
  type IsOptional<TSpecifier$1 extends InputTypeSpecifier> = TSpecifier$1["modifier"] extends `${string}?` ? true : TSpecifier$1["defaultValue"] extends AnyDefaultValue ? true : false;
86
- type AssignableInput<TSchema extends AnyGraphqlSchema, TSpecifiers extends InputTypeSpecifiers> = { readonly [K in keyof TSpecifiers as IsOptional<TSpecifiers[K]> extends true ? K : never]+?: AssignableInputValue<TSchema, TSpecifiers[K]> } & { readonly [K in keyof TSpecifiers as IsOptional<TSpecifiers[K]> extends false ? K : never]-?: AssignableInputValue<TSchema, TSpecifiers[K]> };
152
+ type AssignableInput<TSchema extends AnyGraphqlSchema, TSpecifiers extends InputTypeSpecifiers> = { readonly [K in keyof TSpecifiers as IsOptional<TSpecifiers[K]> extends true ? K : never]+?: FieldArgumentValue<TSchema, TSpecifiers[K]> } & { readonly [K in keyof TSpecifiers as IsOptional<TSpecifiers[K]> extends false ? K : never]-?: FieldArgumentValue<TSchema, TSpecifiers[K]> };
87
153
  /**
88
- * Assignable input value type using typeName + kind for VarRef comparison.
154
+ * Field argument value type using typeName + kind for VarRef comparison.
89
155
  * Uses GetAssignableType which derives typeName + kind from the profile.
156
+ * This name appears in TypeScript error messages when argument types don't match.
90
157
  */
91
- type AssignableInputValue<TSchema extends AnyGraphqlSchema, TSpecifier$1 extends InputTypeSpecifier> = GetAssignableType<InferInputProfile<TSchema, TSpecifier$1>>;
92
- type AssigningInput<TSchema extends AnyGraphqlSchema, TSpecifiers extends InputTypeSpecifiers> = { readonly [K in keyof TSpecifiers]-?: VarRef<TypeProfile.AssigningVarRefBrand<InferInputProfile<TSchema, TSpecifiers[K]>>> };
158
+ type FieldArgumentValue<TSchema extends AnyGraphqlSchema, TSpecifier$1 extends InputTypeSpecifier> = GetAssignableType<InferInputProfile<TSchema, TSpecifier$1>>;
159
+ /**
160
+ * Declared variables record for an operation or fragment.
161
+ * Maps variable names to their VarRef types with proper branding.
162
+ * This name appears in TypeScript error messages when variable access fails.
163
+ */
164
+ type DeclaredVariables<TSchema extends AnyGraphqlSchema, TSpecifiers extends InputTypeSpecifiers> = { readonly [K in keyof TSpecifiers]-?: VarRef<TypeProfile.DeclaredVariableType<InferInputProfile<TSchema, TSpecifiers[K]>>> };
93
165
  type AssignableInputByFieldName<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"], TFieldName$1 extends keyof TSchema["object"][TTypeName$1]["fields"]> = AssignableInput<TSchema, TSchema["object"][TTypeName$1]["fields"][TFieldName$1]["arguments"]>;
94
166
  //#endregion
95
167
  //#region packages/core/src/types/fragment/directives.d.ts
96
- type AnyDirectiveAttachments = {
97
- readonly [key: string]: AnyAssignableInput;
98
- };
168
+ /**
169
+ * Field-level directive attachments as an array of DirectiveRef.
170
+ * Directives are applied in order and validated at build time.
171
+ */
172
+ type AnyDirectiveAttachments = readonly AnyDirectiveRef[];
99
173
  //#endregion
100
174
  //#region packages/core/src/types/fragment/field-selection.d.ts
101
175
  /**
@@ -164,10 +238,47 @@ type InferField<TSchema extends AnyGraphqlSchema, TSelection extends AnyFieldSel
164
238
  } ? GetModifiedType<InferOutputProfile<TSchema, TSpecifier>, TSpecifier["modifier"]> : never);
165
239
  //#endregion
166
240
  //#region packages/core/src/composer/build-document.d.ts
241
+ /**
242
+ * Converts an assignable input value to a GraphQL AST ValueNode.
243
+ *
244
+ * Handles primitives, arrays, objects, and variable references.
245
+ * Returns null for undefined values (field is omitted).
246
+ */
167
247
  declare const buildArgumentValue: (value: AnyAssignableInputValue) => ValueNode | null;
248
+ /**
249
+ * Converts a constant value to a GraphQL AST ConstValueNode.
250
+ *
251
+ * Unlike `buildArgumentValue`, this only handles literal values
252
+ * (no variable references). Used for default values.
253
+ */
168
254
  declare const buildConstValueNode: (value: ConstValue) => ConstValueNode | null;
255
+ /**
256
+ * Wraps a named type with modifiers (non-null, list).
257
+ *
258
+ * Modifier format: starts with `?` (nullable) or `!` (non-null),
259
+ * followed by `[]?` or `[]!` pairs for lists.
260
+ *
261
+ * @example
262
+ * - `"!"` → `String!`
263
+ * - `"?"` → `String`
264
+ * - `"![]!"` → `[String!]!`
265
+ * - `"?[]?"` → `[String]`
266
+ */
169
267
  declare const buildWithTypeModifier: (modifier: TypeModifier, buildType: () => NamedTypeNode) => TypeNode;
268
+ /**
269
+ * Converts an operation type string to a GraphQL AST OperationTypeNode.
270
+ */
170
271
  declare const buildOperationTypeNode: (operation: OperationType) => OperationTypeNode;
272
+ /**
273
+ * Builds a TypedDocumentNode from operation options.
274
+ *
275
+ * This is the main entry point for converting field selections into
276
+ * a GraphQL document AST. The result can be used with any GraphQL
277
+ * client that supports TypedDocumentNode.
278
+ *
279
+ * @param options - Operation configuration (name, type, variables, fields)
280
+ * @returns TypedDocumentNode with inferred input/output types
281
+ */
171
282
  declare const buildDocument: <TSchema extends AnyGraphqlSchema, TFields extends AnyFields, TVarDefinitions extends InputTypeSpecifiers>(options: {
172
283
  operationName: string;
173
284
  operationType: OperationType;
@@ -220,6 +331,130 @@ type ColocatedFields<TEntries extends ColocatedEntries> = UnionToIntersection<{
220
331
  declare const createColocateHelper: () => <TEntries extends ColocatedEntries>(entries: TEntries) => ColocatedFields<TEntries>;
221
332
  type ColocateHelper = ReturnType<typeof createColocateHelper>;
222
333
  //#endregion
334
+ //#region packages/core/src/composer/directive-builder.d.ts
335
+ /**
336
+ * A method that creates a DirectiveRef with specific type information.
337
+ * The TArgs type defines the expected argument shape for the directive.
338
+ */
339
+ type DirectiveMethod<TDirectiveName extends string, TLocations extends readonly DirectiveLocation[], TArgs> = (args: TArgs) => DirectiveRef<{
340
+ directiveName: TDirectiveName;
341
+ locations: TLocations;
342
+ }>;
343
+ /**
344
+ * Type for directive arguments that can include VarRef values.
345
+ * This allows using variables in directive arguments like `{ if: $.shouldSkip }`.
346
+ */
347
+ type DirectiveArgValue = boolean | string | number | null | AnyVarRef;
348
+ /**
349
+ * Standard GraphQL directives that are always available.
350
+ */
351
+ type StandardDirectives = {
352
+ /**
353
+ * @skip directive - conditionally skip a field.
354
+ * @example
355
+ * ```typescript
356
+ * f.email({}, { directives: [$dir.skip({ if: $.hideEmail })] })
357
+ * ```
358
+ */
359
+ skip: DirectiveMethod<"skip", readonly ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"], {
360
+ if: DirectiveArgValue;
361
+ }>;
362
+ /**
363
+ * @include directive - conditionally include a field.
364
+ * @example
365
+ * ```typescript
366
+ * f.email({}, { directives: [$dir.include({ if: $.showEmail })] })
367
+ * ```
368
+ */
369
+ include: DirectiveMethod<"include", readonly ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"], {
370
+ if: DirectiveArgValue;
371
+ }>;
372
+ };
373
+ /**
374
+ * Creates a directive method factory for a specific directive.
375
+ *
376
+ * @param name - The directive name (without @)
377
+ * @param locations - Valid locations where the directive can be applied
378
+ * @returns A function that creates DirectiveRef instances
379
+ *
380
+ * @example
381
+ * ```typescript
382
+ * const skipMethod = createDirectiveMethod("skip", ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"] as const);
383
+ * const skipDirective = skipMethod({ if: true });
384
+ * ```
385
+ */
386
+ declare const createDirectiveMethod: <TDirectiveName extends string, const TLocations extends readonly DirectiveLocation[]>(name: TDirectiveName, locations: TLocations) => (<TArgs extends Record<string, unknown>>(args: TArgs) => DirectiveRef<{
387
+ directiveName: TDirectiveName;
388
+ locations: TLocations;
389
+ }>);
390
+ /**
391
+ * Creates the standard GraphQL directives (@skip, @include).
392
+ * These are always available regardless of schema definition.
393
+ *
394
+ * @returns Object containing skip and include directive methods
395
+ *
396
+ * @example
397
+ * ```typescript
398
+ * const $dir = createStandardDirectives();
399
+ * const skipDirective = $dir.skip({ if: true });
400
+ * ```
401
+ */
402
+ declare const createStandardDirectives: () => StandardDirectives;
403
+ /**
404
+ * Type for any directive method (type-erased).
405
+ */
406
+ type AnyDirectiveMethod = (args: any) => AnyDirectiveRef;
407
+ /**
408
+ * Type for the directive builder that includes standard directives
409
+ * and can be extended with schema-specific directives.
410
+ */
411
+ type DirectiveBuilder<TCustomDirectives extends Record<string, AnyDirectiveMethod> = {}> = StandardDirectives & TCustomDirectives;
412
+ /**
413
+ * Creates a directive builder with standard directives and optional custom directives.
414
+ *
415
+ * @param customDirectives - Additional directive methods from schema (generated by codegen)
416
+ * @returns Combined directive builder with all available directives
417
+ *
418
+ * @internal Used by codegen to create schema-specific directive builders
419
+ */
420
+ declare const createDirectiveBuilder: <TCustomDirectives extends Record<string, AnyDirectiveMethod> = {}>(customDirectives?: TCustomDirectives) => DirectiveBuilder<TCustomDirectives>;
421
+ /**
422
+ * Type guard to check if a value is a DirectiveRef.
423
+ *
424
+ * @param value - Value to check
425
+ * @returns True if value is a DirectiveRef instance
426
+ */
427
+ declare const isDirectiveRef: (value: unknown) => value is AnyDirectiveRef;
428
+ //#endregion
429
+ //#region packages/core/src/types/element/attachment-types.d.ts
430
+ /**
431
+ * Shape constraint for attachment objects used in type utilities.
432
+ */
433
+ type AttachmentShape = {
434
+ name: string;
435
+ createValue: (element: any) => object;
436
+ };
437
+ /**
438
+ * Extracts the property type contribution from a single attachment.
439
+ * Maps GqlElementAttachment<E, N, V> to { [N]: V }
440
+ */
441
+ type AttachmentToProperty<TAttachment> = TAttachment extends {
442
+ name: infer TName extends string;
443
+ createValue: (element: any) => infer TValue extends object;
444
+ } ? { [K in TName]: TValue } : never;
445
+ /**
446
+ * Recursively maps a tuple of attachments to an intersection of their properties.
447
+ *
448
+ * @example
449
+ * type Attachments = [
450
+ * { name: "a"; createValue: (el: any) => { x: number } },
451
+ * { name: "b"; createValue: (el: any) => { y: string } }
452
+ * ];
453
+ * type Result = AttachmentsTupleToIntersection<Attachments>;
454
+ * // Result: { a: { x: number } } & { b: { y: string } }
455
+ */
456
+ type AttachmentsTupleToIntersection<TAttachments extends readonly AttachmentShape[]> = TAttachments extends readonly [infer First extends AttachmentShape, ...infer Rest extends readonly AttachmentShape[]] ? AttachmentToProperty<First> & AttachmentsTupleToIntersection<Rest> : unknown;
457
+ //#endregion
223
458
  //#region packages/core/src/utils/empty-object.d.ts
224
459
  declare const __EMPTY_SYMBOL__: unique symbol;
225
460
  type EmptyObject = {
@@ -245,25 +480,48 @@ declare const empty: () => EmptyObject;
245
480
  * while preserving the original schema information for inference.
246
481
  */
247
482
  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
+ /**
484
+ * Tools provided to field builder callbacks.
485
+ * - `f`: Field selection factories for the current type
486
+ * - `$`: Variable references for the current scope
487
+ */
248
488
  type FieldsBuilderTools<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"] & string, TVariableDefinitions extends InputTypeSpecifiers> = {
249
489
  f: FieldSelectionFactories<TSchema, TTypeName$1>;
250
- $: AssigningInput<TSchema, TVariableDefinitions>;
490
+ $: DeclaredVariables<TSchema, TVariableDefinitions>;
251
491
  };
252
- /** Narrow builder used when a field resolves to an object and we need nested selections. */
492
+ /**
493
+ * Builder for nested object field selections.
494
+ * Used when a field returns an object type requiring sub-selections.
495
+ */
253
496
  type NestedObjectFieldsBuilder<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"] & string, TFields extends AnyNestedObject> = (tools: NoInfer<NestedObjectFieldsBuilderTools<TSchema, TTypeName$1>>) => TFields;
497
+ /**
498
+ * Tools for nested object builders (no variable access).
499
+ * @internal
500
+ */
254
501
  type NestedObjectFieldsBuilderTools<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"] & string> = {
255
502
  f: FieldSelectionFactories<TSchema, TTypeName$1>;
256
503
  };
504
+ /**
505
+ * Builder for union type selections with per-member field definitions.
506
+ */
257
507
  type NestedUnionFieldsBuilder<TSchema extends AnyGraphqlSchema, TMemberName extends string, TUnionFields extends AnyNestedUnion> = { [TTypename in keyof TUnionFields & TMemberName]?: NestedObjectFieldsBuilder<TSchema, TTypename, NonNullable<TUnionFields[TTypename]>> };
258
508
  /** Map each field to a factory capable of emitting fully-typed references. */
259
509
  type FieldSelectionFactories<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"] & string> = { [TFieldName in keyof ObjectFieldRecord<TSchema, TTypeName$1>]: TFieldName extends string ? FieldSelectionFactory<TSchema, FieldSelectionTemplateOf<TSchema, TTypeName$1, TFieldName>> : never };
510
+ /**
511
+ * Type-erased field selection factory.
512
+ * @internal
513
+ */
260
514
  type AnyFieldSelectionFactory = <TAlias extends string | null = null>(fieldArgs: AnyAssignableInput | void, extras?: {
261
515
  alias?: TAlias;
262
- directives?: AnyDirectiveAttachments;
516
+ directives?: AnyDirectiveRef[];
263
517
  }) => AnyFieldSelectionFactoryReturn<TAlias>;
518
+ /**
519
+ * Factory function for creating a typed field selection.
520
+ * Accepts field arguments and optional alias/directives.
521
+ */
264
522
  type FieldSelectionFactory<TSchema extends AnyGraphqlSchema, TSelection extends AnyFieldSelection> = <TAlias extends string | null = null>(fieldArgs: TSelection["args"] | IfOmittable<TSelection["args"], void | null>, extras?: {
265
523
  alias?: TAlias;
266
- directives?: TSelection["directives"];
524
+ directives?: AnyDirectiveRef[];
267
525
  }) => FieldSelectionFactoryReturn<TSchema, TSelection, TAlias>;
268
526
  type AnyFieldSelectionFactoryReturn<TAlias extends string | null> = FieldSelectionFactoryReturn<AnyGraphqlSchema, AnyFieldSelection & {
269
527
  type: OutputObjectSpecifier;
@@ -305,42 +563,138 @@ type LazyEvaluatorContext = {
305
563
  //#region packages/core/src/types/element/gql-element.d.ts
306
564
  declare const GQL_ELEMENT_FACTORY: unique symbol;
307
565
  declare const GQL_ELEMENT_CONTEXT: unique symbol;
566
+ /**
567
+ * Context passed to element definition factories, containing the canonical ID.
568
+ */
308
569
  type GqlElementContext = LazyEvaluatorContext;
570
+ /**
571
+ * Factory function that produces the element definition.
572
+ * May be sync or async (async requires async build mode).
573
+ */
309
574
  type GqlElementDefinitionFactory<T> = (context: GqlElementContext | null) => T | Promise<T>;
310
- type GqlElementAttachment<TElement extends object, TName$1 extends string, TValue extends object> = {
575
+ /**
576
+ * Configuration for attaching a computed property to an element.
577
+ */
578
+ type GqlElementAttachment<TElement extends object, TName$1 extends string, TValue$1 extends object> = {
311
579
  name: TName$1;
312
- createValue: (element: TElement) => TValue;
580
+ createValue: (element: TElement) => TValue$1;
313
581
  };
582
+ /**
583
+ * Abstract base class for all GraphQL elements (Fragment, Operation).
584
+ *
585
+ * Uses lazy evaluation with caching - definition is computed on first access.
586
+ * Subclasses should not be instantiated directly; use static `create` methods.
587
+ *
588
+ * @template TDefinition - The shape of the evaluated definition
589
+ * @template TInfer - Type inference metadata (access via `$infer`)
590
+ */
314
591
  declare abstract class GqlElement<TDefinition extends object, TInfer extends object> {
592
+ /**
593
+ * Type-only property for inference. Throws at runtime.
594
+ * Use with `typeof element.$infer` to extract input/output types.
595
+ */
315
596
  readonly $infer: TInfer;
316
597
  private [GQL_ELEMENT_FACTORY];
317
598
  private [GQL_ELEMENT_CONTEXT];
318
599
  protected constructor(define: GqlElementDefinitionFactory<TDefinition>, getDeps?: () => GqlElement<any, any>[]);
319
- attach<TName$1 extends string, TValue extends object>(attachment: GqlElementAttachment<this, TName$1, TValue>): this & { [_ in TName$1]: TValue };
600
+ /**
601
+ * Attaches lazily-computed properties to this element.
602
+ * Properties are computed once on first access after evaluation.
603
+ *
604
+ * @example Single attachment
605
+ * ```typescript
606
+ * const fragment = gql.default(...)
607
+ * .attach({ name: "utils", createValue: (el) => ({ ... }) });
608
+ * ```
609
+ *
610
+ * @example Multiple attachments (use `as const` for full type inference)
611
+ * ```typescript
612
+ * const fragment = gql.default(...)
613
+ * .attach([
614
+ * { name: "a", createValue: () => ({ x: 1 }) },
615
+ * { name: "b", createValue: () => ({ y: 2 }) },
616
+ * ] as const);
617
+ * ```
618
+ */
619
+ attach<TName$1 extends string, TValue$1 extends object>(attachment: GqlElementAttachment<this, TName$1, TValue$1>): this & { [K in TName$1]: TValue$1 };
620
+ attach<const TAttachments extends readonly AttachmentShape[]>(attachments: TAttachments): this & AttachmentsTupleToIntersection<TAttachments>;
621
+ /**
622
+ * Sets the canonical context for an element. Used by the builder.
623
+ * @internal
624
+ */
320
625
  static setContext<TElement extends GqlElement<any, any>>(element: TElement, context: GqlElementContext): void;
626
+ /**
627
+ * Gets the canonical context of an element, if set.
628
+ * @internal
629
+ */
321
630
  static getContext(element: GqlElement<any, any>): GqlElementContext | null;
631
+ /**
632
+ * Creates a generator for async evaluation. Used by the builder.
633
+ * @internal
634
+ */
322
635
  static createEvaluationGenerator(element: GqlElement<any, any>): Generator<Promise<void>, void, void>;
323
636
  private static evaluateInstantly;
637
+ /**
638
+ * Forces synchronous evaluation. Throws if async operation is needed.
639
+ * @internal
640
+ */
324
641
  static evaluateSync(element: GqlElement<any, any>): void;
325
- static get<TValue extends object>(element: GqlElement<TValue, any>): TValue;
642
+ /**
643
+ * Evaluates and returns the element's definition.
644
+ * Throws if async operation is needed.
645
+ * @internal
646
+ */
647
+ static get<TValue$1 extends object>(element: GqlElement<TValue$1, any>): TValue$1;
326
648
  }
327
649
  //#endregion
328
650
  //#region packages/core/src/types/element/fragment.d.ts
651
+ /**
652
+ * Type alias for any Fragment instance.
653
+ */
329
654
  type AnyFragment = Fragment<string, any, AnyFields, any>;
655
+ /**
656
+ * Type inference metadata for fragments.
657
+ * Access via `typeof fragment.$infer`.
658
+ */
330
659
  type FragmentInferMeta<TVariables, TOutput extends object> = {
331
660
  readonly input: TVariables;
332
661
  readonly output: TOutput;
333
662
  };
663
+ /**
664
+ * Internal artifact shape produced by fragment evaluation.
665
+ * @internal
666
+ */
334
667
  interface FragmentArtifact<TTypeName$1 extends string, TVariables extends Partial<AnyAssignableInput> | void, TFields extends Partial<AnyFields>> {
335
668
  readonly typename: TTypeName$1;
336
669
  readonly spread: (variables: TVariables) => TFields;
337
670
  }
338
671
  declare const __FRAGMENT_BRAND__: unique symbol;
672
+ /**
673
+ * Represents a reusable GraphQL field selection on a specific type.
674
+ *
675
+ * Fragments are created via `gql(({ fragment }) => fragment.TypeName({ ... }))`.
676
+ * Use `spread()` to include the fragment's fields in an operation.
677
+ *
678
+ * @template TTypeName - The GraphQL type this fragment selects from
679
+ * @template TVariables - Variables required when spreading
680
+ * @template TFields - The selected fields structure
681
+ * @template TOutput - Inferred output type from selected fields
682
+ */
339
683
  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> {
340
684
  private readonly [__FRAGMENT_BRAND__];
341
685
  private constructor();
686
+ /** The GraphQL type name this fragment selects from. */
342
687
  get typename(): TTypeName$1;
688
+ /**
689
+ * Spreads this fragment's fields into a parent selection.
690
+ * Pass variables if the fragment defines any.
691
+ */
343
692
  get spread(): (variables: TVariables) => TFields;
693
+ /**
694
+ * Creates a new Fragment instance.
695
+ * Prefer using the `gql(({ fragment }) => ...)` API instead.
696
+ * @internal
697
+ */
344
698
  static create<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"] & string, TVariableDefinitions extends InputTypeSpecifiers, TFields extends AnyFields>(define: () => {
345
699
  typename: TTypeName$1;
346
700
  spread: (variables: OptionalArg<AssignableInput<TSchema, TVariableDefinitions>>) => TFields;
@@ -352,13 +706,27 @@ declare class Fragment<TTypeName$1 extends string, TVariables extends Partial<An
352
706
  }
353
707
  //#endregion
354
708
  //#region packages/core/src/types/element/operation.d.ts
709
+ /**
710
+ * Type alias for any Operation instance.
711
+ */
355
712
  type AnyOperation = AnyOperationOf<"query"> | AnyOperationOf<"mutation"> | AnyOperationOf<"subscription">;
713
+ /**
714
+ * Type alias for an Operation of a specific type.
715
+ */
356
716
  type AnyOperationOf<TOperationType extends OperationType> = Operation<TOperationType, string, string[], any, AnyFields, any>;
717
+ /**
718
+ * Type inference metadata for operations.
719
+ * Access via `typeof operation.$infer`.
720
+ */
357
721
  type OperationInferMeta<TVariables, TData extends object> = {
358
722
  readonly input: TVariables;
359
723
  readonly output: TData;
360
724
  };
361
725
  declare const __OPERATION_BRAND__: unique symbol;
726
+ /**
727
+ * Internal artifact shape produced by operation evaluation.
728
+ * @internal
729
+ */
362
730
  type OperationArtifact<TOperationType extends OperationType, TOperationName extends string, TVariableNames extends string[], TVariables extends AnyConstAssignableInput, TFields extends Partial<AnyFields>, TData extends object> = {
363
731
  readonly operationType: TOperationType;
364
732
  readonly operationName: TOperationName;
@@ -367,15 +735,42 @@ type OperationArtifact<TOperationType extends OperationType, TOperationName exte
367
735
  readonly document: TypedDocumentNode<TData, TVariables>;
368
736
  readonly metadata?: unknown;
369
737
  };
738
+ /**
739
+ * Represents a GraphQL operation (query, mutation, or subscription).
740
+ *
741
+ * Operations are created via `gql(({ query }) => query.operation({ ... }))`.
742
+ * Produces a TypedDocumentNode for type-safe execution with GraphQL clients.
743
+ *
744
+ * @template TOperationType - 'query' | 'mutation' | 'subscription'
745
+ * @template TOperationName - The unique operation name
746
+ * @template TVariableNames - Tuple of variable names
747
+ * @template TVariables - Variable types for the operation
748
+ * @template TFields - Selected fields structure
749
+ * @template TData - Inferred response data type
750
+ */
370
751
  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> {
371
752
  private readonly [__OPERATION_BRAND__];
372
753
  private constructor();
754
+ /** The operation type: 'query', 'mutation', or 'subscription'. */
373
755
  get operationType(): TOperationType;
756
+ /** The unique name of this operation. */
374
757
  get operationName(): TOperationName;
758
+ /** List of variable names defined for this operation. */
375
759
  get variableNames(): TVariableNames;
760
+ /**
761
+ * Returns the field selections. Used for document reconstruction.
762
+ * @internal
763
+ */
376
764
  get documentSource(): () => TFields;
765
+ /** The TypedDocumentNode for use with GraphQL clients. */
377
766
  get document(): TypedDocumentNode<TData, TVariables>;
767
+ /** Custom metadata attached to this operation, if any. */
378
768
  get metadata(): unknown;
769
+ /**
770
+ * Creates a new Operation instance.
771
+ * Prefer using the `gql(({ query }) => ...)` API instead.
772
+ * @internal
773
+ */
379
774
  static create<TSchema extends AnyGraphqlSchema, TOperationType extends OperationType, TOperationName extends string, TVariableDefinitions extends InputTypeSpecifiers, TFields extends AnyFields>(define: (context: GqlElementContext | null) => {
380
775
  operationType: TOperationType;
381
776
  operationName: TOperationName;
@@ -394,25 +789,70 @@ declare class Operation<TOperationType extends OperationType, TOperationName ext
394
789
  }
395
790
  //#endregion
396
791
  //#region packages/core/src/composer/fields-builder.d.ts
792
+ /**
793
+ * Creates field selection factories for a given object type.
794
+ *
795
+ * Returns an object with a factory for each field defined on the type.
796
+ * Factories are cached per schema+type to avoid recreation.
797
+ *
798
+ * @param schema - The GraphQL schema definition
799
+ * @param typeName - The object type name to create factories for
800
+ * @returns Object mapping field names to their selection factories
801
+ *
802
+ * @internal Used by operation and fragment composers
803
+ */
397
804
  declare const createFieldFactories: <TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"] & string>(schema: TSchema, typeName: TTypeName$1) => FieldSelectionFactories<TSchema, TTypeName$1>;
398
805
  //#endregion
399
806
  //#region packages/core/src/composer/input.d.ts
400
- declare const createVarAssignments: <TSchema extends AnyGraphqlSchema, TVariableDefinitions extends InputTypeSpecifiers>(definitions: TVariableDefinitions, providedValues: AnyAssignableInput | void) => AssigningInput<TSchema, TVariableDefinitions>;
401
- declare const createVarRefs: <TSchema extends AnyGraphqlSchema, TVarDefinitions extends InputTypeSpecifiers>(definitions: TVarDefinitions) => AssigningInput<TSchema, TVarDefinitions>;
807
+ /**
808
+ * Creates variable assignments from provided values.
809
+ *
810
+ * Maps variable definitions to VarRefs. If a value is provided,
811
+ * wraps it as a nested-value VarRef. If not provided, creates
812
+ * an undefined VarRef (field will be omitted).
813
+ *
814
+ * Used when spreading fragments with partial variable values.
815
+ *
816
+ * @internal
817
+ */
818
+ declare const createVarAssignments: <TSchema extends AnyGraphqlSchema, TVariableDefinitions extends InputTypeSpecifiers>(definitions: TVariableDefinitions, providedValues: AnyAssignableInput | void) => DeclaredVariables<TSchema, TVariableDefinitions>;
819
+ /**
820
+ * Creates variable references from variable definitions.
821
+ *
822
+ * Maps each variable definition to a VarRef pointing to that variable.
823
+ * Used in operation builders to create the `$` context object.
824
+ *
825
+ * @internal
826
+ */
827
+ declare const createVarRefs: <TSchema extends AnyGraphqlSchema, TVarDefinitions extends InputTypeSpecifiers>(definitions: TVarDefinitions) => DeclaredVariables<TSchema, TVarDefinitions>;
402
828
  //#endregion
403
829
  //#region packages/core/src/composer/fragment.d.ts
404
830
  /**
405
831
  * Type alias for a fragment builder function for a specific object type.
406
- * Used in codegen to generate explicit fragment builder types instead of mapped types.
832
+ *
833
+ * Used by codegen to generate explicit fragment builder types instead of
834
+ * expensive mapped types. This improves IDE performance for large schemas.
407
835
  */
408
836
  type FragmentBuilderFor<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"] & string, TAdapter extends AnyMetadataAdapter = DefaultMetadataAdapter> = <TFields extends AnyFields, TVarDefinitions extends InputTypeSpecifiers = {}>(options: {
409
837
  variables?: TVarDefinitions;
410
838
  metadata?: FragmentMetadataBuilder<ReturnType<typeof createVarRefs<TSchema, TVarDefinitions>>, ExtractAdapterTypes<TAdapter>["fragmentMetadata"]>;
411
839
  fields: FieldsBuilder<TSchema, TTypeName$1, TVarDefinitions, TFields>;
412
840
  }) => ReturnType<typeof Fragment.create<TSchema, TTypeName$1, TVarDefinitions, TFields>>;
841
+ /**
842
+ * Creates fragment builder functions for all object types in the schema.
843
+ *
844
+ * Returns an object with a builder for each type (e.g., `fragment.User`, `fragment.Post`).
845
+ * Each builder creates a `Fragment` that can be spread into operations.
846
+ *
847
+ * @param schema - The GraphQL schema definition
848
+ * @param _adapter - Optional metadata adapter (for fragment metadata)
849
+ * @returns Object mapping type names to fragment builder functions
850
+ *
851
+ * @internal Used by `createGqlElementComposer`
852
+ */
413
853
  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: {
414
854
  variables?: TVarDefinitions | undefined;
415
- metadata?: FragmentMetadataBuilder<AssigningInput<TSchema, TVarDefinitions>, ExtractAdapterTypes<TAdapter>["fragmentMetadata"]> | undefined;
855
+ metadata?: FragmentMetadataBuilder<DeclaredVariables<TSchema, TVarDefinitions>, ExtractAdapterTypes<TAdapter>["fragmentMetadata"]> | undefined;
416
856
  fields: FieldsBuilder<TSchema, TTypeName, TVarDefinitions, TFields>;
417
857
  }) => Fragment<TTypeName, OptionalArg<AssignableInput<TSchema, TVarDefinitions>>, TFields & {
418
858
  [key: symbol]: never;
@@ -471,6 +911,18 @@ type PathSegment = string;
471
911
  * Proxy type that records property accesses.
472
912
  */
473
913
  type SelectableProxy<T> = T;
914
+ /**
915
+ * Gets the full path to a variable within a nested structure.
916
+ *
917
+ * Returns path segments starting with `$variableName` followed by
918
+ * property accesses within that variable's value.
919
+ *
920
+ * @example
921
+ * ```typescript
922
+ * getVariablePath($.filter, p => p.user.id)
923
+ * // Returns: ["$filter", "user", "id"]
924
+ * ```
925
+ */
474
926
  declare const getVariablePath: <T, U>(varRef: VarRef<AnyVarRefBrand>, selector: (proxy: SelectableProxy<T>) => U) => readonly PathSegment[];
475
927
  //#endregion
476
928
  //#region packages/core/src/composer/var-builder.d.ts
@@ -501,7 +953,9 @@ type AssignableDefaultValue<TSchema extends AnyGraphqlSchema, TKind extends Inpu
501
953
  };
502
954
  }[TKind]>;
503
955
  /**
504
- * Variable specifier type.
956
+ * Represents a variable definition with its type, modifier, and optional default.
957
+ *
958
+ * Created by `$var.TypeName("modifier", { default?: ... })` calls.
505
959
  */
506
960
  type VarSpecifier<TKind extends InputTypeKind, TTypeName$1 extends string, TModifier extends TypeModifier, TDefaultFn extends (() => unknown) | null, TDirectives extends AnyConstDirectiveAttachments> = {
507
961
  kind: TKind;
@@ -559,7 +1013,19 @@ type WrappedVarMethod<TVarName extends string, TSchema extends AnyGraphqlSchema,
559
1013
  */
560
1014
  type VarBuilderMethods<TVarName extends string, TSchema extends AnyGraphqlSchema> = { [TName in AllInputTypeNames<TSchema>]: WrappedVarMethod<TVarName, TSchema, InferInputKind<TSchema, TName>, TName> };
561
1015
  /**
562
- * Type for the variable builder function.
1016
+ * Variable builder function type.
1017
+ *
1018
+ * Call with a variable name to get type-specific methods.
1019
+ * Also provides utilities for extracting values from VarRefs.
1020
+ *
1021
+ * @example
1022
+ * ```typescript
1023
+ * // In operation definition:
1024
+ * variables: { userId: $var("userId").ID("!") }
1025
+ *
1026
+ * // In metadata builder:
1027
+ * $var.getValueAt($.userId, p => p)
1028
+ * ```
563
1029
  */
564
1030
  type VarBuilder<TSchema extends AnyGraphqlSchema> = {
565
1031
  <TVarName extends string>(varName: TVarName): VarBuilderMethods<TVarName, TSchema>;
@@ -585,11 +1051,26 @@ type SchemaAwareGetValueAt<TSchema extends AnyGraphqlSchema> = <T extends AnyVar
585
1051
  */
586
1052
  type SchemaAwareGetNameAt<TSchema extends AnyGraphqlSchema> = <T extends AnyVarRefBrand, U>(varRef: VarRef<T>, selector: (proxy: ResolveTypeFromMeta<TSchema, T>) => U) => string;
587
1053
  /**
588
- * Creates a variable builder that uses injected input type methods.
1054
+ * Creates a variable builder using injected input type methods.
1055
+ *
1056
+ * The returned builder provides type-safe variable definition methods
1057
+ * for all input types in the schema. Also includes utilities for
1058
+ * extracting variable names and values from VarRefs.
1059
+ *
1060
+ * @param inputTypeMethods - Methods for each input type (from codegen)
1061
+ * @returns Variable builder with methods for all input types
1062
+ *
1063
+ * @internal Used by `createGqlElementComposer`
589
1064
  */
590
1065
  declare const createVarBuilder: <TSchema extends AnyGraphqlSchema>(inputTypeMethods: InputTypeMethods<TSchema>) => VarBuilder<TSchema>;
591
1066
  //#endregion
592
1067
  //#region packages/core/src/composer/gql-composer.d.ts
1068
+ /**
1069
+ * Function signature for composing GraphQL elements (fragments or operations).
1070
+ *
1071
+ * The composer provides a context with builders for fragments, operations,
1072
+ * variables, and colocation helpers.
1073
+ */
593
1074
  type GqlElementComposer<TContext> = <TResult extends AnyFragment | AnyOperation>(composeElement: (context: TContext) => TResult) => TResult;
594
1075
  /**
595
1076
  * Extracts the helpers type from an adapter.
@@ -607,24 +1088,57 @@ type ExtractMetadataAdapter<TAdapter extends AnyAdapter> = TAdapter extends {
607
1088
  * This is the mapped type that's expensive to compute for large schemas.
608
1089
  */
609
1090
  type FragmentBuildersAll<TSchema extends AnyGraphqlSchema, TAdapter extends AnyMetadataAdapter = DefaultMetadataAdapter> = { readonly [TTypeName in keyof TSchema["object"]]: TTypeName extends string ? FragmentBuilderFor<TSchema, TTypeName, TAdapter> : never };
610
- type GqlElementComposerOptions<TSchema extends AnyGraphqlSchema, TAdapter extends AnyAdapter = DefaultAdapter> = {
1091
+ /**
1092
+ * Configuration options for `createGqlElementComposer`.
1093
+ */
1094
+ type GqlElementComposerOptions<TSchema extends AnyGraphqlSchema, TDirectiveMethods extends StandardDirectives, TAdapter extends AnyAdapter = DefaultAdapter> = {
1095
+ /** Optional adapter for custom helpers and metadata handling. */
611
1096
  adapter?: TAdapter;
1097
+ /** Methods for building variable type specifiers. */
612
1098
  inputTypeMethods: InputTypeMethods<TSchema>;
1099
+ /** Optional custom directive methods (including schema-defined directives). */
1100
+ directiveMethods?: TDirectiveMethods;
613
1101
  };
614
1102
  /**
615
1103
  * Creates a GQL element composer for a given schema.
616
1104
  *
617
- * @typeParam TSchema - The GraphQL schema type
618
- * @typeParam TAdapter - The adapter type (optional)
619
- * @typeParam TFragmentBuilders - Pre-computed fragment builders type (optional, for codegen optimization)
1105
+ * This is the main entry point for defining GraphQL operations and fragments.
1106
+ * The returned function provides a context with:
1107
+ * - `fragment`: Builders for each object type
1108
+ * - `query/mutation/subscription`: Operation builders
1109
+ * - `$var`: Variable definition helpers
1110
+ * - `$dir`: Field directive helpers (@skip, @include)
1111
+ * - `$colocate`: Fragment colocation utilities
1112
+ *
1113
+ * @param schema - The GraphQL schema definition
1114
+ * @param options - Configuration including input type methods and optional adapter
1115
+ * @returns Element composer function
1116
+ *
1117
+ * @example
1118
+ * ```typescript
1119
+ * const gql = createGqlElementComposer(schema, { inputTypeMethods });
1120
+ *
1121
+ * const GetUser = gql(({ query, $var, $dir }) =>
1122
+ * query.operation({
1123
+ * name: "GetUser",
1124
+ * variables: { showEmail: $var("showEmail").Boolean("!") },
1125
+ * fields: ({ f, $ }) => ({
1126
+ * ...f.user({ id: "1" })(({ f }) => ({
1127
+ * ...f.name(),
1128
+ * ...f.email({}, { directives: [$dir.skip({ if: $.showEmail })] }),
1129
+ * })),
1130
+ * }),
1131
+ * })
1132
+ * );
1133
+ * ```
620
1134
  */
621
- declare const createGqlElementComposer: <TSchema extends AnyGraphqlSchema, TFragmentBuilders, TAdapter extends AnyAdapter = DefaultAdapter>(schema: NoInfer<TSchema>, options: GqlElementComposerOptions<NoInfer<TSchema>, NoInfer<TAdapter>>) => GqlElementComposer<{
1135
+ 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>>) => GqlElementComposer<{
622
1136
  fragment: TFragmentBuilders;
623
1137
  query: {
624
1138
  operation: <TOperationName extends string, TFields extends AnyFields, TVarDefinitions extends InputTypeSpecifiers = {}, TOperationMetadata = unknown>(options: {
625
1139
  name: TOperationName;
626
1140
  variables?: TVarDefinitions | undefined;
627
- metadata?: MetadataBuilder<AssigningInput<TSchema, TVarDefinitions>, TOperationMetadata, ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["aggregatedFragmentMetadata"], ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["schemaLevel"]> | undefined;
1141
+ metadata?: MetadataBuilder<DeclaredVariables<TSchema, TVarDefinitions>, TOperationMetadata, ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["aggregatedFragmentMetadata"], ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["schemaLevel"]> | undefined;
628
1142
  fields: FieldsBuilder<TSchema, TSchema["operations"]["query"] & keyof TSchema["object"] & string, TVarDefinitions, TFields>;
629
1143
  }) => Operation<"query", TOperationName, (keyof TVarDefinitions & string)[], ConstAssignableInput<TSchema, TVarDefinitions>, TFields, InferFields<TSchema, TFields>>;
630
1144
  };
@@ -632,7 +1146,7 @@ declare const createGqlElementComposer: <TSchema extends AnyGraphqlSchema, TFrag
632
1146
  operation: <TOperationName extends string, TFields extends AnyFields, TVarDefinitions extends InputTypeSpecifiers = {}, TOperationMetadata = unknown>(options: {
633
1147
  name: TOperationName;
634
1148
  variables?: TVarDefinitions | undefined;
635
- metadata?: MetadataBuilder<AssigningInput<TSchema, TVarDefinitions>, TOperationMetadata, ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["aggregatedFragmentMetadata"], ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["schemaLevel"]> | undefined;
1149
+ metadata?: MetadataBuilder<DeclaredVariables<TSchema, TVarDefinitions>, TOperationMetadata, ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["aggregatedFragmentMetadata"], ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["schemaLevel"]> | undefined;
636
1150
  fields: FieldsBuilder<TSchema, TSchema["operations"]["mutation"] & keyof TSchema["object"] & string, TVarDefinitions, TFields>;
637
1151
  }) => Operation<"mutation", TOperationName, (keyof TVarDefinitions & string)[], ConstAssignableInput<TSchema, TVarDefinitions>, TFields, InferFields<TSchema, TFields>>;
638
1152
  };
@@ -640,15 +1154,31 @@ declare const createGqlElementComposer: <TSchema extends AnyGraphqlSchema, TFrag
640
1154
  operation: <TOperationName extends string, TFields extends AnyFields, TVarDefinitions extends InputTypeSpecifiers = {}, TOperationMetadata = unknown>(options: {
641
1155
  name: TOperationName;
642
1156
  variables?: TVarDefinitions | undefined;
643
- metadata?: MetadataBuilder<AssigningInput<TSchema, TVarDefinitions>, TOperationMetadata, ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["aggregatedFragmentMetadata"], ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["schemaLevel"]> | undefined;
1157
+ metadata?: MetadataBuilder<DeclaredVariables<TSchema, TVarDefinitions>, TOperationMetadata, ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["aggregatedFragmentMetadata"], ExtractAdapterTypes<ExtractMetadataAdapter<TAdapter>>["schemaLevel"]> | undefined;
644
1158
  fields: FieldsBuilder<TSchema, TSchema["operations"]["subscription"] & keyof TSchema["object"] & string, TVarDefinitions, TFields>;
645
1159
  }) => Operation<"subscription", TOperationName, (keyof TVarDefinitions & string)[], ConstAssignableInput<TSchema, TVarDefinitions>, TFields, InferFields<TSchema, TFields>>;
646
1160
  };
647
1161
  $var: VarBuilder<TSchema>;
1162
+ $dir: TDirectiveMethods;
648
1163
  $colocate: <TEntries extends ColocatedEntries>(entries: TEntries) => ColocatedFields<TEntries>;
649
1164
  } & ExtractHelpers<TAdapter>>;
650
1165
  //#endregion
651
1166
  //#region packages/core/src/composer/operation.d.ts
1167
+ /**
1168
+ * Creates a factory for composing GraphQL operations.
1169
+ *
1170
+ * Returns a curried function: first select operation type (query/mutation/subscription),
1171
+ * then define the operation with name, variables, and fields.
1172
+ *
1173
+ * Handles metadata aggregation from fragments (sync or async) and builds
1174
+ * the TypedDocumentNode automatically.
1175
+ *
1176
+ * @param schema - The GraphQL schema definition
1177
+ * @param adapter - Optional metadata adapter for custom metadata handling
1178
+ * @returns Operation type selector function
1179
+ *
1180
+ * @internal Used by `createGqlElementComposer`
1181
+ */
652
1182
  declare const createOperationComposerFactory: <TSchema extends AnyGraphqlSchema, TAdapter extends AnyMetadataAdapter = DefaultMetadataAdapter>(schema: NoInfer<TSchema>, adapter?: TAdapter) => <TOperationType extends OperationType>(operationType: TOperationType) => <TOperationName extends string, TFields extends AnyFields, TVarDefinitions extends InputTypeSpecifiers = {}, TOperationMetadata = unknown>(options: {
653
1183
  name: TOperationName;
654
1184
  variables?: TVarDefinitions;
@@ -661,7 +1191,7 @@ declare const hidden: <T>() => (() => T);
661
1191
  type Hidden<T> = () => T;
662
1192
  //#endregion
663
1193
  //#region packages/core/src/utils/wrap-by-key.d.ts
664
- declare function wrapByKey<TName$1 extends string, TValue>(name: TName$1, value: TValue): { [K in TName$1]: TValue };
1194
+ declare function wrapByKey<TName$1 extends string, TValue$1>(name: TName$1, value: TValue$1): { [K in TName$1]: TValue$1 };
665
1195
  //#endregion
666
- export { NestedUnionFieldsBuilder as $, AnyOperationOf as A, AssignableInput as At, AnyFieldSelectionFactory as B, withFragmentUsageCollection as C, FieldSelectionTemplateOf as Ct, createVarRefs as D, AnyAssignableInput as Dt, createVarAssignments as E, AnyDirectiveAttachments as Et, FragmentInferMeta as F, AnyConstAssignableInput as Ft, FieldSelectionFactoryObjectReturn as G, FieldSelectionFactories as H, GqlElement as I, AnyConstAssignableInputValue as It, FieldSelectionFactoryUnionReturn as J, FieldSelectionFactoryPrimitiveReturn as K, GqlElementAttachment as L, ConstAssignableInput as Lt, OperationInferMeta as M, AssignableInputValue as Mt, AnyFragment as N, AssigningInput as Nt, createFieldFactories as O, AnyAssignableInputValue as Ot, Fragment as P, AnyConstDirectiveAttachments as Pt, NestedObjectFieldsBuilderTools as Q, GqlElementContext as R, ConstAssignableInputValue as Rt, recordFragmentUsage as S, AnyNestedUnion as St, createGqlFragmentComposers as T, InferFields as Tt, FieldSelectionFactory as U, AnyFieldSelectionFactoryReturn as V, FieldSelectionFactoryFieldArguments as W, FieldsBuilderTools as X, FieldsBuilder as Y, NestedObjectFieldsBuilder as Z, VarSpecifier as _, buildWithTypeModifier as _t, ExtractMetadataAdapter as a, ColocateHelper as at, createVarMethodFactory as b, AnyFields as bt, GqlElementComposerOptions as c, createColocateHelper as ct, InputTypeMethods as d, Tuple as dt, EmptyObject as et, ResolveTypeFromMeta as f, UnionToIntersection as ft, VarBuilderMethods as g, buildOperationTypeNode as gt, VarBuilder as h, buildDocument as ht, createOperationComposerFactory as i, empty as it, Operation as j, AssignableInputByFieldName as jt, AnyOperation as k, AnyAssigningInput as kt, createGqlElementComposer as l, StripFunctions as lt, SchemaAwareGetValueAt as m, buildConstValueNode as mt, Hidden as n, OptionalArg as nt, FragmentBuildersAll as o, ColocatedEntries as ot, SchemaAwareGetNameAt as p, buildArgumentValue as pt, FieldSelectionFactoryReturn as q, hidden as r, SwitchIfOmittable as rt, GqlElementComposer as s, ColocatedFields as st, wrapByKey as t, IfOmittable as tt, InputTypeMethod as u, StripSymbols as ut, createVarBuilder as v, AbstractFieldSelection as vt, FragmentBuilderFor as w, InferField as wt, FragmentUsageRecord as x, AnyNestedObject as xt, createVarMethod as y, AnyFieldSelection as yt, GqlElementDefinitionFactory as z, GetAssignableType as zt };
667
- //# sourceMappingURL=index-x4fr7bdv.d.cts.map
1196
+ export { NestedUnionFieldsBuilder as $, AnyDirectiveRefBrand as $t, AnyOperationOf as A, AbstractFieldSelection as At, AnyFieldSelectionFactory as B, AnyAssignableInputValue as Bt, withFragmentUsageCollection as C, Tuple as Ct, createVarRefs as D, buildDocument as Dt, createVarAssignments as E, buildConstValueNode as Et, FragmentInferMeta as F, FieldSelectionTemplateOf as Ft, FieldSelectionFactoryObjectReturn as G, FieldArgumentValue as Gt, FieldSelectionFactories as H, AssignableInput as Ht, GqlElement as I, InferField as It, FieldSelectionFactoryUnionReturn as J, AnyConstAssignableInputValue as Jt, FieldSelectionFactoryPrimitiveReturn as K, AnyConstDirectiveAttachments as Kt, GqlElementAttachment as L, InferFields as Lt, OperationInferMeta as M, AnyFields as Mt, AnyFragment as N, AnyNestedObject as Nt, createFieldFactories as O, buildOperationTypeNode as Ot, Fragment as P, AnyNestedUnion as Pt, NestedObjectFieldsBuilderTools as Q, AnyDirectiveRef as Qt, GqlElementContext as R, AnyDirectiveAttachments as Rt, recordFragmentUsage as S, StripSymbols as St, createGqlFragmentComposers as T, buildArgumentValue as Tt, FieldSelectionFactory as U, AssignableInputByFieldName as Ut, AnyFieldSelectionFactoryReturn as V, AnyAssigningInput as Vt, FieldSelectionFactoryFieldArguments as W, DeclaredVariables as Wt, FieldsBuilderTools as X, ConstAssignableInputValue as Xt, FieldsBuilder as Y, ConstAssignableInput as Yt, NestedObjectFieldsBuilder as Z, GetAssignableType as Zt, VarSpecifier as _, ColocateHelper as _t, ExtractMetadataAdapter as a, AttachmentShape as at, createVarMethodFactory as b, createColocateHelper as bt, GqlElementComposerOptions as c, AnyDirectiveMethod as ct, InputTypeMethods as d, DirectiveMethod as dt, DirectiveLocation as en, EmptyObject as et, ResolveTypeFromMeta as f, StandardDirectives as ft, VarBuilderMethods as g, isDirectiveRef as gt, VarBuilder as h, createStandardDirectives as ht, createOperationComposerFactory as i, empty as it, Operation as j, AnyFieldSelection as jt, AnyOperation as k, buildWithTypeModifier as kt, createGqlElementComposer as l, DirectiveArgValue as lt, SchemaAwareGetValueAt as m, createDirectiveMethod as mt, Hidden as n, DirectiveRefInner as nn, OptionalArg as nt, FragmentBuildersAll as o, AttachmentToProperty as ot, SchemaAwareGetNameAt as p, createDirectiveBuilder as pt, FieldSelectionFactoryReturn as q, AnyConstAssignableInput as qt, hidden as r, SwitchIfOmittable as rt, GqlElementComposer as s, AttachmentsTupleToIntersection as st, wrapByKey as t, DirectiveRef as tn, IfOmittable as tt, InputTypeMethod as u, DirectiveBuilder as ut, createVarBuilder as v, ColocatedEntries as vt, FragmentBuilderFor as w, UnionToIntersection as wt, FragmentUsageRecord as x, StripFunctions as xt, createVarMethod as y, ColocatedFields as yt, GqlElementDefinitionFactory as z, AnyAssignableInput as zt };
1197
+ //# sourceMappingURL=index-wkJ6KSwK.d.ts.map