@axinom/mosaic-db-common 0.31.0 → 0.32.0-rc.0

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.
@@ -16,15 +16,16 @@ END$$;
16
16
  /*-snippet
17
17
  {
18
18
  "body": [
19
- "SELECT ax_define.define_subscription_triggers('id', '${1:table_name}', '${3:app_public}', '${1:table_name}', '${2:SingularTableNameInPascalCase}');",
19
+ "SELECT ax_define.define_subscription_triggers('id', '${1:table_name}', '${3:app_public}', '${1:table_name}', '${2:SINGULAR_TABLE_NAME_IN_SCREAMING_SNAKE_CASE}');",
20
20
  "-- TODO: To enable subscriptions:",
21
21
  "-- - Use `setupHttpServerWithWebsockets` with `setupManagementGQLSubscriptionAuthentication` as 3rd parameter to enable authentication.",
22
- "-- - Create the plugin via SubscriptionsPluginFactory('${1:table_name}', '${2:SingularTableNameInPascalCase}', '${4|UUID,Int|}')",
22
+ "-- - Create the plugin via SubscriptionsPluginFactory('${1:table_name}', '${5:SingularTableNameInPascalCase}', '${4|UUID,Int|}')",
23
23
  "-- - Use `enableSubscriptions` on the `PostgraphileOptionsBuilder`.",
24
24
  "-- - Enhance your HTTP server with websocket support with `enhanceHttpServerWithSubscriptions`."
25
25
  ],
26
26
  "description": [
27
27
  "Defines PostgreSQL triggers for the specified table to enable GraphQL subscriptions functionality.\n",
28
+ "Adds a comment to the main or relation table with a comma-separated list of possible events that is used by SubscriptionsPluginFactory.\n",
28
29
  "3rd parameter of SubscriptionsPluginFactory must be either 'Int' or `UUID' depending on the type of 'id' column."
29
30
  ]
30
31
  }
@@ -32,18 +33,24 @@ snippet-*/
32
33
  CREATE OR REPLACE FUNCTION ax_define.define_subscription_triggers(idColumn text, tableName text, schemaName text, mainTableName text, eventType text) RETURNS void
33
34
  LANGUAGE plpgsql
34
35
  AS $$
36
+ DECLARE
37
+ createEvent text = eventType || '_CREATED';
38
+ changeEvent text = eventType || '_CHANGED';
39
+ deleteEvent text = eventType || '_DELETED';
35
40
  BEGIN
41
+ EXECUTE 'COMMENT ON TABLE ' || schemaName || '.' || tableName || ' IS E''@subscription_events_' || mainTableName || ' ' || createEvent || ',' || changeEvent || ',' || deleteEvent || ''';';
42
+
36
43
  EXECUTE 'DROP TRIGGER IF EXISTS _500_gql_' || tableName || '_inserted ON ' || schemaName || '.' || tableName;
37
44
  EXECUTE 'CREATE TRIGGER _500_gql_' || tableName || '_inserted after insert on ' || schemaName || '.' || tableName || ' ' ||
38
- 'for each row execute procedure ax_utils.tg__graphql_subscription(''' || eventType || 'Created'',''graphql:' || mainTableName || ''',''' || idColumn || ''');';
45
+ 'for each row execute procedure ax_utils.tg__graphql_subscription(''' || createEvent || ''',''graphql:' || mainTableName || ''',''' || idColumn || ''');';
39
46
 
40
47
  EXECUTE 'DROP TRIGGER IF EXISTS _500_gql_' || tableName || '_updated ON ' || schemaName || '.' || tableName;
41
48
  EXECUTE 'CREATE TRIGGER _500_gql_' || tableName || '_updated after update on ' || schemaName || '.' || tableName || ' ' ||
42
- 'for each row execute procedure ax_utils.tg__graphql_subscription(''' || eventType || 'Changed'',''graphql:' || mainTableName || ''',''' || idColumn || ''');';
49
+ 'for each row execute procedure ax_utils.tg__graphql_subscription(''' || changeEvent || ''',''graphql:' || mainTableName || ''',''' || idColumn || ''');';
43
50
 
44
51
  EXECUTE 'DROP TRIGGER IF EXISTS _500_gql_' || tableName || '_deleted ON ' || schemaName || '.' || tableName;
45
52
  EXECUTE 'CREATE TRIGGER _500_gql_' || tableName || '_deleted before delete on ' || schemaName || '.' || tableName || ' ' ||
46
- 'for each row execute procedure ax_utils.tg__graphql_subscription(''' || eventType || 'Deleted'',''graphql:' || mainTableName || ''',''' || idColumn || ''');';
53
+ 'for each row execute procedure ax_utils.tg__graphql_subscription(''' || deleteEvent || ''',''graphql:' || mainTableName || ''',''' || idColumn || ''');';
47
54
  END;
48
55
  $$;
49
56
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axinom/mosaic-db-common",
3
- "version": "0.31.0",
3
+ "version": "0.32.0-rc.0",
4
4
  "description": "This library encapsulates database-related functionality to develop Mosaic based services.",
5
5
  "author": "Axinom",
6
6
  "license": "PROPRIETARY",
@@ -52,5 +52,5 @@
52
52
  "publishConfig": {
53
53
  "access": "public"
54
54
  },
55
- "gitHead": "e583a1076964626d1d0b1f9fb507d1defc307102"
55
+ "gitHead": "9f5b9eb779b45196d00fcd44cc2e0d484207121b"
56
56
  }