Closed caiosba closed 1 year ago
Hi, sorry I somehow missed this PR when you first posted it!
Thanks for sharing your code -- I'm going to think about how to support this. Maybe it's an opportunity to make the view more flexible.
RailsAdmin has a pretty clever way of doing this. They take advantage of the way engine view/asset lookup works: technically, any engine file can be overridden by creating a file with the same path+name in the main app.
So check this out: https://github.com/sferik/rails_admin/blob/master/app/assets/javascripts/rails_admin/custom/ui.coffee
They have a blank file. They include it here: https://github.com/sferik/rails_admin/blob/master/app/assets/javascripts/rails_admin/rails_admin.js#L21
Then, if you want to add your own JS to the app, you just create a file in your app at app/assets/javascripts/rails_admin/custom/ui
, and the file resolver uses your file instead of the provided file.
This would reduce complexity and let you get rid of the config option.
I had to add a few things to the GraphiQL UI, and had change the UI a little bit. One simple way to do that was to simply add a new configuration option that allows the developer to insert a custom script to the page. Also, an event is triggered when the GraphiQL UI is ready.
So, in my custom script, I can listen to that event and make the changes on the UI as needed.
Worked for me, maybe it's useful for the other users... so, I'm submitting this PR.
Ah, and thanks for this great gem!