Skip to content

Broken response parts when defer is used multiple times on the same field #5434

@utay

Description

@utay

Describe the bug

When using defer multiple times on the same field, it introduces broken intermediate parts in the multipart response.

For instance, this query:

{
  __typename @defer
  __typename @defer
}

results in:


---
Content-Type: application/json
Content-Length: 26

{"hasNext":true,"data":{}}
---
Content-Type: application/json
Content-Length: 231

{"incremental":[{"path":["__typename"],"data":["#<GraphQL::Pro::Defer::RootDeferral:0x00007f8952e75148>","#<GraphQL::Pro::Defer::Deferral:0x00007f89532fea70>","#<GraphQL::Pro::Defer::Deferral:0x00007f89532fe700>"]}],"hasNext":true}
---
Content-Type: application/json
Content-Length: 62

{"incremental":[{"path":null,"data":"Query"}],"hasNext":false}
-----

See the stringified GraphQL::Pro::Defer::RootDeferral objects in the intermediate part.

Expected Response

I'd expect graphql to properly merge the deferred fields and return:

---
Content-Type: application/json
Content-Length: 26

{"hasNext":true,"data":{}}
---
Content-Type: application/json
Content-Length: 72

{"incremental":[{"path":["__typename"],"data":"Query"}],"hasNext":false}
-----

Versions

graphql version: 2.5.12
graphql-pro version: 1.29.12
rails version: 8.0.2

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