Skip to content

Commit

Permalink
Adds sorting customization (#4914)
Browse files Browse the repository at this point in the history
  • Loading branch information
PascalSenn authored Apr 11, 2022
1 parent c6cf60c commit 33b7c0c
Show file tree
Hide file tree
Showing 103 changed files with 3,796 additions and 311 deletions.
15 changes: 10 additions & 5 deletions src/HotChocolate/Core/src/Abstractions/ErrorCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,21 @@ public static class Execution

/// <summary>
/// The Oneof Input Objects `{0}` require that exactly one field must be supplied and that
/// field must not be `null`. Oneof Input Objects are a special variant of Input Objects
/// field must not be `null`. Oneof Input Objects are a special variant of Input Objects
/// where the type system asserts that exactly one of the fields must be set and non-null.
/// </summary>
public const string OneOfNoFieldSet = "HC0054";

/// <summary>
/// More than one field of the Oneof Input Object `{0}` is set. Oneof Input Objects
/// are a special variant of Input Objects where the type system asserts that exactly
/// More than one field of the Oneof Input Object `{0}` is set. Oneof Input Objects
/// are a special variant of Input Objects where the type system asserts that exactly
/// one of the fields must be set and non-null.
/// </summary>
public const string OneOfMoreThanOneFieldSet = "HC0055";

/// <summary>
/// `null` was set to the field `{0}`of the Oneof Input Object `{1}`. Oneof Input Objects
/// are a special variant of Input Objects where the type system asserts that exactly
/// `null` was set to the field `{0}`of the Oneof Input Object `{1}`. Oneof Input Objects
/// are a special variant of Input Objects where the type system asserts that exactly
/// one of the fields must be set and non-null.
/// </summary>
public const string OneOfFieldIsNull = "HC0056";
Expand Down Expand Up @@ -257,6 +257,11 @@ public static class Data
/// Type does not contain a valid node field. Only `items` and `nodes` are supported
/// </summary>
public const string NodeFieldWasNotFound = "HC0028";

/// <summary>
/// Inline filtering type does not defined any fields.
/// </summary>
public const string InlineFilterTypeNoFields = "HC0062";
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using HotChocolate.Language;
using HotChocolate.Types;
using HotChocolate.Types.Descriptors;
using HotChocolate.Types.Descriptors.Definitions;

Expand Down
1 change: 1 addition & 0 deletions src/HotChocolate/Core/src/Types/HotChocolate.Types.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<InternalsVisibleTo Include="HotChocolate.Validation" />
<InternalsVisibleTo Include="HotChocolate.Types.CursorPagination" />
<InternalsVisibleTo Include="HotChocolate.ApolloFederation" />
<InternalsVisibleTo Include="HotChocolate.Data" />

<!--Legacy Support-->
<InternalsVisibleTo Include="HotChocolate.Types.Filters" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,21 @@ public InputFieldDefinition(
/// Gets the associated property.
/// </summary>
public PropertyInfo? Property { get; set; }

internal void CopyTo(InputFieldDefinition target)
{
base.CopyTo(target);

target.Property = Property;
}

internal void MergeInto(InputFieldDefinition target)
{
base.MergeInto(target);

if (Property is not null)
{
target.Property = Property;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,19 @@ public override int GetHashCode()
/// <inheritdoc />
public override string ToString()
=> $"{Context}: {Name}->{Dependency}";

public DependantFactoryTypeReference With(
Optional<NameString> name = default,
Optional<ITypeReference> dependency = default,
Optional<Func<IDescriptorContext, TypeSystemObjectBase>> factory = default,
Optional<TypeContext> context = default,
Optional<string?> scope = default)
{
return new DependantFactoryTypeReference(
name.HasValue ? name.Value! : Name,
dependency.HasValue ? dependency.Value! : Dependency,
factory.HasValue ? factory.Value! : Factory,
context.HasValue ? context.Value! : Context,
scope.HasValue ? scope.Value! : Scope);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ public static ExtendedTypeReference Create(
scope);
}

return new ExtendedTypeReference(
type,
context,
scope);
return new ExtendedTypeReference(type, context, scope);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ public static ITypeReference With(
this ITypeReference typeReference,
Optional<TypeContext> context = default,
Optional<string?> scope = default) => typeReference switch
{
ExtendedTypeReference clr => clr.With(context: context, scope: scope),
SchemaTypeReference schema => schema.With(context: context, scope: scope),
SyntaxTypeReference syntax => syntax.With(context: context, scope: scope),
_ => throw new NotSupportedException()
};
{
ExtendedTypeReference clr => clr.With(context: context, scope: scope),
SchemaTypeReference schema => schema.With(context: context, scope: scope),
SyntaxTypeReference syntax => syntax.With(context: context, scope: scope),
DependantFactoryTypeReference d => d.With(context: context, scope: scope),
_ => throw new NotSupportedException()
};
}
Loading

0 comments on commit 33b7c0c

Please sign in to comment.