So, I ended up writing a second yml file with configuration for adding arbitrary fields to generated models
# Add transient fields to the generated glq model models: User: DBUser: github.com/my/package/models.User # # Place all added fields into their own embedded struct with the following field name # field: Internals
Then, I used a very simple plugin built off of the
modelgen.Plugin to add these fields to the models during codegen. I will be experimenting to see if there are any "gotchas" that I might have missed with this approach.
User-MacBook-Pro:test-gql user$ go run github.com/99designs/gqlgen validation failed: packages.Load: /Users/test-gql/schema.resolvers.go:12:73: NewTodo not declared by package models /Users/test-gql/schema.resolvers.go:12:91: Todo not declared by package models /Users/test-gql/schema.resolvers.go:16:63: Todo not declared by package models /Users/test-gql/schema.resolvers.go:21:31: undeclared name: generated /Users/test-gql/schema.resolvers.go:24:28: undeclared name: generated exit status 1
User-MacBook-Pro:test-gql user$ go run server.go resolver.go generated.go package main: found packages main (server.go) and test_gql (resolver.go) in /Users/test-gql
- models - person.go - pet.go - generated.go - resolver.go - server.go - schema.graphql - gqlgen.yml
go run .