Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mdg opened this issue Sep 1, 2024 · 1 comment
Open

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

mdg opened this issue Sep 1, 2024 · 1 comment

Comments

@mdg
Copy link

mdg commented Sep 1, 2024

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

mdg added a commit to pathpub/absinthe that referenced this issue Sep 1, 2024
@mdg
Copy link
Author

mdg commented Sep 1, 2024

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.

mdg added a commit to pathpub/absinthe that referenced this issue Sep 1, 2024
mdg added a commit to pathpub/absinthe that referenced this issue Sep 1, 2024
in Absinthe.Resolution; also:

* add documentation for path_string/1
* add specs for path/1 and path_string/1

this fix is absinthe-graphql#1337
absinthe-graphql#1337
mdg added a commit to pathpub/absinthe that referenced this issue Sep 3, 2024
fix the type on Resolution.path/1

incorporating PR feedback from @benwilson512

issue absinthe-graphql#1337
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant