@rxdi/neo4j 0.7.154 → 0.7.155

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 {
@@ -66,7 +67,7 @@ let Neo4JModule = Neo4JModule_1 = class Neo4JModule {
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;
@@ -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'];
@@ -49,13 +52,27 @@ let UtilService = class UtilService {
49
52
  return (driver) => __awaiter(this, void 0, void 0, function* () {
50
53
  this.validateSchema(schema);
51
54
  const typeDefs = this.generateTypeDefs(schema);
55
+ yield this.initOgmClient(typeDefs)(driver);
52
56
  const neoSchema = new graphql_1.Neo4jGraphQL({
53
57
  typeDefs,
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
+ return newSchema;
64
+ });
65
+ }
66
+ initOgmClient(typeDefs) {
67
+ return (driver) => __awaiter(this, void 0, void 0, function* () {
68
+ const ogm = new graphql_ogm_1.OGM({
69
+ assumeValidSDL: true,
70
+ assumeValid: true,
71
+ typeDefs,
72
+ driver
73
+ });
74
+ yield ogm.init();
75
+ this.ogmProvider.client = ogm;
59
76
  });
60
77
  }
61
78
  mergeSchemas(...schemas) {
@@ -110,6 +127,6 @@ let UtilService = class UtilService {
110
127
  UtilService = __decorate([
111
128
  (0, core_1.Injectable)(),
112
129
  __param(0, (0, core_1.Inject)(injection_tokens_1.NEO4J_MODULE_CONFIG)),
113
- __metadata("design:paramtypes", [Object])
130
+ __metadata("design:paramtypes", [Object, ogm_provider_1.OGMProvider])
114
131
  ], UtilService);
115
132
  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,72 +1,73 @@
1
1
  {
2
- "name": "@rxdi/neo4j",
3
- "version": "0.7.154",
4
- "description": "",
5
- "main": "./dist/index.js",
6
- "types": "./dist/index.d.ts",
7
- "module": "./dist/index.js",
8
- "typings": "./dist/index.d.ts",
9
- "files": [
10
- "dist"
2
+ "name": "@rxdi/neo4j",
3
+ "version": "0.7.155",
4
+ "description": "",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "module": "./dist/index.js",
8
+ "typings": "./dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "scripts": {
13
+ "lint": "tslint -c tslint.json 'src/**/*.{ts,tsx}'",
14
+ "pretest": "npm run lint",
15
+ "test": "echo Test Neo4J",
16
+ "build": "tsc || true"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/rxdi/neo4j"
21
+ },
22
+ "author": "Kristiyan Tachev (@Stradivario)",
23
+ "license": "MIT",
24
+ "bugs": {
25
+ "url": "https://github.com/rxdi/neo4j/issues"
26
+ },
27
+ "homepage": "https://github.com/rxdi/neo4j/blob/master/README.md",
28
+ "dependencies": {
29
+ "@neo4j/graphql": "^3.9.0",
30
+ "@neo4j/graphql-ogm": "^3.9.0",
31
+ "neo4j-driver": "^5.0.1"
32
+ },
33
+ "devDependencies": {
34
+ "graphql": "^14.5.8",
35
+ "@types/graphql": "^14.5.0",
36
+ "graphql-tools": "^5.0.0",
37
+ "@rxdi/core": "^0.7.153",
38
+ "@rxdi/graphql": "^0.7.153",
39
+ "@types/hapi": "^18.0.4",
40
+ "@types/jest": "^24.0.22",
41
+ "@types/node": "^12.0.10",
42
+ "jest": "^24.8.0",
43
+ "jest-cli": "^24.8.1",
44
+ "ts-jest": "^24.0.2",
45
+ "tslint": "^5.20.1",
46
+ "tslint-language-service": "^0.9.9",
47
+ "typescript": "^4.3.5"
48
+ },
49
+ "jest": {
50
+ "testEnvironment": "node",
51
+ "testPathIgnorePatterns": [
52
+ "/node_modules/"
11
53
  ],
12
- "scripts": {
13
- "lint": "tslint -c tslint.json 'src/**/*.{ts,tsx}'",
14
- "pretest": "npm run lint",
15
- "test": "echo Test Neo4J",
16
- "build": "tsc || true"
17
- },
18
- "repository": {
19
- "type": "git",
20
- "url": "https://github.com/rxdi/neo4j"
21
- },
22
- "author": "Kristiyan Tachev (@Stradivario)",
23
- "license": "MIT",
24
- "bugs": {
25
- "url": "https://github.com/rxdi/neo4j/issues"
26
- },
27
- "homepage": "https://github.com/rxdi/neo4j/blob/master/README.md",
28
- "dependencies": {
29
- "@neo4j/graphql": "^3.8.0",
30
- "neo4j-driver": "^5.0.1"
31
- },
32
- "devDependencies": {
33
- "graphql": "^14.5.8",
34
- "@types/graphql": "^14.5.0",
35
- "graphql-tools": "^5.0.0",
36
- "@rxdi/core": "^0.7.153",
37
- "@rxdi/graphql": "^0.7.153",
38
- "@types/hapi": "^18.0.4",
39
- "@types/jest": "^24.0.22",
40
- "@types/node": "^12.0.10",
41
- "jest": "^24.8.0",
42
- "jest-cli": "^24.8.1",
43
- "ts-jest": "^24.0.2",
44
- "tslint": "^5.20.1",
45
- "tslint-language-service": "^0.9.9",
46
- "typescript": "^4.3.5"
54
+ "coverageReporters": [
55
+ "lcov",
56
+ "html"
57
+ ],
58
+ "rootDir": "./",
59
+ "moduleFileExtensions": [
60
+ "ts",
61
+ "tsx",
62
+ "js",
63
+ "json",
64
+ "node"
65
+ ],
66
+ "transform": {
67
+ "\\.(ts|tsx)$": "ts-jest"
47
68
  },
48
- "jest": {
49
- "testEnvironment": "node",
50
- "testPathIgnorePatterns": [
51
- "/node_modules/"
52
- ],
53
- "coverageReporters": [
54
- "lcov",
55
- "html"
56
- ],
57
- "rootDir": "./",
58
- "moduleFileExtensions": [
59
- "ts",
60
- "tsx",
61
- "js",
62
- "json",
63
- "node"
64
- ],
65
- "transform": {
66
- "\\.(ts|tsx)$": "ts-jest"
67
- },
68
- "testRegex": "/src/.*\\.spec.(ts|tsx|js)$",
69
- "verbose": true,
70
- "collectCoverage": true
71
- }
69
+ "testRegex": "/src/.*\\.spec.(ts|tsx|js)$",
70
+ "verbose": true,
71
+ "collectCoverage": true
72
+ }
72
73
  }