@rxdi/neo4j 0.7.154 → 0.7.156

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/dist/index.js CHANGED
@@ -31,6 +31,7 @@ const core_1 = require("@rxdi/core");
31
31
  const injection_tokens_1 = require("./injection.tokens");
32
32
  const graphql_1 = require("@rxdi/graphql");
33
33
  const neo4j_service_1 = require("./neo4j.service");
34
+ const ogm_provider_1 = require("./ogm.provider");
34
35
  let Neo4JModule = Neo4JModule_1 = class Neo4JModule {
35
36
  static forRoot(config = {}) {
36
37
  return {
@@ -59,14 +60,14 @@ let Neo4JModule = Neo4JModule_1 = class Neo4JModule {
59
60
  deps: [neo4j_service_1.UtilService, injection_tokens_1.NEO4J_DRIVER],
60
61
  useFactory: (util, driver) => (schema) => __awaiter(this, void 0, void 0, function* () { return util.augmentSchema(schema)(driver); })
61
62
  }
62
- ])
63
+ ]),
63
64
  ]
64
65
  };
65
66
  }
66
67
  };
67
68
  Neo4JModule = Neo4JModule_1 = __decorate([
68
69
  (0, core_1.Module)({
69
- providers: [neo4j_service_1.UtilService]
70
+ providers: [neo4j_service_1.UtilService, ogm_provider_1.OGMProvider]
70
71
  })
71
72
  ], Neo4JModule);
72
73
  exports.Neo4JModule = Neo4JModule;
@@ -7,6 +7,7 @@ export interface NEO4J_MODULE_CONFIG {
7
7
  password?: string;
8
8
  address?: string | 'bolt://localhost:7687';
9
9
  schemaOverride?(schema: GraphQLSchema): GraphQLSchema;
10
+ schema?: Promise<string>;
10
11
  }
11
12
  export interface RelationshipType {
12
13
  searchIndex?: string;
@@ -1,13 +1,16 @@
1
1
  import { NEO4J_DRIVER, NEO4J_MODULE_CONFIG } from './injection.tokens';
2
2
  import * as neo4j from 'neo4j-driver';
3
3
  import { GraphQLSchema } from 'graphql';
4
+ import { OGMProvider } from './ogm.provider';
4
5
  export declare class UtilService {
5
6
  private config;
6
- constructor(config: NEO4J_MODULE_CONFIG);
7
+ private ogmProvider;
8
+ constructor(config: NEO4J_MODULE_CONFIG, ogmProvider: OGMProvider);
7
9
  private extendSchemaDirectives;
8
10
  private validateSchema;
9
11
  private replaceAll;
10
12
  augmentSchema(schema: GraphQLSchema): (driver: NEO4J_DRIVER) => Promise<GraphQLSchema>;
13
+ initOgmClient(typeDefs: string): (driver: NEO4J_DRIVER) => Promise<void>;
11
14
  mergeSchemas(...schemas: GraphQLSchema[]): GraphQLSchema;
12
15
  createDriver(): neo4j.Driver;
13
16
  generateTypeDefs(schema: GraphQLSchema): string;
@@ -28,9 +28,12 @@ const graphql_tools_1 = require("graphql-tools");
28
28
  const neo4j = require("neo4j-driver");
29
29
  const graphql_1 = require("@neo4j/graphql");
30
30
  const graphql_2 = require("graphql");
31
+ const ogm_provider_1 = require("./ogm.provider");
32
+ const graphql_ogm_1 = require("@neo4j/graphql-ogm");
31
33
  let UtilService = class UtilService {
32
- constructor(config) {
34
+ constructor(config, ogmProvider) {
33
35
  this.config = config;
36
+ this.ogmProvider = ogmProvider;
34
37
  }
35
38
  extendSchemaDirectives(augmentedSchema, schema) {
36
39
  augmentedSchema['_directives'] = schema['_directives'];
@@ -48,14 +51,29 @@ let UtilService = class UtilService {
48
51
  augmentSchema(schema) {
49
52
  return (driver) => __awaiter(this, void 0, void 0, function* () {
50
53
  this.validateSchema(schema);
54
+ const typedSchema = yield this.config.schema;
51
55
  const typeDefs = this.generateTypeDefs(schema);
52
56
  const neoSchema = new graphql_1.Neo4jGraphQL({
53
- typeDefs,
57
+ typeDefs: `${typeDefs} ${typedSchema !== null && typedSchema !== void 0 ? typedSchema : ''}`,
54
58
  driver,
55
59
  assumeValidSDL: true,
56
60
  });
57
61
  const augmentedSchema = yield neoSchema.getSchema();
58
- return this.extendSchemaDirectives(augmentedSchema, schema);
62
+ const newSchema = this.extendSchemaDirectives(augmentedSchema, schema);
63
+ yield this.initOgmClient(typeDefs)(driver);
64
+ return newSchema;
65
+ });
66
+ }
67
+ initOgmClient(typeDefs) {
68
+ return (driver) => __awaiter(this, void 0, void 0, function* () {
69
+ const ogm = new graphql_ogm_1.OGM({
70
+ assumeValidSDL: true,
71
+ assumeValid: true,
72
+ typeDefs,
73
+ driver
74
+ });
75
+ yield ogm.init();
76
+ this.ogmProvider.client = ogm;
59
77
  });
60
78
  }
61
79
  mergeSchemas(...schemas) {
@@ -110,6 +128,6 @@ let UtilService = class UtilService {
110
128
  UtilService = __decorate([
111
129
  (0, core_1.Injectable)(),
112
130
  __param(0, (0, core_1.Inject)(injection_tokens_1.NEO4J_MODULE_CONFIG)),
113
- __metadata("design:paramtypes", [Object])
131
+ __metadata("design:paramtypes", [Object, ogm_provider_1.OGMProvider])
114
132
  ], UtilService);
115
133
  exports.UtilService = UtilService;
@@ -0,0 +1,4 @@
1
+ import { OGM } from '@neo4j/graphql-ogm';
2
+ export declare class OGMProvider<T = OGM> {
3
+ client: OGM<T>;
4
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.OGMProvider = void 0;
10
+ const core_1 = require("@gapi/core");
11
+ let OGMProvider = class OGMProvider {
12
+ };
13
+ OGMProvider = __decorate([
14
+ (0, core_1.Injectable)()
15
+ ], OGMProvider);
16
+ exports.OGMProvider = OGMProvider;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxdi/neo4j",
3
- "version": "0.7.154",
3
+ "version": "0.7.156",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -26,15 +26,16 @@
26
26
  },
27
27
  "homepage": "https://github.com/rxdi/neo4j/blob/master/README.md",
28
28
  "dependencies": {
29
- "@neo4j/graphql": "^3.8.0",
29
+ "@neo4j/graphql": "^3.9.0",
30
+ "@neo4j/graphql-ogm": "^3.9.0",
30
31
  "neo4j-driver": "^5.0.1"
31
32
  },
32
33
  "devDependencies": {
33
34
  "graphql": "^14.5.8",
34
35
  "@types/graphql": "^14.5.0",
35
36
  "graphql-tools": "^5.0.0",
36
- "@rxdi/core": "^0.7.153",
37
- "@rxdi/graphql": "^0.7.153",
37
+ "@rxdi/core": "^0.7.155",
38
+ "@rxdi/graphql": "^0.7.155",
38
39
  "@types/hapi": "^18.0.4",
39
40
  "@types/jest": "^24.0.22",
40
41
  "@types/node": "^12.0.10",