question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Connections inside of union fragments are not converted from arrays

See original GitHub issue

It seems any Relay connection inside a fragment in a union or interface is ignored by the arrToConnection function since this function ignores typedChildren in the SQL AST.

Example query:

{
  files {
    edges {
      node {
        id
        name
        path
        
        ... on Folder {
          contents {
            edges {
              node {
                id
                name
                path
              }
            }
          }
        }
      }
    }
  }
}

Expected output:

{
  "data": {
    "files": {
      "edges": [
        {
          "node": {
            "id": "Rm9sZGVyOjE=",
            "name": "a folder",
            "path": "/",
            "contents ": {
              "edges": [
                {
                  "node": {
                    "id": "Rm9sZGVyOjI=",
                    "name": "another folder",
                    "path": "/a folder/"
                  }
                }
              ]
            }
          }
        }
      ]
    }
  }
}

Actual output:

{
  "data": {
    "files": {
      "edges": [
        {
          "node": {
            "id": "Rm9sZGVyOjE=",
            "name": "a folder",
            "path": "/",
            "contents ": {
              "edges": null
            }
          }
        }
      ]
    }
  }
}

Using debugging mode I can see that the data is retrieved correctly and initially stored as an array but the sqlAST contains the SQLASTNode information in sqlAST.typedChildren.Folder[] rather than sqlAST.children and so it never processes the array into connection format and the response edges is null instead of an array of nodes.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
meticoeuscommented, May 13, 2020

@hugobarreiro Thanks for tackling the unit test part of this fix. I haven’t been able to spend more time on this lately.

1reaction
alexbbtcommented, May 7, 2020

You can definitely contribute these! Please do in fact

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fragments - Apollo GraphQL Docs
Using fragments with unions and interfaces​​ You can define fragments on unions and interfaces. The all_characters query above returns a list of Character ......
Read more >
Union of arrays doesn't get converted to array of unions #35294
Actual behavior: Conversion of union of arrays to array of unions happens only if it's enforced manually, and only if there is no...
Read more >
How to map graphql query which is using union and ...
I'm using union in schema and fragments in query to get what i need and then render it on page. From what i...
Read more >
Data Type (GLSL) - OpenGL Wiki - Khronos Group
Signed integers can be implicitly converted to unsigned integers, but the reverse is not true. Either integer type can be converted into floats,...
Read more >
Common Problems Found in RAML 1.0 API Specifications
Common misconceptions about examples and RAML NamedExample fragments ... References to inner elements are valid only for XSD and JSON schemas.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found