Skip to content

fix: #8264 - fully qualified string not used for types in dataloader generator #8265

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

Conversation

svihpinc
Copy link
Contributor

Summary of the changes (Less than 80 chars)

  • To always get the correct types in generator dataloaders, use the fully qualified string for all types

Closes #8264 (in this specific format)

@CLAassistant
Copy link

CLAassistant commented Apr 26, 2025

CLA assistant check
All committers have signed the CLA.

@svihpinc svihpinc force-pushed the fix-#8264-fully-qualified-string-not-used-for-types-in-dataloader-generator branch from ba643d0 to 562d9ba Compare April 26, 2025 12:23
@michaelstaib
Copy link
Member

Can you add a nullable test case? for both structs and classes?

They should go here:
https://github.com/ChilliCream/graphql-platform/blob/main/src/HotChocolate/Core/test/Types.Analyzers.Tests/DataLoaderTests.cs

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that fully qualified type names are used consistently in DataLoader generators to address issue #8264. Key changes include:

  • Updating snapshot files to use fully qualified type strings for resultMap parameters.
  • Adding a new extension method, ToFullyQualifiedWithNullRefQualifier, in SymbolExtensions.cs.
  • Refactoring DataLoaderFileBuilder to utilize the new helper instead of a hardcoded "global::" prefix.

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

File Description
snapshots/DataLoaderTests.*.md Updated snapshots to include fully qualified type names.
SymbolExtensions.cs Added an extension method for fully qualified type formatting with null ref qualifier.
DataLoaderFileBuilder.cs Updated to use the new extension method for the resultMap parameter.
Comments suppressed due to low confidence (1)

src/HotChocolate/Core/src/Types.Analyzers/Helpers/SymbolExtensions.cs:35

  • Consider adding unit tests for the new ToFullyQualifiedWithNullRefQualifier method to verify its behavior across various type scenarios.
public static string ToFullyQualifiedWithNullRefQualifier(this ITypeSymbol typeSymbol)

@svihpinc
Copy link
Contributor Author

svihpinc commented May 3, 2025

@michaelstaib nullable test cases are already present, eg:

public static Task<Dictionary<int, string?>> GetEntityByIdAsync(

But those tests are for string? type. Do you mean specifically nullable struct and class types?

@svihpinc
Copy link
Contributor Author

svihpinc commented May 3, 2025

@michaelstaib added a test case for #8264 issue, also covers nullable class type

@michaelstaib michaelstaib added this to the HC-15.1.4 milestone May 7, 2025
@michaelstaib michaelstaib added the 🍒 cherry-pick Consider cherry-picking these changes into the previous major version. label May 7, 2025
@michaelstaib michaelstaib merged commit de2a711 into ChilliCream:main May 15, 2025
104 checks passed
Copy link

codecov bot commented May 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (6a3b7a3) to head (89d9291).
Report is 68 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #8265       +/-   ##
==========================================
- Coverage   74.16%       0   -74.17%     
==========================================
  Files        2677       0     -2677     
  Lines      140790       0   -140790     
  Branches    16371       0    -16371     
==========================================
- Hits       104421       0   -104421     
+ Misses      30774       0    -30774     
+ Partials     5595       0     -5595     
Flag Coverage Δ
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 cherry-pick Consider cherry-picking these changes into the previous major version. 🌶️ hot chocolate 🧰 maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataLoader generated source does not include fully qualified type of resultMap, causing build error
3 participants