quicktype-graphql-input 23.1.4 → 23.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,31 +1,31 @@
1
1
  export declare enum __DirectiveLocation {
2
- QUERY = "QUERY",
3
- MUTATION = "MUTATION",
4
- SUBSCRIPTION = "SUBSCRIPTION",
5
- FIELD = "FIELD",
6
- FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION",
7
- FRAGMENT_SPREAD = "FRAGMENT_SPREAD",
8
- INLINE_FRAGMENT = "INLINE_FRAGMENT",
9
- SCHEMA = "SCHEMA",
10
- SCALAR = "SCALAR",
11
- OBJECT = "OBJECT",
12
- FIELD_DEFINITION = "FIELD_DEFINITION",
13
- ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION",
14
- INTERFACE = "INTERFACE",
15
- UNION = "UNION",
16
- ENUM = "ENUM",
17
- ENUM_VALUE = "ENUM_VALUE",
18
- INPUT_OBJECT = "INPUT_OBJECT",
2
+ QUERY = "QUERY",// Location adjacent to a query operation.
3
+ MUTATION = "MUTATION",// Location adjacent to a mutation operation.
4
+ SUBSCRIPTION = "SUBSCRIPTION",// Location adjacent to a subscription operation.
5
+ FIELD = "FIELD",// Location adjacent to a field.
6
+ FRAGMENT_DEFINITION = "FRAGMENT_DEFINITION",// Location adjacent to a fragment definition.
7
+ FRAGMENT_SPREAD = "FRAGMENT_SPREAD",// Location adjacent to a fragment spread.
8
+ INLINE_FRAGMENT = "INLINE_FRAGMENT",// Location adjacent to an inline fragment.
9
+ SCHEMA = "SCHEMA",// Location adjacent to a schema definition.
10
+ SCALAR = "SCALAR",// Location adjacent to a scalar definition.
11
+ OBJECT = "OBJECT",// Location adjacent to an object type definition.
12
+ FIELD_DEFINITION = "FIELD_DEFINITION",// Location adjacent to a field definition.
13
+ ARGUMENT_DEFINITION = "ARGUMENT_DEFINITION",// Location adjacent to an argument definition.
14
+ INTERFACE = "INTERFACE",// Location adjacent to an interface definition.
15
+ UNION = "UNION",// Location adjacent to a union definition.
16
+ ENUM = "ENUM",// Location adjacent to an enum definition.
17
+ ENUM_VALUE = "ENUM_VALUE",// Location adjacent to an enum value definition.
18
+ INPUT_OBJECT = "INPUT_OBJECT",// Location adjacent to an input object type definition.
19
19
  INPUT_FIELD_DEFINITION = "INPUT_FIELD_DEFINITION"
20
20
  }
21
21
  export declare enum TypeKind {
22
- SCALAR = "SCALAR",
23
- OBJECT = "OBJECT",
24
- INTERFACE = "INTERFACE",
25
- UNION = "UNION",
26
- ENUM = "ENUM",
27
- INPUT_OBJECT = "INPUT_OBJECT",
28
- LIST = "LIST",
22
+ SCALAR = "SCALAR",// Indicates this type is a scalar.
23
+ OBJECT = "OBJECT",// Indicates this type is an object. `fields` and `interfaces` are valid fields.
24
+ INTERFACE = "INTERFACE",// Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.
25
+ UNION = "UNION",// Indicates this type is a union. `possibleTypes` is a valid field.
26
+ ENUM = "ENUM",// Indicates this type is an enum. `enumValues` is a valid field.
27
+ INPUT_OBJECT = "INPUT_OBJECT",// Indicates this type is an input object. `inputFields` is a valid field.
28
+ LIST = "LIST",// Indicates this type is a list. `ofType` is a valid field.
29
29
  NON_NULL = "NON_NULL"
30
30
  }
31
31
  export type GraphQLSchema = {
@@ -23,8 +23,8 @@ var __DirectiveLocation;
23
23
  __DirectiveLocation["ENUM"] = "ENUM";
24
24
  __DirectiveLocation["ENUM_VALUE"] = "ENUM_VALUE";
25
25
  __DirectiveLocation["INPUT_OBJECT"] = "INPUT_OBJECT";
26
- __DirectiveLocation["INPUT_FIELD_DEFINITION"] = "INPUT_FIELD_DEFINITION"; // Location adjacent to an input object field definition.
27
- })(__DirectiveLocation = exports.__DirectiveLocation || (exports.__DirectiveLocation = {}));
26
+ __DirectiveLocation["INPUT_FIELD_DEFINITION"] = "INPUT_FIELD_DEFINITION";
27
+ })(__DirectiveLocation || (exports.__DirectiveLocation = __DirectiveLocation = {}));
28
28
  // An enum describing what kind of type a given `__Type` is.
29
29
  var TypeKind;
30
30
  (function (TypeKind) {
@@ -35,5 +35,5 @@ var TypeKind;
35
35
  TypeKind["ENUM"] = "ENUM";
36
36
  TypeKind["INPUT_OBJECT"] = "INPUT_OBJECT";
37
37
  TypeKind["LIST"] = "LIST";
38
- TypeKind["NON_NULL"] = "NON_NULL"; // Indicates this type is a non-null. `ofType` is a valid field.
39
- })(TypeKind = exports.TypeKind || (exports.TypeKind = {}));
38
+ TypeKind["NON_NULL"] = "NON_NULL";
39
+ })(TypeKind || (exports.TypeKind = TypeKind = {}));
package/dist/index.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -66,7 +76,7 @@ function makeNullable(builder, tref, name, fieldName, containingTypeName) {
66
76
  const [maybeNull, nonNulls] = (0, quicktype_core_1.removeNullFromUnion)(t);
67
77
  if (maybeNull)
68
78
  return tref;
69
- return builder.getUnionType(typeNames, (0, collection_utils_1.setMap)(nonNulls, nn => nn.typeRef).add(builder.getPrimitiveType("null")));
79
+ return builder.getUnionType(typeNames, (0, collection_utils_1.setMap)(nonNulls, (nn) => nn.typeRef).add(builder.getPrimitiveType("null")));
70
80
  }
71
81
  // This is really not the way to do this, but it's easy and works. By default
72
82
  // all types in GraphQL are nullable, and non-nullability must be specially marked,
@@ -84,7 +94,7 @@ function removeNull(builder, tref) {
84
94
  if (first) {
85
95
  if (nonNulls.size === 1)
86
96
  return first.typeRef;
87
- return builder.getUnionType(t.getAttributes(), (0, collection_utils_1.setMap)(nonNulls, nn => nn.typeRef));
97
+ return builder.getUnionType(t.getAttributes(), (0, collection_utils_1.setMap)(nonNulls, (nn) => nn.typeRef));
88
98
  }
89
99
  return (0, quicktype_core_1.panic)("Trying to remove null results in empty union.");
90
100
  }
@@ -114,7 +124,11 @@ function hasOptionalDirectives(directives) {
114
124
  function expandSelectionSet(selectionSet, inType, optional) {
115
125
  return selectionSet.selections
116
126
  .reverse()
117
- .map(s => ({ selection: s, inType, optional: optional || hasOptionalDirectives(s.directives) }));
127
+ .map((s) => ({
128
+ selection: s,
129
+ inType,
130
+ optional: optional || hasOptionalDirectives(s.directives),
131
+ }));
118
132
  }
119
133
  class GQLQuery {
120
134
  constructor(schema, queryString) {
@@ -137,7 +151,7 @@ class GQLQuery {
137
151
  if (!fieldType.enumValues) {
138
152
  return (0, quicktype_core_1.panic)("Enum type doesn't have values");
139
153
  }
140
- const values = fieldType.enumValues.map(ev => ev.name);
154
+ const values = fieldType.enumValues.map((ev) => ev.name);
141
155
  let name;
142
156
  let fieldName;
143
157
  if (fieldType.name) {
@@ -201,9 +215,11 @@ class GQLQuery {
201
215
  switch (selection.kind) {
202
216
  case "Field":
203
217
  const fieldName = selection.name.value;
204
- const givenName = selection.alias ? selection.alias.value : fieldName;
218
+ const givenName = selection.alias
219
+ ? selection.alias.value
220
+ : fieldName;
205
221
  const field = getField(inType, fieldName);
206
- let fieldType = this.makeIRTypeFromFieldNode(builder, selection, field.type, nameOrOverride);
222
+ const fieldType = this.makeIRTypeFromFieldNode(builder, selection, field.type, nameOrOverride);
207
223
  properties.set(givenName, builder.makeClassProperty(fieldType, optional));
208
224
  break;
209
225
  case "FragmentSpread": {
@@ -219,7 +235,9 @@ class GQLQuery {
219
235
  const fragmentType = selection.typeCondition
220
236
  ? this._schema.types[selection.typeCondition.name.value]
221
237
  : inType;
222
- const fragmentOptional = optional || fragmentType.name !== inType.name || hasOptionalDirectives(selection.directives);
238
+ const fragmentOptional = optional ||
239
+ fragmentType.name !== inType.name ||
240
+ hasOptionalDirectives(selection.directives);
223
241
  const expanded = expandSelectionSet(selection.selectionSet, fragmentType, fragmentOptional);
224
242
  selections = selections.concat(expanded);
225
243
  break;
@@ -265,12 +283,12 @@ class GQLSchemaFromJSON {
265
283
  this.types = {};
266
284
  this.addTypeFields = (target, source) => {
267
285
  if (source.fields) {
268
- target.fields = source.fields.map(f => {
286
+ target.fields = source.fields.map((f) => {
269
287
  return {
270
288
  name: f.name,
271
289
  description: f.description,
272
290
  type: this.makeType(f.type),
273
- args: f.args.map(this.makeInputValue)
291
+ args: f.args.map(this.makeInputValue),
274
292
  };
275
293
  });
276
294
  // console.log(`${target.name} has ${target.fields.length} fields`);
@@ -288,7 +306,7 @@ class GQLSchemaFromJSON {
288
306
  // console.log(`${target.name} has ${target.inputFields.length} inputFields`);
289
307
  }
290
308
  if (source.enumValues) {
291
- target.enumValues = source.enumValues.map(ev => {
309
+ target.enumValues = source.enumValues.map((ev) => {
292
310
  return { name: ev.name, description: ev.description };
293
311
  });
294
312
  // console.log(`${target.name} has ${target.enumValues.length} enumValues`);
@@ -299,7 +317,7 @@ class GQLSchemaFromJSON {
299
317
  name: iv.name,
300
318
  description: iv.description,
301
319
  type: this.makeType(iv.type),
302
- defaultValue: iv.defaultValue
320
+ defaultValue: iv.defaultValue,
303
321
  };
304
322
  };
305
323
  this.makeType = (t) => {
@@ -314,7 +332,7 @@ class GQLSchemaFromJSON {
314
332
  const type = {
315
333
  kind: t.kind,
316
334
  description: t.description,
317
- ofType: this.makeType(t.ofType)
335
+ ofType: this.makeType(t.ofType),
318
336
  };
319
337
  this.addTypeFields(type, t);
320
338
  return type;
@@ -326,7 +344,11 @@ class GQLSchemaFromJSON {
326
344
  for (const t of schema.__schema.types) {
327
345
  if (!t.name)
328
346
  return (0, quicktype_core_1.panic)("No top-level type name given");
329
- this.types[t.name] = { kind: t.kind, name: t.name, description: t.description };
347
+ this.types[t.name] = {
348
+ kind: t.kind,
349
+ name: t.name,
350
+ description: t.description,
351
+ };
330
352
  }
331
353
  for (const t of schema.__schema.types) {
332
354
  if (!t.name)
@@ -366,12 +388,12 @@ function makeGraphQLQueryTypes(topLevelName, builder, json, queryString) {
366
388
  const dataType = query.makeType(builder, odn, queryName);
367
389
  const dataOrNullType = builder.getUnionType(quicktype_core_1.emptyTypeAttributes, new Set([dataType, builder.getPrimitiveType("null")]));
368
390
  const errorType = builder.getClassType(quicktype_core_1.namesTypeAttributeKind.makeAttributes(quicktype_core_1.TypeNames.make(new Set(["error"]), new Set(["graphQLError"]), false)), (0, collection_utils_1.mapFromObject)({
369
- message: builder.makeClassProperty(builder.getStringType(quicktype_core_1.emptyTypeAttributes, quicktype_core_1.StringTypes.unrestricted), false)
391
+ message: builder.makeClassProperty(builder.getStringType(quicktype_core_1.emptyTypeAttributes, quicktype_core_1.StringTypes.unrestricted), false),
370
392
  }));
371
393
  const errorArray = builder.getArrayType(quicktype_core_1.namesTypeAttributeKind.makeAttributes(quicktype_core_1.TypeNames.make(new Set(["errors"]), new Set(["graphQLErrors"]), false)), errorType);
372
394
  const t = builder.getClassType((0, quicktype_core_1.makeNamesTypeAttributes)(queryName, false), (0, collection_utils_1.mapFromObject)({
373
395
  data: builder.makeClassProperty(dataOrNullType, false),
374
- errors: builder.makeClassProperty(errorArray, true)
396
+ errors: builder.makeClassProperty(errorArray, true),
375
397
  }));
376
398
  types.set(queryName, t);
377
399
  }
@@ -392,7 +414,7 @@ class GraphQLInput {
392
414
  addSourceSync(source) {
393
415
  this._topLevels.set(source.name, {
394
416
  schema: source.schema,
395
- query: source.query
417
+ query: source.query,
396
418
  });
397
419
  }
398
420
  singleStringSchemaSource() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quicktype-graphql-input",
3
- "version": "23.1.4",
3
+ "version": "23.2.1",
4
4
  "package": "Package for using GraphQL as an input language to quicktype",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -11,14 +11,14 @@
11
11
  "build": "tsc"
12
12
  },
13
13
  "dependencies": {
14
- "quicktype-core": "23.1.4",
14
+ "quicktype-core": "23.2.1",
15
15
  "collection-utils": "^1.0.1",
16
16
  "graphql": "^0.11.7"
17
17
  },
18
18
  "devDependencies": {
19
- "@types/node": "18.19.31",
19
+ "@types/node": "~22.14.0",
20
20
  "@types/graphql": "^0.11.7",
21
- "typescript": "4.9.5"
21
+ "typescript": "~5.8.3"
22
22
  },
23
23
  "files": [
24
24
  "dist"