favware/graphql-pokemon

bug: apollo server query builder infinite field recursion

castdrian opened this issue · 1 comments

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

When adding specific properties in the query builder instead of showing the nested properties it just keeps adding itself to the path

Steps To Reproduce

  1. Navigate to the query builder
  2. Click preevolution
  3. Repeat step 2 as many times as desired

Expected behavior

It should display a list of nested properties

Screenshots

ishare-1708860203

Additional context

not sure if the issue lies with apollo and how many fields are affected, but this happens with quite a few of them

In a way this is expected because the type of Evolutions is evolutions: [Pokemon!] and for preevolutions it is preevolutions: [Pokemon!] (read as: an optional array of Pokemon, required).

This issue cannot be resolved because it is valid that 1 pokemon can have 2 nested levels of preevolutions, for example Dragonite -> Dragonair (1) -> Dratini (2).

It should also be noted that this issue exists exclusively for the Apollo query builder interface as the API code ensures that no infinite recursion can occur even when the query prompts for it, for example:
image.

Considering that Apollo normally disables that interface when deploying for production I don't see them providing anything to resolve this. The only reason I have it forcibly enabled is because it's a great way to provide documentation and a play ground to end-users. GraphQL also has no form of type extension/omission, and that would also not work statically anyway because some Pokemon do have evolutions and others do not.