ruby-on-railsgraphql

Error: Could not find generator 'graphql:install'


I created a new Ruby on Rails application and I just installed graphql gem, since I want to use Graphql for the project. But each time I run

rails generate graphql:install

I get the error below

Could not find generator 'graphql:install'. Maybe you meant 'channel', 'assets' or 'generator'
Run rails generate --help for more options.

I have done research and also implemented a few solutions but none seems to be working. What can I try next?


Solution

  • Here's what worked for me:

    Make sure that you have the latest version of graphql.

    For my case, I was running graphql 0.9.2 which was out of date

    I had to open the Gemfile of my project and added the latest version of graphql to the Gemfile

    gem 'graphql', '~> 1.9.12'
    

    And then ran the command below to install/update graphql

    bundle install
    

    Afterwhich I tried running graphql:install again and it worked

    rails generate graphql:install
    

    If this does not work, check to see if you have graphql-relay gem in your Gemfile and remove it.

    And then run bundle install

    That's all.

    I hope this helps