Skip to content

Infinite loop in TransformCompositeFields when using WrapFields #4774

@srolel

Description

@srolel

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • 1. The issue provides a reproduction available on Github, Stackblitz or CodeSandbox

    Make sure to fork this template and run yarn generate in the terminal.

    Please make sure the GraphQL Tools package versions under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided (commit)
  • 4. A pull request is pending review

Describe the bug

When using WrapFields a larger number of times across multiple handlers, a graphql.visit invocation gets increasingly slower. I observed that the selection set in the visited document increases in powers of two for some reason. I'm not sure exactly why but after debugging it is a result of this bit in TransformCompositeFields.

To Reproduce
My implementation is complex (and the issue seems to be a result of that complexity) but because the fix seems harmless I thought I'd report it before trying to reproduce in a minimal example.

Expected behavior

The visit function is not stuck in a loop.

Environment:

  • OS:
  • @graphql-tools/...:
  • NodeJS: 16

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions