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

Rework how entities_field works #104

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

Conversation

maciej-szlosarczyk
Copy link

Hey 👋 Great work on library!

This is a pretty big PR to address the following points:

  • Support Async resolution with 0-arity function
  • Support Dataloader.Ecto
  • Support function capture resolution

The main idea here is to use normal middleware pipeline for each resolved representation instead of looking at what those middlewares actually are. Unfortunately it changes some API examples and tests, but it brings them in-line with how Absinthe works in general. I.e async/2 helper requires the first argument to be a 0-arity function, but for some reason the tests used 1-arity.

@maciej-szlosarczyk maciej-szlosarczyk force-pushed the dataloader-ecto branch 3 times, most recently from e42dfd1 to 3aa1cb9 Compare December 18, 2024 10:00
- Support Async resolution with 0-arity function
- Support Dataloader.Ecto
- Support function capture resolution
@kdawgwilk kdawgwilk requested a review from kzlsakal December 19, 2024 23:05
@kdawgwilk kdawgwilk added the enhancement New feature or request label Dec 19, 2024
Copy link
Collaborator

@kzlsakal kzlsakal left a comment

Choose a reason for hiding this comment

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

@maciej-szlosarczyk thank you so much for working on this! These are some great changes, and I left a few comments. If you can address those, I'll be happy to run another test suite on my end.

lib/absinthe/federation/schema/entities_field.ex Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
test/support/example_item.ex Outdated Show resolved Hide resolved
@maciej-szlosarczyk
Copy link
Author

@kzlsakal Thanks for taking a look, I added the functionality and required test. Should be all good now, let me know if you need to rebase all changes into a single commit and I'll do just that.

Comment on lines +5 to +10
def call(%{arguments: %{item_id: item_id, __typename: "ItemWithModuleMiddleware"}} = res, _opts) do
value = %{item_id: "ModuleMiddleware:#{item_id}", __typename: "ItemWithModuleMiddleware"}
Map.put(res, :value, value)
end

def call(res, _opts) do
Copy link
Collaborator

Choose a reason for hiding this comment

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

Absinthe.Middleware.call/2 has the following function spec:

call(Absinthe.Resolution.t(), term) :: Absinthe.Resolution.t()

We may want to have only one call/2 definition in this test middleware and ensure we're not calling it with something other than an Absinthe.Resolution struct as the first argument, otherwise it could be a breaking change for many codebases that expect what Absinthe specifies for it. What do you think?

Comment on lines +3 to +5

# setup do
# end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# setup do
# end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants