graphql-jerky 1.0.3 → 1.0.5
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.
- package/build/lib.cjs +33 -19
- package/build/lib.d.ts +1 -0
- package/build/lib.mjs +33 -19
- package/package.json +2 -2
package/build/lib.cjs
CHANGED
|
@@ -285,6 +285,9 @@ function renderImports(base, imports, aliases, extMode = "omit") {
|
|
|
285
285
|
.map((symbol) => symbol in aliases ? jen.id(aliases[symbol]).as.id(symbol) : jen.id(symbol))).from.lit(mod);
|
|
286
286
|
}));
|
|
287
287
|
}
|
|
288
|
+
function renderAstNode(astNode) {
|
|
289
|
+
return jen.id("JSON").dot("parse").call(jen.literal(JSON.stringify(astNode, (key, value) => key === "loc" ? undefined : value)));
|
|
290
|
+
}
|
|
288
291
|
function isBuiltInDirective(name) {
|
|
289
292
|
// https://spec.graphql.org/draft/#sec-Type-System.Directives.Built-in-Directives
|
|
290
293
|
switch (name) {
|
|
@@ -366,7 +369,7 @@ class GeneratorContext {
|
|
|
366
369
|
_renderArgumentNodes(nodes) {
|
|
367
370
|
return jen.obj(...Array.from(nodes ?? [], (arg) => jen.prop(arg.name.value, this._renderValueNode(arg.value))));
|
|
368
371
|
}
|
|
369
|
-
_renderFieldObject(type, f, inputFieldDirectives, noresolver) {
|
|
372
|
+
_renderFieldObject(type, f, inputFieldDirectives, astNodeExpr, noresolver) {
|
|
370
373
|
let resolveFn;
|
|
371
374
|
if (!noresolver) {
|
|
372
375
|
let resolver = this._resolversInfo[type.name]?.[f.name];
|
|
@@ -423,12 +426,18 @@ class GeneratorContext {
|
|
|
423
426
|
// executor implementation, but nonetheless accessible by a potential alternate implementation.
|
|
424
427
|
resolveFn && jen.prop("resolve", jen.parens(resolveFn).as.any),
|
|
425
428
|
subscriber && jen.prop("subscribe", jen.parens(renderSymbolReference(this._pkgs, subscriber)).as.any),
|
|
429
|
+
astNodeExpr && jen.prop("astNode", astNodeExpr),
|
|
426
430
|
]));
|
|
427
431
|
}
|
|
428
|
-
_renderFieldsThunk(type, inputFieldDirectives, noresolver) {
|
|
432
|
+
_renderFieldsThunk(type, inputFieldDirectives, includeAstNodes, noresolver) {
|
|
433
|
+
let astNodeExpr;
|
|
434
|
+
if (includeAstNodes) {
|
|
435
|
+
astNodeExpr = jen.id(type.name + "Type").dot("astNode").op("?").dot("fields").op("?.");
|
|
436
|
+
}
|
|
429
437
|
return jen.arrow().parens(jen.obj(...Object.values(type.getFields())
|
|
430
|
-
.
|
|
431
|
-
.
|
|
438
|
+
.map((field, i) => [field, i])
|
|
439
|
+
.sort(([a], [b]) => compareName(a, b))
|
|
440
|
+
.map(([field, i]) => jen.prop(field.name, this._renderFieldObject(type, field, inputFieldDirectives, astNodeExpr?.index(i), noresolver)))));
|
|
432
441
|
}
|
|
433
442
|
_renderOptionalGraphQLTypeType(type) {
|
|
434
443
|
if (type instanceof graphql.GraphQLNonNull) {
|
|
@@ -502,13 +511,14 @@ class GeneratorContext {
|
|
|
502
511
|
.sort(compareName)
|
|
503
512
|
.map((field) => jen.prop(jen.id(field.name).op("?"), this._renderGraphQLTypeType(field.type))));
|
|
504
513
|
}
|
|
505
|
-
_renderGraphQLObjectTypeDefinition(type, { inputFieldDirectives }) {
|
|
514
|
+
_renderGraphQLObjectTypeDefinition(type, { inputFieldDirectives, includeAstNodes }) {
|
|
506
515
|
const typeInterfaces = type.getInterfaces();
|
|
507
|
-
return jen.new.add(this._gql("GraphQLObjectType")).call(jen.obj(jen.prop("name", jen.lit(type.name)), jen.prop("fields", this._renderFieldsThunk(type, inputFieldDirectives, type.name === "Subscription")), ...truthify([
|
|
516
|
+
return jen.new.add(this._gql("GraphQLObjectType")).call(jen.obj(jen.prop("name", jen.lit(type.name)), jen.prop("fields", this._renderFieldsThunk(type, inputFieldDirectives, includeAstNodes, type.name === "Subscription")), ...truthify([
|
|
508
517
|
type.description && jen.prop("description", jen.lit(type.description)),
|
|
509
518
|
typeInterfaces.length && jen.prop("interfaces", jen.arrow().arr(
|
|
510
519
|
// do not sort interfaces, the declaration order may be important
|
|
511
520
|
...typeInterfaces.map(this._renderGraphQLTypeIdentifier, this))),
|
|
521
|
+
includeAstNodes && type.astNode && jen.prop("astNode", renderAstNode(type.astNode)),
|
|
512
522
|
]))).as.add(this._gql("GraphQLObjectType"));
|
|
513
523
|
}
|
|
514
524
|
_renderGraphQLObjectTypeTypes(type) {
|
|
@@ -547,9 +557,10 @@ class GeneratorContext {
|
|
|
547
557
|
],
|
|
548
558
|
];
|
|
549
559
|
}
|
|
550
|
-
_renderGraphQLInterfaceTypeDefinition(type, {
|
|
551
|
-
return jen.new.add(this._gql("GraphQLInterfaceType")).call(jen.obj(jen.prop("name", jen.lit(type.name)), jen.prop("fields", this._renderFieldsThunk(type, inputFieldDirectives)), ...truthify([
|
|
560
|
+
_renderGraphQLInterfaceTypeDefinition(type, { inputFieldDirectives, includeAstNodes }) {
|
|
561
|
+
return jen.new.add(this._gql("GraphQLInterfaceType")).call(jen.obj(jen.prop("name", jen.lit(type.name)), jen.prop("fields", this._renderFieldsThunk(type, inputFieldDirectives, includeAstNodes)), ...truthify([
|
|
552
562
|
type.description && jen.prop("description", jen.lit(type.description)),
|
|
563
|
+
includeAstNodes && type.astNode && jen.prop("astNode", renderAstNode(type.astNode)),
|
|
553
564
|
]))).as.add(this._gql("GraphQLInterfaceType"));
|
|
554
565
|
}
|
|
555
566
|
_renderGraphQLInterfaceTypeTypes(type, { implementors: { implementors } }) {
|
|
@@ -628,9 +639,10 @@ class GeneratorContext {
|
|
|
628
639
|
return jen.prop(field.name, transformedExpr);
|
|
629
640
|
}));
|
|
630
641
|
}
|
|
631
|
-
_renderGraphQLInputObjectTypeDefinition(type, { inputFieldDirectives }) {
|
|
632
|
-
return jen.new.add(this._gql("GraphQLInputObjectType")).call(jen.obj(jen.prop("name", jen.lit(type.name)), jen.prop("fields", this._renderFieldsThunk(type, inputFieldDirectives, true)), ...truthify([
|
|
642
|
+
_renderGraphQLInputObjectTypeDefinition(type, { inputFieldDirectives, includeAstNodes }) {
|
|
643
|
+
return jen.new.add(this._gql("GraphQLInputObjectType")).call(jen.obj(jen.prop("name", jen.lit(type.name)), jen.prop("fields", this._renderFieldsThunk(type, inputFieldDirectives, includeAstNodes, true)), ...truthify([
|
|
633
644
|
type.description && jen.prop("description", jen.lit(type.description)),
|
|
645
|
+
includeAstNodes && type.astNode && jen.prop("astNode", renderAstNode(type.astNode)),
|
|
634
646
|
])));
|
|
635
647
|
}
|
|
636
648
|
_renderGraphQLInputObjectTypeTypes(type, { inputFieldDirectives }) {
|
|
@@ -705,10 +717,11 @@ class GeneratorContext {
|
|
|
705
717
|
}
|
|
706
718
|
throw new Error("unhandled type: " + type.toString());
|
|
707
719
|
}
|
|
708
|
-
_renderGraphQLTypeDefinitions(type, interfaces, inputFieldDirectives) {
|
|
720
|
+
_renderGraphQLTypeDefinitions(type, interfaces, inputFieldDirectives, includeAstNodes) {
|
|
709
721
|
return jen.const.add(this._renderGraphQLTypeIdentifier(type)).op("=").add(this._getRenderDefintionFnForType(type)({
|
|
710
722
|
implementors: interfaces[type.name],
|
|
711
723
|
inputFieldDirectives,
|
|
724
|
+
includeAstNodes,
|
|
712
725
|
}));
|
|
713
726
|
}
|
|
714
727
|
_renderGraphQLTypeTypes(type, interfaces, inputFieldDirectives) {
|
|
@@ -717,11 +730,12 @@ class GeneratorContext {
|
|
|
717
730
|
inputFieldDirectives,
|
|
718
731
|
});
|
|
719
732
|
}
|
|
720
|
-
_renderGraphQLDirectiveDefinition(directive) {
|
|
733
|
+
_renderGraphQLDirectiveDefinition(directive, includeAstNodes) {
|
|
721
734
|
return jen.const.add(this._renderGraphQLTypeIdentifier(directive)).op("=").new.add(this._gql("GraphQLDirective"))
|
|
722
735
|
.call(jen.obj(jen.prop("name", jen.lit(directive.name)), jen.prop("locations", jen.array(...Array.from(directive.locations).sort().map((location) => jen.add(this._gql("DirectiveLocation")).dot(location)))), jen.prop("args", this._renderArgumentsObject(directive.args)), ...truthify([
|
|
723
736
|
directive.description && jen.prop("description", jen.lit(directive.description)),
|
|
724
737
|
directive.isRepeatable && jen.prop("isRepeatable", jen.true),
|
|
738
|
+
includeAstNodes && directive.astNode && jen.prop("astNode", renderAstNode(directive.astNode)),
|
|
725
739
|
])));
|
|
726
740
|
}
|
|
727
741
|
_renderGraphQLDirectiveTypes(directive) {
|
|
@@ -731,12 +745,12 @@ class GeneratorContext {
|
|
|
731
745
|
])), this._renderGraphQLTypeType(arg.type)))),
|
|
732
746
|
]);
|
|
733
747
|
}
|
|
734
|
-
schemaExprs(schema, [types, interfaces, inputFieldDirectives]) {
|
|
748
|
+
schemaExprs(schema, [types, interfaces, inputFieldDirectives, includeAstNodes]) {
|
|
735
749
|
return [
|
|
736
750
|
...[
|
|
737
751
|
// render type definitions
|
|
738
752
|
...types
|
|
739
|
-
.map((type) => [type.name, this._renderGraphQLTypeDefinitions(type, interfaces, inputFieldDirectives)])
|
|
753
|
+
.map((type) => [type.name, this._renderGraphQLTypeDefinitions(type, interfaces, inputFieldDirectives, includeAstNodes)])
|
|
740
754
|
.sort(compareEntryKey),
|
|
741
755
|
// render directive definitions
|
|
742
756
|
...schema.getDirectives()
|
|
@@ -785,10 +799,10 @@ class GeneratorContext {
|
|
|
785
799
|
.sort(compareEntryKey),
|
|
786
800
|
].map(([, expr]) => expr);
|
|
787
801
|
}
|
|
788
|
-
schemaAndTypesExprs(schema,
|
|
802
|
+
schemaAndTypesExprs(schema, args) {
|
|
789
803
|
return [
|
|
790
|
-
...this.schemaExprs(schema,
|
|
791
|
-
...this.typesExprs(schema,
|
|
804
|
+
...this.schemaExprs(schema, args),
|
|
805
|
+
...this.typesExprs(schema, args),
|
|
792
806
|
];
|
|
793
807
|
}
|
|
794
808
|
renderFile(outfile, renderStatements) {
|
|
@@ -870,7 +884,7 @@ class GeneratorContext {
|
|
|
870
884
|
interfaces[iface.name].implementors.push(type);
|
|
871
885
|
}
|
|
872
886
|
}
|
|
873
|
-
return [types, interfaces, inputFieldDirectives];
|
|
887
|
+
return [types, interfaces, inputFieldDirectives, options.includeAstNodes];
|
|
874
888
|
}
|
|
875
889
|
}
|
|
876
890
|
function createGenerator(schema, options) {
|
|
@@ -957,7 +971,7 @@ async function parseTypeResolvers(typeName, glob$1, ignore) {
|
|
|
957
971
|
if (!shouldIgnore(fullpath) && entry.isFile() && entry.name.endsWith(".ts")) {
|
|
958
972
|
for (const [name, reference] of Object.entries(await parseResolverFile(fullpath))) {
|
|
959
973
|
let realName = name;
|
|
960
|
-
if (realName === "default") {
|
|
974
|
+
if (realName === "default" && typeof glob$1 === 'string' && glob$1.endsWith('/*.ts')) {
|
|
961
975
|
realName = path.basename(fullpath, path.extname(fullpath));
|
|
962
976
|
}
|
|
963
977
|
if (realName in result) {
|
package/build/lib.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ interface GenerateOptions {
|
|
|
38
38
|
subscribersInfo?: Awaited<ReturnType<typeof parseTypeResolvers>>;
|
|
39
39
|
graphqlModuleSpecifier?: string;
|
|
40
40
|
extMode?: "omit" | "replace" | "keep";
|
|
41
|
+
includeAstNodes?: boolean;
|
|
41
42
|
}
|
|
42
43
|
declare function createGenerator(schema: GraphQLSchema, options: GenerateOptions): {
|
|
43
44
|
generateSchema: (outfile: string) => string;
|
package/build/lib.mjs
CHANGED
|
@@ -283,6 +283,9 @@ function renderImports(base, imports, aliases, extMode = "omit") {
|
|
|
283
283
|
.map((symbol) => symbol in aliases ? jen$1.id(aliases[symbol]).as.id(symbol) : jen$1.id(symbol))).from.lit(mod);
|
|
284
284
|
}));
|
|
285
285
|
}
|
|
286
|
+
function renderAstNode(astNode) {
|
|
287
|
+
return jen$1.id("JSON").dot("parse").call(jen$1.literal(JSON.stringify(astNode, (key, value) => key === "loc" ? undefined : value)));
|
|
288
|
+
}
|
|
286
289
|
function isBuiltInDirective(name) {
|
|
287
290
|
// https://spec.graphql.org/draft/#sec-Type-System.Directives.Built-in-Directives
|
|
288
291
|
switch (name) {
|
|
@@ -364,7 +367,7 @@ class GeneratorContext {
|
|
|
364
367
|
_renderArgumentNodes(nodes) {
|
|
365
368
|
return jen$1.obj(...Array.from(nodes ?? [], (arg) => jen$1.prop(arg.name.value, this._renderValueNode(arg.value))));
|
|
366
369
|
}
|
|
367
|
-
_renderFieldObject(type, f, inputFieldDirectives, noresolver) {
|
|
370
|
+
_renderFieldObject(type, f, inputFieldDirectives, astNodeExpr, noresolver) {
|
|
368
371
|
let resolveFn;
|
|
369
372
|
if (!noresolver) {
|
|
370
373
|
let resolver = this._resolversInfo[type.name]?.[f.name];
|
|
@@ -421,12 +424,18 @@ class GeneratorContext {
|
|
|
421
424
|
// executor implementation, but nonetheless accessible by a potential alternate implementation.
|
|
422
425
|
resolveFn && jen$1.prop("resolve", jen$1.parens(resolveFn).as.any),
|
|
423
426
|
subscriber && jen$1.prop("subscribe", jen$1.parens(renderSymbolReference(this._pkgs, subscriber)).as.any),
|
|
427
|
+
astNodeExpr && jen$1.prop("astNode", astNodeExpr),
|
|
424
428
|
]));
|
|
425
429
|
}
|
|
426
|
-
_renderFieldsThunk(type, inputFieldDirectives, noresolver) {
|
|
430
|
+
_renderFieldsThunk(type, inputFieldDirectives, includeAstNodes, noresolver) {
|
|
431
|
+
let astNodeExpr;
|
|
432
|
+
if (includeAstNodes) {
|
|
433
|
+
astNodeExpr = jen$1.id(type.name + "Type").dot("astNode").op("?").dot("fields").op("?.");
|
|
434
|
+
}
|
|
427
435
|
return jen$1.arrow().parens(jen$1.obj(...Object.values(type.getFields())
|
|
428
|
-
.
|
|
429
|
-
.
|
|
436
|
+
.map((field, i) => [field, i])
|
|
437
|
+
.sort(([a], [b]) => compareName(a, b))
|
|
438
|
+
.map(([field, i]) => jen$1.prop(field.name, this._renderFieldObject(type, field, inputFieldDirectives, astNodeExpr?.index(i), noresolver)))));
|
|
430
439
|
}
|
|
431
440
|
_renderOptionalGraphQLTypeType(type) {
|
|
432
441
|
if (type instanceof GraphQLNonNull) {
|
|
@@ -500,13 +509,14 @@ class GeneratorContext {
|
|
|
500
509
|
.sort(compareName)
|
|
501
510
|
.map((field) => jen$1.prop(jen$1.id(field.name).op("?"), this._renderGraphQLTypeType(field.type))));
|
|
502
511
|
}
|
|
503
|
-
_renderGraphQLObjectTypeDefinition(type, { inputFieldDirectives }) {
|
|
512
|
+
_renderGraphQLObjectTypeDefinition(type, { inputFieldDirectives, includeAstNodes }) {
|
|
504
513
|
const typeInterfaces = type.getInterfaces();
|
|
505
|
-
return jen$1.new.add(this._gql("GraphQLObjectType")).call(jen$1.obj(jen$1.prop("name", jen$1.lit(type.name)), jen$1.prop("fields", this._renderFieldsThunk(type, inputFieldDirectives, type.name === "Subscription")), ...truthify([
|
|
514
|
+
return jen$1.new.add(this._gql("GraphQLObjectType")).call(jen$1.obj(jen$1.prop("name", jen$1.lit(type.name)), jen$1.prop("fields", this._renderFieldsThunk(type, inputFieldDirectives, includeAstNodes, type.name === "Subscription")), ...truthify([
|
|
506
515
|
type.description && jen$1.prop("description", jen$1.lit(type.description)),
|
|
507
516
|
typeInterfaces.length && jen$1.prop("interfaces", jen$1.arrow().arr(
|
|
508
517
|
// do not sort interfaces, the declaration order may be important
|
|
509
518
|
...typeInterfaces.map(this._renderGraphQLTypeIdentifier, this))),
|
|
519
|
+
includeAstNodes && type.astNode && jen$1.prop("astNode", renderAstNode(type.astNode)),
|
|
510
520
|
]))).as.add(this._gql("GraphQLObjectType"));
|
|
511
521
|
}
|
|
512
522
|
_renderGraphQLObjectTypeTypes(type) {
|
|
@@ -545,9 +555,10 @@ class GeneratorContext {
|
|
|
545
555
|
],
|
|
546
556
|
];
|
|
547
557
|
}
|
|
548
|
-
_renderGraphQLInterfaceTypeDefinition(type, {
|
|
549
|
-
return jen$1.new.add(this._gql("GraphQLInterfaceType")).call(jen$1.obj(jen$1.prop("name", jen$1.lit(type.name)), jen$1.prop("fields", this._renderFieldsThunk(type, inputFieldDirectives)), ...truthify([
|
|
558
|
+
_renderGraphQLInterfaceTypeDefinition(type, { inputFieldDirectives, includeAstNodes }) {
|
|
559
|
+
return jen$1.new.add(this._gql("GraphQLInterfaceType")).call(jen$1.obj(jen$1.prop("name", jen$1.lit(type.name)), jen$1.prop("fields", this._renderFieldsThunk(type, inputFieldDirectives, includeAstNodes)), ...truthify([
|
|
550
560
|
type.description && jen$1.prop("description", jen$1.lit(type.description)),
|
|
561
|
+
includeAstNodes && type.astNode && jen$1.prop("astNode", renderAstNode(type.astNode)),
|
|
551
562
|
]))).as.add(this._gql("GraphQLInterfaceType"));
|
|
552
563
|
}
|
|
553
564
|
_renderGraphQLInterfaceTypeTypes(type, { implementors: { implementors } }) {
|
|
@@ -626,9 +637,10 @@ class GeneratorContext {
|
|
|
626
637
|
return jen$1.prop(field.name, transformedExpr);
|
|
627
638
|
}));
|
|
628
639
|
}
|
|
629
|
-
_renderGraphQLInputObjectTypeDefinition(type, { inputFieldDirectives }) {
|
|
630
|
-
return jen$1.new.add(this._gql("GraphQLInputObjectType")).call(jen$1.obj(jen$1.prop("name", jen$1.lit(type.name)), jen$1.prop("fields", this._renderFieldsThunk(type, inputFieldDirectives, true)), ...truthify([
|
|
640
|
+
_renderGraphQLInputObjectTypeDefinition(type, { inputFieldDirectives, includeAstNodes }) {
|
|
641
|
+
return jen$1.new.add(this._gql("GraphQLInputObjectType")).call(jen$1.obj(jen$1.prop("name", jen$1.lit(type.name)), jen$1.prop("fields", this._renderFieldsThunk(type, inputFieldDirectives, includeAstNodes, true)), ...truthify([
|
|
631
642
|
type.description && jen$1.prop("description", jen$1.lit(type.description)),
|
|
643
|
+
includeAstNodes && type.astNode && jen$1.prop("astNode", renderAstNode(type.astNode)),
|
|
632
644
|
])));
|
|
633
645
|
}
|
|
634
646
|
_renderGraphQLInputObjectTypeTypes(type, { inputFieldDirectives }) {
|
|
@@ -703,10 +715,11 @@ class GeneratorContext {
|
|
|
703
715
|
}
|
|
704
716
|
throw new Error("unhandled type: " + type.toString());
|
|
705
717
|
}
|
|
706
|
-
_renderGraphQLTypeDefinitions(type, interfaces, inputFieldDirectives) {
|
|
718
|
+
_renderGraphQLTypeDefinitions(type, interfaces, inputFieldDirectives, includeAstNodes) {
|
|
707
719
|
return jen$1.const.add(this._renderGraphQLTypeIdentifier(type)).op("=").add(this._getRenderDefintionFnForType(type)({
|
|
708
720
|
implementors: interfaces[type.name],
|
|
709
721
|
inputFieldDirectives,
|
|
722
|
+
includeAstNodes,
|
|
710
723
|
}));
|
|
711
724
|
}
|
|
712
725
|
_renderGraphQLTypeTypes(type, interfaces, inputFieldDirectives) {
|
|
@@ -715,11 +728,12 @@ class GeneratorContext {
|
|
|
715
728
|
inputFieldDirectives,
|
|
716
729
|
});
|
|
717
730
|
}
|
|
718
|
-
_renderGraphQLDirectiveDefinition(directive) {
|
|
731
|
+
_renderGraphQLDirectiveDefinition(directive, includeAstNodes) {
|
|
719
732
|
return jen$1.const.add(this._renderGraphQLTypeIdentifier(directive)).op("=").new.add(this._gql("GraphQLDirective"))
|
|
720
733
|
.call(jen$1.obj(jen$1.prop("name", jen$1.lit(directive.name)), jen$1.prop("locations", jen$1.array(...Array.from(directive.locations).sort().map((location) => jen$1.add(this._gql("DirectiveLocation")).dot(location)))), jen$1.prop("args", this._renderArgumentsObject(directive.args)), ...truthify([
|
|
721
734
|
directive.description && jen$1.prop("description", jen$1.lit(directive.description)),
|
|
722
735
|
directive.isRepeatable && jen$1.prop("isRepeatable", jen$1.true),
|
|
736
|
+
includeAstNodes && directive.astNode && jen$1.prop("astNode", renderAstNode(directive.astNode)),
|
|
723
737
|
])));
|
|
724
738
|
}
|
|
725
739
|
_renderGraphQLDirectiveTypes(directive) {
|
|
@@ -729,12 +743,12 @@ class GeneratorContext {
|
|
|
729
743
|
])), this._renderGraphQLTypeType(arg.type)))),
|
|
730
744
|
]);
|
|
731
745
|
}
|
|
732
|
-
schemaExprs(schema, [types, interfaces, inputFieldDirectives]) {
|
|
746
|
+
schemaExprs(schema, [types, interfaces, inputFieldDirectives, includeAstNodes]) {
|
|
733
747
|
return [
|
|
734
748
|
...[
|
|
735
749
|
// render type definitions
|
|
736
750
|
...types
|
|
737
|
-
.map((type) => [type.name, this._renderGraphQLTypeDefinitions(type, interfaces, inputFieldDirectives)])
|
|
751
|
+
.map((type) => [type.name, this._renderGraphQLTypeDefinitions(type, interfaces, inputFieldDirectives, includeAstNodes)])
|
|
738
752
|
.sort(compareEntryKey),
|
|
739
753
|
// render directive definitions
|
|
740
754
|
...schema.getDirectives()
|
|
@@ -783,10 +797,10 @@ class GeneratorContext {
|
|
|
783
797
|
.sort(compareEntryKey),
|
|
784
798
|
].map(([, expr]) => expr);
|
|
785
799
|
}
|
|
786
|
-
schemaAndTypesExprs(schema,
|
|
800
|
+
schemaAndTypesExprs(schema, args) {
|
|
787
801
|
return [
|
|
788
|
-
...this.schemaExprs(schema,
|
|
789
|
-
...this.typesExprs(schema,
|
|
802
|
+
...this.schemaExprs(schema, args),
|
|
803
|
+
...this.typesExprs(schema, args),
|
|
790
804
|
];
|
|
791
805
|
}
|
|
792
806
|
renderFile(outfile, renderStatements) {
|
|
@@ -868,7 +882,7 @@ class GeneratorContext {
|
|
|
868
882
|
interfaces[iface.name].implementors.push(type);
|
|
869
883
|
}
|
|
870
884
|
}
|
|
871
|
-
return [types, interfaces, inputFieldDirectives];
|
|
885
|
+
return [types, interfaces, inputFieldDirectives, options.includeAstNodes];
|
|
872
886
|
}
|
|
873
887
|
}
|
|
874
888
|
function createGenerator(schema, options) {
|
|
@@ -955,7 +969,7 @@ async function parseTypeResolvers(typeName, glob, ignore) {
|
|
|
955
969
|
if (!shouldIgnore(fullpath) && entry.isFile() && entry.name.endsWith(".ts")) {
|
|
956
970
|
for (const [name, reference] of Object.entries(await parseResolverFile(fullpath))) {
|
|
957
971
|
let realName = name;
|
|
958
|
-
if (realName === "default") {
|
|
972
|
+
if (realName === "default" && typeof glob === 'string' && glob.endsWith('/*.ts')) {
|
|
959
973
|
realName = basename(fullpath, extname(fullpath));
|
|
960
974
|
}
|
|
961
975
|
if (realName in result) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphql-jerky",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Jerky is a schema-first static graphql schema lightweight code generator.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "./build/bin/jerky.cjs",
|
|
@@ -34,4 +34,4 @@
|
|
|
34
34
|
"build"
|
|
35
35
|
],
|
|
36
36
|
"license": "MIT"
|
|
37
|
-
}
|
|
37
|
+
}
|