Skip to content

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

Open
@mdg

Description

@mdg

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

Environment

  • Elixir version (elixir -v): 1.16.2
  • Absinthe version (mix deps | grep absinthe): 1.7.8
  • Client Framework and version (Relay, Apollo, etc): n/a

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.

def path_string(%__MODULE__{path: path}) do
Enum.map(path, fn
%{name: name, alias: alias} ->
alias || name
%{schema_node: schema_node} ->
schema_node.name
end)
end

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