-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move code for generation of the APQ extension into GraphQLRequest
- Loading branch information
Showing
9 changed files
with
94 additions
and
36 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,34 @@ | ||
#if NET6_0_OR_GREATER | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace GraphQL; | ||
|
||
/// <summary> | ||
/// Value record for a GraphQL query string | ||
/// Value object representing a GraphQL query string and storing the corresponding APQ hash. <br /> | ||
/// Use this to hold query strings you want to use more than once. | ||
/// </summary> | ||
/// <param name="Text">the actual query string</param> | ||
public readonly record struct GraphQLQuery([StringSyntax("GraphQL")] string Text) | ||
public class GraphQLQuery : IEquatable<GraphQLQuery> | ||
{ | ||
/// <summary> | ||
/// The actual query string | ||
/// </summary> | ||
public string Text { get; } | ||
|
||
/// <summary> | ||
/// The SHA256 hash used for the advanced persisted queries feature (APQ) | ||
/// </summary> | ||
public string Sha256Hash { get; } | ||
|
||
public GraphQLQuery([StringSyntax("GraphQL")] string text) | ||
{ | ||
Text = text; | ||
Sha256Hash = Hash.Compute(Text); | ||
} | ||
|
||
public static implicit operator string(GraphQLQuery query) | ||
=> query.Text; | ||
}; | ||
#endif | ||
|
||
public bool Equals(GraphQLQuery other) => Sha256Hash == other.Sha256Hash; | ||
|
||
public override bool Equals(object? obj) => obj is GraphQLQuery other && Equals(other); | ||
|
||
public override int GetHashCode() => Sha256Hash.GetHashCode(); | ||
} |
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