-
-
Notifications
You must be signed in to change notification settings - Fork 749
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed naming issues with generic types (#6461)
Co-authored-by: Michael Staib <[email protected]>
- Loading branch information
1 parent
1e78ece
commit a13fa04
Showing
3 changed files
with
240 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/HotChocolate/Core/test/Types.Tests/GenericTypeNamingTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using HotChocolate.Execution; | ||
using HotChocolate.Tests; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
#nullable enable | ||
|
||
namespace HotChocolate; | ||
|
||
public class GenericTypesNamingTests | ||
{ | ||
[Fact] | ||
public async Task NamingResolution() | ||
{ | ||
await new ServiceCollection() | ||
.AddGraphQL() | ||
.AddQueryType<Query>() | ||
.BuildSchemaAsync() | ||
.MatchSnapshotAsync(); | ||
} | ||
|
||
public class Query | ||
{ | ||
public Tuple<int> OneGenericType => default!; | ||
public Tuple<int, int> TwoGenericsType => default!; | ||
public Tuple<int, int, int> ThreeGenericsType => default!; | ||
public Tuple<int, int, int, int> FourGenericsType => default!; | ||
public Tuple<int, int, int, int, int> FiveGenericTypes => default!; | ||
public Tuple<int, int, int, int, int, int> SixGenericTypes => default!; | ||
public Tuple<int, int, int, int, int, int, int> SevenGenericTypes => default!; | ||
public EightElementsTuple<int, int, int, int, int, int, int, int> EightGenericTypes => default!; | ||
public NineElementsTuple<int, int, int, int, int, int, int, int, int> NineGenericTypes => default!; | ||
public TenElementsTuple<int, int, int, int, int, int, int, int, int, int> TenGenericTypes => default!; | ||
public Foo<int> IntBar => default!; | ||
public Foo<string> StringBar => default!; | ||
public Foo<Bar> CustomNameBar => default!; | ||
} | ||
|
||
public class EightElementsTuple<T1, T2, T3, T4, T5, T6, T7, T8> : Tuple<T1, T2, T3, T4, T5, T6, T7> | ||
{ | ||
public T8 Item8 { get; set; } = default!; | ||
|
||
public EightElementsTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8) | ||
: base(item1, item2, item3, item4, item5, item6, item7) | ||
{ | ||
Item8 = item8; | ||
} | ||
} | ||
|
||
public class NineElementsTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> : EightElementsTuple<T1, T2, T3, T4, T5, T6, T7, T8> | ||
{ | ||
public T9 Item9 { get; set; } = default!; | ||
|
||
public NineElementsTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8, T9 item9) | ||
: base(item1, item2, item3, item4, item5, item6, item7, item8) | ||
{ | ||
Item9 = item9; | ||
} | ||
} | ||
|
||
public class TenElementsTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> : NineElementsTuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> | ||
{ | ||
public T10 Item10 { get; set; } = default!; | ||
|
||
public TenElementsTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8, T9 item9, T10 item10) | ||
: base(item1, item2, item3, item4, item5, item6, item7, item8, item9) | ||
{ | ||
Item10 = item10; | ||
} | ||
} | ||
|
||
[GraphQLName("Bar")] | ||
public class Foo<T> | ||
{ | ||
public T Test { get; init; } | ||
} | ||
|
||
[GraphQLName("MyType")] | ||
public class Bar | ||
{ | ||
public int Test { get; init; } | ||
} | ||
} |
120 changes: 120 additions & 0 deletions
120
...ocolate/Core/test/Types.Tests/__snapshots__/GenericTypesNamingTests.NamingResolution.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
schema { | ||
query: Query | ||
} | ||
|
||
type BarOfInt32 { | ||
test: Int! | ||
} | ||
|
||
type BarOfMyType { | ||
test: MyType! | ||
} | ||
|
||
type BarOfString { | ||
test: String! | ||
} | ||
|
||
type EightElementsTupleOfInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32 { | ||
item8: Int! | ||
item1: Int! | ||
item2: Int! | ||
item3: Int! | ||
item4: Int! | ||
item5: Int! | ||
item6: Int! | ||
item7: Int! | ||
} | ||
|
||
type MyType { | ||
test: Int! | ||
} | ||
|
||
type NineElementsTupleOfInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32 { | ||
item9: Int! | ||
item8: Int! | ||
item1: Int! | ||
item2: Int! | ||
item3: Int! | ||
item4: Int! | ||
item5: Int! | ||
item6: Int! | ||
item7: Int! | ||
} | ||
|
||
type Query { | ||
oneGenericType: TupleOfInt32! | ||
twoGenericsType: TupleOfInt32AndInt32! | ||
threeGenericsType: TupleOfInt32AndInt32AndInt32! | ||
fourGenericsType: TupleOfInt32AndInt32AndInt32AndInt32! | ||
fiveGenericTypes: TupleOfInt32AndInt32AndInt32AndInt32AndInt32! | ||
sixGenericTypes: TupleOfInt32AndInt32AndInt32AndInt32AndInt32AndInt32! | ||
sevenGenericTypes: TupleOfInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32! | ||
eightGenericTypes: EightElementsTupleOfInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32! | ||
nineGenericTypes: NineElementsTupleOfInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32! | ||
tenGenericTypes: TenElementsTupleOfInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32! | ||
intBar: BarOfInt32! | ||
stringBar: BarOfString! | ||
customNameBar: BarOfMyType! | ||
} | ||
|
||
type TenElementsTupleOfInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32 { | ||
item10: Int! | ||
item9: Int! | ||
item8: Int! | ||
item1: Int! | ||
item2: Int! | ||
item3: Int! | ||
item4: Int! | ||
item5: Int! | ||
item6: Int! | ||
item7: Int! | ||
} | ||
|
||
type TupleOfInt32 { | ||
item1: Int! | ||
} | ||
|
||
type TupleOfInt32AndInt32 { | ||
item1: Int! | ||
item2: Int! | ||
} | ||
|
||
type TupleOfInt32AndInt32AndInt32 { | ||
item1: Int! | ||
item2: Int! | ||
item3: Int! | ||
} | ||
|
||
type TupleOfInt32AndInt32AndInt32AndInt32 { | ||
item1: Int! | ||
item2: Int! | ||
item3: Int! | ||
item4: Int! | ||
} | ||
|
||
type TupleOfInt32AndInt32AndInt32AndInt32AndInt32 { | ||
item1: Int! | ||
item2: Int! | ||
item3: Int! | ||
item4: Int! | ||
item5: Int! | ||
} | ||
|
||
type TupleOfInt32AndInt32AndInt32AndInt32AndInt32AndInt32 { | ||
item1: Int! | ||
item2: Int! | ||
item3: Int! | ||
item4: Int! | ||
item5: Int! | ||
item6: Int! | ||
} | ||
|
||
type TupleOfInt32AndInt32AndInt32AndInt32AndInt32AndInt32AndInt32 { | ||
item1: Int! | ||
item2: Int! | ||
item3: Int! | ||
item4: Int! | ||
item5: Int! | ||
item6: Int! | ||
item7: Int! | ||
} |