dictyBase / graphql-server

dictyBase GraphQL server built using gqlgen
BSD 2-Clause "Simplified" License
0 stars 3 forks source link

Use custom models for all services #24

Open erichartline opened 5 years ago

erichartline commented 5 years ago

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 commented 4 years ago

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 commented 4 years ago

Models:

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.