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

Question/Suggestion: Hook plugin into modelgen #876

Closed
nurdism opened this issue Sep 24, 2019 · 1 comment
Closed

Question/Suggestion: Hook plugin into modelgen #876

nurdism opened this issue Sep 24, 2019 · 1 comment
Labels

Comments

@nurdism
Copy link

nurdism commented Sep 24, 2019

I was looking for a way to add a tag to the model gen with a directive, for things like ORMs and Validation of stuct fields, is there a way to hook into that? Or is this not currently possible?

@nurdism nurdism changed the title Question/Suggestion: Hook into plugin into modelgen Question/Suggestion: Hook plugin into modelgen Sep 24, 2019
@stale
Copy link

stale bot commented Nov 23, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 23, 2019
@stale stale bot closed this as completed Dec 1, 2019
cgxxv pushed a commit to cgxxv/gqlgen that referenced this issue Mar 25, 2022
This change introduces option to implement custom hook for model
generation plugin without the need to completly copy the whole `modelgen` plugin.

One very possible case is as described in 99designs#876 and with this change the solution for
that can be:

```golang
func mutateHook(b *ModelBuild) *ModelBuild {
	for _, model := range b.Models {
		for _, field := range model.Fields {
			field.Tag += ` orm_binding:"` + model.Name + `.`  +  field.Name + `"`
		}
	}

	return b
}

...

func main() {
    p := modelgen.Plugin {
        MutateHook: mutateHook,
    }

    ...
}

```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant