Skip to content
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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

michaelstaib
Copy link
Collaborator

@michaelstaib michaelstaib commented Aug 23, 2024

Why make this change?

With Hot Chocolate 14 we have invested a lot into security, performance and GraphQL protocol standards.

What is this change?

This PR will modernize the GraphQL stack of dab.

How was this tested?

  • Integration Tests
  • Unit Tests

@@ -197,263 +196,260 @@ public static bool CreateAuthorizationDirectiveIfNecessary(
/// <returns>True when name resolution succeeded, false otherwise.</returns>
public static bool TryExtractGraphQLFieldModelName(IDirectiveCollection fieldDirectives, [NotNullWhen(true)] out string? modelName)
{
foreach (Directive dir in fieldDirectives)
foreach (Directive dir in fieldDirectives[ModelDirectiveType.DirectiveName])
Copy link
Collaborator Author

@michaelstaib michaelstaib Aug 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Needs Discussion] The original code here looked wrong ... lets chat about the intention here.

@michaelstaib
Copy link
Collaborator Author

@Aniruddh25, I will probably complete it this with whom shall I go through changes and questions?

Nuget.config Outdated Show resolved Hide resolved
@@ -189,7 +189,7 @@ private void OnNewFileContentsDetected(object? sender, EventArgs e)
/// <returns>True if the config was loaded, otherwise false.</returns>
public bool TryLoadConfig(
string path,
[NotNullWhen(true)] out RuntimeConfig? outConfig,
[NotNullWhen(true)] out RuntimeConfig? config,
Copy link
Collaborator Author

@michaelstaib michaelstaib Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Info] I changed the name here to bring it back into alignment with the XML docs

IReadOnlyList<AuthorizeDirective> directives,
CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
Copy link
Collaborator Author

@michaelstaib michaelstaib Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[TODO] This needs an implementation still

@@ -683,6 +683,7 @@ void ProcessPaginationFields(IReadOnlyList<ISelectionNode> paginationSelections)
/// takes place which is required to fetch nested data.
/// </summary>
/// <param name="selections">Fields selection in the GraphQL Query.</param>
// TODO : This is inefficient and could lead to errors. we should rewrite this to use the ISelection API.
Copy link
Collaborator Author

@michaelstaib michaelstaib Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[TODO] This needs a rewrite on top of ISelection

@@ -378,8 +378,8 @@ private void TestTypeNameChanges(DatabaseObject databaseobject, string objectNam
Assert.IsTrue(namespaceString.Contains("Azure.DataApiBuilder.Config.DatabasePrimitives"));
Assert.AreEqual(namespaceString, "Azure.DataApiBuilder.Config.DatabasePrimitives." + objectName);

string projectNameString = typeNameSplitParts[1].Trim();
Assert.AreEqual(projectNameString, "Azure.DataApiBuilder.Config");
string projectstring = typeNameSplitParts[1].Trim();
Copy link
Collaborator Author

@michaelstaib michaelstaib Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[TODO] Why change this?

@@ -277,7 +277,6 @@ private void AddGraphQLService(IServiceCollection services, GraphQLRuntimeOption
})
.AddHttpRequestInterceptor<IntrospectionInterceptor>()
.AddAuthorization()
.AllowIntrospection(false)
Copy link
Collaborator Author

@michaelstaib michaelstaib Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Needs Discussion] AllowIntrospection is no longer needed. With HC 14 we have this as a default for production environment. There are a couple of other changes around this that we should discuss.

// Allows DAB to override the HTTP error code set by HotChocolate.
// This is used to ensure HTTP code 4XX is set when the datatbase
// returns a "bad request" error such as stored procedure params missing.
.UseRequest<DetermineStatusCodeMiddleware>()
Copy link
Collaborator Author

@michaelstaib michaelstaib Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Info] This middleware replaces the serializer. In HC 14 we can hint status codes we would want to use if the execution runs on the HTTP transport. This allows us to centralize the whole execution flow in one place.

@michaelstaib
Copy link
Collaborator Author

@JerryNixon can you trigger the tests on this?

@Aniruddh25
Copy link
Contributor

/azp run

@sezal98
Copy link
Contributor

sezal98 commented Dec 31, 2024

/azp run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants