Skip to content

Commit 5ee5d08

Browse files
committed
Introduce driver level Hydration and Dehydration hooks
This hooks enable driver users to globaly map their own data types to Neo4j driver types and vice-versa.
1 parent e191168 commit 5ee5d08

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+490
-173
lines changed

packages/bolt-connection/src/bolt/bolt-protocol-v1.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ export default class BoltProtocol {
7474
{ disableLosslessIntegers, useBigInt } = {},
7575
createResponseHandler = () => null,
7676
log,
77-
onProtocolError
77+
onProtocolError,
78+
hydrationHooks,
79+
dehydrationHooks
7880
) {
7981
this._server = server || {}
8082
this._chunker = chunker
@@ -86,11 +88,13 @@ export default class BoltProtocol {
8688
this._fatalError = null
8789
this._lastMessageSignature = null
8890
this._config = { disableLosslessIntegers, useBigInt }
91+
this._hydrationHooks = hydrationHooks
92+
this._dehydrationHooks = dehydrationHooks
8993
}
9094

9195
get transformer () {
9296
if (this._transformer === undefined) {
93-
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)))
97+
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)), this._hydrationHooks, this._dehydrationHooks)
9498
}
9599
return this._transformer
96100
}

packages/bolt-connection/src/bolt/bolt-protocol-v2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default class BoltProtocol extends BoltProtocolV1 {
3737

3838
get transformer () {
3939
if (this._transformer === undefined) {
40-
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)))
40+
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)), this._hydrationHooks, this._dehydrationHooks)
4141
}
4242
return this._transformer
4343
}

packages/bolt-connection/src/bolt/bolt-protocol-v3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default class BoltProtocol extends BoltProtocolV2 {
4848

4949
get transformer () {
5050
if (this._transformer === undefined) {
51-
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)))
51+
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)), this._hydrationHooks, this._dehydrationHooks)
5252
}
5353
return this._transformer
5454
}

packages/bolt-connection/src/bolt/bolt-protocol-v4x0.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export default class BoltProtocol extends BoltProtocolV3 {
4646

4747
get transformer () {
4848
if (this._transformer === undefined) {
49-
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)))
49+
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)), this._hydrationHooks, this._dehydrationHooks)
5050
}
5151
return this._transformer
5252
}

packages/bolt-connection/src/bolt/bolt-protocol-v4x1.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export default class BoltProtocol extends BoltProtocolV4 {
4949
createResponseHandler = () => null,
5050
log,
5151
onProtocolError,
52+
hydrationHooks,
53+
dehydrationHooks,
5254
serversideRouting
5355
) {
5456
super(
@@ -57,7 +59,9 @@ export default class BoltProtocol extends BoltProtocolV4 {
5759
packstreamConfig,
5860
createResponseHandler,
5961
log,
60-
onProtocolError
62+
onProtocolError,
63+
hydrationHooks,
64+
dehydrationHooks
6165
)
6266
this._serversideRouting = serversideRouting
6367
}
@@ -68,7 +72,7 @@ export default class BoltProtocol extends BoltProtocolV4 {
6872

6973
get transformer () {
7074
if (this._transformer === undefined) {
71-
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)))
75+
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)), this._hydrationHooks, this._dehydrationHooks)
7276
}
7377
return this._transformer
7478
}

packages/bolt-connection/src/bolt/bolt-protocol-v4x2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default class BoltProtocol extends BoltProtocolV41 {
3434

3535
get transformer () {
3636
if (this._transformer === undefined) {
37-
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)))
37+
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)), this._hydrationHooks, this._dehydrationHooks)
3838
}
3939
return this._transformer
4040
}

packages/bolt-connection/src/bolt/bolt-protocol-v4x3.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default class BoltProtocol extends BoltProtocolV42 {
3939

4040
get transformer () {
4141
if (this._transformer === undefined) {
42-
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)))
42+
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)), this._hydrationHooks, this._dehydrationHooks)
4343
}
4444
return this._transformer
4545
}
@@ -126,6 +126,6 @@ export default class BoltProtocol extends BoltProtocolV42 {
126126
this._transformer = new Transformer(Object.values({
127127
...transformersFactories,
128128
...utcTransformersFactories
129-
}).map(create => create(this._config, this._log)))
129+
}).map(create => create(this._config, this._log)), this._hydrationHooks, this._dehydrationHooks)
130130
}
131131
}

packages/bolt-connection/src/bolt/bolt-protocol-v4x4.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default class BoltProtocol extends BoltProtocolV43 {
3939

4040
get transformer () {
4141
if (this._transformer === undefined) {
42-
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)))
42+
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)), this._hydrationHooks, this._dehydrationHooks)
4343
}
4444
return this._transformer
4545
}
@@ -178,6 +178,6 @@ export default class BoltProtocol extends BoltProtocolV43 {
178178
this._transformer = new Transformer(Object.values({
179179
...transformersFactories,
180180
...utcTransformersFactories
181-
}).map(create => create(this._config, this._log)))
181+
}).map(create => create(this._config, this._log)), this._hydrationHooks, this._dehydrationHooks)
182182
}
183183
}

packages/bolt-connection/src/bolt/bolt-protocol-v5x0.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default class BoltProtocol extends BoltProtocolV44 {
3737

3838
get transformer () {
3939
if (this._transformer === undefined) {
40-
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)))
40+
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)), this._hydrationHooks, this._dehydrationHooks)
4141
}
4242
return this._transformer
4343
}

packages/bolt-connection/src/bolt/bolt-protocol-v5x1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default class BoltProtocol extends BoltProtocolV5x0 {
3737

3838
get transformer () {
3939
if (this._transformer === undefined) {
40-
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)))
40+
this._transformer = new Transformer(Object.values(transformersFactories).map(create => create(this._config, this._log)), this._hydrationHooks, this._dehydrationHooks)
4141
}
4242
return this._transformer
4343
}

0 commit comments

Comments
 (0)