Skip to content

Instantly share code, notes, and snippets.

@aerze
Created February 19, 2020 09:14
Show Gist options
  • Save aerze/5ab8839cee8a1312798166b4af3934e3 to your computer and use it in GitHub Desktop.
Save aerze/5ab8839cee8a1312798166b4af3934e3 to your computer and use it in GitHub Desktop.
I decided to write notes as I was debugging a thing to show junior devs what it's like in the _real_ world.

Attempting to install graphql plugin for Strapi (strapi.io)

My project is a basic starter using the directions on installing for docker. Containers are running smooth, db running, server running. I was able to create a few content types (schemas) per the tutorial with minor tweaks. I am able to make a request from the browser, now I'm looking to install a graphql plugin so that I can tailor the response.

It is 11:10pm, Tuesday.

  • Tried clicking the download option from within the admin plugins page, while server was running.
    • Failed? While the graphql extension did work, I could not find the config file in the host directory of the docker container's volume that I was expecting.
    • Going to assume that the plugin installer, was somehow not able to write to the volume?
  • Tried running the basic command npm run strapi install graphql on the host machine.
    • Failed. Got spawn yarn ENOENT.
    • Maybe it's because the initial setup ran in the container?
  • Tried running the command from inside the container.
    • Side-note: How to open bash in a local docker container

      # docker exec -it <container_name> bash
      docker exec -it strapi bash
    • Failed? Output shows a completed "installing dependencies" step but nothing else, still no config file.
    • Maybe it's something to do with docker volume permissions?
      • It seems to much work to debug the permissions right now, going to try to find another way to install the plugin.
  • Tried using npx strapi install in the hopes that it doesn't use the strapi in the local node_modules.
    • Failed. Same error as initial attempt.
    • I'm questioning why I tried this, I know, it's going to use what's in the local node_modules.
  • Tried installing strapi globally, then running strapi install graphql
    • Failed. Same error as initial attempt.
    • Again, it's the same strapi version so it makes sense that result is equal too.
  • Tried looking for "graphql" issues in github.
    • There were none (at least in the first page), and the issue would be pretty recent I think.
  • Confirmed that strapi version is the latest.
  • Started looking up directions for installing yarn, but don't want to add another tool at this time.

After following the strapi install command through the node_modules in the /app, found the relevant script strapi/commands/install, I see that the presence of the yarn.lock is how strapi decides to use yarn. It seems that strapi ran an install script when it initialized inside the container that installed yarn instead of using npm. (Though I don't know how it was able to write to the volume then, if it couldn't earlier...)

  • Tried removing yarn.lock, all node_modules/, and installing again with npm install and running initial command again from host machine
    • Failed? Again output shows a completed "Installing dependencies" step, but no other messages.
    • Maybe it's a unix-y no output is good output?
    • But more importantly still no config file.

Going back to the docs, because of a suspicion, that maybe, just perhaps, the file isn't created automatically...

  • Tried reading the documentation carefully...
    • ...
    • ...
    • You can edit these configurations by CREATING the file

    • I was supposed to create the file
    • looks like it installed properly from the beginning.

It is now 12:40 am, Wednesday.

nice.

...

  • restored yarn.lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment