walmartlabs / lacinia

GraphQL implementation in pure Clojure
http://lacinia.readthedocs.io/en/latest/
Other
1.81k stars 162 forks source link

Fix runtime error when aggregating results with error-containing left-value #449

Closed namenu closed 5 months ago

namenu commented 12 months ago

The query below causes an infinite wait when executed.

query HangingQuery($id: ID!) {
  node(id: $id) {
    ... on Post {
      ... on Post {
        author {
          alwaysError
        }
      }
      author {
        name
      }
    }
  }
}

On the other hand, if you reverse the order of the field declarations, it will not.

query HangingQuery($id: ID!) {
  node(id: $id) {
    ... on Post {
      author {
        name
      }
      ... on Post {      # change the order
        author {
          alwaysError
        }
      }
    }
  }
}

It's worth noting that the fragment must be used to reproduce the error.

I guess in the process of doing merge-selected-values, even though the left-value value is nil (which is resolved by alwaysError), update to nil is called (which cause runtime error).

This PR fixes this issue.

CLAassistant commented 12 months ago

CLA assistant check
All committers have signed the CLA.

hlship commented 5 months ago

I'm sorry that I haven't kept track of this. I'd like to create a 1.2.2 release, but looks like your patch will need to be updated. If you can put that together, I'd be happy to merge.