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

A way to change middleware of _entities field #71

Open
rewritten opened this issue Feb 9, 2023 · 4 comments
Open

A way to change middleware of _entities field #71

rewritten opened this issue Feb 9, 2023 · 4 comments
Labels
question Further information is requested

Comments

@rewritten
Copy link
Contributor

As of now, the middleware for the generated _entities field is hardcoded to be the Absinthe.Federation.Schema.EntitiesField module (https://github.com/DivvyPayHQ/absinthe_federation/blob/v0.3.2/lib/absinthe/federation/schema/entities_field.ex#L80).

Is there a way to plug another middleware there in its place?

@kdawgwilk
Copy link
Collaborator

You could modify the schema pipeline and remove absinthe_federation pipeline phases and replace them with your own. Not sure if our pipelines give the right granularity to just remove that one field but we could change that to make it easier

@rewritten
Copy link
Contributor Author

Interesting, I will give it a shot. It might be interesting to have a way to opt out of the federation phases. Or maybe that is just a matter of not using this package, and explicitly declare the _Entity interface and the _entities root field...

Feel free to close if the opt-out feature is not interesting for you.

@maartenvanvliet
Copy link

You could also try to change the middleware using the hydrate/2 callback. It's not documented well, but there are examples in the tests of Absinthe.

@rewritten
Copy link
Contributor Author

Or, I could prepend a middleware that makes sure to take control of that specific field. I'll try this out.

@kzlsakal kzlsakal added the question Further information is requested label Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants