Skip to content

Commit

Permalink
Fix remaining PR issues
Browse files Browse the repository at this point in the history
  • Loading branch information
PSanetra committed Feb 5, 2024
1 parent c550b98 commit d06122c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
9 changes: 8 additions & 1 deletion src/GraphQL.Tests/Utilities/SchemaBuilderExecutionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ interface Pet {

var serviceCollection = new ServiceCollection()
.AddScoped<PetQueryType>()
.AddSingleton<IGraphTypeFactory<EnumerationGraphType>, GenericGraphTypeFactory<CaseInsensitiveEnumerationGraphType>>()
.AddSingleton<IGraphTypeFactory<EnumerationGraphType>, DefaultGraphTypeFactory<CaseInsensitiveEnumerationGraphType>>()
.AddGraphQL(b => b
.AddSchema(services =>
{
Expand Down Expand Up @@ -962,6 +962,13 @@ public override void Add(EnumValueDefinition value)

_aliasValues.TryGetValue(strName.ToUpperInvariant(), out value);

if (value != null)
{
return value;
}

_aliasValues.TryGetValue(strName.ToConstantCase(), out value);

return value;
}
}
13 changes: 13 additions & 0 deletions src/GraphQL/Types/DefaultGraphTypeFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace GraphQL.Types;

/// <summary>
/// A generic factory to create instances of specific <typeparamref name="TGraphType"/> implementations from parameterless constructors.
/// </summary>
public class DefaultGraphTypeFactory<TGraphType> : IGraphTypeFactory<TGraphType> where TGraphType : IGraphType
{
/// <summary>
/// Create a new instance of <typeparamref name="TGraphType"/>. Requires a parameterless constructor.
/// </summary>
/// <returns></returns>
public TGraphType Create() => Activator.CreateInstance<TGraphType>();
}
13 changes: 0 additions & 13 deletions src/GraphQL/Types/GenericGraphTypeFactory.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/GraphQL/Types/IGraphTypeFactory.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace GraphQL.Types;

/// <summary>
/// A factory to create instances of specific TGraphType implementations.
/// A factory to create instances of specific <typeparamref name="TGraphType"/> implementations.
/// </summary>
public interface IGraphTypeFactory<out TGraphType> where TGraphType : IGraphType
{
/// <summary>
/// Create a new instance of TGraphType
/// Create a new instance of <typeparamref name="TGraphType"/>
/// </summary>
/// <returns></returns>
public TGraphType Create();
Expand Down

0 comments on commit d06122c

Please sign in to comment.