-
Notifications
You must be signed in to change notification settings - Fork 308
HotChocolate 16 Milestone 11 Migration #3136
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
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 |
|---|---|---|
|
|
@@ -117,14 +117,14 @@ private static IEnumerable<LabelledColumn> GenerateQueryColumns(SelectionSetNode | |
| [MemberNotNull(nameof(OrderByColumns))] | ||
| private void Init(IDictionary<string, object?> queryParams) | ||
| { | ||
| ISelection selection = _context.Selection; | ||
| Selection selection = _context.Selection; | ||
| ObjectType underlyingType = selection.Field.Type.NamedType<ObjectType>(); | ||
|
|
||
| IsPaginated = QueryBuilder.IsPaginationType(underlyingType); | ||
| OrderByColumns = new(); | ||
| if (IsPaginated) | ||
| { | ||
| FieldNode? fieldNode = ExtractQueryField(selection.SyntaxNode); | ||
| FieldNode? fieldNode = ExtractQueryField(selection.SyntaxNodes[0].Node); | ||
|
|
||
| if (fieldNode is not null) | ||
| { | ||
|
|
@@ -139,7 +139,7 @@ private void Init(IDictionary<string, object?> queryParams) | |
| } | ||
| else | ||
| { | ||
| Columns.AddRange(GenerateQueryColumns(selection.SyntaxNode.SelectionSet!, _context.Operation.Document, SourceAlias)); | ||
| Columns.AddRange(GenerateQueryColumns(selection.SyntaxNodes[0].Node.SelectionSet!, _context.Operation.Document, SourceAlias)); | ||
|
Contributor
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. Does this accessor need a guard or helper? |
||
| string typeName = GraphQLUtils.TryExtractGraphQLFieldModelName(underlyingType.Directives, out string? modelName) ? | ||
| modelName : | ||
| underlyingType.Name; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -126,7 +126,7 @@ public SqlQueryStructure( | |
| sqlMetadataProvider, | ||
| authorizationResolver, | ||
| ctx.Selection.Field, | ||
| ctx.Selection.SyntaxNode, | ||
| ctx.Selection.SyntaxNodes[0].Node, | ||
|
Collaborator
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. Is SyntaxNodes guaranteed to have at least 1 node?
Contributor
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. Perhaps using |
||
| // The outermost query is where we start, so this can define | ||
| // create the IncrementingInteger that will be shared between | ||
| // all subqueries in this query. | ||
|
|
@@ -173,7 +173,7 @@ public SqlQueryStructure( | |
| IsMultipleCreateOperation = isMultipleCreateOperation; | ||
|
|
||
| ObjectField schemaField = _ctx.Selection.Field; | ||
| FieldNode? queryField = _ctx.Selection.SyntaxNode; | ||
| FieldNode? queryField = _ctx.Selection.SyntaxNodes[0].Node; | ||
|
Contributor
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. Does this accessor need a guard or helper? |
||
|
|
||
| IOutputType outputType = schemaField.Type; | ||
| _underlyingFieldType = outputType.NamedType<ObjectType>(); | ||
|
|
@@ -182,7 +182,7 @@ public SqlQueryStructure( | |
|
|
||
| if (PaginationMetadata.IsPaginated) | ||
| { | ||
| if (queryField != null && queryField.SelectionSet != null) | ||
| if (queryField.SelectionSet != null) | ||
| { | ||
| // process pagination fields without overriding them | ||
| ProcessPaginationFields(queryField.SelectionSet.Selections); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ public async ValueTask InvokeAsync(RequestContext context) | |
| } | ||
|
|
||
| contextData[ExecutionContextData.HttpStatusCode] = HttpStatusCode.BadRequest; | ||
| context.Result = singleResult.WithContextData(contextData.ToImmutable()); | ||
| singleResult.ContextData = contextData.ToImmutable(); | ||
|
Contributor
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. Can you confirm this is the intended HC16 approach and that the mutated result is guaranteed to be the one returned on context.Result? |
||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,8 +100,8 @@ public static FieldDefinitionNode GenerateStoredProcedureSchema( | |
|
|
||
| /// <summary> | ||
| /// Takes the result from DB as JsonDocument and formats it in a way that can be filtered by column | ||
| /// name. It parses the Json document into a list of Dictionary with key as result_column_name | ||
| /// with it's corresponding value. | ||
| /// name. It parses the JSON document into a list of Dictionary with key as result_column_name | ||
| /// with its corresponding value. | ||
| /// returns an empty list in case of no result | ||
| /// or stored-procedure is trying to read from DB without READ permission. | ||
| /// </summary> | ||
|
|
@@ -156,12 +156,12 @@ private static Tuple<string, IValueNode> ConvertValueToGraphQLType(string defaul | |
| { | ||
| Tuple<string, IValueNode> valueNode = paramValueType switch | ||
| { | ||
| UUID_TYPE => new(UUID_TYPE, new UuidType().ParseValue(Guid.Parse(defaultValueFromConfig))), | ||
| UUID_TYPE => new(UUID_TYPE, new UuidType().ValueToLiteral(Guid.Parse(defaultValueFromConfig))), | ||
| BYTE_TYPE => new(BYTE_TYPE, new IntValueNode(byte.Parse(defaultValueFromConfig))), | ||
| SHORT_TYPE => new(SHORT_TYPE, new IntValueNode(short.Parse(defaultValueFromConfig))), | ||
| INT_TYPE => new(INT_TYPE, new IntValueNode(int.Parse(defaultValueFromConfig))), | ||
| LONG_TYPE => new(LONG_TYPE, new IntValueNode(long.Parse(defaultValueFromConfig))), | ||
| SINGLE_TYPE => new(SINGLE_TYPE, new SingleType().ParseValue(float.Parse(defaultValueFromConfig))), | ||
| SINGLE_TYPE => new(SINGLE_TYPE, new SingleType().ValueToLiteral(float.Parse(defaultValueFromConfig))), | ||
| FLOAT_TYPE => new(FLOAT_TYPE, new FloatValueNode(double.Parse(defaultValueFromConfig))), | ||
| DECIMAL_TYPE => new(DECIMAL_TYPE, new FloatValueNode(decimal.Parse(defaultValueFromConfig))), | ||
| STRING_TYPE => new(STRING_TYPE, new StringValueNode(defaultValueFromConfig)), | ||
|
|
@@ -174,10 +174,10 @@ var s when s.Equals("true", StringComparison.OrdinalIgnoreCase) => true, | |
| var s when s.Equals("false", StringComparison.OrdinalIgnoreCase) => false, | ||
| _ => throw new FormatException($"String '{defaultValueFromConfig}' was not recognized as a valid Boolean.") | ||
| })), | ||
| DATETIME_TYPE => new(DATETIME_TYPE, new DateTimeType().ParseResult( | ||
| DATETIME_TYPE => new(DATETIME_TYPE, new DateTimeType().ValueToLiteral( | ||
| DateTime.Parse(defaultValueFromConfig, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.AssumeUniversal))), | ||
| BYTEARRAY_TYPE => new(BYTEARRAY_TYPE, new ByteArrayType().ParseValue(Convert.FromBase64String(defaultValueFromConfig))), | ||
| LOCALTIME_TYPE => new(LOCALTIME_TYPE, new HotChocolate.Types.NodaTime.LocalTimeType().ParseResult(LocalTimePattern.ExtendedIso.Parse(defaultValueFromConfig).Value)), | ||
|
Collaborator
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. Do both |
||
| BYTEARRAY_TYPE => new(BYTEARRAY_TYPE, new Base64StringType().ValueToLiteral(Convert.FromBase64String(defaultValueFromConfig))), | ||
| LOCALTIME_TYPE => new(LOCALTIME_TYPE, new HotChocolate.Types.NodaTime.LocalTimeType().ValueToLiteral(LocalTimePattern.ExtendedIso.Parse(defaultValueFromConfig).Value)), | ||
| _ => throw new NotSupportedException(message: $"The {defaultValueFromConfig} parameter's value type [{paramValueType}] is not supported.") | ||
| }; | ||
|
|
||
|
|
||
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.
Same as the SQL Structure, should we consider a guard or helper around SyntaxNodes in case it is empty or to indicate that we expect just one?