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

Fix naming issues with generic types #6461

Merged
merged 7 commits into from
Aug 21, 2023
Merged

Conversation

N-Olbert
Copy link
Contributor

Summary of the changes (Less than 80 chars)

  • Dynamically determine the index of the `-char
  • Consider GraphQLNameAttribute for generic types

Closes #6392 and #6293

Determine the length of the generic type postfix delimiter instead of using a hardcoded length. Added unittest.
Consider GraphQLNameAttribute for generic types.
@CLAassistant
Copy link

CLAassistant commented Aug 20, 2023

CLA assistant check
All committers have signed the CLA.

@michaelstaib
Copy link
Member

Thanks for contributing.

I have one issue with the PR. This should be named Bar. It is in any case a bad schema design to expose these generated names ... but this takes away the ability to fix the name. Further, it breaks behavior, effecting everyone who uses this behavior without a way out of this.

[GraphQLName("Bar")] // Note
    public class Foo<T>
    {
        public T Test { get; init; }
    }

I know that this can be many types .... But we cannot break behavior here.

@github-actions
Copy link

HotChocolate.Subscriptions.Postgres.BackgroundTaskTests.RunContinuously_Should_WaitForASecond_When_HandlerThrowsException [FAIL]

@github-actions
Copy link

HotChocolate.Execution.Integration.StarWarsCodeFirst.StarWarsCodeFirstTests.Depth_Analysis_Overrides_Are_Not_Cached [FAIL]

@codecov
Copy link

codecov bot commented Aug 21, 2023

Codecov Report

Patch coverage: 86.36% and project coverage change: -0.03% ⚠️

Comparison is base (1e78ece) 78.99% compared to head (98dfd6b) 78.96%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6461      +/-   ##
==========================================
- Coverage   78.99%   78.96%   -0.03%     
==========================================
  Files        2911     2897      -14     
  Lines      139228   138627     -601     
==========================================
- Hits       109978   109464     -514     
+ Misses      29250    29163      -87     
Flag Coverage Δ
unittests 78.96% <86.36%> (-0.03%) ⬇️

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

Files Changed Coverage Δ
...ate/Core/src/Abstractions/NameFormattingHelpers.cs 88.69% <86.36%> (ø)

... and 37 files with indirect coverage changes

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

@N-Olbert
Copy link
Contributor Author

@michaelstaib We could introduce a property to configure this, how about (naming is for sure not the best)

[GraphQLName("Bar", IncludeTypeParameterNaming = true)]
public class Foo<T>
{
    public T Test { get; init; }
}

IncludeTypeParameterNaming = true becomes BarOfType
IncludeTypeParameterNaming = false (default) becomes Bar

@github-actions
Copy link

HotChocolate.Subscriptions.Postgres.BackgroundTaskTests.RunContinuously_Should_WaitForASecond_When_HandlerThrowsException [FAIL]

@github-actions
Copy link

HotChocolate.Execution.Integration.DataLoader.DataLoaderTests.ClassDataLoader_Resolve_From_DependencyInjection [FAIL]

@michaelstaib
Copy link
Member

I sat down with @PascalSenn to discuss it a bit ... we can still pin the legacy behavior, which is important to get this into a dot release. I modified the test a bit to include this pinning behavior. We will merge it once the build is done.

@sonarcloud
Copy link

sonarcloud bot commented Aug 21, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@michaelstaib michaelstaib merged commit a13fa04 into ChilliCream:main Aug 21, 2023
@michaelstaib
Copy link
Member

@michaelstaib
Copy link
Member

Thanks again for contributing!

This was referenced Sep 10, 2023
renovate bot referenced this pull request in orso-co/Orso.Arpa.Api Sep 16, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [HotChocolate.Abstractions](https://chillicream.com/)
([source](https://github.com/ChilliCream/graphql-platform)) | nuget |
minor | `13.4.0` -> `13.5.1` |
| [HotChocolate.AspNetCore](https://chillicream.com/)
([source](https://github.com/ChilliCream/graphql-platform)) | nuget |
minor | `13.4.0` -> `13.5.1` |
| [HotChocolate.AspNetCore.Authorization](https://chillicream.com/)
([source](https://github.com/ChilliCream/graphql-platform)) | nuget |
minor | `13.4.0` -> `13.5.1` |
| [HotChocolate.Data](https://chillicream.com/)
([source](https://github.com/ChilliCream/graphql-platform)) | nuget |
minor | `13.4.0` -> `13.5.1` |
| [HotChocolate.Data.EntityFramework](https://chillicream.com/)
([source](https://github.com/ChilliCream/graphql-platform)) | nuget |
minor | `13.4.0` -> `13.5.1` |
| [HotChocolate.Types](https://chillicream.com/)
([source](https://github.com/ChilliCream/graphql-platform)) | nuget |
minor | `13.4.0` -> `13.5.1` |

---

### Release Notes

<details>
<summary>ChilliCream/graphql-platform
(HotChocolate.Abstractions)</summary>

###
[`v13.5.1`](https://github.com/ChilliCream/graphql-platform/releases/tag/13.5.1)

[Compare
Source](https://github.com/ChilliCream/graphql-platform/compare/13.5.0...13.5.1)

##### What's Changed

- StrawberryShake public access modifier must be default. by
[@&#8203;michaelstaib](https://github.com/michaelstaib) in
[https://github.com/ChilliCream/graphql-platform/pull/6472](https://github.com/ChilliCream/graphql-platform/pull/6472)

**Full Changelog**:
ChilliCream/graphql-platform@13.5.0...13.5.1

###
[`v13.5.0`](https://github.com/ChilliCream/graphql-platform/releases/tag/13.5.0)

[Compare
Source](https://github.com/ChilliCream/graphql-platform/compare/13.4.0...13.5.0)

#### What's Changed

- Added GraphQL Request Field Limit. by
[@&#8203;michaelstaib](https://github.com/michaelstaib) in
[https://github.com/ChilliCream/graphql-platform/pull/6381](https://github.com/ChilliCream/graphql-platform/pull/6381)
- Fixed Subscription Complete Issue for ValueType Message. by
[@&#8203;michaelstaib](https://github.com/michaelstaib) in
[https://github.com/ChilliCream/graphql-platform/pull/6383](https://github.com/ChilliCream/graphql-platform/pull/6383)
- Optimized the Type Module Source Generator by
[@&#8203;michaelstaib](https://github.com/michaelstaib) in
[https://github.com/ChilliCream/graphql-platform/pull/6388](https://github.com/ChilliCream/graphql-platform/pull/6388)
- Adds postgres transport for subscriptions by
[@&#8203;PascalSenn](https://github.com/PascalSenn) in
[https://github.com/ChilliCream/graphql-platform/pull/6387](https://github.com/ChilliCream/graphql-platform/pull/6387)
- Expose internals of Fusion to BCP services by
[@&#8203;PascalSenn](https://github.com/PascalSenn) in
[https://github.com/ChilliCream/graphql-platform/pull/6390](https://github.com/ChilliCream/graphql-platform/pull/6390)
- Include .NET 8.0 tools in StrawberryShake package by
[@&#8203;repne](https://github.com/repne) in
[https://github.com/ChilliCream/graphql-platform/pull/6395](https://github.com/ChilliCream/graphql-platform/pull/6395)
- Upgrade default BCP middleware version by
[@&#8203;PascalSenn](https://github.com/PascalSenn) in
[https://github.com/ChilliCream/graphql-platform/pull/6410](https://github.com/ChilliCream/graphql-platform/pull/6410)
- Scope the projection selection properly when using the mutation
conventions. by [@&#8203;hahn-kev](https://github.com/hahn-kev) in
[https://github.com/ChilliCream/graphql-platform/pull/6444](https://github.com/ChilliCream/graphql-platform/pull/6444)
- Reintroduce RequestContextAccessor by
[@&#8203;michaelstaib](https://github.com/michaelstaib) in
[https://github.com/ChilliCream/graphql-platform/pull/6454](https://github.com/ChilliCream/graphql-platform/pull/6454)
- Publicly expose ability to register an error type on a mutation field
by [@&#8203;benmccallum](https://github.com/benmccallum) in
[https://github.com/ChilliCream/graphql-platform/pull/6463](https://github.com/ChilliCream/graphql-platform/pull/6463)
- Removed Path Pooling by
[@&#8203;michaelstaib](https://github.com/michaelstaib) in
[https://github.com/ChilliCream/graphql-platform/pull/6394](https://github.com/ChilliCream/graphql-platform/pull/6394)
- Fixed naming issues with generic types by
[@&#8203;N-Olbert](https://github.com/N-Olbert) in
[https://github.com/ChilliCream/graphql-platform/pull/6461](https://github.com/ChilliCream/graphql-platform/pull/6461)
- Fixed Batch Pool for DataLoader was cleared to early. by
[@&#8203;michaelstaib](https://github.com/michaelstaib) in
[https://github.com/ChilliCream/graphql-platform/pull/6465](https://github.com/ChilliCream/graphql-platform/pull/6465)
- Added configurable access for generated Strawberry Shake clients
([#&#8203;6374](https://github.com/ChilliCream/graphql-platform/issues/6374))
by [@&#8203;nih0n](https://github.com/nih0n) in
[https://github.com/ChilliCream/graphql-platform/pull/6416](https://github.com/ChilliCream/graphql-platform/pull/6416)

**Full Changelog**:
ChilliCream/graphql-platform@13.4.0...13.5.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 10pm every weekday,every
weekend,before 5am every weekday" in timezone Europe/Berlin, Automerge -
At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/orso-co/Orso.Arpa.Api).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi44My4wIiwidXBkYXRlZEluVmVyIjoiMzYuODMuMCIsInRhcmdldEJyYW5jaCI6ImRldmVsb3AifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@ZhelninMaksim
Copy link

Is there any way I can skip or override this behavior? In the last version, I defined the names for such types myself and would like to keep that behavior, is it possible?

@N-Olbert
Copy link
Contributor Author

@ZhelninMaksim : You may overwrite the name using a custom attribute. This has precedence.

public sealed class CustomGenericTypeName : DescriptorAttribute
{
    public string Name {get; init;} = default!;

    protected override void TryConfigure(IDescriptorContext context, IDescriptor descriptor, ICustomAttributeProvider element)
    {
        if (descriptor is IObjectTypeDescriptor d)
        {
            d.Name(Name);
        }
    }
}

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

Successfully merging this pull request may close these issues.

Generated name is wrong for generic types with many type parameters
4 participants