absinthe-graphql / absinthe

The GraphQL toolkit for Elixir
http://absinthe-graphql.org
Other
4.27k stars 525 forks source link

Absinthe.Resolution.path_string/1 crashes if path includes a list #1337

Open mdg opened 2 weeks ago

mdg commented 2 weeks ago

I have a patch for this one ready. Just submitting the issue for referencing from the PR.

Environment

Expected behavior

Expected Absinthe.Resolution.path_string/1 to always return a list of strings and not raise a FunctionClauseError

Actual behavior

If the query path contains a list, the path value list contains an integer for the node in the path that is a list item. The fn passed to the map matches on maps and a FunctionClauseError is raised when it gets to the integer. case statement fails with a FunctionClause

Relevant Schema/Middleware Code

Schema has to include a list upstream from the field being resolved when path_string is called. https://github.com/absinthe-graphql/absinthe/blob/3d0823bd71c2ebb94357a5588c723e053de8c66a/lib/absinthe/resolution.ex#L238-L246

mdg commented 2 weeks ago

This function doesn't actually have any documentation so it's not entirely clear how it's different from path/1. In attempting to add the documentation, it's unclear how to describe what it does.