Recursive types #16

Closed
opened 2024-10-08 04:22:58 +02:00 by prescientmoon · 2 comments
Contributor

Hi!

Sometimes types might refer to themselves (think of __Type having a field ofType of type __Type, which is required for introspection). The easiest approach is to bound this recursiveness to a certain depth (I'm getting infinite loops unless I do that). Are those infinite loops to be expected, or is that something on my end? (asking so I know whether to spend more time trying to debug this)

Hi! Sometimes types might refer to themselves (think of `__Type` having a field `ofType` of type `__Type`, which is required for introspection). The easiest approach is to bound this recursiveness to a certain depth (I'm getting infinite loops unless I do that). Are those infinite loops to be expected, or is that something on my end? (asking so I know whether to spend more time trying to debug this)
Owner

Sounds like a bug. I checked the schema of my GraphQL application and it doesn't seem to have recursive types, so I wouldn't notice.

Ideally the library shouldn't care about the depth of recursion, it's the problem of the schema author, but it depends on what causes the problem.

What do I have to do to reproduce this, define a schema with a recursive type and run some query against it?

Sounds like a bug. I checked the schema of my GraphQL application and it doesn't seem to have recursive types, so I wouldn't notice. Ideally the library shouldn't care about the depth of recursion, it's the problem of the schema author, but it depends on what causes the problem. What do I have to do to reproduce this, define a schema with a recursive type and run some query against it?
Author
Contributor

@belka Hi! I was getting those errors when implementing an introspection system. I ended up memoizing the __Type resolver (that's the biggest offender) and limiting the depth to 30 (which should be enough for any serious app). I'm not sure what the simplest way to reproduce this would be, but I guess we can close it for now.

@belka Hi! I was getting those errors when implementing an introspection system. I ended up memoizing the `__Type` resolver (that's the biggest offender) and limiting the depth to 30 (which should be enough for any serious app). I'm not sure what the simplest way to reproduce this would be, but I guess we can close it for now.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: OSS/graphql#16
No description provided.