Skip to content

Fragments used in Fragments are leading to big source.body string #4255

@marvinsemmelroth

Description

@marvinsemmelroth

We have a really big query in our application which is orchestrated by many (mostly the same) fragments. When parsing to a DocumentNode, the parser inlines all does fragments (Without checking for duplicates) into one big string (2-2.5MB - 180k Lines). Some fragments are up to 1.600 times references, which is taking up alot of memory in the JS Heap.

I think a solution would be to move all Subfragments to the query declaration but since we also use these fragments to access the cache (using apollo-client), we still need those fragments to be working standalone.

The fragments are already parsed DocumentNodes so also parsing them again and again should be pretty imperformant. My suggestion would be to add the possibility to pass already parsed definitions to the parser/to the Source-Construct, which then can be used instead of creating them again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions