-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hot Chocolate 14 Migration #2348
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,7 +137,7 @@ public async ValueTask ExecuteMutateAsync(IMiddlewareContext context) | |
/// <returns> | ||
/// Returns the runtime field value. | ||
/// </returns> | ||
public static object? ExecuteLeafField(IPureResolverContext context) | ||
public static object? ExecuteLeafField(IResolverContext context) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The pure resolver context and the resolver context are now aligned. |
||
{ | ||
// This means this field is a scalar, so we don't need to do | ||
// anything for it. | ||
|
@@ -190,7 +190,7 @@ fieldValue.ValueKind is not (JsonValueKind.Undefined or JsonValueKind.Null)) | |
/// <returns> | ||
/// Returns a new json object. | ||
/// </returns> | ||
public object? ExecuteObjectField(IPureResolverContext context) | ||
public object? ExecuteObjectField(IResolverContext context) | ||
{ | ||
string dataSourceName = GraphQLUtils.GetDataSourceNameFromGraphQLContext(context, _runtimeConfigProvider.GetConfig()); | ||
DataSource ds = _runtimeConfigProvider.GetConfig().GetDataSourceFromDataSourceName(dataSourceName); | ||
|
@@ -226,7 +226,7 @@ fieldValue.ValueKind is not (JsonValueKind.Undefined or JsonValueKind.Null)) | |
/// <returns>The resolved list, a JSON array, returned as type 'object?'.</returns> | ||
/// <remarks>Return type is 'object?' instead of a 'List of JsonElements' because when this function returns JsonElement, | ||
/// the HC12 engine doesn't know how to handle the JsonElement and results in requests failing at runtime.</remarks> | ||
public object? ExecuteListField(IPureResolverContext context) | ||
public object? ExecuteListField(IResolverContext context) | ||
{ | ||
string dataSourceName = GraphQLUtils.GetDataSourceNameFromGraphQLContext(context, _runtimeConfigProvider.GetConfig()); | ||
DataSource ds = _runtimeConfigProvider.GetConfig().GetDataSourceFromDataSourceName(dataSourceName); | ||
|
@@ -267,7 +267,7 @@ private static void SetContextResult(IMiddlewareContext context, JsonDocument? r | |
} | ||
|
||
private static bool TryGetPropertyFromParent( | ||
IPureResolverContext context, | ||
IResolverContext context, | ||
out JsonElement propertyValue) | ||
{ | ||
JsonElement parent = context.Parent<JsonElement>(); | ||
|
@@ -444,7 +444,7 @@ public static InputObjectType InputObjectTypeFromIInputField(IInputField field) | |
/// CosmosDB does not utilize pagination metadata. So this function will return null | ||
/// when executing GraphQl queries against CosmosDB. | ||
/// </summary> | ||
private static IMetadata? GetMetadata(IPureResolverContext context) | ||
private static IMetadata? GetMetadata(IResolverContext context) | ||
{ | ||
if (context.Selection.ResponseName == QueryBuilder.PAGINATION_FIELD_NAME && context.Path.Parent is not null) | ||
{ | ||
|
@@ -493,7 +493,7 @@ public static InputObjectType InputObjectTypeFromIInputField(IInputField field) | |
/// </summary> | ||
/// <param name="context">Pure resolver context</param> | ||
/// <returns>Pagination metadata</returns> | ||
private static IMetadata GetMetadataObjectField(IPureResolverContext context) | ||
private static IMetadata GetMetadataObjectField(IResolverContext context) | ||
{ | ||
// Depth Levels: / 0 / 1 / 2 / 3 | ||
// Example Path: /books/items/items[0]/publishers | ||
|
@@ -515,7 +515,7 @@ private static IMetadata GetMetadataObjectField(IPureResolverContext context) | |
{ | ||
// This check handles when the current selection is a relationship field because in that case, | ||
// there will be no context data entry. | ||
// e.g. metadata for index 4 will not exist. only 3. | ||
// e.g. metadata for index 4 will not exist. only 3. | ||
// Depth: / 0 / 1 / 2 / 3 / 4 | ||
// Path: /books/items/items[0]/publishers/books | ||
string objectParentName = GetMetadataKey(context.Path) + "::" + context.Path.Parent!.Depth; | ||
|
@@ -562,7 +562,7 @@ private static string GetMetadataKey(IFieldSelection rootSelection) | |
/// context.Path -> /books depth(0) | ||
/// context.Selection -> books { items {id, title}} | ||
/// </summary> | ||
private static void SetNewMetadata(IPureResolverContext context, IMetadata? metadata) | ||
private static void SetNewMetadata(IResolverContext context, IMetadata? metadata) | ||
{ | ||
string metadataKey = GetMetadataKey(context.Selection) + "::" + context.Path.Depth; | ||
context.ContextData.Add(metadataKey, metadata); | ||
|
@@ -574,7 +574,7 @@ private static void SetNewMetadata(IPureResolverContext context, IMetadata? meta | |
/// </summary> | ||
/// <param name="context">Pure resolver context</param> | ||
/// <param name="metadata">Pagination metadata</param> | ||
private static void SetNewMetadataChildren(IPureResolverContext context, IMetadata? metadata) | ||
private static void SetNewMetadataChildren(IResolverContext context, IMetadata? metadata) | ||
{ | ||
// When context.Path is /entity/items the metadata key is "entity" | ||
// The context key will use the depth of "items" so that the provided | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using HotChocolate; | ||
using HotChocolate.Language; | ||
using HotChocolate.Types; | ||
|
||
|
@@ -13,7 +12,7 @@ namespace Azure.DataApiBuilder.Service.GraphQLBuilder.CustomScalars | |
/// </summary> | ||
public class SingleType : FloatTypeBase<float> | ||
{ | ||
public static readonly NameString TypeName = new("Single"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We removed NameString in Hot Chocolate 13 as this semantic string object just caused a lot of allocation. |
||
public static readonly string TypeName = new("Single"); | ||
public static readonly string SingleDescription = "IEEE 754 32 bit float"; | ||
|
||
public SingleType() | ||
|
@@ -27,7 +26,7 @@ public SingleType() | |
/// </summary> | ||
public SingleType(float min, float max) | ||
: this( | ||
TypeName.Value, | ||
TypeName, | ||
SingleDescription, | ||
min, | ||
max, | ||
|
@@ -39,7 +38,7 @@ public SingleType(float min, float max) | |
/// Initializes a new instance of the <see cref="SingleType"/> class. | ||
/// </summary> | ||
public SingleType( | ||
NameString name, | ||
string name, | ||
string? description = null, | ||
float min = float.MinValue, | ||
float max = float.MaxValue, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,11 +54,8 @@ public static string Target(FieldDefinitionNode field) | |
/// <returns>The name of the target object if the relationship is found, null otherwise.</returns> | ||
public static string? GetTarget(IInputField infield) | ||
{ | ||
Directive? directive = (Directive?)infield.Directives.FirstOrDefault(d => d.Name.Value == DirectiveName); | ||
DirectiveNode? directiveNode = directive?.ToNode(); | ||
ArgumentNode? arg = directiveNode?.Arguments.First(a => a.Name.Value == "target"); | ||
|
||
return (string?)arg?.Value.Value; | ||
Directive? directive = (Directive?)infield.Directives.FirstOrDefault(DirectiveName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The directive collection has now optimized lookup methods. which reduces the code needed to get things from type system members. |
||
return directive?.GetArgumentValue<string>("target"); | ||
} | ||
|
||
/// <summary> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With Hot Chocolate we have abstracted the authorization hooks to allow users to more easily bring in new. providers without the need to rely on ASP.NET core APIs