question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for circular references in dynamically produced schemas

See original GitHub issue

Using 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:closed
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
michaelstaibcommented, Apr 28, 2019

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.

0reactions
michaelstaibcommented, Sep 26, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support for circular references in dynamically produced ...
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...
Read more >
Dynamically creating graphql schema with circular ...
The problem is circular references. When I'm creating AuthorType I need BookType to be already created and vise versa. So resulting schema ......
Read more >
Database design: circular reference but dynamically created
So circular reference is created after successful execution, but if compilation failed no record is created in executions. Link between vectors ...
Read more >
Working with Circular References
Working with Circular References ... A circular relationship is a circular hierarchy relationship between two views in an XML definition or within a...
Read more >
W3C XML Schema Definition Language (XSD) 1.1 Part 1
This W3C Recommendation specifies the W3C XML Schema Definition Language (XSD) 1.1. It is here made available for use by W3C members and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found