@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
@@ -5,44 +5,27 @@
5
5
  "definitions": {
6
6
  "field": {
7
7
  "type": "object",
8
- "required": [
9
- "name",
10
- "type"
11
- ],
8
+ "required": ["name", "type"],
12
9
  "additionalProperties": true,
13
10
  "properties": {
14
11
  "name": {
15
12
  "type": "string",
16
13
  "default": "id",
17
- "examples": [
18
- "id"
19
- ]
14
+ "examples": ["id"]
20
15
  },
21
16
  "type": {
22
17
  "type": "object",
23
- "required": [
24
- "pgType",
25
- "gqlType"
26
- ],
18
+ "required": ["pgType", "gqlType"],
27
19
  "additionalProperties": true,
28
20
  "properties": {
29
21
  "gqlType": {
30
- "type": [
31
- "string",
32
- "null"
33
- ]
22
+ "type": ["string", "null"]
34
23
  },
35
24
  "pgType": {
36
- "type": [
37
- "string",
38
- "null"
39
- ]
25
+ "type": ["string", "null"]
40
26
  },
41
27
  "subtype": {
42
- "type": [
43
- "string",
44
- "null"
45
- ]
28
+ "type": ["string", "null"]
46
29
  }
47
30
  }
48
31
  }
@@ -58,9 +41,7 @@
58
41
  "name": {
59
42
  "type": "string",
60
43
  "default": "User",
61
- "examples": [
62
- "User"
63
- ]
44
+ "examples": ["User"]
64
45
  },
65
46
  "fields": {
66
47
  "type": "array",
@@ -88,9 +69,7 @@
88
69
  "refTable": {
89
70
  "type": "string",
90
71
  "default": "User",
91
- "examples": [
92
- "User"
93
- ]
72
+ "examples": ["User"]
94
73
  },
95
74
  "fromKey": {
96
75
  "$ref": "#/definitions/field"
@@ -99,25 +78,16 @@
99
78
  "$ref": "#/definitions/field"
100
79
  }
101
80
  },
102
- "required": [
103
- "refTable",
104
- "fromKey",
105
- "toKey"
106
- ],
81
+ "required": ["refTable", "fromKey", "toKey"],
107
82
  "additionalProperties": false
108
83
  }
109
84
  }
110
85
  },
111
- "required": [
112
- "name",
113
- "fields"
114
- ],
86
+ "required": ["name", "fields"],
115
87
  "additionalProperties": false
116
88
  }
117
89
  }
118
90
  },
119
- "required": [
120
- "tables"
121
- ],
91
+ "required": ["tables"],
122
92
  "additionalProperties": false
123
93
  }
@@ -1,4 +1,9 @@
1
- export declare function validateMetaObject(obj: any): true | {
2
- errors: import("ajv").ErrorObject<string, Record<string, any>, unknown>[];
1
+ export interface ValidationResult {
2
+ errors: unknown[] | null | undefined;
3
3
  message: string;
4
- };
4
+ }
5
+ /**
6
+ * Validate a MetaObject against the JSON schema
7
+ * @returns true if valid, or an object with errors and message if invalid
8
+ */
9
+ export declare function validateMetaObject(obj: unknown): true | ValidationResult;
@@ -6,13 +6,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.validateMetaObject = validateMetaObject;
7
7
  const ajv_1 = __importDefault(require("ajv"));
8
8
  const format_json_1 = __importDefault(require("./format.json"));
9
+ let cachedAjv = null;
10
+ let cachedValidator = null;
11
+ function getValidator() {
12
+ if (!cachedAjv) {
13
+ cachedAjv = new ajv_1.default({ allErrors: true });
14
+ cachedValidator = cachedAjv.compile(format_json_1.default);
15
+ }
16
+ return {
17
+ ajv: cachedAjv,
18
+ validator: cachedValidator,
19
+ };
20
+ }
21
+ /**
22
+ * Validate a MetaObject against the JSON schema
23
+ * @returns true if valid, or an object with errors and message if invalid
24
+ */
9
25
  function validateMetaObject(obj) {
10
- const ajv = new ajv_1.default({ allErrors: true });
11
- const valid = ajv.validate(format_json_1.default, obj);
26
+ const { ajv, validator } = getValidator();
27
+ const valid = validator(obj);
12
28
  if (valid)
13
29
  return true;
14
30
  return {
15
- errors: ajv.errors,
16
- message: ajv.errorsText(ajv.errors, { separator: '\n' }),
31
+ errors: validator.errors,
32
+ message: ajv.errorsText(validator.errors, { separator: '\n' }),
17
33
  };
18
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/graphql-query",
3
- "version": "3.2.4",
3
+ "version": "3.3.0",
4
4
  "description": "Constructive GraphQL Query",
5
5
  "author": "Constructive <developers@constructive.io>",
6
6
  "main": "index.js",
@@ -34,9 +34,10 @@
34
34
  "grafast": "1.0.0-rc.7",
35
35
  "graphile-build-pg": "5.0.0-rc.5",
36
36
  "graphile-config": "1.0.0-rc.5",
37
- "graphile-settings": "^4.3.4",
37
+ "graphile-settings": "^4.5.0",
38
38
  "graphql": "^16.9.0",
39
39
  "inflection": "^3.0.0",
40
+ "inflekt": "^0.3.1",
40
41
  "lru-cache": "^10.4.3",
41
42
  "postgraphile": "5.0.0-rc.7"
42
43
  },
@@ -50,5 +51,5 @@
50
51
  "devDependencies": {
51
52
  "makage": "^0.1.10"
52
53
  },
53
- "gitHead": "1b17d61b375abaa04310abe05c2a3ca5881ac650"
54
+ "gitHead": "1e0c774144be23a4c57a15ffe54ea0ec9fbd7c55"
54
55
  }
@@ -1,11 +1,10 @@
1
- import type { FieldSelection, IntrospectionSchema, MetaObject, QueryBuilderOptions, QueryBuilderResult, QueryDefinition, SelectionOptions } from './types';
1
+ import type { MetaObject, QueryBuilderOptions, QueryBuilderResult, QueryDefinition, QueryFieldSelection, QueryIntrospectionSchema, QuerySelectionOptions } from './types';
2
2
  export * as MetaObject from './meta-object';
3
3
  export declare class QueryBuilder {
4
- _introspection: IntrospectionSchema;
4
+ _introspection: QueryIntrospectionSchema;
5
5
  _meta: MetaObject;
6
6
  private _models;
7
7
  private _model;
8
- private _fields;
9
8
  private _key;
10
9
  private _queryName;
11
10
  private _ast;
@@ -19,29 +18,29 @@ export declare class QueryBuilder {
19
18
  query(model: string): QueryBuilder;
20
19
  _findQuery(): string;
21
20
  _findMutation(): string;
22
- select(selection?: SelectionOptions | null): QueryBuilder;
21
+ select(selection?: QuerySelectionOptions | null): QueryBuilder;
23
22
  edges(useEdges: boolean): QueryBuilder;
24
23
  getMany({ select }?: {
25
- select?: SelectionOptions;
24
+ select?: QuerySelectionOptions;
26
25
  }): QueryBuilder;
27
26
  all({ select }?: {
28
- select?: SelectionOptions;
27
+ select?: QuerySelectionOptions;
29
28
  }): QueryBuilder;
30
29
  count(): QueryBuilder;
31
30
  getOne({ select }?: {
32
- select?: SelectionOptions;
31
+ select?: QuerySelectionOptions;
33
32
  }): QueryBuilder;
34
33
  create({ select }?: {
35
- select?: SelectionOptions;
34
+ select?: QuerySelectionOptions;
36
35
  }): QueryBuilder;
37
36
  delete({ select }?: {
38
- select?: SelectionOptions;
37
+ select?: QuerySelectionOptions;
39
38
  }): QueryBuilder;
40
39
  update({ select }?: {
41
- select?: SelectionOptions;
40
+ select?: QuerySelectionOptions;
42
41
  }): QueryBuilder;
43
42
  queryName(name: string): QueryBuilder;
44
43
  print(): QueryBuilderResult;
45
- pickScalarFields: (selection: SelectionOptions | null, defn: QueryDefinition) => FieldSelection[];
46
- pickAllFields: (selection: SelectionOptions, defn: QueryDefinition) => FieldSelection[];
44
+ pickScalarFields: (selection: QuerySelectionOptions | null, defn: QueryDefinition) => QueryFieldSelection[];
45
+ pickAllFields: (selection: QuerySelectionOptions, defn: QueryDefinition) => QueryFieldSelection[];
47
46
  }
package/query-builder.js CHANGED
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.QueryBuilder = exports.MetaObject = void 0;
37
37
  const graphql_1 = require("graphql");
38
- const inflection_1 = require("inflection");
38
+ const inflekt_1 = require("inflekt");
39
39
  const ast_1 = require("./ast");
40
40
  const meta_object_1 = require("./meta-object");
41
41
  exports.MetaObject = __importStar(require("./meta-object"));
@@ -45,7 +45,6 @@ class QueryBuilder {
45
45
  _meta;
46
46
  _models;
47
47
  _model;
48
- _fields;
49
48
  _key;
50
49
  _queryName;
51
50
  _ast;
@@ -69,21 +68,16 @@ class QueryBuilder {
69
68
  * Save all gql queries and mutations by model name for quicker lookup
70
69
  */
71
70
  initModelMap() {
72
- this._models = Object.keys(this._introspection).reduce((map, key) => {
73
- const defn = this._introspection[key];
74
- map = {
75
- ...map,
76
- [defn.model]: {
77
- ...map[defn.model],
78
- ...{ [key]: defn },
79
- },
80
- };
81
- return map;
82
- }, {});
71
+ this._models = {};
72
+ for (const [key, defn] of Object.entries(this._introspection)) {
73
+ if (!this._models[defn.model]) {
74
+ this._models[defn.model] = {};
75
+ }
76
+ this._models[defn.model][key] = defn;
77
+ }
83
78
  }
84
79
  clear() {
85
80
  this._model = '';
86
- this._fields = [];
87
81
  this._key = null;
88
82
  this._queryName = '';
89
83
  this._ast = null;
@@ -130,13 +124,13 @@ class QueryBuilder {
130
124
  const getInputName = (mutationType) => {
131
125
  switch (mutationType) {
132
126
  case 'delete': {
133
- return `Delete${(0, inflection_1.camelize)(this._model)}Input`;
127
+ return `Delete${(0, inflekt_1.camelize)(this._model)}Input`;
134
128
  }
135
129
  case 'create': {
136
- return `Create${(0, inflection_1.camelize)(this._model)}Input`;
130
+ return `Create${(0, inflekt_1.camelize)(this._model)}Input`;
137
131
  }
138
132
  case 'patch': {
139
- return `Update${(0, inflection_1.camelize)(this._model)}Input`;
133
+ return `Update${(0, inflekt_1.camelize)(this._model)}Input`;
140
134
  }
141
135
  default:
142
136
  throw new Error('Unhandled mutation type' + mutationType);
@@ -165,7 +159,7 @@ class QueryBuilder {
165
159
  getMany({ select } = {}) {
166
160
  this._op = 'getMany';
167
161
  this._key = this._findQuery();
168
- this.queryName((0, inflection_1.camelize)(['get', (0, inflection_1.underscore)(this._key), 'query'].join('_'), true));
162
+ this.queryName((0, inflekt_1.camelize)(['get', (0, inflekt_1.underscore)(this._key), 'query'].join('_'), true));
169
163
  const defn = this._introspection[this._key];
170
164
  this.select(select);
171
165
  this._ast = (0, ast_1.getMany)({
@@ -180,7 +174,7 @@ class QueryBuilder {
180
174
  all({ select } = {}) {
181
175
  this._op = 'getMany';
182
176
  this._key = this._findQuery();
183
- this.queryName((0, inflection_1.camelize)(['get', (0, inflection_1.underscore)(this._key), 'query', 'all'].join('_'), true));
177
+ this.queryName((0, inflekt_1.camelize)(['get', (0, inflekt_1.underscore)(this._key), 'query', 'all'].join('_'), true));
184
178
  const defn = this._introspection[this._key];
185
179
  this.select(select);
186
180
  this._ast = (0, ast_1.getAll)({
@@ -194,7 +188,7 @@ class QueryBuilder {
194
188
  count() {
195
189
  this._op = 'getMany';
196
190
  this._key = this._findQuery();
197
- this.queryName((0, inflection_1.camelize)(['get', (0, inflection_1.underscore)(this._key), 'count', 'query'].join('_'), true));
191
+ this.queryName((0, inflekt_1.camelize)(['get', (0, inflekt_1.underscore)(this._key), 'count', 'query'].join('_'), true));
198
192
  const defn = this._introspection[this._key];
199
193
  this._ast = (0, ast_1.getCount)({
200
194
  queryName: this._queryName,
@@ -206,7 +200,7 @@ class QueryBuilder {
206
200
  getOne({ select } = {}) {
207
201
  this._op = 'getOne';
208
202
  this._key = this._findQuery();
209
- this.queryName((0, inflection_1.camelize)(['get', (0, inflection_1.underscore)(this._key), 'query'].join('_'), true));
203
+ this.queryName((0, inflekt_1.camelize)(['get', (0, inflekt_1.underscore)(this._key), 'query'].join('_'), true));
210
204
  const defn = this._introspection[this._key];
211
205
  this.select(select);
212
206
  this._ast = (0, ast_1.getOne)({
@@ -222,7 +216,7 @@ class QueryBuilder {
222
216
  this._op = 'mutation';
223
217
  this._mutation = 'create';
224
218
  this._key = this._findMutation();
225
- this.queryName((0, inflection_1.camelize)([(0, inflection_1.underscore)(this._key), 'mutation'].join('_'), true));
219
+ this.queryName((0, inflekt_1.camelize)([(0, inflekt_1.underscore)(this._key), 'mutation'].join('_'), true));
226
220
  const defn = this._introspection[this._key];
227
221
  this.select(select);
228
222
  this._ast = (0, ast_1.createOne)({
@@ -237,7 +231,7 @@ class QueryBuilder {
237
231
  this._op = 'mutation';
238
232
  this._mutation = 'delete';
239
233
  this._key = this._findMutation();
240
- this.queryName((0, inflection_1.camelize)([(0, inflection_1.underscore)(this._key), 'mutation'].join('_'), true));
234
+ this.queryName((0, inflekt_1.camelize)([(0, inflekt_1.underscore)(this._key), 'mutation'].join('_'), true));
241
235
  const defn = this._introspection[this._key];
242
236
  this.select(select);
243
237
  this._ast = (0, ast_1.deleteOne)({
@@ -251,7 +245,7 @@ class QueryBuilder {
251
245
  this._op = 'mutation';
252
246
  this._mutation = 'patch';
253
247
  this._key = this._findMutation();
254
- this.queryName((0, inflection_1.camelize)([(0, inflection_1.underscore)(this._key), 'mutation'].join('_'), true));
248
+ this.queryName((0, inflekt_1.camelize)([(0, inflekt_1.underscore)(this._key), 'mutation'].join('_'), true));
255
249
  const defn = this._introspection[this._key];
256
250
  this.select(select);
257
251
  this._ast = (0, ast_1.patchOne)({
@@ -302,7 +296,8 @@ function pickScalarFields(selection, defn) {
302
296
  return true;
303
297
  return Object.keys(selection).includes(fieldName);
304
298
  })
305
- .filter((fieldName) => !isRelationalField(fieldName, modelMeta) && isInTableSchema(fieldName))
299
+ .filter((fieldName) => !isRelationalField(fieldName, modelMeta) &&
300
+ isInTableSchema(fieldName))
306
301
  .map((fieldName) => ({
307
302
  name: fieldName,
308
303
  isObject: false,
@@ -347,9 +342,10 @@ function pickAllFields(selection, defn) {
347
342
  }
348
343
  const referencedForeignConstraint = modelMeta.foreignConstraints.find((constraint) => constraint.fromKey.name === fieldName ||
349
344
  constraint.fromKey.alias === fieldName);
350
- const subFields = Object.keys(fieldOptions.select).filter((subField) => {
345
+ const selectOptions = fieldOptions;
346
+ const subFields = Object.keys(selectOptions.select).filter((subField) => {
351
347
  return (!isRelationalField(subField, modelMeta) &&
352
- isWhiteListed(fieldOptions.select[subField]));
348
+ isWhiteListed(selectOptions.select[subField]));
353
349
  });
354
350
  const isBelongTo = !!referencedForeignConstraint;
355
351
  const fieldSelection = {
@@ -357,7 +353,7 @@ function pickAllFields(selection, defn) {
357
353
  isObject: true,
358
354
  isBelongTo,
359
355
  selection: subFields.map((name) => ({ name, isObject: false })),
360
- variables: fieldOptions.variables,
356
+ variables: selectOptions.variables,
361
357
  };
362
358
  // Need to further expand selection of object fields,
363
359
  // but only non-graphql-builtin, non-relation fields
@@ -412,5 +408,5 @@ function isRelationalField(fieldName, modelMeta) {
412
408
  // Get getMany op name from model
413
409
  // ie. UserSetting => userSettings
414
410
  function modelNameToGetMany(model) {
415
- return (0, inflection_1.camelize)((0, inflection_1.pluralize)((0, inflection_1.underscore)(model)), true);
411
+ return (0, inflekt_1.camelize)((0, inflekt_1.pluralize)((0, inflekt_1.underscore)(model)), true);
416
412
  }
@@ -1,4 +1,5 @@
1
1
  import type { DocumentNode, FieldNode, SelectionSetNode, VariableDefinitionNode } from 'graphql';
2
+ import type { CleanField } from './schema';
2
3
  export type ASTNode = DocumentNode | FieldNode | SelectionSetNode | VariableDefinitionNode;
3
4
  export interface NestedProperties {
4
5
  [key: string]: QueryProperty | NestedProperties;
@@ -22,7 +23,12 @@ export interface MutationDefinition extends QueryDefinition {
22
23
  qtype: 'mutation';
23
24
  mutationType: 'create' | 'patch' | 'delete';
24
25
  }
25
- export interface IntrospectionSchema {
26
+ /**
27
+ * Runtime QueryBuilder's internal schema map.
28
+ * Named with 'Query' prefix to avoid collision with the standard
29
+ * GraphQL IntrospectionSchema from ./introspection.ts
30
+ */
31
+ export interface QueryIntrospectionSchema {
26
32
  [key: string]: QueryDefinition | MutationDefinition;
27
33
  }
28
34
  export interface MetaFieldType {
@@ -38,7 +44,6 @@ export interface MetaField {
38
44
  name: string;
39
45
  type: MetaFieldType;
40
46
  }
41
- export type CleanField = MetaField;
42
47
  export interface MetaConstraint {
43
48
  name: string;
44
49
  type: MetaFieldType;
@@ -63,22 +68,22 @@ export type GraphQLVariableValue = string | number | boolean | null;
63
68
  export interface GraphQLVariables {
64
69
  [key: string]: GraphQLVariableValue | GraphQLVariableValue[] | GraphQLVariables | GraphQLVariables[];
65
70
  }
66
- export interface FieldSelection {
71
+ export interface QueryFieldSelection {
67
72
  name: string;
68
73
  isObject: boolean;
69
- fieldDefn?: MetaField;
70
- selection?: FieldSelection[];
74
+ fieldDefn?: MetaField | CleanField;
75
+ selection?: QueryFieldSelection[];
71
76
  variables?: GraphQLVariables;
72
77
  isBelongTo?: boolean;
73
78
  }
74
- export interface SelectionOptions {
79
+ export interface QuerySelectionOptions {
75
80
  [fieldName: string]: boolean | {
76
81
  select: Record<string, boolean>;
77
82
  variables?: GraphQLVariables;
78
83
  };
79
84
  }
80
85
  export interface QueryBuilderInstance {
81
- _introspection: IntrospectionSchema;
86
+ _introspection: QueryIntrospectionSchema;
82
87
  _meta: MetaObject;
83
88
  _edges?: boolean;
84
89
  }
@@ -86,18 +91,18 @@ export interface ASTFunctionParams {
86
91
  queryName: string;
87
92
  operationName: string;
88
93
  query: QueryDefinition;
89
- selection: FieldSelection[];
94
+ selection: QueryFieldSelection[];
90
95
  builder?: QueryBuilderInstance;
91
96
  }
92
97
  export interface MutationASTParams {
93
98
  mutationName: string;
94
99
  operationName: string;
95
100
  mutation: MutationDefinition;
96
- selection?: FieldSelection[];
101
+ selection?: QueryFieldSelection[];
97
102
  }
98
103
  export interface QueryBuilderOptions {
99
104
  meta: MetaObject;
100
- introspection: IntrospectionSchema;
105
+ introspection: QueryIntrospectionSchema;
101
106
  }
102
107
  export interface QueryBuilderResult {
103
108
  _hash: string;
@@ -107,23 +112,23 @@ export interface QueryBuilderResult {
107
112
  export interface IQueryBuilder {
108
113
  query(model: string): IQueryBuilder;
109
114
  getMany(options?: {
110
- select?: SelectionOptions;
115
+ select?: QuerySelectionOptions;
111
116
  }): IQueryBuilder;
112
117
  getOne(options?: {
113
- select?: SelectionOptions;
118
+ select?: QuerySelectionOptions;
114
119
  }): IQueryBuilder;
115
120
  all(options?: {
116
- select?: SelectionOptions;
121
+ select?: QuerySelectionOptions;
117
122
  }): IQueryBuilder;
118
123
  count(): IQueryBuilder;
119
124
  create(options?: {
120
- select?: SelectionOptions;
125
+ select?: QuerySelectionOptions;
121
126
  }): IQueryBuilder;
122
127
  update(options?: {
123
- select?: SelectionOptions;
128
+ select?: QuerySelectionOptions;
124
129
  }): IQueryBuilder;
125
130
  delete(options?: {
126
- select?: SelectionOptions;
131
+ select?: QuerySelectionOptions;
127
132
  }): IQueryBuilder;
128
133
  edges(useEdges: boolean): IQueryBuilder;
129
134
  print(): QueryBuilderResult;
@@ -158,6 +163,8 @@ export interface ExecutorCacheStats {
158
163
  maxSize: number;
159
164
  }
160
165
  /**
161
- * Re-export GraphQL execution types for convenience
166
+ * Re-export GraphQL execution types for convenience.
167
+ * Note: GraphQLError is NOT re-exported here to avoid collision with
168
+ * the client/error.ts GraphQLError interface (which is the PostGraphile-oriented one).
162
169
  */
163
- export type { ExecutionResult, GraphQLError, GraphQLSchema, } from 'graphql';
170
+ export type { ExecutionResult, GraphQLSchema } from 'graphql';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Barrel export for all types
3
+ *
4
+ * Re-exports both the original QueryBuilder runtime types (core.ts)
5
+ * and the codegen-style types (schema, introspection, query, mutation, selection)
6
+ */
7
+ export * from './core';
8
+ export * from './schema';
9
+ export * from './introspection';
10
+ export * from './query';
11
+ export * from './mutation';
12
+ export * from './selection';
package/types/index.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /**
3
+ * Barrel export for all types
4
+ *
5
+ * Re-exports both the original QueryBuilder runtime types (core.ts)
6
+ * and the codegen-style types (schema, introspection, query, mutation, selection)
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ // Original QueryBuilder runtime types
24
+ __exportStar(require("./core"), exports);
25
+ // Codegen-style schema types (CleanTable, CleanField, etc.)
26
+ __exportStar(require("./schema"), exports);
27
+ // Introspection types
28
+ __exportStar(require("./introspection"), exports);
29
+ // Query types (QueryOptions, Filter, etc.)
30
+ __exportStar(require("./query"), exports);
31
+ // Mutation types
32
+ __exportStar(require("./mutation"), exports);
33
+ // Selection types (FieldSelection presets, SimpleFieldSelection, etc.)
34
+ __exportStar(require("./selection"), exports);