Skip to content

Commit

Permalink
Merge branch 'main' into http-version-default
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib authored Oct 31, 2023
2 parents 738661c + e92bc8d commit dc73038
Show file tree
Hide file tree
Showing 881 changed files with 1,297 additions and 1,086 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"errors": [
{
"message": "The \u0060\u0060 authorization policy does not exist.",
"message": "The `` authorization policy does not exist.",
"locations": [
{
"line": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ public async Task ValidationError(string? acceptHeader, HttpTransportVersion tra
Status Code: {expectedStatusCode}
-------------------------->
" +
@"{""errors"":[{""message"":""Expected a \u0060Name\u0060-token, but found a " +
@"\u0060Dollar\u0060-token."",""locations"":[{""line"":1,""column"":8}]," +
@"{""errors"":[{""message"":""Expected a `Name`-token, but found a " +
@"`Dollar`-token."",""locations"":[{""line"":1,""column"":8}]," +
@"""extensions"":{""code"":""HC0011""}}]}");
}

Expand Down Expand Up @@ -246,18 +246,18 @@ public async Task ValidationError2(string? acceptHeader, HttpTransportVersion tr
Status Code: {expectedStatusCode}
-------------------------->
" +
@"{""errors"":[{""message"":""\u0060__type\u0060 is an object, interface or " +
@"{""errors"":[{""message"":""`__type` is an object, interface or " +
@"union type field. Leaf selections on objects, interfaces, and unions without " +
@"subfields are disallowed."",""locations"":[{""line"":1,""column"":3}]," +
@"""extensions"":{""declaringType"":""Query"",""field"":""__type""," +
@"""type"":""__Type"",""responseName"":""__type""," +
@"""specifiedBy"":""http://spec.graphql.org/October2021/#sec-Field-Selections-" +
@"on-Objects-Interfaces-and-Unions-Types""}},{""message"":""The field \u0060name" +
@"\u0060 does not exist on the type \u0060Query\u0060."",""locations"":[{" +
@"on-Objects-Interfaces-and-Unions-Types""}},{""message"":""The field `name" +
@"` does not exist on the type `Query`."",""locations"":[{" +
@"""line"":1,""column"":10}],""extensions"":{""type"":""Query""," +
@"""field"":""name"",""responseName"":""name"",""specifiedBy"":" +
@"""http://spec.graphql.org/October2021/#sec-Field-Selections-on-Objects-" +
@"Interfaces-and-Unions-Types""}},{""message"":""The argument \u0060name\u0060 " +
@"Interfaces-and-Unions-Types""}},{""message"":""The argument `name` " +
@"is required."",""locations"":[{""line"":1,""column"":3}],""extensions"":{" +
@"""type"":""Query"",""field"":""__type"",""argument"":""name""," +
@"""specifiedBy"":""http://spec.graphql.org/October2021/#sec-Required-Arguments""" +
Expand Down Expand Up @@ -293,7 +293,7 @@ public async Task UnsupportedAcceptHeaderValue()
Status Code: BadRequest
-------------------------->
{""errors"":[{""message"":""Unable to parse the accept header value " +
@"\u0060unsupported\u0060."",""extensions"":{""headerValue"":""unsupported""," +
@"`unsupported`."",""extensions"":{""headerValue"":""unsupported""," +
@"""code"":""HC0064""}}]}");
}

Expand Down Expand Up @@ -325,7 +325,7 @@ public async Task UnsupportedApplicationAcceptHeaderValue()
-------------------------->
Status Code: NotAcceptable
-------------------------->
{""errors"":[{""message"":""None of the \u0060Accept\u0060 header values is supported.""," +
{""errors"":[{""message"":""None of the `Accept` header values is supported.""," +
@"""extensions"":{""code"":""HC0063""}}]}");
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"errors":[{"message":"The type \u0060Xyz\u0060 does not exist.","extensions":{"typeName":"Xyz","code":"HC0060"}}]}
{"errors":[{"message":"The type `Xyz` does not exist.","extensions":{"typeName":"Xyz","code":"HC0060"}}]}
4 changes: 2 additions & 2 deletions src/HotChocolate/Core/src/Types/IReadOnlySchemaOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ public interface IReadOnlySchemaOptions

/// <inheritdoc cref="SchemaOptions.StripLeadingIFromInterface"/>
bool StripLeadingIFromInterface { get; }

/// <inheritdoc cref="SchemaOptions.EnableTrueNullability"/>
bool EnableTrueNullability { get; }

/// <inheritdoc cref="SchemaOptions.EnableTag"/>
bool EnableTag { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ internal static bool IsType(this IType type, TypeKind kind)
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool IsType(this IType type, TypeKind kind1, TypeKind kind2)
internal static bool IsType(this IType type, TypeKind kind1, TypeKind kind2)
{
if (type.Kind == kind1 || type.Kind == kind2)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ public IOutputType NonNullString

public IDictionary<string, object?> ContextData { get; set; } = default!;

public List<FieldInfoPair> CurrentFieldPairs { get; } = new();

public List<FieldInfoPair> NextFieldPairs { get; } = new();

public HashSet<FieldInfoPair> ProcessedFieldPairs { get; } = new();

public IList<FieldInfo> RentFieldInfoList()
{
var buffer = _buffers.Peek();
Expand Down Expand Up @@ -159,6 +165,9 @@ public void Clear()
InputFields.Clear();
_errors.Clear();
List.Clear();
CurrentFieldPairs.Clear();
NextFieldPairs.Clear();
ProcessedFieldPairs.Clear();
UnexpectedErrorsDetected = false;
Count = 0;
Max = 0;
Expand Down
40 changes: 38 additions & 2 deletions src/HotChocolate/Core/src/Validation/FieldInfo.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using HotChocolate.Language;
using HotChocolate.Types;

Expand All @@ -7,7 +8,7 @@ namespace HotChocolate.Validation;
/// The validation field info provides access to the field node and the type
/// information of the referenced field.
/// </summary>
public readonly struct FieldInfo
public readonly struct FieldInfo : IEquatable<FieldInfo>
{
/// <summary>
/// Initializes a new instance of <see cref="FieldInfo"/>
Expand Down Expand Up @@ -41,4 +42,39 @@ public FieldInfo(IType declaringType, IType type, FieldNode field)
/// Gets the field selection.
/// </summary>
public FieldNode Field { get; }
}

/// <summary>
/// Compares this field info to another field info.
/// </summary>
/// <param name="other">
/// The other field info.
/// </param>
/// <returns>
/// <c>true</c> if the field infos are equal.
/// </returns>
public bool Equals(FieldInfo other)
=> Field.Equals(other.Field) &&
DeclaringType.Equals(other.DeclaringType) &&
Type.Equals(other.Type);

/// <summary>
/// Compares this field info to another object.
/// </summary>
/// <param name="obj">
/// The other object.
/// </param>
/// <returns>
/// <c>true</c> if the field infos are equal.
/// </returns>
public override bool Equals(object? obj)
=> obj is FieldInfo other && Equals(other);

/// <summary>
/// Returns the hash code of this instance.
/// </summary>
/// <returns>
/// The hash code of this instance.
/// </returns>
public override int GetHashCode()
=> HashCode.Combine(Field, DeclaringType, Type);
}
67 changes: 67 additions & 0 deletions src/HotChocolate/Core/src/Validation/FieldInfoPair.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using System;

namespace HotChocolate.Validation;

/// <summary>
/// Represents a pair of field infos.
/// </summary>
public readonly struct FieldInfoPair : IEquatable<FieldInfoPair>
{
/// <summary>
/// Initializes a new instance of <see cref="FieldInfoPair"/>.
/// </summary>
/// <param name="fieldA">
/// The first field info.
/// </param>
/// <param name="fieldB">
/// The second field info.
/// </param>
public FieldInfoPair(FieldInfo fieldA, FieldInfo fieldB)
{
FieldA = fieldA;
FieldB = fieldB;
}

/// <summary>
/// Gets the first field info.
/// </summary>
public FieldInfo FieldA { get; }

/// <summary>
/// Gets the second field info.
/// </summary>
public FieldInfo FieldB { get; }

/// <summary>
/// Compares this field info pair to another field info pair.
/// </summary>
/// <param name="other">
/// The other field info pair.
/// </param>
/// <returns>
/// <c>true</c> if the field info pairs are equal.
/// </returns>
public bool Equals(FieldInfoPair other)
=> FieldA.Equals(other.FieldA) && FieldB.Equals(other.FieldB);

/// <summary>
/// Compares this field info pair to another object.
/// </summary>
/// <param name="obj">
/// The other object.
/// </param>
/// <returns>
/// <c>true</c> if the field info pairs are equal.
/// </returns>
public override bool Equals(object? obj)
=> obj is FieldInfoPair other && Equals(other);

/// <summary>
/// Returns the hash code for this field info pair.
/// </summary>
/// <returns>
/// The hash code for this field info pair.
/// </returns>
public override int GetHashCode()
=> HashCode.Combine(FieldA, FieldB);
}
15 changes: 15 additions & 0 deletions src/HotChocolate/Core/src/Validation/IDocumentValidatorContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,21 @@ public interface IDocumentValidatorContext : ISyntaxVisitorContext
/// </summary>
IDictionary<string, object?> ContextData { get; }

/// <summary>
/// When processing field merging this list holds the field pairs that are processed.
/// </summary>
List<FieldInfoPair> CurrentFieldPairs { get; }

/// <summary>
/// When processing field merging this list holds the field pairs that are processed next.
/// </summary>
List<FieldInfoPair> NextFieldPairs { get; }

/// <summary>
/// When processing field merging this set represents the already processed field pairs.
/// </summary>
HashSet<FieldInfoPair> ProcessedFieldPairs { get; }

/// <summary>
/// Rents a list of field infos.
/// </summary>
Expand Down
Loading

0 comments on commit dc73038

Please sign in to comment.