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

graphql-linq / GraphQL.Linq / 19446377243

17 Nov 2025 10:14PM UTC coverage: 89.147% (-0.06%) from 89.207%
19446377243

Pull #9

github

web-flow
Merge d8cb85342 into 7a9ef28d3
Pull Request #9: Add automatic data loader registration and bump GraphQL to 8.8.0

476 of 497 branches covered (95.77%)

Branch coverage included in aggregate %.

7 of 10 new or added lines in 7 files covered. (70.0%)

2366 of 2691 relevant lines covered (87.92%)

2.72 hits per line

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

55.26
/src/GraphQL.Linq.EntityFrameworkCore2/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.EntityFrameworkCore2;
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 LinqToDB to the GraphQL builder.
16
    /// </summary>
17
    public static IGraphQLBuilder AddLinq(this IGraphQLBuilder builder)
18
    {
×
19
        if (builder == null)
×
20
            throw new ArgumentNullException(nameof(builder));
×
21

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

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

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

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

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

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

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

46
        return builder;
×
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
    {
1✔
55
        if (builder == null)
1✔
56
            throw new ArgumentNullException(nameof(builder));
×
57

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

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

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

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

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

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

85
        return builder;
1✔
86
    }
1✔
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