Support for circular references in dynamically produced schemas
See original GitHub issueUsing the usual static .Type<MyType>()
declaration on fields we can create types which refer to themselves in their fields, eg. CharacterType
in the Star Wars example uses
descriptor.Field("friends")
.Type<ListType<CharacterType>>();
to add a list of its own type to itself as a field.
I’m not clear on how to do this when constructing types dynamically with the “types as instances” API since the referenced type won’t exist yet:
descriptor.Field("friends")
.Type(new ListType(new CharacterType()));
(if I’m not mistaken, it appears to not be supported currently.)
Not being able to do this is very limiting on the kinds of schemas that can be produced dynamically. In my case I’d like to be able to use Hot Chocolate for dynamic schema production (it’s much closer to being able to achieve this than graphql-dotnet). Could there be an addition of a “reference type” so we can write something like:
descriptor.Field("friends")
.Type(new ListType(new NamedTypeReference("Character")));
(or have a ctor overload on ObjectType
whose configure
delegate provides the end type as a parameter, or anything else that makes the end result possible?)
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (6 by maintainers)
Top GitHub Comments
Sorry, I misread you again,
you just want a type name reference with the standard types. I got it now 😃
OK, lets put this in the version backlog.
I will close this one since we have decided to move the subject of dynamic schemas to the next release. We will soon create a feature issue lining out how we will enable dynamic schemas.