Skip to content

Commit

Permalink
refactor: update default constructor for the base repository
Browse files Browse the repository at this point in the history
  • Loading branch information
psyphore committed Sep 14, 2019
1 parent 2c39632 commit 7511bb0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions DataAccess/DataAccess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<PackageReference Include="Neo4j.Driver" Version="1.7.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Models\Models.csproj" />
</ItemGroup>

<ItemGroup>
<Reference Include="Microsoft.Extensions.Caching.Abstractions">
<HintPath>C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.caching.abstractions\2.2.0\lib\netstandard2.0\Microsoft.Extensions.Caching.Abstractions.dll</HintPath>
Expand Down
5 changes: 3 additions & 2 deletions DataAccess/Repository.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DataAccess.Interfaces;
using Models.DTOs.Configuration;
using Neo4j.Driver.V1;
using System.Threading.Tasks;

Expand All @@ -8,9 +9,9 @@ public class Repository : IRepository
{
private readonly IDriver _driver;

public Repository(string uri, string username, string password)
public Repository(Connection connection)
{
_driver = GraphDatabase.Driver(uri, AuthTokens.Basic(username, password));
_driver = GraphDatabase.Driver(connection.BoltURL, AuthTokens.Basic(connection.Username, connection.Password));
}

public ISession GetSession(AccessMode mode)
Expand Down
5 changes: 4 additions & 1 deletion IoC/RegisterFrameworks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DataAccess;
using DataAccess.Interfaces;
using GraphQL;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand All @@ -24,9 +25,11 @@ public static void RegisterTypes(IServiceCollection services, IConfiguration con

services.AddTransient(o =>
{
return new Repository(neo4j.BoltURL, neo4j.Username, neo4j.Password);
return new Repository(neo4j);
});

services.AddTransient<IRepository, Repository>();

services.AddSingleton<IDocumentExecuter, DocumentExecuter>();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Models/GraphQLTypes/Person/PersonType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public PersonType() //ContextServiceLocator contextServiceLocator
Field(x => x.Id);
Field(x => x.Firstname, true);
Field(x => x.Lastname, true);
Field(x => x.Manager);
// Field(x => x.Manager);
Field(x => x.Team);
Field(x => x.Line);
Field(x => x.Buildings);
Expand Down

0 comments on commit 7511bb0

Please sign in to comment.