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

ResourceGenerator overwrites existing controller #35

Open
LoganDSPrice opened this issue Sep 9, 2019 · 1 comment
Open

ResourceGenerator overwrites existing controller #35

LoganDSPrice opened this issue Sep 9, 2019 · 1 comment

Comments

@LoganDSPrice
Copy link

Overwriting existing controllers when generating a resource limits the utility of the gem. It makes it much more difficult to add Graphiti to an existing application.

Pain point
Adding Graphiti to an existing application with generate graphiti:resource [RESOURCE_NAME] --model=[MODEL_NAME] overwrites the existing controller. You can skip the overwrite, but then the controller code must be written by hand. Also, if you use destroy graphiti:resource... it deletes the controller file whether the generator initially overwrote the file or not. This inflexibility also increases the difficulty of calling the generator inside other custom generators.

Suggested solutions:

  • Break out the responsibilities of the ResourceGenerator into separate generators and create a single scaffold generator which incorporates all of the generators
    • The scaffold generator could have options to exclude specific generators (e.g. --no-controller)
  • Instead of overwriting controllers, create separate namespaced controllers specifically for Graphiti. The file structure could be sourced from the namespace recorded in .graphiticfg.yml.
@arjan0307
Copy link

I''m dealing with the same problem. The workaround I use is overwrite the controller, move the controller to the namespace and then use git checkout to restore the original controller, which is far from ideal.

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

2 participants