• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

graphql-linq / GraphQL.Linq / 19446803163

17 Nov 2025 10:32PM UTC coverage: 87.392% (-1.8%) from 89.147%
19446803163

Pull #10

github

web-flow
Merge 9011fa9cd into a893cba86
Pull Request #10: Add better support for multiple database contexts

476 of 501 branches covered (95.01%)

Branch coverage included in aggregate %.

0 of 60 new or added lines in 4 files covered. (0.0%)

2366 of 2751 relevant lines covered (86.01%)

2.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

55.26
/src/GraphQL.Linq.EntityFrameworkCore10/Helpers.cs
1
// © 2025 American Community Developers, Inc. All Rights Reserved. See LICENSE.txt for details.
2

3
using GraphQL.DI;
4
using GraphQL.Linq.GraphApi;
5
using Microsoft.EntityFrameworkCore;
6

7
namespace GraphQL.Linq.EntityFrameworkCore10;
8

9
/// <summary>
10
/// Helper methods for configuring GraphQL.Linq with Entity Framework Core.
11
/// </summary>
12
public static class Helpers
13
{
14
    /// <summary>
15
    /// Adds GraphQL.Linq services for Entity Framework Core to the GraphQL builder.
16
    /// </summary>
17
    public static IGraphQLBuilder AddLinq(this IGraphQLBuilder builder)
NEW
18
    {
×
NEW
19
        if (builder == null)
×
NEW
20
            throw new ArgumentNullException(nameof(builder));
×
21

22
        //register the IEfGraphQLService
NEW
23
        builder.Services.TryRegister(typeof(IEfGraphQLService<>), typeof(EfGraphQLService<>), DI.ServiceLifetime.Singleton);
×
24

25
        //register the ILinqGraphExecuter
NEW
26
        builder.Services.TryRegister(typeof(ILinqGraphExecuter<>), typeof(LinqGraphExecuter<>), DI.ServiceLifetime.Singleton);
×
NEW
27
        builder.Services.TryRegister<ILinqGraphExecuter, LinqGraphExecuter>(DI.ServiceLifetime.Singleton);
×
28

29
        //register the IEfDbPrimaryKeyNamesProvider
NEW
30
        builder.Services.TryRegister(typeof(IEfDbPrimaryKeyNamesProvider<>), typeof(EfDbPrimaryKeyNamesProvider<>), DI.ServiceLifetime.Singleton);
×
31

32
        //register the IEfDbContextTypeProvider
NEW
33
        builder.Services.TryRegister<IEfDbContextTypeProvider, EfDbContextTypeProvider>(DI.ServiceLifetime.Singleton);
×
34

35
        //register the connection type
NEW
36
        builder.Services.TryRegister(typeof(EfConnectionType<>), typeof(EfConnectionType<>), DI.ServiceLifetime.Singleton);
×
NEW
37
        builder.Services.TryRegister(typeof(EfEdgeType<>), typeof(EfEdgeType<>), DI.ServiceLifetime.Singleton);
×
NEW
38
        builder.AddGraphTypeMappingProvider<EfConnectionMapper>();
×
39

40
        //enable resolve field context accessor
NEW
41
        builder.AddResolveFieldContextAccessor();
×
42

43
        //enable data loaders
NEW
44
        builder.AddDataLoader();
×
45

NEW
46
        return builder;
×
NEW
47
    }
×
48

49
    /// <summary>
50
    /// Adds GraphQL.Linq services for Entity Framework Core to the GraphQL builder.
51
    /// </summary>
52
    public static IGraphQLBuilder AddLinq<TDbContext>(this IGraphQLBuilder builder, Action<GraphQLLinqOptions<TDbContext>>? setupAction = null)
53
        where TDbContext : DbContext
54
    {
2✔
55
        if (builder == null)
2✔
56
            throw new ArgumentNullException(nameof(builder));
×
57

58
        //set up options
59
        var options = new GraphQLLinqOptions<TDbContext>();
2✔
60
        setupAction?.Invoke(options);
2✔
61

62
        //register the IEfGraphQLService
63
        builder.Services.TryRegister<IEfDbPrimaryKeyNamesProvider<TDbContext>, EfDbPrimaryKeyNamesProvider<TDbContext>>(
2✔
64
            DI.ServiceLifetime.Singleton);
2✔
65
        builder.Services.TryRegister<IEfGraphQLService<TDbContext>, EfGraphQLService<TDbContext>>(
2✔
66
            DI.ServiceLifetime.Singleton);
2✔
67

68
        //register the ILinqGraphExecuter
69
        builder.Services.TryRegister<ILinqGraphExecuter<TDbContext>, LinqGraphExecuter<TDbContext>>(
2✔
70
            DI.ServiceLifetime.Singleton);
2✔
71
        builder.Services.TryRegister<ILinqGraphExecuter, LinqGraphExecuter<TDbContext>>(
2✔
72
            DI.ServiceLifetime.Singleton);
2✔
73

74
        //register the connection type
75
        builder.Services.TryRegister(typeof(EfConnectionType<>), typeof(EfConnectionType<>), DI.ServiceLifetime.Singleton);
2✔
76
        builder.Services.TryRegister(typeof(EfEdgeType<>), typeof(EfEdgeType<>), DI.ServiceLifetime.Singleton);
2✔
77
        builder.AddGraphTypeMappingProvider<EfConnectionMapper>();
2✔
78

79
        //enable resolve field context accessor
80
        builder.AddResolveFieldContextAccessor();
2✔
81

82
        //enable data loaders
83
        builder.AddDataLoader();
2✔
84

85
        return builder;
2✔
86
    }
2✔
87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc