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

NonNullType for attribute generated object types #7805

Closed
josepvg opened this issue Dec 3, 2024 · 1 comment
Closed

NonNullType for attribute generated object types #7805

josepvg opened this issue Dec 3, 2024 · 1 comment

Comments

@josepvg
Copy link

josepvg commented Dec 3, 2024

Product

Hot Chocolate

Version

14

Link to minimal reproduction

Exaple in steps to reproduce

Steps to reproduce

If i define a class like this:
[ObjectType]
public static partial class AppointmentNode
{

then i can not use it in a NonNullType like this
descriptor.Field(f => f.TAppointments)
.Name("appointments")
.Description("The appointments for this resource")
.Type<NonNullType<ListType<NonNullType< AppointmentNode >>>>() // Explicitly define the type
.UseFiltering();

I had to use the old
public class AppointmentNode : ObjectType
{

What is expected?

defining the class using the objecttype attribute should work the same

What is actually happening?

Compile type error since AppointmentNode is not of type IType

Relevant log output

Additional context

No response

@michaelstaib
Copy link
Member

[ObjectType]
public static partial class AppointmentNode

Is not valid in any case. The source generator API you are referring to only exists when you specify the generic [ObjectType<Appointment>] in which case you can refer in the fluent api to it like the following:
NonNullType<ListType<NonNullType<ObjectType<AppointmentNode>>>>>

the ObjectTypeAttribute that is non generic is for if you have an instance type like

[ObjectType]
public class Appointment
{
	public int Id { get; set: }
}

in which case you refer to it in the same way as shown above.

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

No branches or pull requests

2 participants