@orion-js/graphql 3.3.24 → 3.3.25

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.
@@ -10,10 +10,10 @@ async function default_1(options) {
10
10
  const fields = {};
11
11
  for (const key of Object.keys(subscriptions)) {
12
12
  const subscription = subscriptions[key];
13
- subscription.key = key;
13
+ subscription.name = subscription.name || key;
14
14
  const type = await (0, getType_1.default)(subscription.returns, options);
15
15
  const args = await (0, getArgs_1.default)(subscription.params);
16
- fields[key] = {
16
+ fields[subscription.name] = {
17
17
  type,
18
18
  args,
19
19
  async subscribe(root, params, viewer) {
package/lib/index.d.ts CHANGED
@@ -9,3 +9,4 @@ import * as GraphQL from 'graphql';
9
9
  export { GraphQL, startGraphQL, startGraphiQL, resolversSchemas, ResolverParams, serializeSchema, subscription, getBasicResultQuery };
10
10
  export * from './types';
11
11
  export * from './service';
12
+ export * from './websockerViewer';
package/lib/index.js CHANGED
@@ -44,3 +44,4 @@ const GraphQL = __importStar(require("graphql"));
44
44
  exports.GraphQL = GraphQL;
45
45
  __exportStar(require("./types"), exports);
46
46
  __exportStar(require("./service"), exports);
47
+ __exportStar(require("./websockerViewer"), exports);
@@ -14,7 +14,10 @@ function Subscriptions() {
14
14
  exports.Subscriptions = Subscriptions;
15
15
  function Subscription(options) {
16
16
  return function (object, propertyName, index) {
17
- const sub = (0, __1.subscription)(options);
17
+ const sub = (0, __1.subscription)({
18
+ name: propertyName,
19
+ ...options
20
+ });
18
21
  object.subscriptions = object.subscriptions || {};
19
22
  object.subscriptions[propertyName] = sub;
20
23
  services_1.Container.registerHandler({
@@ -49,6 +49,7 @@ describe('Subscriptions classes', () => {
49
49
  expect(subscriptions.onUserCreated).toBeDefined();
50
50
  const instance = (0, services_1.getInstance)(ExampleSubscriptionsService);
51
51
  expect(instance.onUserCreated.publish).toBeDefined();
52
+ expect(instance.onUserCreated.name).toBe('onUserCreated');
52
53
  // await instance.onUserCreated.publish({name: 'test'}, {name: 'test'})
53
54
  });
54
55
  });
@@ -8,19 +8,19 @@ const getChannelName_1 = __importDefault(require("./getChannelName"));
8
8
  const resolvers_1 = require("@orion-js/resolvers");
9
9
  const createSubscription = function (options) {
10
10
  const subscription = {
11
- key: 'notInitialized'
11
+ name: options.name
12
12
  };
13
13
  // the publish function
14
14
  subscription.publish = async (params, data) => {
15
15
  const pubsub = (0, pubsub_1.getPubsub)();
16
- const channelName = (0, getChannelName_1.default)(subscription.key, params);
17
- await pubsub.publish(channelName, { [subscription.key]: data });
16
+ const channelName = (0, getChannelName_1.default)(subscription.name, params);
17
+ await pubsub.publish(channelName, { [subscription.name]: data });
18
18
  };
19
19
  subscription.subscribe = async (params, viewer) => {
20
20
  const pubsub = (0, pubsub_1.getPubsub)();
21
21
  try {
22
22
  await (0, resolvers_1.checkPermissions)({ params, viewer }, options);
23
- const channelName = (0, getChannelName_1.default)(subscription.key, params);
23
+ const channelName = (0, getChannelName_1.default)(subscription.name, params);
24
24
  return pubsub.asyncIterator(channelName);
25
25
  }
26
26
  catch (error) {
@@ -1,6 +1,6 @@
1
1
  import { ResolverOptions } from '@orion-js/resolvers';
2
2
  export interface OrionSubscription<TParams = any, ReturnType = any> {
3
- key: string;
3
+ name: string;
4
4
  params: object;
5
5
  subscribe: (callParams: object, viewer: object) => {};
6
6
  returns: ReturnType;
@@ -11,4 +11,5 @@ export interface OrionSubscriptionsMap {
11
11
  [key: string]: OrionSubscription;
12
12
  }
13
13
  export interface OrionSubscriptionOptions extends Omit<ResolverOptions, 'resolve'> {
14
+ name?: string;
14
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-js/graphql",
3
- "version": "3.3.24",
3
+ "version": "3.3.25",
4
4
  "main": "lib/index.js",
5
5
  "author": "nicolaslopezj",
6
6
  "license": "MIT",
@@ -14,12 +14,12 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@orion-js/helpers": "^3.3.20",
17
- "@orion-js/http": "^3.3.20",
18
- "@orion-js/models": "^3.3.20",
19
- "@orion-js/resolvers": "^3.3.20",
17
+ "@orion-js/http": "^3.3.25",
18
+ "@orion-js/models": "^3.3.25",
19
+ "@orion-js/resolvers": "^3.3.25",
20
20
  "@orion-js/schema": "^3.3.20",
21
21
  "@orion-js/services": "^3.3.20",
22
- "@orion-js/typed-model": "^3.3.21",
22
+ "@orion-js/typed-model": "^3.3.25",
23
23
  "apollo-server-core": "3.5.0",
24
24
  "graphql-iso-date": "^3.6.1",
25
25
  "graphql-subscriptions": "^2.0.0",
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "feaf1c65091873a8a59d674a681c37bb9607b35b"
48
+ "gitHead": "ed68403cef114f593dd16535db8993560f4f1849"
49
49
  }