Skip to content

Commit

Permalink
[Fusion] Add lookup requirements. (#7804)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib authored Dec 9, 2024
1 parent c3e7d34 commit c443c83
Show file tree
Hide file tree
Showing 42 changed files with 2,575 additions and 2,927 deletions.
1 change: 1 addition & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<PackageVersion Include="System.Reactive" Version="6.0.0" />
<PackageVersion Include="Xunit" Version="2.9.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="17.12.5" />
<PackageVersion Include="TUnit" Version="0.4.71" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public bool TryHandle(
var attributeContainingTypeSymbol = attributeSymbol.ContainingType;
var fullName = attributeContainingTypeSymbol.ToDisplayString();

// We do a start with here to capture the generic and non generic variant of
// We do a startWith to capture the generic and non-generic variants of
// the object type extension attribute.
if (fullName.StartsWith(ExtendObjectTypeAttribute, Ordinal) &&
context.SemanticModel.GetDeclaredSymbol(possibleType) is { } typeExt)
Expand Down
2,373 changes: 684 additions & 1,689 deletions src/HotChocolate/Core/src/Types/Properties/TypeResources.Designer.cs

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions src/HotChocolate/Core/src/Types/Properties/TypeResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,6 @@
<data name="DirectiveTypeDescriptor_OnlyProperties" xml:space="preserve">
<value>Only property expressions are allowed to describe a directive type argument.</value>
</data>
<data name="DirectiveTypeFactory_LocationNotSupported" xml:space="preserve">
<value>The specified location `{0}` is not supported.</value>
</data>
<data name="DirectiveType_NoLocations" xml:space="preserve">
<value>The `{0}` directive does not declare any location on which it is valid.</value>
</data>
Expand Down
2 changes: 1 addition & 1 deletion src/HotChocolate/Core/src/Types/SchemaPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private static DirectiveDefinitionNode PrintDirectiveTypeDefinition(

var locations = directiveType.Locations
.AsEnumerable()
.Select(l => new NameNode(l.MapDirectiveLocation().ToString()))
.Select(l => new NameNode(l.Format().ToString()))
.ToList();

return new DirectiveDefinitionNode
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,95 +1,13 @@
using System.Globalization;
using HotChocolate.Configuration;
using HotChocolate.Language;
using HotChocolate.Properties;
using HotChocolate.Types.Descriptors;
using HotChocolate.Types.Descriptors.Definitions;
using static HotChocolate.DirectiveLocationUtils;

namespace HotChocolate.Types.Factories;

internal sealed class DirectiveTypeFactory : ITypeFactory<DirectiveDefinitionNode, DirectiveType>
{
private static readonly Dictionary<Language.DirectiveLocation, DirectiveLocation> _locs =
new()
{
{
Language.DirectiveLocation.Query,
DirectiveLocation.Query
},
{
Language.DirectiveLocation.Mutation,
DirectiveLocation.Mutation
},
{
Language.DirectiveLocation.Subscription,
DirectiveLocation.Subscription
},
{
Language.DirectiveLocation.Field,
DirectiveLocation.Field
},
{
Language.DirectiveLocation.FragmentDefinition,
DirectiveLocation.FragmentDefinition
},
{
Language.DirectiveLocation.FragmentSpread,
DirectiveLocation.FragmentSpread
},
{
Language.DirectiveLocation.InlineFragment,
DirectiveLocation.InlineFragment
},
{
Language.DirectiveLocation.Schema,
DirectiveLocation.Schema
},
{
Language.DirectiveLocation.Scalar,
DirectiveLocation.Scalar
},
{
Language.DirectiveLocation.Object,
DirectiveLocation.Object
},
{
Language.DirectiveLocation.FieldDefinition,
DirectiveLocation.FieldDefinition
},
{
Language.DirectiveLocation.ArgumentDefinition,
DirectiveLocation.ArgumentDefinition
},
{
Language.DirectiveLocation.Interface,
DirectiveLocation.Interface
},
{
Language.DirectiveLocation.Union,
DirectiveLocation.Union
},
{
Language.DirectiveLocation.Enum,
DirectiveLocation.Enum
},
{
Language.DirectiveLocation.EnumValue,
DirectiveLocation.EnumValue
},
{
Language.DirectiveLocation.InputObject,
DirectiveLocation.InputObject
},
{
Language.DirectiveLocation.InputFieldDefinition,
DirectiveLocation.InputFieldDefinition
},
{
Language.DirectiveLocation.VariableDefinition,
DirectiveLocation.VariableDefinition
}
};

public DirectiveType Create(IDescriptorContext context, DirectiveDefinitionNode node)
{
var typeDefinition = new DirectiveTypeDefinition(
Expand Down Expand Up @@ -133,28 +51,6 @@ private static void DeclareLocations(
DirectiveTypeDefinition parent,
DirectiveDefinitionNode node)
{
foreach (var location in node.Locations)
{
if (Language.DirectiveLocation.TryParse(
location.Value,
out var parsedLocation))
{
parent.Locations |= MapDirectiveLocation(parsedLocation);
}
}
}

private static DirectiveLocation MapDirectiveLocation(
Language.DirectiveLocation location)
{
if (!_locs.TryGetValue(location, out var loc))
{
throw new NotSupportedException(string.Format(
CultureInfo.InvariantCulture,
TypeResources.DirectiveTypeFactory_LocationNotSupported,
location));
}

return loc;
parent.Locations = Parse(node.Locations);
}
}
Loading

0 comments on commit c443c83

Please sign in to comment.