Removes any fields that look to be internal based on presence of "dbId" in field name or arg.
services.
.AddGraphQLServer()
.AddTypeRewriter(new RemoveInternalFieldsRewriter())
Removes any fields that look to be internal based on presence of "dbId" in field name or arg.
services.
.AddGraphQLServer()
.AddTypeRewriter(new RemoveInternalFieldsRewriter())
A converter setup for System.Text.Json that:
Helpful in transition off Newtonsoft if your clients were passing string values but you still want to serialize out as numeric. Related issue that might make this redundant: dotnet/runtime#61726
Usage:
options.Converters.Add(new EnumConverterUsingEnumParseFactory());
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics.CodeAnalysis; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
namespace VerifyTests | |
{ | |
public static class VerifySettingsExtensions | |
{ |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using RazorEngineCore; | |
namespace MyCompany.Templating.RazorEngineCore | |
{ | |
public static class IRazorEngineExtensions | |
{ | |
// See: |
using System.Net; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Mvc.Testing; | |
using Snapshooter.Json; | |
using Xunit; | |
namespace MyCompany.MyService | |
{ | |
public class GraphQLSchemaTests | |
: IClassFixture<WebApplicationFactory<Startup>> |
General setup:
npm install --save-dev bootstrap@4.0.0-beta.2 node-sass sass-loader
/// <summary> | |
/// Prevents use of certain field names typically used in introspection queries. | |
/// Useful for production environments where you may want to guard against such queries. | |
/// </summary> | |
/// <remarks> | |
/// Compatible with v10 of HotChocolate. | |
/// </summary> | |
public class NoIntrospectionValidationRule : IQueryValidationRule | |
{ | |
private static readonly HashSet<string> _bannedFieldNames = new HashSet<string>() { "__schema", "__type" }; |
A middleware to provide resolvers with their own, scoped instance, of a service. Example here is IMediator, but this could be made generic. |
/// <summary> | |
/// Custom naming conventions. | |
/// | |
/// Usage in v10: | |
/// <c>services.AddSingleton<INamingConventions, NamingConventions>()</c> | |
/// <c>IRequestExecutorBuilder.AddConvention<INamingConventions>(new NamingConventions())</c> | |
/// Usage in v11: | |
/// | |
/// </summary> | |
public class NamingConventions : DefaultNamingConventions |
#nullable enable | |
using Microsoft.EntityFrameworkCore; | |
namespace MyCompany | |
{ | |
/// <summary> | |
/// An abstraction around EF Core's DbContextPool (as it's an internal API that becomes public in .NET 5) | |
/// for renting a DbContext. | |
/// </summary> | |
public interface IDbContextPool<TDbContext> |