Skip to content

Commit

Permalink
feat: adds handler on oncomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalSenn committed Nov 20, 2020
1 parent c48c160 commit e4d685e
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using HotChocolate.Language;
using HotChocolate.Types.Descriptors.Definitions;

namespace HotChocolate.Types
namespace HotChocolate.Internal
{
internal static class TypeDependencyHelper
public static class TypeDependencyHelper
{
public static void RegisterDependencies(
this ITypeDiscoveryContext context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using HotChocolate.Configuration;
using HotChocolate.Internal;
using HotChocolate.Properties;
using HotChocolate.Types.Descriptors;
using HotChocolate.Types.Descriptors.Definitions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Reflection;
using HotChocolate.Configuration;
using HotChocolate.Internal;
using HotChocolate.Language;
using HotChocolate.Types.Descriptors;
using HotChocolate.Types.Descriptors.Definitions;
Expand Down
1 change: 1 addition & 0 deletions src/HotChocolate/Core/src/Types/Types/InterfaceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using HotChocolate.Configuration;
using HotChocolate.Internal;
using HotChocolate.Language;
using HotChocolate.Resolvers;
using HotChocolate.Types.Descriptors;
Expand Down
1 change: 1 addition & 0 deletions src/HotChocolate/Core/src/Types/Types/ObjectType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using HotChocolate.Configuration;
using HotChocolate.Internal;
using HotChocolate.Language;
using HotChocolate.Resolvers;
using HotChocolate.Types.Descriptors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using HotChocolate.Configuration;
using HotChocolate.Internal;
using HotChocolate.Types;
using HotChocolate.Types.Descriptors;
using HotChocolate.Types.Descriptors.Definitions;
Expand All @@ -14,6 +16,34 @@ public class FilterTypeInterceptor

public override bool CanHandle(ITypeSystemObjectContext context) => true;

public override void OnBeforeRegisterDependencies(
ITypeDiscoveryContext discoveryContext,
DefinitionBase? definition,
IDictionary<string, object?> contextData)
{
if (definition is FilterInputTypeDefinition def)
{
IFilterConvention convention = GetConvention(
discoveryContext.DescriptorContext,
def.Scope);

SchemaTypeReference typeReference = TypeReference.Create(
discoveryContext.Type,
def.Scope);

var descriptor = FilterInputTypeDescriptor.New(
discoveryContext.DescriptorContext,
def.EntityType,
def.Scope);

convention.ApplyConfigurations(typeReference, descriptor);

FilterInputTypeDefinition extensionDefinition = descriptor.CreateDefinition();

discoveryContext.RegisterDependencies(extensionDefinition);
}
}

public override void OnBeforeCompleteName(
ITypeCompletionContext completionContext,
DefinitionBase? definition,
Expand All @@ -30,7 +60,7 @@ public class FilterTypeInterceptor
def.EntityType,
def.Scope);

var typeReference = TypeReference.Create(
SchemaTypeReference typeReference = TypeReference.Create(
completionContext.Type,
def.Scope);

Expand All @@ -41,6 +71,26 @@ public class FilterTypeInterceptor
descriptor.CreateDefinition(),
def);

if (def.Scope is not null)
{
definition.Name = completionContext.Scope +
"_" +
definition.Name;
}
}
}

public override void OnBeforeCompleteType(
ITypeCompletionContext completionContext,
DefinitionBase? definition,
IDictionary<string, object?> contextData)
{
if (definition is FilterInputTypeDefinition def)
{
IFilterConvention convention = GetConvention(
completionContext.DescriptorContext,
def.Scope);

foreach (InputFieldDefinition field in def.Fields)
{
if (field is FilterFieldDefinition filterFieldDefinition)
Expand Down Expand Up @@ -72,14 +122,6 @@ public class FilterTypeInterceptor
}
}
}


if (def.Scope is not null)
{
definition.Name = completionContext.Scope +
"_" +
definition.Name;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,30 +154,22 @@ input PointFilterInput {
x: ComparableOperationFilterInputOfDoubleFilterInput
y: ComparableOperationFilterInputOfDoubleFilterInput
z: ComparableOperationFilterInputOfDoubleFilterInput
"Returns the area of this Geometry.\nAreal Geometries have a non-zero area.\nThey override this function to compute the area.\nOthers return 0.0\n\n\n**Returns:**\nThe area of the Geometry."
area: ComparableOperationFilterInputOfDoubleFilterInput
"Gets the boundary of this geometry.\nZero-dimensional geometries have no boundary by definition,\nso an empty GeometryCollection is returned."
boundary: GeometryFilterInput
"Computes the centroid of this Geometry.\nThe centroid\nis equal to the centroid of the set of component Geometries of highest\ndimension (since the lower-dimension geometries contribute zero\n\"weight\" to the centroid).\n\nThe centroid of an empty geometry is POINT EMPTY.\n\n\n**Returns:**\nA Point which is the centroid of this Geometry."
centroid: PointFilterInput
dimension: EnumOperationFilterInputOfDimensionFilterInput
"Gets a geometry representing the envelope (bounding box) of this Geometry.\n\n\n**Returns:**\n\nA Geometry representing the envelope of this Geometry"
envelope: GeometryFilterInput
"Returns the name of this object's interface.\n\n\n**Returns:**\n\"Point\""
geometryType: StringOperationFilterInput
"Computes an interior point of this Geometry.\n\n\n**Returns:**\nA Point which is in the interior of this Geometry."
interiorPoint: PointFilterInput
"Tests whether this Geometry is simple.\n\nThe SFS definition of simplicity\nfollows the general rule that a Geometry is simple if it has no points of\nself-tangency, self-intersection or other anomalous points.\n\nSimplicity is defined for each Geometry subclass as follows:\n\nValid polygonal geometries are simple, since their rings\nmust not self-intersect. IsSimple\ntests for this condition and reports false if it is not met.\n(This is a looser test than checking for validity).\nLinear rings have the same semantics.\nLinear geometries are simple iff they do not self-intersect at points\nother than boundary points.\nZero-dimensional geometries (points) are simple iff they have no\nrepeated points.\nEmpty Geometrys are always simple.\n\n\n\n**Returns:**\ntrue if this Geometry is simple"
isSimple: BooleanOperationFilterInput
"Tests whether this Geometry is topologically\nvalid, according to the OGC SFS specification.\nFor validity rules see the documentation for the specific geometry subclass.\n\n\n**Returns:**\ntrue if this Geometry is valid."
isValid: BooleanOperationFilterInput
"Returns the length of this Geometry.\nLinear geometries return their length.\nAreal geometries return their perimeter.\nThey override this function to compute the length.\nOthers return 0.0\n\n\n**Returns:**\nThe length of the Geometry."
length: ComparableOperationFilterInputOfDoubleFilterInput
numPoints: ComparableOperationFilterInputOfInt32FilterInput
"Gets the OGC geometry type"
ogcGeometryType: EnumOperationFilterInputOfOgcGeometryTypeFilterInput
pointOnSurface: PointFilterInput
"Sets the ID of the Spatial Reference System used by the Geometry."
sRID: ComparableOperationFilterInputOfInt32FilterInput
contains: GeometryContainsOperationTypeFilterInput
distance: GeometryDistanceOperationTypeFilterInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,28 +150,21 @@ input GeometryWithinOperationTypeFilterInput {
input LineStringFilterInput {
and: [LineStringFilterInput!]
or: [LineStringFilterInput!]
"Returns the area of this Geometry.\nAreal Geometries have a non-zero area.\nThey override this function to compute the area.\nOthers return 0.0\n\n\n**Returns:**\nThe area of the Geometry."
area: ComparableOperationFilterInputOfDoubleFilterInput
boundary: GeometryFilterInput
"Computes the centroid of this Geometry.\nThe centroid\nis equal to the centroid of the set of component Geometries of highest\ndimension (since the lower-dimension geometries contribute zero\n\"weight\" to the centroid).\n\nThe centroid of an empty geometry is POINT EMPTY.\n\n\n**Returns:**\nA Point which is the centroid of this Geometry."
centroid: PointFilterInput
dimension: EnumOperationFilterInputOfDimensionFilterInput
"Gets a geometry representing the envelope (bounding box) of this Geometry.\n\n\n**Returns:**\n\nA Geometry representing the envelope of this Geometry"
envelope: GeometryFilterInput
"Returns the name of this object's interface.\n\n\n**Returns:**\n\"LineString\""
geometryType: StringOperationFilterInput
"Computes an interior point of this Geometry.\n\n\n**Returns:**\nA Point which is in the interior of this Geometry."
interiorPoint: PointFilterInput
"Tests whether this Geometry is simple.\n\nThe SFS definition of simplicity\nfollows the general rule that a Geometry is simple if it has no points of\nself-tangency, self-intersection or other anomalous points.\n\nSimplicity is defined for each Geometry subclass as follows:\n\nValid polygonal geometries are simple, since their rings\nmust not self-intersect. IsSimple\ntests for this condition and reports false if it is not met.\n(This is a looser test than checking for validity).\nLinear rings have the same semantics.\nLinear geometries are simple iff they do not self-intersect at points\nother than boundary points.\nZero-dimensional geometries (points) are simple iff they have no\nrepeated points.\nEmpty Geometrys are always simple.\n\n\n\n**Returns:**\ntrue if this Geometry is simple"
isSimple: BooleanOperationFilterInput
"Tests whether this Geometry is topologically\nvalid, according to the OGC SFS specification.\nFor validity rules see the documentation for the specific geometry subclass.\n\n\n**Returns:**\ntrue if this Geometry is valid."
isValid: BooleanOperationFilterInput
"Returns the length of this LineString\n\n\n**Returns:**\nThe length of the polygon."
length: ComparableOperationFilterInputOfDoubleFilterInput
numPoints: ComparableOperationFilterInputOfInt32FilterInput
ogcGeometryType: EnumOperationFilterInputOfOgcGeometryTypeFilterInput
pointOnSurface: PointFilterInput
"Sets the ID of the Spatial Reference System used by the Geometry."
sRID: ComparableOperationFilterInputOfInt32FilterInput
contains: GeometryContainsOperationTypeFilterInput
distance: GeometryDistanceOperationTypeFilterInput
Expand All @@ -189,30 +182,22 @@ input PointFilterInput {
x: ComparableOperationFilterInputOfDoubleFilterInput
y: ComparableOperationFilterInputOfDoubleFilterInput
z: ComparableOperationFilterInputOfDoubleFilterInput
"Returns the area of this Geometry.\nAreal Geometries have a non-zero area.\nThey override this function to compute the area.\nOthers return 0.0\n\n\n**Returns:**\nThe area of the Geometry."
area: ComparableOperationFilterInputOfDoubleFilterInput
"Gets the boundary of this geometry.\nZero-dimensional geometries have no boundary by definition,\nso an empty GeometryCollection is returned."
boundary: GeometryFilterInput
"Computes the centroid of this Geometry.\nThe centroid\nis equal to the centroid of the set of component Geometries of highest\ndimension (since the lower-dimension geometries contribute zero\n\"weight\" to the centroid).\n\nThe centroid of an empty geometry is POINT EMPTY.\n\n\n**Returns:**\nA Point which is the centroid of this Geometry."
centroid: PointFilterInput
dimension: EnumOperationFilterInputOfDimensionFilterInput
"Gets a geometry representing the envelope (bounding box) of this Geometry.\n\n\n**Returns:**\n\nA Geometry representing the envelope of this Geometry"
envelope: GeometryFilterInput
"Returns the name of this object's interface.\n\n\n**Returns:**\n\"Point\""
geometryType: StringOperationFilterInput
"Computes an interior point of this Geometry.\n\n\n**Returns:**\nA Point which is in the interior of this Geometry."
interiorPoint: PointFilterInput
"Tests whether this Geometry is simple.\n\nThe SFS definition of simplicity\nfollows the general rule that a Geometry is simple if it has no points of\nself-tangency, self-intersection or other anomalous points.\n\nSimplicity is defined for each Geometry subclass as follows:\n\nValid polygonal geometries are simple, since their rings\nmust not self-intersect. IsSimple\ntests for this condition and reports false if it is not met.\n(This is a looser test than checking for validity).\nLinear rings have the same semantics.\nLinear geometries are simple iff they do not self-intersect at points\nother than boundary points.\nZero-dimensional geometries (points) are simple iff they have no\nrepeated points.\nEmpty Geometrys are always simple.\n\n\n\n**Returns:**\ntrue if this Geometry is simple"
isSimple: BooleanOperationFilterInput
"Tests whether this Geometry is topologically\nvalid, according to the OGC SFS specification.\nFor validity rules see the documentation for the specific geometry subclass.\n\n\n**Returns:**\ntrue if this Geometry is valid."
isValid: BooleanOperationFilterInput
"Returns the length of this Geometry.\nLinear geometries return their length.\nAreal geometries return their perimeter.\nThey override this function to compute the length.\nOthers return 0.0\n\n\n**Returns:**\nThe length of the Geometry."
length: ComparableOperationFilterInputOfDoubleFilterInput
numPoints: ComparableOperationFilterInputOfInt32FilterInput
"Gets the OGC geometry type"
ogcGeometryType: EnumOperationFilterInputOfOgcGeometryTypeFilterInput
pointOnSurface: PointFilterInput
"Sets the ID of the Spatial Reference System used by the Geometry."
sRID: ComparableOperationFilterInputOfInt32FilterInput
contains: GeometryContainsOperationTypeFilterInput
distance: GeometryDistanceOperationTypeFilterInput
Expand Down

0 comments on commit e4d685e

Please sign in to comment.