DotNet4Neo4j / Neo4jClient

.NET client binding for Neo4j
https://www.nuget.org/packages/Neo4jClient
Microsoft Public License
431 stars 146 forks source link

Querying for paths using BoltGraphClient (returning PathsResultBolt) does not work when using a different client JsonContractResolver #431

Closed andrew-ubco closed 2 years ago

andrew-ubco commented 2 years ago

Unless I am mistaken, querying for paths does not work correctly if you have setup the BoltGraphClient to use a different JsonContractResolver. StatementResultHelper.ToJsonString does not use JsonSettings in a couple of its calls to JsonConvert.SerializeObject, so querying for paths and returning PathsResultBolt does not deserialize all properties correctly.

ToJsonString is called with a Path object (from Neo4j Driver), which gets serialized without regard to the JsonSettings. Then when deserializing the result to PathsResultBolt, the correct contract resolver is used (but this is different to the one used for serialization).

Versions:

To Reproduce

Steps to reproduce the behavior:

  1. Create a BoltGraphClient
  2. Set the client's JsonContractResolver, eg. client.JsonContractResolver = new CamelCasePropertyNamesContractResolver()
  3. Execute a query returning a path, eg.
    result = (await client.Cypher
    .Match("p = (a:A {prop:'value'})-[*]->(b:B)")
    .Return<PathsResultBolt>("p")
    .ResultsAsync).ToList();

Expected behaviour

The result should be a correctly deserialized list of PathsResultBolt objects, each containing nodes and relationships, and all properties are populated correctly.

Additional context

If this is indeed a bug I have a potential fix (and tests), so will submit a PR.

andrew-ubco commented 2 years ago

On further investigation, this may be fixed by just decorating the properties of the relationship and node inner classes of PathsResultBolt (ie. PathsResultBolt.PathsResultBoltRelationship and PathsResultBolt.PathsResultBoltNode) with appropriate JsonProperty attributes. I am investigating further to determine if this fixes the issue I'm seeing.

andrew-ubco commented 2 years ago

Hi, is anyone actively reviewing issues/PRs? It's been a couple of months since I reported (and created a possible fix for) this.

Thanks, Andrew

cskardon commented 2 years ago

Oh hey, sorry about that, I'll have a look when I have time. Unfortunately there's just a lot of work which will always trump free things

On Wed, 23 Mar 2022, 03:35 andrew-ubco, @.***> wrote:

Hi, is anyone actively reviewing issues/PRs? It's been a couple of months since I reported (and created a possible fix for) this.

Thanks, Andrew

— Reply to this email directly, view it on GitHub https://github.com/DotNet4Neo4j/Neo4jClient/issues/431#issuecomment-1075879669, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOJ6XNLRSNFF6PGLFTL6L3VBKGOPANCNFSM5MWRUR4Q . You are receiving this because you were assigned.Message ID: @.***>