Comments (14)
For those wanting to make this work on the API only rails app.
Add the following to your Gemfile.
gem 'sass-rails'
gem 'uglifier'
gem 'coffee-rails'
And un comment or add the following to your application.rb
require "sprockets/railtie"
from graphiql-rails.
Just got graphiql-rails
to work with my Rails 6, API only app, and here are the steps I took:
- Adding
graphiql-rails
Gemfile. It works withoutuglifier
,coffee-rails
andsass-rails
.
group :development do
...
gem "graphiql-rails"
end
and add to routes.rb
like in README.
if Rails.env.development?
mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/graphql"
end
- Add
require "sprockets/railtie"
on top ofconfig/development.rbconfig/application.rb
require "sprockets/railtie"
- Sprockets will complain that
manifest.js
is needed. Here is the simplest version that works, based on @MITSUBOSHI changes
--- add to `app/assets/config/manifest.js`
//= link graphiql/rails/application.css
//= link graphiql/rails/application.js
And it works!
from graphiql-rails.
anyone managed to solve this on Rails 7 ??
from graphiql-rails.
I left out adding the assets related gems (sass-rails, uglifier, coffee-rails) to my API only Rails app (v5.1.2) & graphiql seems to work fine. 😉
from graphiql-rails.
For rails 6 create app/assets/config/manifest.js
and add
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css
from graphiql-rails.
Thanks for following up! I guess this gem depends on sprockets routing being hooked up. Feel free to PR the documentation if you can think of a way to explain that clearly.
from graphiql-rails.
@jam35L I need to serve images uploaded using Carrierwave in an API-only app, so I uncommented require "sprockets/railtie"
but it's still not working even with sass-rails, uglifier, coffee-rails gems, any ideas?
from graphiql-rails.
@yasser-sobhy Please clarify which part is not working. Your API only app is not working or you can't access your images?
from graphiql-rails.
from graphiql-rails.
@zfhui Did you have your
rails app in api mode?
from graphiql-rails.
Hi.
I have the same issue.
I have Rails API only app.
And i can't add styles with app/assets/stylesheets/application.scss.
I don't see any request for css/js file even after adding gem 'sass-rails', gem 'uglifier', gem 'coffee-rails',
require "sprockets/railtie" and even adding application.html.haml.
rake assets:precompile creates the application...css but not request for that file comes.
from graphiql-rails.
The problem was that i've added application.html.haml not to app/views/layouts/ folder.
Now everything is OK.
from graphiql-rails.
Thx @jam35L
from graphiql-rails.
anyone managed to solve this on Rails 7 ??
I created a PR for this over a year ago, but has been ignored. The fix is pretty simple. My PR has fallen out of sync with main. The maintainers should fix this ASAP as including Sprockets in Rails 7 does not work and is ill advised.
from graphiql-rails.
Related Issues (20)
- der
- Graphql query execute is getting freeze from model callbacks HOT 1
- Build issue when bumping graphiql-rails from 1.8.0 to 1.9.0 HOT 7
- doesn't work with propshaft HOT 2
- Using themes/custom CSS
- conditionally render route HOT 6
- onEditQuery is undefined HOT 1
- AbstractController::ActionNotFound (The action 'execute' could not be found for GraphqlController): HOT 1
- AssetNotPrecompiled error with Sprockets 4.0 HOT 27
- How to use this gem with graphql subscription? HOT 1
- default context variables HOT 1
- GraphiQL::Rails::EditorsController#show raising on new Rails 6 app HOT 3
- Question about request header configuration with initializer HOT 1
- Using GraphiQL in your Rails app without this gem HOT 7
- uninitialized constant GraphqlController::GraphQLIntroSchema Did you mean? GraphQlIntroSchema HOT 1
- Is this gem dead? HOT 1
- Support for subscriptions HOT 3
- headerEditorEnabled config HOT 1
- sass not needed anymore? HOT 2
- Your application has sessions disabled HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphiql-rails.