@constructive-io/graphql-query 3.2.4 → 3.3.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 (88) hide show
  1. package/README.md +411 -65
  2. package/ast.d.ts +4 -4
  3. package/ast.js +24 -9
  4. package/client/error.d.ts +95 -0
  5. package/client/error.js +277 -0
  6. package/client/execute.d.ts +57 -0
  7. package/client/execute.js +124 -0
  8. package/client/index.d.ts +8 -0
  9. package/client/index.js +20 -0
  10. package/client/typed-document.d.ts +31 -0
  11. package/client/typed-document.js +44 -0
  12. package/custom-ast.d.ts +22 -8
  13. package/custom-ast.js +16 -1
  14. package/esm/ast.js +22 -7
  15. package/esm/client/error.js +271 -0
  16. package/esm/client/execute.js +120 -0
  17. package/esm/client/index.js +8 -0
  18. package/esm/client/typed-document.js +40 -0
  19. package/esm/custom-ast.js +16 -1
  20. package/esm/generators/field-selector.js +381 -0
  21. package/esm/generators/index.js +13 -0
  22. package/esm/generators/mutations.js +200 -0
  23. package/esm/generators/naming-helpers.js +154 -0
  24. package/esm/generators/select.js +661 -0
  25. package/esm/index.js +30 -0
  26. package/esm/introspect/index.js +9 -0
  27. package/esm/introspect/infer-tables.js +697 -0
  28. package/esm/introspect/schema-query.js +120 -0
  29. package/esm/introspect/transform-schema.js +271 -0
  30. package/esm/introspect/transform.js +38 -0
  31. package/esm/meta-object/convert.js +3 -0
  32. package/esm/meta-object/format.json +11 -41
  33. package/esm/meta-object/validate.js +20 -4
  34. package/esm/query-builder.js +14 -18
  35. package/esm/types/index.js +18 -0
  36. package/esm/types/introspection.js +54 -0
  37. package/esm/types/mutation.js +4 -0
  38. package/esm/types/query.js +4 -0
  39. package/esm/types/schema.js +5 -0
  40. package/esm/types/selection.js +4 -0
  41. package/esm/utils.js +69 -0
  42. package/generators/field-selector.d.ts +30 -0
  43. package/generators/field-selector.js +387 -0
  44. package/generators/index.d.ts +9 -0
  45. package/generators/index.js +42 -0
  46. package/generators/mutations.d.ts +30 -0
  47. package/generators/mutations.js +238 -0
  48. package/generators/naming-helpers.d.ts +48 -0
  49. package/generators/naming-helpers.js +169 -0
  50. package/generators/select.d.ts +39 -0
  51. package/generators/select.js +705 -0
  52. package/index.d.ts +19 -0
  53. package/index.js +34 -1
  54. package/introspect/index.d.ts +9 -0
  55. package/introspect/index.js +25 -0
  56. package/introspect/infer-tables.d.ts +42 -0
  57. package/introspect/infer-tables.js +700 -0
  58. package/introspect/schema-query.d.ts +20 -0
  59. package/introspect/schema-query.js +123 -0
  60. package/introspect/transform-schema.d.ts +86 -0
  61. package/introspect/transform-schema.js +281 -0
  62. package/introspect/transform.d.ts +20 -0
  63. package/introspect/transform.js +43 -0
  64. package/meta-object/convert.d.ts +3 -0
  65. package/meta-object/convert.js +3 -0
  66. package/meta-object/format.json +11 -41
  67. package/meta-object/validate.d.ts +8 -3
  68. package/meta-object/validate.js +20 -4
  69. package/package.json +4 -3
  70. package/query-builder.d.ts +11 -12
  71. package/query-builder.js +25 -29
  72. package/{types.d.ts → types/core.d.ts} +25 -18
  73. package/types/index.d.ts +12 -0
  74. package/types/index.js +34 -0
  75. package/types/introspection.d.ts +121 -0
  76. package/types/introspection.js +62 -0
  77. package/types/mutation.d.ts +45 -0
  78. package/types/mutation.js +5 -0
  79. package/types/query.d.ts +91 -0
  80. package/types/query.js +5 -0
  81. package/types/schema.d.ts +265 -0
  82. package/types/schema.js +6 -0
  83. package/types/selection.d.ts +43 -0
  84. package/types/selection.js +5 -0
  85. package/utils.d.ts +17 -0
  86. package/utils.js +72 -0
  87. /package/esm/{types.js → types/core.js} +0 -0
  88. /package/{types.js → types/core.js} +0 -0
@@ -0,0 +1,121 @@
1
+ /**
2
+ * GraphQL Introspection Types
3
+ *
4
+ * Standard types for GraphQL schema introspection via __schema query.
5
+ * These mirror the GraphQL introspection spec.
6
+ */
7
+ /**
8
+ * Reference to a GraphQL type - can be nested for wrappers like NON_NULL and LIST
9
+ */
10
+ export interface IntrospectionTypeRef {
11
+ kind: IntrospectionTypeKind;
12
+ name: string | null;
13
+ ofType: IntrospectionTypeRef | null;
14
+ }
15
+ export type IntrospectionTypeKind = 'SCALAR' | 'OBJECT' | 'INPUT_OBJECT' | 'ENUM' | 'LIST' | 'NON_NULL' | 'INTERFACE' | 'UNION';
16
+ /**
17
+ * Input value - used for both field arguments and INPUT_OBJECT fields
18
+ */
19
+ export interface IntrospectionInputValue {
20
+ name: string;
21
+ description: string | null;
22
+ type: IntrospectionTypeRef;
23
+ defaultValue: string | null;
24
+ }
25
+ /**
26
+ * Field on an OBJECT or INTERFACE type
27
+ */
28
+ export interface IntrospectionField {
29
+ name: string;
30
+ description: string | null;
31
+ args: IntrospectionInputValue[];
32
+ type: IntrospectionTypeRef;
33
+ isDeprecated: boolean;
34
+ deprecationReason: string | null;
35
+ }
36
+ /**
37
+ * Enum value definition
38
+ */
39
+ export interface IntrospectionEnumValue {
40
+ name: string;
41
+ description: string | null;
42
+ isDeprecated: boolean;
43
+ deprecationReason: string | null;
44
+ }
45
+ /**
46
+ * Complete type definition from introspection
47
+ */
48
+ export interface IntrospectionType {
49
+ kind: IntrospectionTypeKind;
50
+ name: string;
51
+ description: string | null;
52
+ /** Fields for OBJECT and INTERFACE types */
53
+ fields: IntrospectionField[] | null;
54
+ /** Input fields for INPUT_OBJECT types */
55
+ inputFields: IntrospectionInputValue[] | null;
56
+ /** Possible types for INTERFACE and UNION types */
57
+ possibleTypes: Array<{
58
+ name: string;
59
+ }> | null;
60
+ /** Enum values for ENUM types */
61
+ enumValues: IntrospectionEnumValue[] | null;
62
+ /** Interfaces implemented by OBJECT types */
63
+ interfaces: Array<{
64
+ name: string;
65
+ }> | null;
66
+ }
67
+ /**
68
+ * Root type references in schema
69
+ */
70
+ export interface IntrospectionRootType {
71
+ name: string;
72
+ }
73
+ /**
74
+ * Full schema introspection result
75
+ */
76
+ export interface IntrospectionSchema {
77
+ queryType: IntrospectionRootType;
78
+ mutationType: IntrospectionRootType | null;
79
+ subscriptionType: IntrospectionRootType | null;
80
+ types: IntrospectionType[];
81
+ directives: IntrospectionDirective[];
82
+ }
83
+ /**
84
+ * Directive definition
85
+ */
86
+ export interface IntrospectionDirective {
87
+ name: string;
88
+ description: string | null;
89
+ locations: string[];
90
+ args: IntrospectionInputValue[];
91
+ }
92
+ /**
93
+ * Response from introspection query
94
+ */
95
+ export interface IntrospectionQueryResponse {
96
+ __schema: IntrospectionSchema;
97
+ }
98
+ /**
99
+ * Check if type kind is a wrapper (LIST or NON_NULL)
100
+ */
101
+ export declare function isWrapperType(kind: IntrospectionTypeKind): boolean;
102
+ /**
103
+ * Check if type kind is a named type (has a name)
104
+ */
105
+ export declare function isNamedType(kind: IntrospectionTypeKind): boolean;
106
+ /**
107
+ * Unwrap a type reference to get the base named type
108
+ */
109
+ export declare function unwrapType(typeRef: IntrospectionTypeRef): IntrospectionTypeRef;
110
+ /**
111
+ * Get the base type name from a possibly wrapped type
112
+ */
113
+ export declare function getBaseTypeName(typeRef: IntrospectionTypeRef): string | null;
114
+ /**
115
+ * Check if a type reference is non-null (required)
116
+ */
117
+ export declare function isNonNull(typeRef: IntrospectionTypeRef): boolean;
118
+ /**
119
+ * Check if a type reference is a list
120
+ */
121
+ export declare function isList(typeRef: IntrospectionTypeRef): boolean;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ /**
3
+ * GraphQL Introspection Types
4
+ *
5
+ * Standard types for GraphQL schema introspection via __schema query.
6
+ * These mirror the GraphQL introspection spec.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.isWrapperType = isWrapperType;
10
+ exports.isNamedType = isNamedType;
11
+ exports.unwrapType = unwrapType;
12
+ exports.getBaseTypeName = getBaseTypeName;
13
+ exports.isNonNull = isNonNull;
14
+ exports.isList = isList;
15
+ // ============================================================================
16
+ // Type Guards
17
+ // ============================================================================
18
+ /**
19
+ * Check if type kind is a wrapper (LIST or NON_NULL)
20
+ */
21
+ function isWrapperType(kind) {
22
+ return kind === 'LIST' || kind === 'NON_NULL';
23
+ }
24
+ /**
25
+ * Check if type kind is a named type (has a name)
26
+ */
27
+ function isNamedType(kind) {
28
+ return !isWrapperType(kind);
29
+ }
30
+ /**
31
+ * Unwrap a type reference to get the base named type
32
+ */
33
+ function unwrapType(typeRef) {
34
+ let current = typeRef;
35
+ while (current.ofType) {
36
+ current = current.ofType;
37
+ }
38
+ return current;
39
+ }
40
+ /**
41
+ * Get the base type name from a possibly wrapped type
42
+ */
43
+ function getBaseTypeName(typeRef) {
44
+ return unwrapType(typeRef).name;
45
+ }
46
+ /**
47
+ * Check if a type reference is non-null (required)
48
+ */
49
+ function isNonNull(typeRef) {
50
+ return typeRef.kind === 'NON_NULL';
51
+ }
52
+ /**
53
+ * Check if a type reference is a list
54
+ */
55
+ function isList(typeRef) {
56
+ if (typeRef.kind === 'LIST')
57
+ return true;
58
+ if (typeRef.kind === 'NON_NULL' && typeRef.ofType) {
59
+ return typeRef.ofType.kind === 'LIST';
60
+ }
61
+ return false;
62
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Mutation-related types
3
+ */
4
+ import type { FieldSelection } from './selection';
5
+ /**
6
+ * Options for mutation operations
7
+ */
8
+ export interface MutationOptions {
9
+ /** Fields to return after mutation */
10
+ returning?: string[];
11
+ /** Field selection for returned data */
12
+ fieldSelection?: FieldSelection;
13
+ }
14
+ /**
15
+ * Input for create mutations
16
+ * Wraps the actual data in PostGraphile's expected format
17
+ */
18
+ export interface CreateInput<T = Record<string, unknown>> {
19
+ [tableName: string]: T;
20
+ }
21
+ /**
22
+ * Input for update mutations
23
+ */
24
+ export interface UpdateInput<T = Record<string, unknown>> {
25
+ /** Primary key value */
26
+ id: string | number;
27
+ /** Fields to update */
28
+ patch: T;
29
+ }
30
+ /**
31
+ * Input for delete mutations
32
+ */
33
+ export interface DeleteInput {
34
+ /** Primary key value */
35
+ id: string | number;
36
+ }
37
+ /**
38
+ * Standard mutation result
39
+ */
40
+ export interface MutationResult<T = unknown> {
41
+ /** The affected record */
42
+ data?: T;
43
+ /** Client mutation ID (PostGraphile) */
44
+ clientMutationId?: string;
45
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * Mutation-related types
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Query-related types for building GraphQL operations
3
+ */
4
+ import type { FieldSelection } from './selection';
5
+ /**
6
+ * Relay-style pagination info
7
+ */
8
+ export interface PageInfo {
9
+ hasNextPage: boolean;
10
+ hasPreviousPage: boolean;
11
+ startCursor?: string | null;
12
+ endCursor?: string | null;
13
+ }
14
+ /**
15
+ * Relay-style connection result
16
+ */
17
+ export interface ConnectionResult<T = unknown> {
18
+ nodes: T[];
19
+ totalCount: number;
20
+ pageInfo: PageInfo;
21
+ }
22
+ /**
23
+ * Options for building SELECT queries
24
+ */
25
+ export interface QueryOptions {
26
+ /** Number of records to fetch (alias for first) */
27
+ first?: number;
28
+ /** Alias for first */
29
+ limit?: number;
30
+ /** Offset for pagination */
31
+ offset?: number;
32
+ /** Cursor for forward pagination */
33
+ after?: string;
34
+ /** Cursor for backward pagination */
35
+ before?: string;
36
+ /** Filter conditions */
37
+ where?: Filter;
38
+ /** Sort order */
39
+ orderBy?: OrderByItem[];
40
+ /** Field selection options */
41
+ fieldSelection?: FieldSelection;
42
+ /**
43
+ * Maps requested relation field names to actual schema field names (or null to omit).
44
+ * When the mapped name differs from the key, a GraphQL alias is emitted so the
45
+ * consumer sees a stable field name regardless of the server-side name.
46
+ *
47
+ * Example: `{ contact: 'contactByOwnerId' }` emits `contact: contactByOwnerId { … }`
48
+ * Pass `null` to suppress a relation entirely: `{ internalNotes: null }`
49
+ */
50
+ relationFieldMap?: Record<string, string | null>;
51
+ /** Include pageInfo in response */
52
+ includePageInfo?: boolean;
53
+ }
54
+ /**
55
+ * Single order by specification
56
+ */
57
+ export interface OrderByItem {
58
+ field: string;
59
+ direction: 'asc' | 'desc';
60
+ }
61
+ /**
62
+ * All supported filter operators
63
+ */
64
+ export type FilterOperator = 'isNull' | 'equalTo' | 'notEqualTo' | 'distinctFrom' | 'notDistinctFrom' | 'in' | 'notIn' | 'lessThan' | 'lessThanOrEqualTo' | 'greaterThan' | 'greaterThanOrEqualTo' | 'includes' | 'notIncludes' | 'includesInsensitive' | 'notIncludesInsensitive' | 'startsWith' | 'notStartsWith' | 'startsWithInsensitive' | 'notStartsWithInsensitive' | 'endsWith' | 'notEndsWith' | 'endsWithInsensitive' | 'notEndsWithInsensitive' | 'like' | 'notLike' | 'likeInsensitive' | 'notLikeInsensitive' | 'equalToInsensitive' | 'notEqualToInsensitive' | 'distinctFromInsensitive' | 'notDistinctFromInsensitive' | 'inInsensitive' | 'notInInsensitive' | 'contains' | 'containedBy' | 'overlaps' | 'intersects' | 'intersects3D' | 'containsProperly' | 'coveredBy' | 'covers' | 'crosses' | 'disjoint' | 'orderingEquals' | 'touches' | 'within' | 'bboxIntersects2D' | 'bboxIntersects3D' | 'bboxOverlapsOrLeftOf' | 'bboxOverlapsOrRightOf' | 'bboxOverlapsOrBelow' | 'bboxOverlapsOrAbove' | 'bboxLeftOf' | 'bboxRightOf' | 'bboxBelow' | 'bboxAbove' | 'bboxContains' | 'bboxEquals';
65
+ /**
66
+ * Filter on a single field
67
+ */
68
+ export type FieldFilter = {
69
+ [K in FilterOperator]?: unknown;
70
+ };
71
+ /**
72
+ * Filter on related records
73
+ */
74
+ export interface RelationalFilter {
75
+ /** All related records must match */
76
+ every?: Filter;
77
+ /** At least one related record must match */
78
+ some?: Filter;
79
+ /** No related records match */
80
+ none?: Filter;
81
+ }
82
+ /**
83
+ * Main filter type - can be nested
84
+ */
85
+ export type Filter = {
86
+ [field: string]: FieldFilter | RelationalFilter | Filter;
87
+ } & {
88
+ and?: Filter[];
89
+ or?: Filter[];
90
+ not?: Filter;
91
+ };
package/types/query.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * Query-related types for building GraphQL operations
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,265 @@
1
+ /**
2
+ * Core schema types for representing PostGraphile table metadata
3
+ * These are "clean" versions that remove nullable/undefined complexity
4
+ */
5
+ /**
6
+ * Represents a database table with its fields and relations
7
+ */
8
+ export interface CleanTable {
9
+ name: string;
10
+ /** Description from PostgreSQL COMMENT (smart comments stripped) */
11
+ description?: string;
12
+ fields: CleanField[];
13
+ relations: CleanRelations;
14
+ /** PostGraphile inflection rules for this table */
15
+ inflection?: TableInflection;
16
+ /** Query operation names from introspection */
17
+ query?: TableQueryNames;
18
+ /** Constraint information */
19
+ constraints?: TableConstraints;
20
+ }
21
+ /**
22
+ * PostGraphile-generated names for this table
23
+ */
24
+ export interface TableInflection {
25
+ /** All rows connection query name (e.g., "users") */
26
+ allRows: string;
27
+ /** Simple all rows query name */
28
+ allRowsSimple: string;
29
+ /** Condition type name (e.g., "UserCondition") */
30
+ conditionType: string;
31
+ /** Connection type name (e.g., "UsersConnection") */
32
+ connection: string;
33
+ /** Create field name */
34
+ createField: string;
35
+ /** Create input type (e.g., "CreateUserInput") */
36
+ createInputType: string;
37
+ /** Create payload type */
38
+ createPayloadType: string;
39
+ /** Delete by primary key mutation name */
40
+ deleteByPrimaryKey: string | null;
41
+ /** Delete payload type */
42
+ deletePayloadType: string;
43
+ /** Edge type name */
44
+ edge: string;
45
+ /** Edge field name */
46
+ edgeField: string;
47
+ /** Enum type name */
48
+ enumType: string;
49
+ /** Filter type name (e.g., "UserFilter") */
50
+ filterType: string | null;
51
+ /** Input type name (e.g., "UserInput") */
52
+ inputType: string;
53
+ /** OrderBy enum type (e.g., "UsersOrderBy") */
54
+ orderByType: string;
55
+ /** Patch field name */
56
+ patchField: string;
57
+ /** Patch type (e.g., "UserPatch") */
58
+ patchType: string | null;
59
+ /** Table field name (singular, e.g., "user") */
60
+ tableFieldName: string;
61
+ /** Table type name (e.g., "User") */
62
+ tableType: string;
63
+ /** Type name */
64
+ typeName: string;
65
+ /** Update by primary key mutation name */
66
+ updateByPrimaryKey: string | null;
67
+ /** Update payload type */
68
+ updatePayloadType: string | null;
69
+ }
70
+ /**
71
+ * Query operation names from introspection
72
+ */
73
+ export interface TableQueryNames {
74
+ /** All rows query name */
75
+ all: string;
76
+ /** Single row query name */
77
+ one: string | null;
78
+ /** Create mutation name */
79
+ create: string;
80
+ /** Update mutation name */
81
+ update: string | null;
82
+ /** Delete mutation name */
83
+ delete: string | null;
84
+ /** Patch field name in update mutation input (e.g., "userPatch" for UpdateUserInput) */
85
+ patchFieldName?: string;
86
+ }
87
+ /**
88
+ * Table constraints
89
+ */
90
+ export interface TableConstraints {
91
+ primaryKey: ConstraintInfo[];
92
+ foreignKey: ForeignKeyConstraint[];
93
+ unique: ConstraintInfo[];
94
+ }
95
+ export interface ConstraintInfo {
96
+ name: string;
97
+ fields: CleanField[];
98
+ }
99
+ export interface ForeignKeyConstraint extends ConstraintInfo {
100
+ refTable: string;
101
+ refFields: CleanField[];
102
+ }
103
+ /**
104
+ * Represents a field/column in a table
105
+ */
106
+ export interface CleanField {
107
+ name: string;
108
+ /** Description from PostgreSQL COMMENT (smart comments stripped) */
109
+ description?: string;
110
+ type: CleanFieldType;
111
+ /** Whether the column has a NOT NULL constraint (inferred from NON_NULL wrapper on entity type field) */
112
+ isNotNull?: boolean | null;
113
+ /** Whether the column has a DEFAULT value (inferred by comparing entity vs CreateInput field nullability) */
114
+ hasDefault?: boolean | null;
115
+ }
116
+ /**
117
+ * Field type information from PostGraphile introspection
118
+ */
119
+ export interface CleanFieldType {
120
+ /** GraphQL type name (e.g., "String", "UUID", "Int") */
121
+ gqlType: string;
122
+ /** Whether this is an array type */
123
+ isArray: boolean;
124
+ /** Type modifier (for precision, length, etc.) */
125
+ modifier?: string | number | null;
126
+ /** PostgreSQL type alias (domain name) */
127
+ pgAlias?: string | null;
128
+ /** PostgreSQL native type (e.g., "text", "uuid", "integer") */
129
+ pgType?: string | null;
130
+ /** Subtype for composite types */
131
+ subtype?: string | null;
132
+ /** Type modifier from PostgreSQL */
133
+ typmod?: number | null;
134
+ }
135
+ /**
136
+ * All relation types for a table
137
+ */
138
+ export interface CleanRelations {
139
+ belongsTo: CleanBelongsToRelation[];
140
+ hasOne: CleanHasOneRelation[];
141
+ hasMany: CleanHasManyRelation[];
142
+ manyToMany: CleanManyToManyRelation[];
143
+ }
144
+ /**
145
+ * BelongsTo relation (foreign key on this table)
146
+ */
147
+ export interface CleanBelongsToRelation {
148
+ fieldName: string | null;
149
+ isUnique: boolean;
150
+ referencesTable: string;
151
+ type: string | null;
152
+ keys: CleanField[];
153
+ }
154
+ /**
155
+ * HasOne relation (foreign key on other table, unique)
156
+ */
157
+ export interface CleanHasOneRelation {
158
+ fieldName: string | null;
159
+ isUnique: boolean;
160
+ referencedByTable: string;
161
+ type: string | null;
162
+ keys: CleanField[];
163
+ }
164
+ /**
165
+ * HasMany relation (foreign key on other table, not unique)
166
+ */
167
+ export interface CleanHasManyRelation {
168
+ fieldName: string | null;
169
+ isUnique: boolean;
170
+ referencedByTable: string;
171
+ type: string | null;
172
+ keys: CleanField[];
173
+ }
174
+ /**
175
+ * ManyToMany relation (through junction table)
176
+ */
177
+ export interface CleanManyToManyRelation {
178
+ fieldName: string | null;
179
+ rightTable: string;
180
+ junctionTable: string;
181
+ type: string | null;
182
+ }
183
+ /**
184
+ * Clean representation of a GraphQL operation (query or mutation)
185
+ * Derived from introspection data
186
+ */
187
+ export interface CleanOperation {
188
+ /** Operation name (e.g., "login", "currentUser", "cars") */
189
+ name: string;
190
+ /** Operation kind */
191
+ kind: 'query' | 'mutation';
192
+ /** Arguments/variables for the operation */
193
+ args: CleanArgument[];
194
+ /** Return type */
195
+ returnType: CleanTypeRef;
196
+ /** Description from schema */
197
+ description?: string;
198
+ /** Whether this is deprecated */
199
+ isDeprecated?: boolean;
200
+ /** Deprecation reason */
201
+ deprecationReason?: string;
202
+ }
203
+ /**
204
+ * Clean representation of an operation argument
205
+ */
206
+ export interface CleanArgument {
207
+ /** Argument name */
208
+ name: string;
209
+ /** Argument type */
210
+ type: CleanTypeRef;
211
+ /** Default value (as string) */
212
+ defaultValue?: string;
213
+ /** Description from schema */
214
+ description?: string;
215
+ }
216
+ /**
217
+ * Clean type reference - simplified from introspection TypeRef
218
+ */
219
+ export interface CleanTypeRef {
220
+ /** Type kind */
221
+ kind: 'SCALAR' | 'OBJECT' | 'INPUT_OBJECT' | 'ENUM' | 'LIST' | 'NON_NULL';
222
+ /** Type name (null for LIST and NON_NULL wrappers) */
223
+ name: string | null;
224
+ /** Inner type for LIST and NON_NULL wrappers */
225
+ ofType?: CleanTypeRef;
226
+ /** Resolved TypeScript type string */
227
+ tsType?: string;
228
+ /** Fields for OBJECT types */
229
+ fields?: CleanObjectField[];
230
+ /** Input fields for INPUT_OBJECT types */
231
+ inputFields?: CleanArgument[];
232
+ /** Values for ENUM types */
233
+ enumValues?: string[];
234
+ }
235
+ /**
236
+ * Field on an object type
237
+ */
238
+ export interface CleanObjectField {
239
+ /** Field name */
240
+ name: string;
241
+ /** Field type */
242
+ type: CleanTypeRef;
243
+ /** Description */
244
+ description?: string;
245
+ }
246
+ /**
247
+ * Registry of all types in the schema for resolution
248
+ */
249
+ export type TypeRegistry = Map<string, ResolvedType>;
250
+ /**
251
+ * Resolved type with all details populated
252
+ */
253
+ export interface ResolvedType {
254
+ kind: 'SCALAR' | 'OBJECT' | 'INPUT_OBJECT' | 'ENUM' | 'INTERFACE' | 'UNION';
255
+ name: string;
256
+ description?: string;
257
+ /** Fields for OBJECT types */
258
+ fields?: CleanObjectField[];
259
+ /** Input fields for INPUT_OBJECT types */
260
+ inputFields?: CleanArgument[];
261
+ /** Values for ENUM types */
262
+ enumValues?: string[];
263
+ /** Possible types for UNION types */
264
+ possibleTypes?: string[];
265
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Core schema types for representing PostGraphile table metadata
4
+ * These are "clean" versions that remove nullable/undefined complexity
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Field selection types for controlling which fields are included in queries
3
+ */
4
+ /**
5
+ * Simple field selection options
6
+ */
7
+ export interface SimpleFieldSelection {
8
+ /** Specific fields to include */
9
+ select?: string[];
10
+ /** Relations to include with their fields */
11
+ include?: Record<string, string[] | boolean>;
12
+ /** Simple relation inclusion (just names) */
13
+ includeRelations?: string[];
14
+ /** Fields to exclude */
15
+ exclude?: string[];
16
+ /** Maximum depth for nested relations */
17
+ maxDepth?: number;
18
+ }
19
+ /**
20
+ * Predefined field selection presets
21
+ */
22
+ export type FieldSelectionPreset =
23
+ /** Just id and primary display field */
24
+ 'minimal'
25
+ /** Common display fields */
26
+ | 'display'
27
+ /** All scalar fields */
28
+ | 'all'
29
+ /** All fields including relations */
30
+ | 'full';
31
+ /**
32
+ * Main field selection type - preset or custom
33
+ */
34
+ export type FieldSelection = FieldSelectionPreset | SimpleFieldSelection;
35
+ /**
36
+ * Internal selection options format used by query builder
37
+ */
38
+ export interface SelectionOptions {
39
+ [fieldName: string]: boolean | {
40
+ select: Record<string, boolean>;
41
+ variables?: Record<string, unknown>;
42
+ };
43
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * Field selection types for controlling which fields are included in queries
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
package/utils.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Utility functions for GraphQL query generation
3
+ */
4
+ /**
5
+ * Strip PostGraphile smart comments and boilerplate from a description string.
6
+ *
7
+ * Smart comments are lines starting with `@` (e.g., `@omit`, `@name newName`).
8
+ * Boilerplate descriptions are generic PostGraphile-generated text that repeats
9
+ * on every mutation input, clientMutationId field, etc.
10
+ *
11
+ * This returns only the meaningful human-readable portion of the comment,
12
+ * or undefined if the result is empty or boilerplate.
13
+ *
14
+ * @param description - Raw description from GraphQL introspection
15
+ * @returns Cleaned description, or undefined if empty/boilerplate
16
+ */
17
+ export declare function stripSmartComments(description: string | null | undefined, enabled?: boolean): string | undefined;