quicktype-graphql-input 0.0.58 → 0.0.60

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.
@@ -28,7 +28,7 @@ export declare enum TypeKind {
28
28
  LIST = "LIST",
29
29
  NON_NULL = "NON_NULL"
30
30
  }
31
- export declare type GraphQLSchema = {
31
+ export type GraphQLSchema = {
32
32
  __schema: {
33
33
  __typename: "__Schema";
34
34
  queryType: {
@@ -327,7 +327,7 @@ export declare type GraphQLSchema = {
327
327
  }>;
328
328
  };
329
329
  };
330
- export declare type FullTypeFragment = {
330
+ export type FullTypeFragment = {
331
331
  __typename: "__Type";
332
332
  kind: TypeKind;
333
333
  name: string | null;
@@ -557,7 +557,7 @@ export declare type FullTypeFragment = {
557
557
  } | null;
558
558
  }> | null;
559
559
  };
560
- export declare type InputValueFragment = {
560
+ export type InputValueFragment = {
561
561
  __typename: "__InputValue";
562
562
  name: string;
563
563
  description: string | null;
@@ -603,7 +603,7 @@ export declare type InputValueFragment = {
603
603
  };
604
604
  defaultValue: string | null;
605
605
  };
606
- export declare type TypeRefFragment = {
606
+ export type TypeRefFragment = {
607
607
  __typename: "__Type";
608
608
  kind: TypeKind;
609
609
  name: string | null;
@@ -2,6 +2,7 @@
2
2
  /* tslint:disable */
3
3
  // This file was automatically generated and should not be edited.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.TypeKind = exports.__DirectiveLocation = void 0;
5
6
  // A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.
6
7
  var __DirectiveLocation;
7
8
  (function (__DirectiveLocation) {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TypeBuilder, Input, RunContext } from "quicktype-core";
2
- export declare type GraphQLSourceData = {
2
+ export type GraphQLSourceData = {
3
3
  name: string;
4
4
  schema: any;
5
5
  query: string;
package/dist/index.js CHANGED
@@ -1,27 +1,52 @@
1
1
  "use strict";
2
2
  /* tslint:disable:strict-boolean-expressions */
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
3
26
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
28
  return new (P || (P = Promise))(function (resolve, reject) {
5
29
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
30
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
31
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
32
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
33
  });
10
34
  };
11
35
  Object.defineProperty(exports, "__esModule", { value: true });
12
- const graphql = require("graphql/language");
36
+ exports.GraphQLInput = void 0;
37
+ const graphql = __importStar(require("graphql/language"));
13
38
  const collection_utils_1 = require("collection-utils");
14
39
  const quicktype_core_1 = require("quicktype-core");
15
40
  const GraphQLSchema_1 = require("./GraphQLSchema");
16
41
  function getField(t, name) {
17
42
  if (!t.fields)
18
- return quicktype_core_1.panic(`Required field ${name} in type ${t.name} which doesn't have fields.`);
43
+ return (0, quicktype_core_1.panic)(`Required field ${name} in type ${t.name} which doesn't have fields.`);
19
44
  for (const f of t.fields) {
20
45
  if (f.name === name) {
21
46
  return f;
22
47
  }
23
48
  }
24
- return quicktype_core_1.panic(`Required field ${name} not defined on type ${t.name}.`);
49
+ return (0, quicktype_core_1.panic)(`Required field ${name} not defined on type ${t.name}.`);
25
50
  }
26
51
  function makeNames(name, fieldName, containingTypeName) {
27
52
  const alternatives = [];
@@ -35,14 +60,14 @@ function makeNames(name, fieldName, containingTypeName) {
35
60
  }
36
61
  function makeNullable(builder, tref, name, fieldName, containingTypeName) {
37
62
  const typeNames = makeNames(name, fieldName, containingTypeName);
38
- const t = quicktype_core_1.derefTypeRef(tref, builder.typeGraph);
63
+ const t = (0, quicktype_core_1.derefTypeRef)(tref, builder.typeGraph);
39
64
  if (!(t instanceof quicktype_core_1.UnionType)) {
40
65
  return builder.getUnionType(typeNames, new Set([tref, builder.getPrimitiveType("null")]));
41
66
  }
42
- const [maybeNull, nonNulls] = quicktype_core_1.removeNullFromUnion(t);
67
+ const [maybeNull, nonNulls] = (0, quicktype_core_1.removeNullFromUnion)(t);
43
68
  if (maybeNull)
44
69
  return tref;
45
- return builder.getUnionType(typeNames, collection_utils_1.setMap(nonNulls, nn => nn.typeRef).add(builder.getPrimitiveType("null")));
70
+ return builder.getUnionType(typeNames, (0, collection_utils_1.setMap)(nonNulls, nn => nn.typeRef).add(builder.getPrimitiveType("null")));
46
71
  }
47
72
  // This is really not the way to do this, but it's easy and works. By default
48
73
  // all types in GraphQL are nullable, and non-nullability must be specially marked,
@@ -51,18 +76,18 @@ function makeNullable(builder, tref, name, fieldName, containingTypeName) {
51
76
  // (and the null) might be left unreachable in the graph. Provenance checking
52
77
  // won't work in this case, which is why it's disabled in testing for GraphQL.
53
78
  function removeNull(builder, tref) {
54
- const t = quicktype_core_1.derefTypeRef(tref, builder.typeGraph);
79
+ const t = (0, quicktype_core_1.derefTypeRef)(tref, builder.typeGraph);
55
80
  if (!(t instanceof quicktype_core_1.UnionType)) {
56
81
  return tref;
57
82
  }
58
- const nonNulls = quicktype_core_1.removeNullFromUnion(t)[1];
59
- const first = collection_utils_1.iterableFirst(nonNulls);
83
+ const nonNulls = (0, quicktype_core_1.removeNullFromUnion)(t)[1];
84
+ const first = (0, collection_utils_1.iterableFirst)(nonNulls);
60
85
  if (first) {
61
86
  if (nonNulls.size === 1)
62
87
  return first.typeRef;
63
- return builder.getUnionType(t.getAttributes(), collection_utils_1.setMap(nonNulls, nn => nn.typeRef));
88
+ return builder.getUnionType(t.getAttributes(), (0, collection_utils_1.setMap)(nonNulls, nn => nn.typeRef));
64
89
  }
65
- return quicktype_core_1.panic("Trying to remove null results in empty union.");
90
+ return (0, quicktype_core_1.panic)("Trying to remove null results in empty union.");
66
91
  }
67
92
  function makeScalar(builder, ft) {
68
93
  switch (ft.name) {
@@ -106,12 +131,12 @@ class GQLQuery {
106
131
  case GraphQLSchema_1.TypeKind.INTERFACE:
107
132
  case GraphQLSchema_1.TypeKind.UNION:
108
133
  if (!fieldNode.selectionSet) {
109
- return quicktype_core_1.panic("No selection set on object or interface");
134
+ return (0, quicktype_core_1.panic)("No selection set on object or interface");
110
135
  }
111
136
  return makeNullable(builder, this.makeIRTypeFromSelectionSet(builder, fieldNode.selectionSet, fieldType, fieldNode.name.value, containingTypeName), fieldNode.name.value, null, containingTypeName);
112
137
  case GraphQLSchema_1.TypeKind.ENUM:
113
138
  if (!fieldType.enumValues) {
114
- return quicktype_core_1.panic("Enum type doesn't have values");
139
+ return (0, quicktype_core_1.panic)("Enum type doesn't have values");
115
140
  }
116
141
  const values = fieldType.enumValues.map(ev => ev.name);
117
142
  let name;
@@ -129,21 +154,21 @@ class GQLQuery {
129
154
  break;
130
155
  case GraphQLSchema_1.TypeKind.INPUT_OBJECT:
131
156
  // FIXME: Support input objects
132
- return quicktype_core_1.panic("Input objects not supported");
157
+ return (0, quicktype_core_1.panic)("Input objects not supported");
133
158
  case GraphQLSchema_1.TypeKind.LIST:
134
159
  if (!fieldType.ofType) {
135
- return quicktype_core_1.panic("No type for list");
160
+ return (0, quicktype_core_1.panic)("No type for list");
136
161
  }
137
162
  result = builder.getArrayType(quicktype_core_1.emptyTypeAttributes, this.makeIRTypeFromFieldNode(builder, fieldNode, fieldType.ofType, containingTypeName));
138
163
  break;
139
164
  case GraphQLSchema_1.TypeKind.NON_NULL:
140
165
  if (!fieldType.ofType) {
141
- return quicktype_core_1.panic("No type for non-null");
166
+ return (0, quicktype_core_1.panic)("No type for non-null");
142
167
  }
143
168
  result = removeNull(builder, this.makeIRTypeFromFieldNode(builder, fieldNode, fieldType.ofType, containingTypeName));
144
169
  break;
145
170
  default:
146
- return quicktype_core_1.assertNever(fieldType.kind);
171
+ return (0, quicktype_core_1.assertNever)(fieldType.kind);
147
172
  }
148
173
  if (optional) {
149
174
  result = makeNullable(builder, result, fieldNode.name.value, null, containingTypeName);
@@ -153,17 +178,17 @@ class GQLQuery {
153
178
  this.getFragment = (name) => {
154
179
  const fragment = this._fragments[name];
155
180
  if (!fragment)
156
- return quicktype_core_1.panic(`Fragment ${name} is not defined.`);
181
+ return (0, quicktype_core_1.panic)(`Fragment ${name} is not defined.`);
157
182
  return fragment;
158
183
  };
159
184
  this.makeIRTypeFromSelectionSet = (builder, selectionSet, gqlType, containingFieldName, containingTypeName, overrideName) => {
160
185
  if (gqlType.kind !== GraphQLSchema_1.TypeKind.OBJECT &&
161
186
  gqlType.kind !== GraphQLSchema_1.TypeKind.INTERFACE &&
162
187
  gqlType.kind !== GraphQLSchema_1.TypeKind.UNION) {
163
- return quicktype_core_1.panic("Type for selection set is not object, interface, or union.");
188
+ return (0, quicktype_core_1.panic)("Type for selection set is not object, interface, or union.");
164
189
  }
165
190
  if (!gqlType.name) {
166
- return quicktype_core_1.panic("Object, interface, or union type doesn't have a name.");
191
+ return (0, quicktype_core_1.panic)("Object, interface, or union type doesn't have a name.");
167
192
  }
168
193
  const nameOrOverride = overrideName || gqlType.name;
169
194
  const properties = new Map();
@@ -200,7 +225,7 @@ class GQLQuery {
200
225
  break;
201
226
  }
202
227
  default:
203
- quicktype_core_1.assertNever(selection);
228
+ (0, quicktype_core_1.assertNever)(selection);
204
229
  }
205
230
  }
206
231
  return builder.getClassType(makeNames(nameOrOverride, containingFieldName, containingTypeName), properties);
@@ -219,7 +244,7 @@ class GQLQuery {
219
244
  this._fragments[def.name.value] = def;
220
245
  }
221
246
  }
222
- quicktype_core_1.messageAssert(queries.length >= 1, "GraphQLNoQueriesDefined", {});
247
+ (0, quicktype_core_1.messageAssert)(queries.length >= 1, "GraphQLNoQueriesDefined", {});
223
248
  this.queries = queries;
224
249
  }
225
250
  makeType(builder, query, queryName) {
@@ -228,11 +253,11 @@ class GQLQuery {
228
253
  }
229
254
  if (query.operation === "mutation") {
230
255
  if (this._schema.mutationType === undefined) {
231
- return quicktype_core_1.panic("This GraphQL endpoint has no mutations.");
256
+ return (0, quicktype_core_1.panic)("This GraphQL endpoint has no mutations.");
232
257
  }
233
258
  return this.makeIRTypeFromSelectionSet(builder, query.selectionSet, this._schema.mutationType, null, queryName, "data");
234
259
  }
235
- return quicktype_core_1.panic(`Unknown query operation type: "${query.operation}"`);
260
+ return (0, quicktype_core_1.panic)(`Unknown query operation type: "${query.operation}"`);
236
261
  }
237
262
  }
238
263
  class GQLSchemaFromJSON {
@@ -281,11 +306,11 @@ class GQLSchemaFromJSON {
281
306
  if (t.name) {
282
307
  const namedType = this.types[t.name];
283
308
  if (!namedType)
284
- return quicktype_core_1.panic(`Type ${t.name} not found`);
309
+ return (0, quicktype_core_1.panic)(`Type ${t.name} not found`);
285
310
  return namedType;
286
311
  }
287
312
  if (!t.ofType)
288
- return quicktype_core_1.panic(`Type of kind ${t.kind} has neither name nor ofType`);
313
+ return (0, quicktype_core_1.panic)(`Type of kind ${t.kind} has neither name nor ofType`);
289
314
  const type = {
290
315
  kind: t.kind,
291
316
  description: t.description,
@@ -296,23 +321,23 @@ class GQLSchemaFromJSON {
296
321
  };
297
322
  const schema = json.data;
298
323
  if (schema.__schema.queryType.name === null) {
299
- return quicktype_core_1.panic("Query type doesn't have a name.");
324
+ return (0, quicktype_core_1.panic)("Query type doesn't have a name.");
300
325
  }
301
326
  for (const t of schema.__schema.types) {
302
327
  if (!t.name)
303
- return quicktype_core_1.panic("No top-level type name given");
328
+ return (0, quicktype_core_1.panic)("No top-level type name given");
304
329
  this.types[t.name] = { kind: t.kind, name: t.name, description: t.description };
305
330
  }
306
331
  for (const t of schema.__schema.types) {
307
332
  if (!t.name)
308
- return quicktype_core_1.panic("This cannot happen");
333
+ return (0, quicktype_core_1.panic)("This cannot happen");
309
334
  const type = this.types[t.name];
310
335
  this.addTypeFields(type, t);
311
336
  // console.log(`type ${type.name} is ${type.kind}`);
312
337
  }
313
338
  const queryType = this.types[schema.__schema.queryType.name];
314
339
  if (queryType === undefined) {
315
- return quicktype_core_1.panic("Query type not found.");
340
+ return (0, quicktype_core_1.panic)("Query type not found.");
316
341
  }
317
342
  // console.log(`query type ${queryType.name} is ${queryType.kind}`);
318
343
  this.queryType = queryType;
@@ -320,11 +345,11 @@ class GQLSchemaFromJSON {
320
345
  return;
321
346
  }
322
347
  if (schema.__schema.mutationType.name === null) {
323
- return quicktype_core_1.panic("Mutation type doesn't have a name.");
348
+ return (0, quicktype_core_1.panic)("Mutation type doesn't have a name.");
324
349
  }
325
350
  const mutationType = this.types[schema.__schema.mutationType.name];
326
351
  if (mutationType === undefined) {
327
- return quicktype_core_1.panic("Mutation type not found.");
352
+ return (0, quicktype_core_1.panic)("Mutation type not found.");
328
353
  }
329
354
  this.mutationType = mutationType;
330
355
  }
@@ -336,15 +361,15 @@ function makeGraphQLQueryTypes(topLevelName, builder, json, queryString) {
336
361
  for (const odn of query.queries) {
337
362
  const queryName = odn.name ? odn.name.value : topLevelName;
338
363
  if (types.has(queryName)) {
339
- return quicktype_core_1.panic(`Duplicate query name ${queryName}`);
364
+ return (0, quicktype_core_1.panic)(`Duplicate query name ${queryName}`);
340
365
  }
341
366
  const dataType = query.makeType(builder, odn, queryName);
342
367
  const dataOrNullType = builder.getUnionType(quicktype_core_1.emptyTypeAttributes, new Set([dataType, builder.getPrimitiveType("null")]));
343
- const errorType = builder.getClassType(quicktype_core_1.namesTypeAttributeKind.makeAttributes(quicktype_core_1.TypeNames.make(new Set(["error"]), new Set(["graphQLError"]), false)), collection_utils_1.mapFromObject({
368
+ 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)({
344
369
  message: builder.makeClassProperty(builder.getStringType(quicktype_core_1.emptyTypeAttributes, quicktype_core_1.StringTypes.unrestricted), false)
345
370
  }));
346
371
  const errorArray = builder.getArrayType(quicktype_core_1.namesTypeAttributeKind.makeAttributes(quicktype_core_1.TypeNames.make(new Set(["errors"]), new Set(["graphQLErrors"]), false)), errorType);
347
- const t = builder.getClassType(quicktype_core_1.makeNamesTypeAttributes(queryName, false), collection_utils_1.mapFromObject({
372
+ const t = builder.getClassType((0, quicktype_core_1.makeNamesTypeAttributes)(queryName, false), (0, collection_utils_1.mapFromObject)({
348
373
  data: builder.makeClassProperty(dataOrNullType, false),
349
374
  errors: builder.makeClassProperty(errorArray, true)
350
375
  }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quicktype-graphql-input",
3
- "version": "0.0.58",
3
+ "version": "0.0.60",
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",
@@ -8,25 +8,24 @@
8
8
  "repository": "https://github.com/quicktype/quicktype",
9
9
  "scripts": {
10
10
  "clean": "rm -rf dist node_modules *~",
11
- "prepare": "npm run build",
12
11
  "build": "tsc",
13
12
  "tslint": "tslint --project ."
14
13
  },
15
14
  "dependencies": {
16
- "quicktype-core": "^7.0.35",
15
+ "quicktype-core": "^7.0.37",
17
16
  "collection-utils": "^1.0.1",
18
17
  "graphql": "^0.11.7"
19
18
  },
20
19
  "devDependencies": {
21
- "@types/node": "^8.10.10",
20
+ "@types/node": "18.11.18",
22
21
  "@types/graphql": "^0.11.7",
23
- "typescript": "~3.2.1",
22
+ "typescript": "4.9.4",
24
23
  "tslint": "^5.11.0"
25
24
  },
26
25
  "files": [
27
26
  "dist/**"
28
27
  ],
29
28
  "config": {
30
- "commit": "b3ef38043ae6a0dc6a64760f50c0a43cbba053b6"
29
+ "commit": "53f6df68305127ad0b4751225b2628712583463f"
31
30
  }
32
31
  }