-
-
Notifications
You must be signed in to change notification settings - Fork 744
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Operation Compiler for Conditional Selections. (#5977)
- Loading branch information
1 parent
bd27dc5
commit 106f0ed
Showing
20 changed files
with
487 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
src/HotChocolate/Core/src/Execution/Processing/SelectionPath.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using System; | ||
using HotChocolate.Utilities; | ||
|
||
namespace HotChocolate.Execution.Processing; | ||
|
||
/// <summary> | ||
/// Represents GraphQL selection path which is used in the operation compiler. | ||
/// </summary> | ||
public sealed class SelectionPath : IEquatable<SelectionPath> | ||
{ | ||
private SelectionPath(string name, SelectionPath? parent = null) | ||
{ | ||
Name = name; | ||
Parent = parent; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the name of the current path segment. | ||
/// </summary> | ||
public string Name { get; } | ||
|
||
/// <summary> | ||
/// Gets the parent path segment. | ||
/// </summary> | ||
public SelectionPath? Parent { get; } | ||
|
||
/// <summary> | ||
/// Gets the root path segment. | ||
/// </summary> | ||
public static SelectionPath Root { get; } = new("$root"); | ||
|
||
/// <summary> | ||
/// Creates a new path segment. | ||
/// </summary> | ||
/// <param name="name"> | ||
/// The name of the path segment. | ||
/// </param> | ||
/// <returns> | ||
/// Returns a new path segment. | ||
/// </returns> | ||
public SelectionPath Append(string name) => new(name, this); | ||
|
||
/// <summary> | ||
/// Indicates whether the current path is equal to another path. | ||
/// </summary> | ||
/// <param name="other">A path to compare with this path.</param> | ||
/// <returns> | ||
/// <see langword="true" /> if the current path is equal to the | ||
/// <paramref name="other" /> parameter; otherwise, <see langword="false" />. | ||
/// </returns> | ||
public bool Equals(SelectionPath? other) | ||
{ | ||
if (other is null) | ||
{ | ||
return false; | ||
} | ||
|
||
if (ReferenceEquals(this, other)) | ||
{ | ||
return true; | ||
} | ||
|
||
if (Name.EqualsOrdinal(other.Name)) | ||
{ | ||
if (ReferenceEquals(Parent, other.Parent)) | ||
{ | ||
return true; | ||
} | ||
|
||
return Equals(Parent, other.Parent); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
/// <summary> | ||
/// Indicates whether the current path is equal to another path. | ||
/// </summary> | ||
/// <param name="obj"> | ||
/// An object to compare with this path. | ||
/// </param> | ||
/// <returns> | ||
/// <see langword="true" /> if the current path is equal to the | ||
/// <paramref name="obj" /> parameter; otherwise, <see langword="false" />. | ||
/// </returns> | ||
public override bool Equals(object? obj) | ||
=> Equals(obj as SelectionPath); | ||
|
||
/// <summary> | ||
/// Returns the hash code for this path. | ||
/// </summary> | ||
/// <returns></returns> | ||
public override int GetHashCode() | ||
=> HashCode.Combine(Name, Parent); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/HotChocolate/Core/src/Execution/Properties/Resources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.