• 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

51.35
/src/GraphQL.Linq.LinqToDb/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 LinqToDB;
6

7
namespace GraphQL.Linq.LinqToDb;
8

9
/// <summary>
10
/// Helper methods for configuring GraphQL.Linq with LinqToDB.
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(EfGraphQLServiceWithStringSplit<>), 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 LinqToDB to the GraphQL builder with configuration options.
51
    /// </summary>
52
    public static IGraphQLBuilder AddLinq<TDbContext>(this IGraphQLBuilder builder, Action<GraphQLLinqOptions<TDbContext>>? setupAction = null)
53
        where TDbContext : IDataContext
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
        if (options.UseStringSplit)
1✔
64
            builder.Services.TryRegister<IEfGraphQLService<TDbContext>, EfGraphQLServiceWithStringSplit<TDbContext>>(DI.ServiceLifetime.Singleton);
1✔
65
        else
66
            builder.Services.TryRegister<IEfGraphQLService<TDbContext>, EfGraphQLService<TDbContext>>(DI.ServiceLifetime.Singleton);
×
67

68
        //register the IEfDbKeyNames
69
        builder.Services.TryRegister<IEfDbPrimaryKeyNamesProvider<TDbContext>, EfDbPrimaryKeyNamesProvider<TDbContext>>(DI.ServiceLifetime.Singleton);
1✔
70

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

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

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

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

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