gqlgen icon indicating copy to clipboard operation
gqlgen copied to clipboard

Update generated stubs

Open vektah opened this issue 6 years ago • 6 comments

It would be very useful to compare current schema to a set of RootResolvers (passed in as args? maybe in config?) and add any missing resolvers as stubs to the generated code.

Bonus points for dealing with conflicts.

This is a long standing idea thats been floating around since #9.

@matthewmueller mentioned https://github.com/golang/go/issues/20744 might make this tricky. Perhaps it needs to use the AST to make decisions but do the edits on the raw file bytes?

vektah avatar Jul 23 '18 05:07 vektah

Regarding conflicts, the way I've been thinking about this is:

Add resolver no conflict, ideally add in the proper order as the schema, but bottom of the file is okay too.

Update resolver schema is source of truth, update function signature, but don't change function body. If the user defined return value variables, leave those intact too. Cheap alternative is to just print out what needs to be changed and let the user do it manually.

Delete resolver never delete code. Instead, mark the resolver as unused by prepending _ to the resolver function.

matthewmueller avatar Jul 23 '18 05:07 matthewmueller

any update?

igtm avatar Aug 22 '19 03:08 igtm

Apparently https://github.com/dave/dst is a thing that is good

mtibben avatar Sep 16 '19 18:09 mtibben

Any progress on this?

nadilas avatar Jan 02 '20 18:01 nadilas

Any progress on this?

exfly avatar Mar 12 '20 04:03 exfly

Any progress on this?

borisbsv avatar Nov 04 '21 12:11 borisbsv