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

Use custom models for all services #24

Open
erichartline opened this issue Mar 25, 2019 · 2 comments
Open

Use custom models for all services #24

erichartline opened this issue Mar 25, 2019 · 2 comments

Comments

@erichartline
Copy link
Contributor

For strain and plasmid, we had to create our own custom models rather than just pointing them to the original protocol buffer struct. Should we update the other models to match this format, or should we leave them pointing directly at the protocol buffers?

@erichartline
Copy link
Contributor Author

After further review, yes we should use custom models. This will enable us to only create resolvers for what is actually needed and it will remove a lot of redundant code. See the latest models used for Strain and Plasmid for examples on how to do so.

@erichartline
Copy link
Contributor Author

erichartline commented May 18, 2020

Models:

  • User
  • Role
  • Permission
  • Content
  • Publication
  • Author
  • Strain
  • Plasmid
  • Order
  • Auth

Steps to implement:

  1. Add new file in models package with your custom models.
  2. Update gqlgen.yml to point at the new model and specify any resolvers that need to be handled individually. For now, this would likely only be certain stock fields that retrieve data from annotations, not stock db.
  3. Run script -- go generate ./...
  4. Check diff of genresolver.go and make note of the methods that were removed. Now go to individual resolver file, i.e. resolver/order/order.go and remove those same resolvers.
  5. Run unit tests and build the application to check for anything else that might need to be changed for the new models.

@erichartline erichartline changed the title Should we use custom models for all services? Use custom models for all services May 18, 2020
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

1 participant