Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Neo4j] Test Fixes #5545

Merged
merged 20 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 21 additions & 6 deletions src/HotChocolate/Neo4J/HotChocolate.Neo4J.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Utilities", ".
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Abstractions", "..\Core\src\Abstractions\HotChocolate.Abstractions.csproj", "{384C2579-EBEF-44DC-8F54-2B9558E07ADB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Data.Neo4J.Language.Tests", "test\HotChocolate.Data.Neo4J.Language.Tests\HotChocolate.Data.Neo4J.Language.Tests.csproj", "{8325D43F-3F12-4C4F-8887-5FA714AA8EC7}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Data.Neo4J.Language.Tests", "test\Data.Neo4J.Language.Tests\HotChocolate.Data.Neo4J.Language.Tests.csproj", "{8325D43F-3F12-4C4F-8887-5FA714AA8EC7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Data.Neo4J.Filtering.Tests", "test\HotChocolate.Data.Neo4J.Filtering.Tests\HotChocolate.Data.Neo4J.Filtering.Tests.csproj", "{81EC7457-71A6-4E87-943A-DBA5059599F7}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Data.Neo4J.Filtering.Tests", "test\Data.Neo4J.Filtering.Tests\HotChocolate.Data.Neo4J.Filtering.Tests.csproj", "{81EC7457-71A6-4E87-943A-DBA5059599F7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Data.Neo4J.Sorting.Tests", "test\HotChocolate.Data.Neo4J.Sorting.Tests\HotChocolate.Data.Neo4J.Sorting.Tests.csproj", "{FE82E164-96FE-4C44-B241-D19C2387A2C9}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Data.Neo4J.Sorting.Tests", "test\Data.Neo4J.Sorting.Tests\HotChocolate.Data.Neo4J.Sorting.Tests.csproj", "{FE82E164-96FE-4C44-B241-D19C2387A2C9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Data.Neo4J.Projections.Tests", "test\HotChocolate.Data.Neo4J.Projections.Tests\HotChocolate.Data.Neo4J.Projections.Tests.csproj", "{B8CDE36A-9FD3-479E-AB8A-245082523D00}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Data.Neo4J.Projections.Tests", "test\Data.Neo4J.Projections.Tests\HotChocolate.Data.Neo4J.Projections.Tests.csproj", "{B8CDE36A-9FD3-479E-AB8A-245082523D00}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Data.Neo4J.Paging.Tests", "test\HotChocolate.Data.Neo4J.Paging.Tests\HotChocolate.Data.Neo4J.Paging.Tests.csproj", "{2A4849BE-4105-4068-B1FD-D875094EE619}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Data.Neo4J.Paging.Tests", "test\Data.Neo4J.Paging.Tests\HotChocolate.Data.Neo4J.Paging.Tests.csproj", "{2A4849BE-4105-4068-B1FD-D875094EE619}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Data.Neo4J.Integration.Tests", "test\HotChocolate.Data.Neo4J.Integration.Tests\HotChocolate.Data.Neo4J.Integration.Tests.csproj", "{2AB0B430-5150-4983-B62E-E7DD7FABBB3B}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Data.Neo4J.Integration.Tests", "test\Data.Neo4J.Integration.Tests\HotChocolate.Data.Neo4J.Integration.Tests.csproj", "{2AB0B430-5150-4983-B62E-E7DD7FABBB3B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HotChocolate.Data.Neo4J.Testing", "test\Data.Neo4J.Testing\HotChocolate.Data.Neo4J.Testing.csproj", "{E6631F91-84AC-4C01-8A9A-1586378F27C1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -218,6 +220,18 @@ Global
{2AB0B430-5150-4983-B62E-E7DD7FABBB3B}.Release|x64.Build.0 = Release|Any CPU
{2AB0B430-5150-4983-B62E-E7DD7FABBB3B}.Release|x86.ActiveCfg = Release|Any CPU
{2AB0B430-5150-4983-B62E-E7DD7FABBB3B}.Release|x86.Build.0 = Release|Any CPU
{E6631F91-84AC-4C01-8A9A-1586378F27C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E6631F91-84AC-4C01-8A9A-1586378F27C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6631F91-84AC-4C01-8A9A-1586378F27C1}.Debug|x64.ActiveCfg = Debug|Any CPU
{E6631F91-84AC-4C01-8A9A-1586378F27C1}.Debug|x64.Build.0 = Debug|Any CPU
{E6631F91-84AC-4C01-8A9A-1586378F27C1}.Debug|x86.ActiveCfg = Debug|Any CPU
{E6631F91-84AC-4C01-8A9A-1586378F27C1}.Debug|x86.Build.0 = Debug|Any CPU
{E6631F91-84AC-4C01-8A9A-1586378F27C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6631F91-84AC-4C01-8A9A-1586378F27C1}.Release|Any CPU.Build.0 = Release|Any CPU
{E6631F91-84AC-4C01-8A9A-1586378F27C1}.Release|x64.ActiveCfg = Release|Any CPU
{E6631F91-84AC-4C01-8A9A-1586378F27C1}.Release|x64.Build.0 = Release|Any CPU
{E6631F91-84AC-4C01-8A9A-1586378F27C1}.Release|x86.ActiveCfg = Release|Any CPU
{E6631F91-84AC-4C01-8A9A-1586378F27C1}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5219FDEE-0427-4429-BDBE-76DC00742027} = {381E7519-8284-4D97-A28C-AF8B1F79C11B}
Expand All @@ -234,5 +248,6 @@ Global
{B8CDE36A-9FD3-479E-AB8A-245082523D00} = {828618C0-B8D0-4AEC-984C-99B759FA523F}
{2A4849BE-4105-4068-B1FD-D875094EE619} = {828618C0-B8D0-4AEC-984C-99B759FA523F}
{2AB0B430-5150-4983-B62E-E7DD7FABBB3B} = {828618C0-B8D0-4AEC-984C-99B759FA523F}
{E6631F91-84AC-4C01-8A9A-1586378F27C1} = {828618C0-B8D0-4AEC-984C-99B759FA523F}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HotChocolate.Types;
using HotChocolate.Types.Descriptors;

Expand All @@ -25,4 +24,4 @@ public override void OnConfigure(
.Extend()
.OnBeforeCreate(x => x.ContextData.Add(nameof(Neo4JNodeAttribute), this));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;

namespace HotChocolate.Data.Neo4J;

[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class Neo4JNodeIdAttribute : Attribute
{
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Neo4j.Driver;

namespace HotChocolate.Data.Neo4J;
Expand All @@ -26,4 +23,4 @@ private static async Task<List<TReturn>> MapAsync<TReturn>(

return list;
}
}
}
1 change: 0 additions & 1 deletion src/HotChocolate/Neo4J/src/Data/ErrorHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Linq;
using HotChocolate.Data.Filters;
using HotChocolate.Data.Sorting;
using HotChocolate.Language;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using ServiceStack.Text;

namespace HotChocolate.Data.Neo4J;
Expand All @@ -19,4 +17,4 @@ public IEnumerable MapValues(IEnumerable fromList, Type toInstanceOfType)

return to;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using System.Collections;

namespace HotChocolate.Data.Neo4J;

internal interface ICollectionMapper
{
IEnumerable MapValues(IEnumerable fromList, Type toInstanceOfType);
}
}
63 changes: 40 additions & 23 deletions src/HotChocolate/Neo4J/src/Data/Execution/Neo4JExecutable.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using HotChocolate.Data.Neo4J.Language;
using HotChocolate.Data.Neo4J.Sorting;
using HotChocolate.Language;
Expand Down Expand Up @@ -52,7 +48,7 @@ public Neo4JExecutable(IAsyncSession session)
}

/// <inheritdoc />
public object? Source => _session;
public object Source => _session;

/// <inheritdoc />
public async ValueTask<IList> ToListAsync(CancellationToken cancellationToken)
Expand Down Expand Up @@ -117,22 +113,55 @@ public StatementBuilder Pipeline()
{
var statement = Cypher.Match(Node).Return(Node);

if (_filters is not null)
ApplyFilters(statement);
ApplyProjections(statement);
ApplyPaging(statement);
ApplySorting(statement);

return statement;
}

private void ApplyFilters(StatementBuilder statement)
{
if (_filters is null)
{
statement.Match(new Where(_filters), Node);
return;
}

if (_projection is not null)
statement.Match(new Where(_filters), Node);
}

private void ApplyProjections(StatementBuilder statement)
{
if (_projection is null)
{
statement.Return(Node.Project(_projection));
return;
}

statement.Return(Node.Project(_projection));
}

private void ApplyPaging(StatementBuilder statement)
{
if (_limit is not null)
{
statement.Limit((int)_limit);
}

if (_skip is not null)
{
statement.Skip((int)_skip);
}
}

private void ApplySorting(StatementBuilder statement)
{
if (_sorting is null)
{
return statement;
return;
}

var sorts = new List<SortItem>();
var sorts = new List<SortItem>(_sorting.Length);

foreach (var sort in _sorting)
{
Expand All @@ -148,17 +177,5 @@ public StatementBuilder Pipeline()
}

statement.OrderBy(sorts);

if (_limit is not null)
{
statement.Limit((int)_limit);
}

if (_skip is not null)
{
statement.Limit((int)_skip);
}

return statement;
}
}
4 changes: 1 addition & 3 deletions src/HotChocolate/Neo4J/src/Data/Execution/ValueMapper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Neo4j.Driver;
using ServiceStack;

Expand Down Expand Up @@ -44,4 +42,4 @@ public static T MapValue<T>(object cypherValue)
_ => cypherValue.As<T>()
};
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HotChocolate.Data.Neo4J.Paging;
using HotChocolate.Execution.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HotChocolate.Data.Filters;

namespace HotChocolate.Data.Neo4J.Filtering;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HotChocolate.Data.Filters;
using HotChocolate.Data.Neo4J.Language;
using HotChocolate.Language;
Expand Down Expand Up @@ -39,4 +38,4 @@ public override Condition HandleOperation(
.Property(context.GetNeo4JFilterScope().GetPath())
.GreaterThan(Cypher.LiteralOf(parsedValue));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HotChocolate.Data.Filters;
using HotChocolate.Data.Neo4J.Language;
using HotChocolate.Language;
Expand Down Expand Up @@ -39,4 +38,4 @@ public override Condition HandleOperation(
.Property(context.GetNeo4JFilterScope().GetPath())
.GreaterThanOEqualTo(Cypher.LiteralOf(parsedValue));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HotChocolate.Data.Filters;
using HotChocolate.Data.Neo4J.Language;
using HotChocolate.Language;
Expand Down Expand Up @@ -39,4 +38,4 @@ public override Condition HandleOperation(
.Property(context.GetNeo4JFilterScope().GetPath())
.LessThan(Cypher.LiteralOf(parsedValue));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HotChocolate.Data.Filters;
using HotChocolate.Data.Neo4J.Language;
using HotChocolate.Language;
Expand Down Expand Up @@ -39,4 +38,4 @@ public override Condition HandleOperation(
.Property(context.GetNeo4JFilterScope().GetPath())
.LessThanOrEqualTo(Cypher.LiteralOf(parsedValue));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HotChocolate.Data.Filters;
using HotChocolate.Data.Neo4J.Language;
using HotChocolate.Language;
Expand Down Expand Up @@ -40,4 +39,4 @@ public override Condition HandleOperation(
.GreaterThan(Cypher.LiteralOf(parsedValue))
.Not();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HotChocolate.Data.Filters;
using HotChocolate.Data.Neo4J.Language;
using HotChocolate.Language;
Expand Down Expand Up @@ -40,4 +39,4 @@ public override Condition HandleOperation(
.GreaterThanOEqualTo(Cypher.LiteralOf(parsedValue))
.Not();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HotChocolate.Data.Filters;
using HotChocolate.Data.Neo4J.Language;
using HotChocolate.Language;
Expand Down Expand Up @@ -40,4 +39,4 @@ public override Condition HandleOperation(
.LessThan(Cypher.LiteralOf(parsedValue))
.Not();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HotChocolate.Data.Filters;
using HotChocolate.Data.Neo4J.Language;
using HotChocolate.Language;
Expand Down Expand Up @@ -40,4 +39,4 @@ public override Condition HandleOperation(
.LessThanOrEqualTo(Cypher.LiteralOf(parsedValue))
.Not();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HotChocolate.Configuration;
using HotChocolate.Data.Filters;
using HotChocolate.Data.Neo4J.Language;
Expand Down Expand Up @@ -49,4 +48,4 @@ parsedValue is bool parsedBool &&

throw new InvalidOperationException();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using HotChocolate.Configuration;
using HotChocolate.Data.Filters;
using HotChocolate.Data.Neo4J.Language;
using HotChocolate.Internal;
using HotChocolate.Language;
using HotChocolate.Language.Visitors;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HotChocolate.Data.Filters;
using HotChocolate.Data.Neo4J.Language;
using HotChocolate.Language;
Expand Down Expand Up @@ -33,4 +32,4 @@ public override Condition HandleOperation(
.Property(context.GetNeo4JFilterScope().GetPath())
.Contains(Cypher.LiteralOf(str));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HotChocolate.Data.Filters;
using HotChocolate.Data.Neo4J.Language;
using HotChocolate.Language;
Expand Down Expand Up @@ -33,4 +32,4 @@ public override Condition HandleOperation(
.Property(context.GetNeo4JFilterScope().GetPath())
.EndsWith(Cypher.LiteralOf(str));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using HotChocolate.Data.Filters;
using HotChocolate.Data.Neo4J.Language;
using HotChocolate.Language;
Expand Down Expand Up @@ -34,4 +33,4 @@ public override Condition HandleOperation(
.Contains(Cypher.LiteralOf(str))
.Not();
}
}
}
Loading