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

fix path_string crash when path includes list #1338

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mdg
Copy link

@mdg mdg commented 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 #1337

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
Copy link
Contributor

@benwilson512 benwilson512 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the correct

@@ -128,6 +128,7 @@ defmodule Absinthe.Resolution do
In this case `5` is the 0 based index in the list of users the field is currently
at.
"""
@spec path(t()) :: [String.t()]
def path(%{path: path}) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this spec is correct. This returns the query nodes, not strings. Also, in the case of lists, it returns integers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll switch to [String.t() | integer()]


```elixir
resolve fn _, _, resolution ->
Absinthe.Resolution.path(resolution) #=> ["email", "users", "RootQueryType"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The desired output here is probably to stringify the integer so that the information isn't lost. This is also a breaking change so we'll need to release this under a new minor version.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added back the integers as strings. I would suggest this isn't a breaking change, b/c no one was using the previous behavior b/c it was broken.

fix the type on Resolution.path/1

incorporating PR feedback from @benwilson512

issue absinthe-graphql#1337
@mdg mdg requested a review from benwilson512 September 3, 2024 22:33
@mdg
Copy link
Author

mdg commented Sep 3, 2024

I've tried to address the feedback

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

Successfully merging this pull request may close these issues.

2 participants