dillonkearns / elm-graphql

Autogenerate type-safe GraphQL queries in Elm.
https://package.elm-lang.org/packages/dillonkearns/elm-graphql/latest
BSD 3-Clause "New" or "Revised" License
778 stars 107 forks source link

Update usage example #591

Closed MarcoDaniels closed 2 years ago

MarcoDaniels commented 2 years ago

when using npx, elm-graphql is pointing to a deprecated package: https://www.npmjs.com/package/elm-graphql

dillonkearns commented 2 years ago

npx is a bit overloaded because it can both run a local version of a package, or run a remote package that isn't installed. Older versions of npm would install and run these remote packages without a prompt. In the last year or two, they introduced a change where they prompt you to install something remotely before running it. You can make it explicit that you don't want the remote option with npx --no-install.

The instructions say to install @dillonkearns/elm-graphql first, and then to use npx to run the locally installed version. So the section reads as:

After following the installation instructions to install the @dillonkearns/elm-graphql NPM package and the proper Elm packages (see the Setup section for details). Once you've installed everything, running the elm-graphql code generation tool is as simple as this: npx elm-graphql https://elm-graphql.herokuapp.com --base StarWars --output examples/src

I'd be okay with changing the command to npx --no-install elm-graphql, but I'd prefer not to do the command in the current pull request diff because that doesn't follow the setup instructions intention which is to recommend saving @dillonkearns/elm-graphql to the project's package.json and then running the local executable.

MarcoDaniels commented 2 years ago

That makes a lot of sense. I usually tend to leave the dependencies that I only need once out of the package.json, that why I went straight to the npx.

Thanks!

dillonkearns commented 2 years ago

Yeah, npx is nice for running quick one-off scripts, in the case of codegen tools however, I think it's a good practice to keep it as a dev dependency so you can lock in a specific version and have a reproducible way to re-run the code generator. That way if there is ever an issue with a specific version, that's in your version control with your NPM dependency versions.