Skip to content

Commit

Permalink
v8.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Abraham committed Jun 21, 2024
1 parent a0a5209 commit c016895
Show file tree
Hide file tree
Showing 75 changed files with 799 additions and 736 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed class GraphQLDeprecationReasonAttribute : Attribute
{
public GraphQLDeprecationReasonAttribute(string deprecationReason)
{
deprecationReason.AssertNotBlank();
deprecationReason.ThrowIfBlank();

this.DeprecationReason = deprecationReason;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed class GraphQLDescriptionAttribute : Attribute
{
public GraphQLDescriptionAttribute(string description)
{
description.AssertNotBlank();
description.ThrowIfBlank();

this.Description = description;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed class GraphQLInputNameAttribute : Attribute
/// <exception cref="ArgumentNullException"/>
public GraphQLInputNameAttribute(string name)
{
name.AssertNotBlank();
name.ThrowIfBlank();

this.Name = name;
}
Expand Down
2 changes: 1 addition & 1 deletion src/TypeCache.GraphQL/Attributes/GraphQLNameAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed class GraphQLNameAttribute : Attribute
/// <exception cref="ArgumentNullException"/>
public GraphQLNameAttribute(string name)
{
name.AssertNotBlank();
name.ThrowIfBlank();

this.Name = name;
}
Expand Down
4 changes: 2 additions & 2 deletions src/TypeCache.GraphQL/Extensions/GraphQLExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ public static Type ToGraphQLType(this Type @this, bool isInputType)
return @this.ToGraphQLEnumType();

var objectType = @this.GetObjectType();
(objectType is ObjectType.Delegate).AssertFalse();
(objectType is ObjectType.Object).AssertFalse();
(objectType is ObjectType.Delegate).ThrowIfTrue();
(objectType is ObjectType.Object).ThrowIfTrue();

var scalarGraphType = @this.GetScalarType().ToGraphType();
if (scalarGraphType is not null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static class ResolveFieldContextExtensions
{
public static DataTable GetArgumentAsDataTable(this IResolveFieldContext @this, string name, ObjectSchema objectSchema)
{
name.AssertNotBlank();
name.ThrowIfBlank();

var table = objectSchema.CreateDataTable();
var arguments = @this.GetArgument<IEnumerable<IDictionary<string, object>>>(name).ToArray();
Expand Down
38 changes: 19 additions & 19 deletions src/TypeCache.GraphQL/Extensions/SchemaExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using GraphQL.Types;
using Microsoft.Extensions.DependencyInjection;
using TypeCache.Attributes;
using TypeCache.Collections;
using TypeCache.Data;
using TypeCache.Data.Extensions;
using TypeCache.Extensions;
Expand All @@ -16,6 +15,7 @@
using TypeCache.GraphQL.Resolvers;
using TypeCache.GraphQL.SqlApi;
using TypeCache.GraphQL.Types;
using TypeCache.Utilities;

namespace TypeCache.GraphQL.Extensions;

Expand Down Expand Up @@ -59,7 +59,7 @@ public static FieldType[] AddDatabaseSchemaQueries(this ISchema @this, IDataSour
/// <exception cref="ArgumentNullException"/>
public static FieldType AddDatabaseSchemaQuery(this ISchema @this, IDataSource dataSource, SchemaCollection collection)
{
dataSource.AssertNotNull();
dataSource.ThrowIfNull();
var table = dataSource.GetDatabaseSchema(collection);
var graphDatabasesEnum = new EnumerationGraphType
{
Expand Down Expand Up @@ -136,7 +136,7 @@ public static void AddDatabaseEndpoints(this ISchema @this, IDataSource dataSour
const string ColumnName = nameof(ColumnName);
const string ColumnType = nameof(ColumnType);

dataSource.AssertNotNull();
dataSource.ThrowIfNull();

database ??= dataSource.DefaultDatabase;
var objectSchemas = dataSource.ObjectSchemas.Values.ToArray();
Expand Down Expand Up @@ -830,8 +830,8 @@ public static void AddSqlApiEndpoints<T>(this ISchema @this, IDataSource dataSou
public static FieldType AddSqlApiCallProcedureEndpoint<T>(this ISchema @this, IDataSource dataSource, string procedure, bool mutation, string? graphQlName = null, IGraphType? graphQlType = null)
where T : notnull, new()
{
dataSource.AssertNotNull();
procedure.AssertNotBlank();
dataSource.ThrowIfNull();
procedure.ThrowIfBlank();

var name = dataSource.Escape(procedure);
var objectSchema = dataSource.ObjectSchemas[name];
Expand Down Expand Up @@ -875,8 +875,8 @@ public static FieldType AddSqlApiCallProcedureEndpoint<T>(this ISchema @this, ID
public static FieldType AddSqlApiDeleteDataEndpoint<T>(this ISchema @this, IDataSource dataSource, string table, string? graphQlName = null)
where T : notnull, new()
{
dataSource.AssertNotNull();
table.AssertNotBlank();
dataSource.ThrowIfNull();
table.ThrowIfBlank();

var name = dataSource.Escape(table);
var objectSchema = dataSource.ObjectSchemas[name];
Expand Down Expand Up @@ -910,8 +910,8 @@ public static FieldType AddSqlApiDeleteDataEndpoint<T>(this ISchema @this, IData
public static FieldType AddSqlApiDeleteEndpoint<T>(this ISchema @this, IDataSource dataSource, string table, string? graphQlName = null)
where T : notnull, new()
{
dataSource.AssertNotNull();
table.AssertNotBlank();
dataSource.ThrowIfNull();
table.ThrowIfBlank();

var name = dataSource.Escape(table);
var objectSchema = dataSource.ObjectSchemas[name];
Expand Down Expand Up @@ -946,8 +946,8 @@ public static FieldType AddSqlApiDeleteEndpoint<T>(this ISchema @this, IDataSour
public static FieldType AddSqlApiInsertDataEndpoint<T>(this ISchema @this, IDataSource dataSource, string table, string? graphQlName = null)
where T : notnull, new()
{
dataSource.AssertNotNull();
table.AssertNotBlank();
dataSource.ThrowIfNull();
table.ThrowIfBlank();

var name = dataSource.Escape(table);
var objectSchema = dataSource.ObjectSchemas[name];
Expand Down Expand Up @@ -982,8 +982,8 @@ public static FieldType AddSqlApiInsertDataEndpoint<T>(this ISchema @this, IData
public static FieldType AddSqlApiInsertEndpoint<T>(this ISchema @this, IDataSource dataSource, string table, string? graphQlName = null)
where T : notnull, new()
{
dataSource.AssertNotNull();
table.AssertNotBlank();
dataSource.ThrowIfNull();
table.ThrowIfBlank();

var name = dataSource.Escape(table);
var objectSchema = dataSource.ObjectSchemas[name];
Expand Down Expand Up @@ -1040,8 +1040,8 @@ public static FieldType AddSqlApiInsertEndpoint<T>(this ISchema @this, IDataSour
public static FieldType AddSqlApiSelectEndpoint<T>(this ISchema @this, IDataSource dataSource, string table, string? graphQlName = null)
where T : notnull, new()
{
dataSource.AssertNotNull();
table.AssertNotBlank();
dataSource.ThrowIfNull();
table.ThrowIfBlank();

var name = dataSource.Escape(table);
var objectSchema = dataSource.ObjectSchemas[name];
Expand Down Expand Up @@ -1095,8 +1095,8 @@ public static FieldType AddSqlApiSelectEndpoint<T>(this ISchema @this, IDataSour
public static FieldType AddSqlApiUpdateDataEndpoint<T>(this ISchema @this, IDataSource dataSource, string table, string? graphQlName = null)
where T : notnull, new()
{
dataSource.AssertNotNull();
table.AssertNotBlank();
dataSource.ThrowIfNull();
table.ThrowIfBlank();

var name = dataSource.Escape(table);
var objectSchema = dataSource.ObjectSchemas[name];
Expand Down Expand Up @@ -1130,8 +1130,8 @@ public static FieldType AddSqlApiUpdateDataEndpoint<T>(this ISchema @this, IData
public static FieldType AddSqlApiUpdateEndpoint<T>(this ISchema @this, IDataSource dataSource, string table, string? graphQlName = null)
where T : notnull, new()
{
dataSource.AssertNotNull();
table.AssertNotBlank();
dataSource.ThrowIfNull();
table.ThrowIfBlank();

var name = dataSource.Escape(table);
var objectSchema = dataSource.ObjectSchemas[name];
Expand Down
16 changes: 8 additions & 8 deletions src/TypeCache.GraphQL/Resolvers/BatchLoaderFieldResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using GraphQL;
using GraphQL.DataLoader;
using Microsoft.Extensions.DependencyInjection;
using TypeCache.Collections;
using TypeCache.Extensions;
using TypeCache.GraphQL.Extensions;
using TypeCache.Utilities;
using IResolveFieldContext = global::GraphQL.IResolveFieldContext;

namespace TypeCache.GraphQL.Resolvers;
Expand All @@ -24,10 +24,10 @@ public sealed class BatchLoaderFieldResolver<PARENT, CHILD, MATCH> : FieldResolv
/// <exception cref="ArgumentOutOfRangeException"/>
public BatchLoaderFieldResolver(MethodInfo methodInfo, Func<PARENT, MATCH> getParentKey, Func<CHILD, MATCH> getChildKey, bool returnCollection)
{
methodInfo.AssertNotNull();
getParentKey.AssertNotNull();
getChildKey.AssertNotNull();
methodInfo.ReturnType.IsAny<CHILD[], IEnumerable<CHILD>, Task<CHILD[]>, Task<IEnumerable<CHILD>>, ValueTask<CHILD[]>, ValueTask<IEnumerable<CHILD>>>().AssertTrue();
methodInfo.ThrowIfNull();
getParentKey.ThrowIfNull();
getChildKey.ThrowIfNull();
methodInfo.ReturnType.IsAny<CHILD[], IEnumerable<CHILD>, Task<CHILD[]>, Task<IEnumerable<CHILD>>, ValueTask<CHILD[]>, ValueTask<IEnumerable<CHILD>>>().ThrowIfFalse();

this._DataLoaderKey = Invariant($"{typeof(PARENT).GraphQLName()}.{methodInfo.GraphQLName()}");
this._MethodInfo = methodInfo;
Expand All @@ -39,11 +39,11 @@ public BatchLoaderFieldResolver(MethodInfo methodInfo, Func<PARENT, MATCH> getPa
/// <exception cref="ArgumentNullException"/>
protected override async ValueTask<object?> ResolveAsync(IResolveFieldContext context)
{
context.RequestServices.AssertNotNull();
context.Source.AssertNotNull();
context.RequestServices.ThrowIfNull();
context.Source.ThrowIfNull();

var dataLoaderAccessor = context.RequestServices.GetRequiredService<IDataLoaderContextAccessor>();
dataLoaderAccessor.Context.AssertNotNull();
dataLoaderAccessor.Context.ThrowIfNull();

var key = this._GetParentKey((PARENT)context.Source);
if (this._ReturnCollection)
Expand Down
10 changes: 5 additions & 5 deletions src/TypeCache.GraphQL/Resolvers/ItemLoaderFieldResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public sealed class ItemLoaderFieldResolver<T> : FieldResolver
/// <exception cref="ArgumentException"/>
public ItemLoaderFieldResolver(MethodInfo methodInfo)
{
methodInfo.IsStatic.AssertTrue();
methodInfo.ReturnType.IsAny<T, Task<T>, ValueTask<T>>().AssertTrue();
methodInfo.IsStatic.ThrowIfFalse();
methodInfo.ReturnType.IsAny<T, Task<T>, ValueTask<T>>().ThrowIfFalse();

this._MethodHandle = methodInfo.MethodHandle;
this._Name = methodInfo.GraphQLName();
Expand All @@ -27,12 +27,12 @@ public ItemLoaderFieldResolver(MethodInfo methodInfo)
/// <exception cref="ArgumentNullException"/>
protected override async ValueTask<object?> ResolveAsync(IResolveFieldContext context)
{
context.RequestServices.AssertNotNull();
context.Source.AssertNotNull();
context.RequestServices.ThrowIfNull();
context.Source.ThrowIfNull();

var dataLoaderAccessor = context.RequestServices.GetRequiredService<IDataLoaderContextAccessor>();
var dataLoaderContext = dataLoaderAccessor.Context;
dataLoaderContext.AssertNotNull();
dataLoaderContext.ThrowIfNull();

var loaderKey = Invariant($"{context.Source.GetType().GraphQLName()}.{this._Name}");
var dataLoader = dataLoaderContext.GetOrAddLoader<T>(loaderKey, () => this.LoadData(context));
Expand Down
2 changes: 1 addition & 1 deletion src/TypeCache.GraphQL/Resolvers/MethodFieldResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public sealed class MethodFieldResolver(MethodInfo methodInfo) : FieldResolver
{
protected override async ValueTask<object?> ResolveAsync(IResolveFieldContext context)
{
context.RequestServices.AssertNotNull();
context.RequestServices.ThrowIfNull();

var arguments = context.GetArguments(methodInfo).ToArray();
object? result;
Expand Down
4 changes: 2 additions & 2 deletions src/TypeCache.GraphQL/Resolvers/MethodSourceStreamResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ public MethodSourceStreamResolver(MethodInfo methodInfo)
if (returnType is ObjectType.Task || returnType is ObjectType.ValueTask)
returnsObservable = methodInfo.ReturnType.GenericTypeArguments.Single().GetObjectType() is ObjectType.Observable;

returnsObservable.AssertTrue();
returnsObservable.ThrowIfFalse();
}

this._MethodInfo = methodInfo;
}

protected override ValueTask<IObservable<object?>> ResolveAsync(global::GraphQL.IResolveFieldContext context)
{
context.RequestServices.AssertNotNull();
context.RequestServices.ThrowIfNull();

var arguments = context.GetArguments(this._MethodInfo).ToArray();
object? result;
Expand Down
2 changes: 1 addition & 1 deletion src/TypeCache.GraphQL/Resolvers/PropertyFieldResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public sealed class PropertyFieldResolver<T>(PropertyInfo propertyInfo) : FieldR
{
protected override async ValueTask<object?> ResolveAsync(IResolveFieldContext context)
{
propertyInfo.AssertNotNull();
propertyInfo.ThrowIfNull();

var source = context.Source switch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
using System.Data;
using GraphQL;
using Microsoft.Extensions.DependencyInjection;
using TypeCache.Collections;
using TypeCache.Data;
using TypeCache.Data.Extensions;
using TypeCache.Extensions;
using TypeCache.GraphQL.Extensions;
using TypeCache.GraphQL.SqlApi;
using TypeCache.Mediation;
using TypeCache.Utilities;
using static TypeCache.Data.DataSourceType;

namespace TypeCache.GraphQL.Resolvers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
using System.Data;
using GraphQL;
using Microsoft.Extensions.DependencyInjection;
using TypeCache.Collections;
using TypeCache.Data;
using TypeCache.Data.Extensions;
using TypeCache.Extensions;
using TypeCache.GraphQL.Extensions;
using TypeCache.GraphQL.SqlApi;
using TypeCache.Mediation;
using TypeCache.Utilities;
using static TypeCache.Data.DataSourceType;

namespace TypeCache.GraphQL.Resolvers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
using System.Data;
using GraphQL;
using Microsoft.Extensions.DependencyInjection;
using TypeCache.Collections;
using TypeCache.Data;
using TypeCache.Data.Extensions;
using TypeCache.Extensions;
using TypeCache.GraphQL.Extensions;
using TypeCache.GraphQL.SqlApi;
using TypeCache.Mediation;
using TypeCache.Utilities;
using static TypeCache.Data.DataSourceType;

namespace TypeCache.GraphQL.Resolvers;
Expand Down
2 changes: 1 addition & 1 deletion src/TypeCache.GraphQL/TypeCache.GraphQL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Nullable>enable</Nullable>
<RootNamespace>TypeCache.GraphQL</RootNamespace>
<PackageId>TypeCache.GraphQL</PackageId>
<Version>8.3.0</Version>
<Version>8.3.1</Version>
<Authors>Samuel Abraham &lt;[email protected]&gt;</Authors>
<Company>Samuel Abraham &lt;[email protected]&gt;</Company>
<Title>TypeCache GraphQL</Title>
Expand Down
2 changes: 1 addition & 1 deletion src/TypeCache.GraphQL/Types/GraphQLHashIdType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public sealed class GraphQLHashIdType : ScalarGraphType
/// <exception cref="ArgumentNullException"/>
public GraphQLHashIdType(IHashMaker hashMaker)
{
hashMaker.AssertNotNull();
hashMaker.ThrowIfNull();

this._HashMaker = hashMaker;
this.Name = "HashID";
Expand Down
2 changes: 1 addition & 1 deletion src/TypeCache.GraphQL/Types/GraphQLInterfaceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public sealed class GraphQLInterfaceType<T> : InterfaceGraphType<T>
{
public GraphQLInterfaceType()
{
typeof(T).IsInterface.AssertTrue();
typeof(T).IsInterface.ThrowIfFalse();

this.Name = typeof(T).GraphQLName();

Expand Down
4 changes: 2 additions & 2 deletions src/TypeCache.GraphQL/Types/GraphQLObjectType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public FieldType AddQueryItem<CHILD, MATCH>(MethodInfo methodInfo, Func<T, MATCH
where CHILD : notnull
where MATCH : notnull
{
methodInfo.ReturnType.IsAny<CHILD[], IEnumerable<CHILD>, Task<CHILD[]>, Task<IEnumerable<CHILD>>, ValueTask<CHILD[]>, ValueTask<IEnumerable<CHILD>>>().AssertTrue();
methodInfo.ReturnType.IsAny<CHILD[], IEnumerable<CHILD>, Task<CHILD[]>, Task<IEnumerable<CHILD>>, ValueTask<CHILD[]>, ValueTask<IEnumerable<CHILD>>>().ThrowIfFalse();

var fieldType = new FieldType()
{
Expand Down Expand Up @@ -106,7 +106,7 @@ public FieldType AddQueryCollection<CHILD, MATCH>(MethodInfo methodInfo, Func<T,
where CHILD : notnull
where MATCH : notnull
{
methodInfo.ReturnType.IsAny<CHILD[], IEnumerable<CHILD>, Task<CHILD[]>, Task<IEnumerable<CHILD>>, ValueTask<CHILD[]>, ValueTask<IEnumerable<CHILD>>>().AssertTrue();
methodInfo.ReturnType.IsAny<CHILD[], IEnumerable<CHILD>, Task<CHILD[]>, Task<IEnumerable<CHILD>>, ValueTask<CHILD[]>, ValueTask<IEnumerable<CHILD>>>().ThrowIfFalse();

var fieldType = new FieldType()
{
Expand Down
6 changes: 3 additions & 3 deletions src/TypeCache.Web/Attributes/RequireClaimAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) 2021 Samuel Abraham

using Microsoft.AspNetCore.Authorization;
using TypeCache.Collections;
using TypeCache.Extensions;
using TypeCache.Utilities;
using TypeCache.Web.Requirements;

namespace TypeCache.Web.Attributes;
Expand All @@ -19,12 +19,12 @@ public RequireClaimAttribute(string[] claims) : base(nameof(ClaimAuthorizationRe
{
const char separator = '=';

claims.AssertNotEmpty();
claims.ThrowIfEmpty();

this.Claims = new Dictionary<string, string[]>(claims.Length, StringComparer.OrdinalIgnoreCase);
claims?.ForEach(claim =>
{
(claim.StartsWith(separator) || claim.EndsWith(separator) || claim.Count(c => c.Equals(separator)) > 1).AssertFalse();
(claim.StartsWith(separator) || claim.EndsWith(separator) || claim.Count(c => c.Equals(separator)) > 1).ThrowIfTrue();
if (claim.Contains(separator))
{
Expand Down
Loading

0 comments on commit c016895

Please sign in to comment.