Skip to content

Conversation

@axelson
Copy link
Contributor

@axelson axelson commented Sep 25, 2025

This allows using Module.concat/1,2 to provide the middleware. The benefit of this is that the resolver no longer has a compile-time dependency on the middleware, and more importantly a transitive dependency on all the middleware's runtime dependencies.

Here is an example of a supported field definition:

field :folder, non_null(:folder) do
  arg :id, non_null(:string)
  middleware Module.concat(MyAppWeb.GraphQL, MyMiddleware), some_options: [42]
  resolve &SomeResolver.project_folder/3
end

This almost works today, but MyMiddleware doesn't receive the provided options.

Fix is related to #1359

This is more of a PoC/RFC right now. We may actually want to go with an approach that targets the compiler directly, like these two related ecto commits:

@cschiewek cschiewek changed the title Support module concat in middleware to avoid compile-time dependencies feat: Support module concat in middleware to avoid compile-time dependencies Oct 28, 2025
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.

1 participant