File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed
src/Types/Types/Attributes
test/Types.Analyzers.Tests Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -68,9 +68,9 @@ protected override void OnConfigure(
68
68
/// interpreted as a GraphQL object type.
69
69
/// This class is used by the Hot Chocolate source generator.
70
70
/// </summary>
71
- [ AttributeUsage ( AttributeTargets . Class ) ]
71
+ [ AttributeUsage ( AttributeTargets . Class | AttributeTargets . Struct ) ]
72
72
public sealed class ObjectTypeAttribute < T >
73
- : Attribute where T : class
73
+ : Attribute
74
74
{
75
75
public Type Type => typeof ( T ) ;
76
76
}
Original file line number Diff line number Diff line change @@ -13,15 +13,25 @@ public class Book
13
13
public string ? Title { get ; set ; }
14
14
15
15
public Author ? Author => null ;
16
+
17
+ public Publisher ? Publisher => null ;
16
18
}
17
19
18
20
public class Author
19
21
{
20
22
public string Name { get ; set ; } = default ! ;
21
23
}
22
24
25
+ public readonly record struct Publisher ( string Name ) ;
26
+
23
27
[ ObjectType < Author > ]
24
28
public static partial class AuthorNode
25
29
{
26
30
public static string Address ( [ Parent ] Author author ) => "something" ;
27
31
}
32
+
33
+ [ ObjectType < Publisher > ]
34
+ public static partial class PublisherNode
35
+ {
36
+ public static string Company ( [ Parent ] Publisher author ) => "something" ;
37
+ }
Original file line number Diff line number Diff line change @@ -33,6 +33,11 @@ type Person implements Node & Entity {
33
33
address : String !
34
34
}
35
35
36
+ type Publisher {
37
+ company : String !
38
+ name : String !
39
+ }
40
+
36
41
type Query {
37
42
"Fetches an object given its ID."
38
43
node ("ID of the object." id : ID ! ): Node
@@ -50,6 +55,7 @@ type Query {
50
55
type SomeBook {
51
56
title : String
52
57
author : Author
58
+ publisher : Publisher
53
59
}
54
60
55
61
type Subscription {
You can’t perform that action at this time.
0 commit comments