graphql-modules 3.0.0 → 3.1.0-alpha-20260116090840-08162811390e78b3ef9ab473ee1def1311c81b6f

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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  <!-- [![modules](https://user-images.githubusercontent.com/25294569/64067074-ed185b80-cc2a-11e9-8f4d-5f1e19feaa0a.gif)](https://graphql-modules.com/) -->
5
5
 
6
6
  [![npm version](https://badge.fury.io/js/graphql-modules.svg)](https://www.npmjs.com/package/graphql-modules)
7
- ![CI](https://github.com/Urigo/graphql-modules/workflows/CI/badge.svg)
7
+ ![CI](https://github.com/graphql-hive/graphql-modules/workflows/CI/badge.svg)
8
8
  [![Discord Chat](https://img.shields.io/discord/625400653321076807)](https://the-guild.dev/discord)
9
9
  [![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg?maxAge=2592000)]()
10
10
 
package/index.js CHANGED
@@ -141,6 +141,7 @@ class InjectionToken {
141
141
  function isType(v) {
142
142
  return typeof v === 'function' && v !== Object;
143
143
  }
144
+ exports.Scope = void 0;
144
145
  (function (Scope) {
145
146
  Scope[Scope["Singleton"] = 0] = "Singleton";
146
147
  Scope[Scope["Operation"] = 1] = "Operation";
@@ -1545,6 +1546,12 @@ function createResolvers(config, metadata, app) {
1545
1546
  });
1546
1547
  resolvers[typeName][fieldName].subscribe = resolver;
1547
1548
  }
1549
+ if (isDefined(obj[fieldName].extensions)) {
1550
+ // Do NOT add a resolve if one is not specified, it will cause
1551
+ // change in behavior in systems like `grafast`
1552
+ resolvers[typeName][fieldName].extensions =
1553
+ obj[fieldName].extensions;
1554
+ }
1548
1555
  }
1549
1556
  }
1550
1557
  }
@@ -1665,6 +1672,14 @@ function addObject({ typeName, fields, container, config, }) {
1665
1672
  writeResolverMetadata(resolver.subscribe, config);
1666
1673
  container[typeName][fieldName].subscribe = resolver.subscribe;
1667
1674
  }
1675
+ // extensions
1676
+ if (isDefined(resolver.extensions)) {
1677
+ if (container[typeName][fieldName].extensions) {
1678
+ throw new ResolverDuplicatedError(`Duplicated resolver of "${typeName}.${fieldName}" (extensions object)`, useLocation({ dirname: config.dirname, id: config.id }));
1679
+ }
1680
+ writeResolverMetadata(resolver.extensions, config);
1681
+ container[typeName][fieldName].extensions = resolver.extensions;
1682
+ }
1668
1683
  }
1669
1684
  }
1670
1685
  }
@@ -1795,7 +1810,9 @@ function isResolveFn(value) {
1795
1810
  return typeof value === 'function';
1796
1811
  }
1797
1812
  function isResolveOptions(value) {
1798
- return isDefined(value.resolve) || isDefined(value.subscribe);
1813
+ return (isDefined(value.resolve) ||
1814
+ isDefined(value.subscribe) ||
1815
+ isDefined(value.extensions));
1799
1816
  }
1800
1817
  function isScalarResolver(obj) {
1801
1818
  return obj instanceof graphql.GraphQLScalarType;
package/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { makeExecutableSchema } from '@graphql-tools/schema';
2
- import { GraphQLSchema, execute as execute$1, subscribe, visit, Kind, GraphQLScalarType, concatAST, defaultFieldResolver, parse } from 'graphql';
2
+ import { GraphQLSchema, execute as execute$1, subscribe, visit, Kind, concatAST, defaultFieldResolver, GraphQLScalarType, parse } from 'graphql';
3
3
  import { wrapSchema } from '@graphql-tools/wrap';
4
4
  import { mergeDeepWith } from 'ramda';
5
5
 
@@ -1542,6 +1542,12 @@ function createResolvers(config, metadata, app) {
1542
1542
  });
1543
1543
  resolvers[typeName][fieldName].subscribe = resolver;
1544
1544
  }
1545
+ if (isDefined(obj[fieldName].extensions)) {
1546
+ // Do NOT add a resolve if one is not specified, it will cause
1547
+ // change in behavior in systems like `grafast`
1548
+ resolvers[typeName][fieldName].extensions =
1549
+ obj[fieldName].extensions;
1550
+ }
1545
1551
  }
1546
1552
  }
1547
1553
  }
@@ -1662,6 +1668,14 @@ function addObject({ typeName, fields, container, config, }) {
1662
1668
  writeResolverMetadata(resolver.subscribe, config);
1663
1669
  container[typeName][fieldName].subscribe = resolver.subscribe;
1664
1670
  }
1671
+ // extensions
1672
+ if (isDefined(resolver.extensions)) {
1673
+ if (container[typeName][fieldName].extensions) {
1674
+ throw new ResolverDuplicatedError(`Duplicated resolver of "${typeName}.${fieldName}" (extensions object)`, useLocation({ dirname: config.dirname, id: config.id }));
1675
+ }
1676
+ writeResolverMetadata(resolver.extensions, config);
1677
+ container[typeName][fieldName].extensions = resolver.extensions;
1678
+ }
1665
1679
  }
1666
1680
  }
1667
1681
  }
@@ -1792,7 +1806,9 @@ function isResolveFn(value) {
1792
1806
  return typeof value === 'function';
1793
1807
  }
1794
1808
  function isResolveOptions(value) {
1795
- return isDefined(value.resolve) || isDefined(value.subscribe);
1809
+ return (isDefined(value.resolve) ||
1810
+ isDefined(value.subscribe) ||
1811
+ isDefined(value.extensions));
1796
1812
  }
1797
1813
  function isScalarResolver(obj) {
1798
1814
  return obj instanceof GraphQLScalarType;
@@ -1,3 +1,4 @@
1
+ import { GraphQLFieldExtensions } from 'graphql';
1
2
  import { ModuleConfig } from './types';
2
3
  import { ModuleMetadata } from './metadata';
3
4
  import { ResolveFn, ID } from './../shared/types';
@@ -8,5 +9,5 @@ interface ResolverMetadata {
8
9
  export declare function createResolvers(config: ModuleConfig, metadata: ModuleMetadata, app: {
9
10
  middlewareMap: MiddlewareMap;
10
11
  }): Record<string, any>;
11
- export declare function readResolverMetadata(resolver: ResolveFn): ResolverMetadata;
12
+ export declare function readResolverMetadata(resolver: ResolveFn | GraphQLFieldExtensions<any, any, any>): ResolverMetadata;
12
13
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphql-modules",
3
- "version": "3.0.0",
3
+ "version": "3.1.0-alpha-20260116090840-08162811390e78b3ef9ab473ee1def1311c81b6f",
4
4
  "description": "Create reusable, maintainable, testable and extendable GraphQL modules",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {