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

Feature Request: Dry up Schema Notation #44

Open
cpursley opened this issue Jul 4, 2021 · 3 comments
Open

Feature Request: Dry up Schema Notation #44

cpursley opened this issue Jul 4, 2021 · 3 comments

Comments

@cpursley
Copy link

cpursley commented Jul 4, 2021

This is a really great effort. The CRUD Repo and Resolver modules are really helpful. It reminds me of some of the things Hasura is trying to accomplish.

It would be also be helpful to DRY up Absinthe schema notation by pulling in the Ecto Schemas and auto-generating the Absinthe objects since the fields are often the same thing.

Any thoughts on this or ideas on how I could go about this and contribute to the project?

@cpursley cpursley changed the title Feature Request: Dry up Schema Notations Feature Request: Dry up Schema Notation Jul 4, 2021
@cpursley
Copy link
Author

cpursley commented Jul 6, 2021

It looks like they are doing something similar to what I'm thinking about in this library: https://hexdocs.pm/dilute/Dilute.html#module-types

@gabrielpra1
Copy link
Member

Hey @cpursley, thanks for the suggestion!

I have already thought about this in the past, but in my current implementations, there's usually a reasonable difference between the Ecto Schema and the Absinthe Objects (not exposing all database fields and adding extra custom fields that are calculated via resolvers). Therefore, I don't see the 2 schemas as code duplication, since I think it's good to have these different layers.

So I think the best way to go about this problem would be to rely on generators that generate both schemas as a starting point, and then allow the developers to customize them as needed. Something similar to mix phx.gen.schema, that generates not only the Ecto Schema, but also the Absinthe Schema. Maybe this could even go into Absinthe's repo, not sure.

What do you think?

@cpursley
Copy link
Author

cpursley commented Jul 6, 2021

Hi @gabrielpra1 ~ those are good points and would give you a good place to start.

There might be some ideas here if you want to build gen it into Crudry: https://github.com/sashman/absinthe_gen (or just use this lib)

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

2 participants