@graphql-mesh/neo4j 1.0.0-alpha-3fc47d119.0 → 1.0.0-alpha-20230420181317-a95037648
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/{index.js → cjs/index.js} +43 -23
- package/cjs/package.json +1 -0
- package/{index.mjs → esm/index.js} +35 -15
- package/package.json +29 -21
- package/typings/index.d.cts +14 -0
- package/typings/index.d.ts +14 -0
- package/index.d.ts +0 -16
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const graphql_scalars_1 = require("graphql-scalars");
|
|
5
|
+
const neo4j_driver_1 = tslib_1.__importDefault(require("neo4j-driver"));
|
|
6
|
+
const cross_helpers_1 = require("@graphql-mesh/cross-helpers");
|
|
7
|
+
const store_1 = require("@graphql-mesh/store");
|
|
8
|
+
const utils_1 = require("@graphql-mesh/utils");
|
|
9
|
+
const graphql_1 = require("@neo4j/graphql");
|
|
10
|
+
const introspector_1 = require("@neo4j/introspector");
|
|
12
11
|
function getEventEmitterFromPubSub(pubsub) {
|
|
13
12
|
return {
|
|
14
13
|
on(event, listener) {
|
|
@@ -29,22 +28,24 @@ function getEventEmitterFromPubSub(pubsub) {
|
|
|
29
28
|
addListener(event, listener) {
|
|
30
29
|
return this.on(event, listener);
|
|
31
30
|
},
|
|
31
|
+
setMaxListeners() {
|
|
32
|
+
return this;
|
|
33
|
+
},
|
|
32
34
|
};
|
|
33
35
|
}
|
|
34
36
|
class Neo4JHandler {
|
|
35
|
-
constructor({ config, baseDir, pubsub, store
|
|
37
|
+
constructor({ config, baseDir, pubsub, store, logger, importFn, }) {
|
|
36
38
|
this.config = config;
|
|
37
39
|
this.baseDir = baseDir;
|
|
38
40
|
this.pubsub = pubsub;
|
|
39
|
-
this.typeDefs = store
|
|
41
|
+
this.typeDefs = store.proxy('typeDefs', store_1.PredefinedProxyOptions.StringWithoutValidation);
|
|
40
42
|
this.logger = logger;
|
|
41
|
-
this.fetchFn = fetchFn;
|
|
42
43
|
this.importFn = importFn;
|
|
43
44
|
}
|
|
44
45
|
getCachedTypeDefs(driver) {
|
|
45
46
|
return this.typeDefs.getWithSet(async () => {
|
|
46
|
-
if (this.config.
|
|
47
|
-
return
|
|
47
|
+
if (this.config.source) {
|
|
48
|
+
return (0, utils_1.readFileOrUrl)(this.config.source, {
|
|
48
49
|
cwd: this.baseDir,
|
|
49
50
|
allowUnknownExtensions: true,
|
|
50
51
|
importFn: this.importFn,
|
|
@@ -54,12 +55,29 @@ class Neo4JHandler {
|
|
|
54
55
|
}
|
|
55
56
|
else {
|
|
56
57
|
this.logger.info('Inferring the schema from the database: ', `"${this.config.database || 'neo4j'}"`);
|
|
57
|
-
|
|
58
|
+
let replaceAllPolyfilled = false;
|
|
59
|
+
if (!String.prototype.replaceAll) {
|
|
60
|
+
replaceAllPolyfilled = true;
|
|
61
|
+
// eslint-disable-next-line no-extend-native
|
|
62
|
+
String.prototype.replaceAll = function (str, newStr) {
|
|
63
|
+
if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') {
|
|
64
|
+
return this.replace(str, newStr);
|
|
65
|
+
}
|
|
66
|
+
return this.replace(new RegExp(str, 'g'), newStr);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const typeDefs = await (0, introspector_1.toGraphQLTypeDefs)(() => driver.session({ database: this.config.database, defaultAccessMode: neo4j_driver_1.default.session.READ }));
|
|
70
|
+
if (replaceAllPolyfilled) {
|
|
71
|
+
// eslint-disable-next-line no-extend-native
|
|
72
|
+
delete String.prototype.replaceAll;
|
|
73
|
+
}
|
|
74
|
+
return typeDefs;
|
|
58
75
|
}
|
|
59
76
|
});
|
|
60
77
|
}
|
|
61
|
-
async getMeshSource() {
|
|
62
|
-
|
|
78
|
+
async getMeshSource({ fetchFn }) {
|
|
79
|
+
this.fetchFn = fetchFn;
|
|
80
|
+
const driver = neo4j_driver_1.default.driver(this.config.endpoint, neo4j_driver_1.default.auth.basic(this.config.username, this.config.password), {
|
|
63
81
|
useBigInt: true,
|
|
64
82
|
logging: {
|
|
65
83
|
logger: (level, message) => this.logger[level](message),
|
|
@@ -73,15 +91,18 @@ class Neo4JHandler {
|
|
|
73
91
|
});
|
|
74
92
|
const typeDefs = await this.getCachedTypeDefs(driver);
|
|
75
93
|
const events = getEventEmitterFromPubSub(this.pubsub);
|
|
76
|
-
const neo4jGraphQL = new
|
|
94
|
+
const neo4jGraphQL = new graphql_1.Neo4jGraphQL({
|
|
77
95
|
typeDefs,
|
|
78
96
|
config: {
|
|
79
97
|
driverConfig: {
|
|
80
98
|
database: this.config.database,
|
|
81
99
|
},
|
|
82
|
-
enableDebug: !!
|
|
100
|
+
enableDebug: !!cross_helpers_1.process.env.DEBUG,
|
|
83
101
|
skipValidateTypeDefs: true,
|
|
84
102
|
},
|
|
103
|
+
resolvers: {
|
|
104
|
+
BigInt: graphql_scalars_1.GraphQLBigInt,
|
|
105
|
+
},
|
|
85
106
|
plugins: {
|
|
86
107
|
subscriptions: {
|
|
87
108
|
events,
|
|
@@ -95,5 +116,4 @@ class Neo4JHandler {
|
|
|
95
116
|
};
|
|
96
117
|
}
|
|
97
118
|
}
|
|
98
|
-
|
|
99
|
-
module.exports = Neo4JHandler;
|
|
119
|
+
exports.default = Neo4JHandler;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Neo4jGraphQL } from '@neo4j/graphql';
|
|
1
|
+
import { GraphQLBigInt } from 'graphql-scalars';
|
|
3
2
|
import neo4j from 'neo4j-driver';
|
|
3
|
+
import { process } from '@graphql-mesh/cross-helpers';
|
|
4
4
|
import { PredefinedProxyOptions } from '@graphql-mesh/store';
|
|
5
5
|
import { readFileOrUrl } from '@graphql-mesh/utils';
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import { Neo4jGraphQL } from '@neo4j/graphql';
|
|
7
|
+
import { toGraphQLTypeDefs } from '@neo4j/introspector';
|
|
8
8
|
function getEventEmitterFromPubSub(pubsub) {
|
|
9
9
|
return {
|
|
10
10
|
on(event, listener) {
|
|
@@ -25,22 +25,24 @@ function getEventEmitterFromPubSub(pubsub) {
|
|
|
25
25
|
addListener(event, listener) {
|
|
26
26
|
return this.on(event, listener);
|
|
27
27
|
},
|
|
28
|
+
setMaxListeners() {
|
|
29
|
+
return this;
|
|
30
|
+
},
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
|
-
class Neo4JHandler {
|
|
31
|
-
constructor({ config, baseDir, pubsub, store, logger,
|
|
33
|
+
export default class Neo4JHandler {
|
|
34
|
+
constructor({ config, baseDir, pubsub, store, logger, importFn, }) {
|
|
32
35
|
this.config = config;
|
|
33
36
|
this.baseDir = baseDir;
|
|
34
37
|
this.pubsub = pubsub;
|
|
35
|
-
this.typeDefs = store.proxy('typeDefs
|
|
38
|
+
this.typeDefs = store.proxy('typeDefs', PredefinedProxyOptions.StringWithoutValidation);
|
|
36
39
|
this.logger = logger;
|
|
37
|
-
this.fetchFn = fetchFn;
|
|
38
40
|
this.importFn = importFn;
|
|
39
41
|
}
|
|
40
42
|
getCachedTypeDefs(driver) {
|
|
41
43
|
return this.typeDefs.getWithSet(async () => {
|
|
42
|
-
if (this.config.
|
|
43
|
-
return readFileOrUrl(this.config.
|
|
44
|
+
if (this.config.source) {
|
|
45
|
+
return readFileOrUrl(this.config.source, {
|
|
44
46
|
cwd: this.baseDir,
|
|
45
47
|
allowUnknownExtensions: true,
|
|
46
48
|
importFn: this.importFn,
|
|
@@ -50,12 +52,29 @@ class Neo4JHandler {
|
|
|
50
52
|
}
|
|
51
53
|
else {
|
|
52
54
|
this.logger.info('Inferring the schema from the database: ', `"${this.config.database || 'neo4j'}"`);
|
|
53
|
-
|
|
55
|
+
let replaceAllPolyfilled = false;
|
|
56
|
+
if (!String.prototype.replaceAll) {
|
|
57
|
+
replaceAllPolyfilled = true;
|
|
58
|
+
// eslint-disable-next-line no-extend-native
|
|
59
|
+
String.prototype.replaceAll = function (str, newStr) {
|
|
60
|
+
if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') {
|
|
61
|
+
return this.replace(str, newStr);
|
|
62
|
+
}
|
|
63
|
+
return this.replace(new RegExp(str, 'g'), newStr);
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const typeDefs = await toGraphQLTypeDefs(() => driver.session({ database: this.config.database, defaultAccessMode: neo4j.session.READ }));
|
|
67
|
+
if (replaceAllPolyfilled) {
|
|
68
|
+
// eslint-disable-next-line no-extend-native
|
|
69
|
+
delete String.prototype.replaceAll;
|
|
70
|
+
}
|
|
71
|
+
return typeDefs;
|
|
54
72
|
}
|
|
55
73
|
});
|
|
56
74
|
}
|
|
57
|
-
async getMeshSource() {
|
|
58
|
-
|
|
75
|
+
async getMeshSource({ fetchFn }) {
|
|
76
|
+
this.fetchFn = fetchFn;
|
|
77
|
+
const driver = neo4j.driver(this.config.endpoint, neo4j.auth.basic(this.config.username, this.config.password), {
|
|
59
78
|
useBigInt: true,
|
|
60
79
|
logging: {
|
|
61
80
|
logger: (level, message) => this.logger[level](message),
|
|
@@ -78,6 +97,9 @@ class Neo4JHandler {
|
|
|
78
97
|
enableDebug: !!process.env.DEBUG,
|
|
79
98
|
skipValidateTypeDefs: true,
|
|
80
99
|
},
|
|
100
|
+
resolvers: {
|
|
101
|
+
BigInt: GraphQLBigInt,
|
|
102
|
+
},
|
|
81
103
|
plugins: {
|
|
82
104
|
subscriptions: {
|
|
83
105
|
events,
|
|
@@ -91,5 +113,3 @@ class Neo4JHandler {
|
|
|
91
113
|
};
|
|
92
114
|
}
|
|
93
115
|
}
|
|
94
|
-
|
|
95
|
-
export default Neo4JHandler;
|
package/package.json
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/neo4j",
|
|
3
|
-
"version": "1.0.0-alpha-
|
|
3
|
+
"version": "1.0.0-alpha-20230420181317-a95037648",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@graphql-mesh/
|
|
7
|
-
"@graphql-mesh/
|
|
8
|
-
"graphql": "
|
|
6
|
+
"@graphql-mesh/cross-helpers": "^0.3.4",
|
|
7
|
+
"@graphql-mesh/store": "1.0.0-alpha-20230420181317-a95037648",
|
|
8
|
+
"@graphql-mesh/types": "1.0.0-alpha-20230420181317-a95037648",
|
|
9
|
+
"@graphql-mesh/utils": "1.0.0-alpha-20230420181317-a95037648",
|
|
10
|
+
"@graphql-tools/utils": "^9.2.1",
|
|
11
|
+
"graphql": "*",
|
|
12
|
+
"tslib": "^2.4.0"
|
|
9
13
|
},
|
|
10
14
|
"dependencies": {
|
|
11
|
-
"@graphql
|
|
12
|
-
"@graphql-mesh/store": "1.0.0-alpha-3fc47d119.0",
|
|
13
|
-
"@graphql-tools/utils": "8.8.0",
|
|
14
|
-
"@neo4j/graphql": "3.6.0",
|
|
15
|
+
"@neo4j/graphql": "3.18.1",
|
|
15
16
|
"@neo4j/introspector": "^1.0.1",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
17
|
+
"graphql-scalars": "^1.20.4",
|
|
18
|
+
"neo4j-driver": "5.7.0"
|
|
18
19
|
},
|
|
19
20
|
"repository": {
|
|
20
21
|
"type": "git",
|
|
@@ -22,21 +23,28 @@
|
|
|
22
23
|
"directory": "packages/handlers/neo4j"
|
|
23
24
|
},
|
|
24
25
|
"license": "MIT",
|
|
25
|
-
"main": "index.js",
|
|
26
|
-
"module": "index.
|
|
27
|
-
"typings": "index.d.ts",
|
|
26
|
+
"main": "cjs/index.js",
|
|
27
|
+
"module": "esm/index.js",
|
|
28
|
+
"typings": "typings/index.d.ts",
|
|
28
29
|
"typescript": {
|
|
29
|
-
"definition": "index.d.ts"
|
|
30
|
+
"definition": "typings/index.d.ts"
|
|
30
31
|
},
|
|
32
|
+
"type": "module",
|
|
31
33
|
"exports": {
|
|
32
34
|
".": {
|
|
33
|
-
"require":
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
35
|
+
"require": {
|
|
36
|
+
"types": "./typings/index.d.cts",
|
|
37
|
+
"default": "./cjs/index.js"
|
|
38
|
+
},
|
|
39
|
+
"import": {
|
|
40
|
+
"types": "./typings/index.d.ts",
|
|
41
|
+
"default": "./esm/index.js"
|
|
42
|
+
},
|
|
43
|
+
"default": {
|
|
44
|
+
"types": "./typings/index.d.ts",
|
|
45
|
+
"default": "./esm/index.js"
|
|
46
|
+
}
|
|
39
47
|
},
|
|
40
48
|
"./package.json": "./package.json"
|
|
41
49
|
}
|
|
42
|
-
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Driver } from 'neo4j-driver';
|
|
2
|
+
import { GetMeshSourcePayload, ImportFn, MeshFetch, MeshHandler, MeshHandlerOptions, MeshSource, YamlConfig } from '@graphql-mesh/types';
|
|
3
|
+
export default class Neo4JHandler implements MeshHandler {
|
|
4
|
+
private config;
|
|
5
|
+
private baseDir;
|
|
6
|
+
private pubsub;
|
|
7
|
+
private typeDefs;
|
|
8
|
+
private logger;
|
|
9
|
+
fetchFn: MeshFetch;
|
|
10
|
+
importFn: ImportFn;
|
|
11
|
+
constructor({ config, baseDir, pubsub, store, logger, importFn, }: MeshHandlerOptions<YamlConfig.Neo4JHandler>);
|
|
12
|
+
getCachedTypeDefs(driver: Driver): Promise<string>;
|
|
13
|
+
getMeshSource({ fetchFn }: GetMeshSourcePayload): Promise<MeshSource>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Driver } from 'neo4j-driver';
|
|
2
|
+
import { GetMeshSourcePayload, ImportFn, MeshFetch, MeshHandler, MeshHandlerOptions, MeshSource, YamlConfig } from '@graphql-mesh/types';
|
|
3
|
+
export default class Neo4JHandler implements MeshHandler {
|
|
4
|
+
private config;
|
|
5
|
+
private baseDir;
|
|
6
|
+
private pubsub;
|
|
7
|
+
private typeDefs;
|
|
8
|
+
private logger;
|
|
9
|
+
fetchFn: MeshFetch;
|
|
10
|
+
importFn: ImportFn;
|
|
11
|
+
constructor({ config, baseDir, pubsub, store, logger, importFn, }: MeshHandlerOptions<YamlConfig.Neo4JHandler>);
|
|
12
|
+
getCachedTypeDefs(driver: Driver): Promise<string>;
|
|
13
|
+
getMeshSource({ fetchFn }: GetMeshSourcePayload): Promise<MeshSource>;
|
|
14
|
+
}
|
package/index.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Driver } from 'neo4j-driver';
|
|
2
|
-
import { YamlConfig, MeshHandler, GetMeshSourceOptions, ImportFn } from '@graphql-mesh/types';
|
|
3
|
-
export default class Neo4JHandler implements MeshHandler {
|
|
4
|
-
private config;
|
|
5
|
-
private baseDir;
|
|
6
|
-
private pubsub;
|
|
7
|
-
private typeDefs;
|
|
8
|
-
private logger;
|
|
9
|
-
fetchFn: typeof fetch;
|
|
10
|
-
importFn: ImportFn;
|
|
11
|
-
constructor({ config, baseDir, pubsub, store, logger, fetchFn, importFn, }: GetMeshSourceOptions<YamlConfig.Neo4JHandler>);
|
|
12
|
-
getCachedTypeDefs(driver: Driver): Promise<string>;
|
|
13
|
-
getMeshSource(): Promise<{
|
|
14
|
-
schema: import("graphql").GraphQLSchema;
|
|
15
|
-
}>;
|
|
16
|
-
}
|