public static IDataLoader <TKey, TValue[]> GroupDataLoader <TKey, TValue>(
            this IResolverContext context,
            FetchGroup <TKey, TValue> fetch,
            string?key = null)
            where TKey : notnull
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (fetch is null)
            {
                throw new ArgumentNullException(nameof(fetch));
            }

            IServiceProvider    services = context.Services;
            IDataLoaderRegistry reg      = services.GetRequiredService <IDataLoaderRegistry>();
            Func <FetchGroupedDataLoader <TKey, TValue> > createDataLoader =
                () => new FetchGroupedDataLoader <TKey, TValue>(
                    services.GetRequiredService <IBatchScheduler>(),
                    fetch);

            return(key is null
                ? reg.GetOrRegister(createDataLoader)
                : reg.GetOrRegister(key, createDataLoader));
        }
        public static IDataLoader <TKey, TValue> CacheDataLoader <TKey, TValue>(
            this IResolverContext context,
            FetchCacheCt <TKey, TValue> fetch,
            string?key    = null,
            int cacheSize = DataLoaderDefaults.CacheSize)
            where TKey : notnull
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (fetch is null)
            {
                throw new ArgumentNullException(nameof(fetch));
            }

            IServiceProvider    services = context.Services;
            IDataLoaderRegistry reg      = services.GetRequiredService <IDataLoaderRegistry>();
            Func <FetchCacheDataLoader <TKey, TValue> > createDataLoader =
                () => new FetchCacheDataLoader <TKey, TValue>(
                    fetch,
                    cacheSize);

            return(key is null
                ? reg.GetOrRegister(createDataLoader)
                : reg.GetOrRegister(key, createDataLoader));
        }
        public static IDataLoader <TKey, TValue> BatchDataLoader <TKey, TValue>(
            this IResolverContext context,
            FetchBatch <TKey, TValue> fetch,
            string?key = null)
            where TKey : notnull
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (fetch is null)
            {
                throw new ArgumentNullException(nameof(fetch));
            }

            IServiceProvider    services = context.Services;
            IDataLoaderRegistry reg      = services.GetRequiredService <IDataLoaderRegistry>();

            FetchBatchDataLoader <TKey, TValue> Loader()
            => new(
                fetch,
                services.GetRequiredService <IBatchScheduler>(),
                services.GetRequiredService <DataLoaderOptions>());

            return(key is null
                ? reg.GetOrRegister(Loader)
                : reg.GetOrRegister(key, Loader));
        }
        public static T DataLoader <T>(this IResolverContext context)
            where T : notnull, IDataLoader
        {
            if (context is null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            IServiceProvider    services = context.Services;
            IDataLoaderRegistry reg      = services.GetRequiredService <IDataLoaderRegistry>();

            return(reg.GetOrRegister(() => CreateDataLoader <T>(services)));
        }