graphql-jerky 1.0.11 → 1.0.12

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 CHANGED
@@ -458,7 +458,9 @@ class GeneratorContext {
458
458
  let resolveFn;
459
459
  if (!noresolver) {
460
460
  let resolver = this._resolversInfo[type.name]?.[f.name];
461
- if (type instanceof graphql.GraphQLObjectType && !resolver) {
461
+ if ((type instanceof graphql.GraphQLObjectType ||
462
+ type instanceof graphql.GraphQLInterfaceType) &&
463
+ !resolver) {
462
464
  // try to find resolver in interface in the declaration order
463
465
  for (const iface of type.getInterfaces()) {
464
466
  resolver = this._resolversInfo[iface.name]?.[f.name];
@@ -702,11 +704,16 @@ class GeneratorContext {
702
704
  ];
703
705
  }
704
706
  _renderGraphQLInterfaceTypeDefinition(type, { inputFieldDirectives, includeAstNodes }) {
707
+ const typeInterfaces = type.getInterfaces();
705
708
  return jen.new
706
709
  .add(this._gql("GraphQLInterfaceType"))
707
710
  .call(jen.obj(jen.prop("name", jen.lit(type.name)), jen.prop("fields", this._renderFieldsThunk(type, inputFieldDirectives, includeAstNodes)), ...truthify([
708
711
  type.description &&
709
712
  jen.prop("description", jen.lit(type.description)),
713
+ typeInterfaces.length &&
714
+ jen.prop("interfaces", jen.arrow().arr(
715
+ // do not sort interfaces, the declaration order may be important
716
+ ...typeInterfaces.map(this._renderGraphQLTypeIdentifier, this))),
710
717
  includeAstNodes &&
711
718
  type.astNode &&
712
719
  jen.prop("astNode", renderAstNode(type.astNode)),
package/build/lib.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import path, { resolve, basename, extname, posix } from 'node:path';
2
2
  import { pathToFileURL, fileURLToPath } from 'node:url';
3
- import { GraphQLNonNull, GraphQLList, GraphQLScalarType, GraphQLEnumType, GraphQLDirective, Kind, GraphQLObjectType, getNamedType, getNullableType, GraphQLInterfaceType, GraphQLUnionType, GraphQLInputObjectType, DirectiveLocation, specifiedDirectives, isTypeExtensionNode, GraphQLError, isTypeDefinitionNode, parse as parse$3, Source, buildASTSchema, validateSchema } from 'graphql';
3
+ import { GraphQLNonNull, GraphQLList, GraphQLScalarType, GraphQLEnumType, GraphQLDirective, Kind, GraphQLObjectType, GraphQLInterfaceType, getNamedType, getNullableType, GraphQLUnionType, GraphQLInputObjectType, DirectiveLocation, specifiedDirectives, isTypeExtensionNode, GraphQLError, isTypeDefinitionNode, parse as parse$3, Source, buildASTSchema, validateSchema } from 'graphql';
4
4
  import jen$1, { jen } from 'jennifer-js';
5
5
  import format from 'jennifer-js/format';
6
6
  import partition from 'just-partition';
@@ -456,7 +456,9 @@ class GeneratorContext {
456
456
  let resolveFn;
457
457
  if (!noresolver) {
458
458
  let resolver = this._resolversInfo[type.name]?.[f.name];
459
- if (type instanceof GraphQLObjectType && !resolver) {
459
+ if ((type instanceof GraphQLObjectType ||
460
+ type instanceof GraphQLInterfaceType) &&
461
+ !resolver) {
460
462
  // try to find resolver in interface in the declaration order
461
463
  for (const iface of type.getInterfaces()) {
462
464
  resolver = this._resolversInfo[iface.name]?.[f.name];
@@ -700,11 +702,16 @@ class GeneratorContext {
700
702
  ];
701
703
  }
702
704
  _renderGraphQLInterfaceTypeDefinition(type, { inputFieldDirectives, includeAstNodes }) {
705
+ const typeInterfaces = type.getInterfaces();
703
706
  return jen$1.new
704
707
  .add(this._gql("GraphQLInterfaceType"))
705
708
  .call(jen$1.obj(jen$1.prop("name", jen$1.lit(type.name)), jen$1.prop("fields", this._renderFieldsThunk(type, inputFieldDirectives, includeAstNodes)), ...truthify([
706
709
  type.description &&
707
710
  jen$1.prop("description", jen$1.lit(type.description)),
711
+ typeInterfaces.length &&
712
+ jen$1.prop("interfaces", jen$1.arrow().arr(
713
+ // do not sort interfaces, the declaration order may be important
714
+ ...typeInterfaces.map(this._renderGraphQLTypeIdentifier, this))),
708
715
  includeAstNodes &&
709
716
  type.astNode &&
710
717
  jen$1.prop("astNode", renderAstNode(type.astNode)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql-jerky",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "Jerky is a schema-first static graphql schema lightweight code generator.",
5
5
  "type": "module",
6
6
  "bin": {