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

Ruby nixpack attempts to precompile assets in some API-only apps #1154

Open
1 task done
mhuggins opened this issue Aug 5, 2024 · 1 comment
Open
1 task done

Ruby nixpack attempts to precompile assets in some API-only apps #1154

mhuggins opened this issue Aug 5, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mhuggins
Copy link

mhuggins commented Aug 5, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When building a GraphQL API, it can be useful to include GraphiQL for users to interact with the GraphQL API via the web. GraphiQL is the typical approach to providing such an interface. However, the graphiql-rails ruby gem depends on propshaft or sprockets being installed as well to serve the JS & CSS.

Because the ruby nixpack determines if a Rails app is API-only by checking for the existence of "propshaft" or "sprockets" in the app's Gemfile, it's getting false-positives.

To address this, I would suggest searching in either config/application.rb for the string config.api_only = true or app/application_controller.rb for the string ActionController::API instead.

To reproduce

  1. Create a rails app that is API-only: rails new my-api-app --api
  2. Add graphql, graphiql-rails, & propshaft dependencies to Gemfile:
    gem 'graphiql-rails'
    gem 'graphql'
    gem 'propshaft'
  3. Install gems: bundle install
  4. Add route to config/routes.rb for GraphQL & GraphiQL:
    Rails.application.routes.draw do
      post '/graphql', to: 'graphql#execute'
      mount GraphiQL::Rails::Engine, at: '/', graphql_path: '/graphql'
    end
  5. Use the ruby nixpack with this application.

Expected behavior

The ruby nixpack should not run bundle exec rake assets:precompile.

Environment

Railsway.app deployment

@mhuggins mhuggins added the bug Something isn't working label Aug 5, 2024
@mhuggins
Copy link
Author

mhuggins commented Aug 5, 2024

As a workaround, create a lib/tasks/assets.rake file with the following:

# frozen_string_literal: true

Rake::Task['assets:precompile'].clear

namespace :assets do
  task precompile: :environment do
    # noop
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant