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

API Generation failure with custom scalars and npm package 3.5.0-3.6.0 #150

Closed
mattdb opened this issue May 24, 2019 · 1 comment
Closed
Labels

Comments

@mattdb
Copy link
Contributor

mattdb commented May 24, 2019

When running API generator using the --scalar-codecs flag, all generated GraphQL files are simply:

module Main exposing (..)

(entirety of file)

This fairly obviously causes the VerifyScalarCodecs compilation check to fail. Removing the --scalar-codecs flag makes things generate and work as expected.

Things that helped:

  • I am able to generate the API files when using the bin/elm-graphql built from source.
  • Adding fs-extra@8.0.1 to the dev dependencies in my project allows the npm packaged elm-graphql to generate as expected. (Hat tip to @nonpop on Elm Slack for that discovery)

Things that did not help:

  • Using the contents of the generated ScalarCodecs.elm file in place of my custom one
@mattdb mattdb changed the title API Generation failure with CustomScalars and npm package 3.5.0-3.6.0 API Generation failure with custom scalars and npm package 3.5.0-3.6.0 May 24, 2019
@dillonkearns
Copy link
Owner

Thank you Matt for your help here! I'll repost the update from our Slack thread here for future reference.

I found the issue, it was that I needed to pass in the --bundle-node-modules flag in order for ParcelJS to include the NPM dependencies.

https://parceljs.org/cli.html#force-node-modules-bundling

Preventing the issue in the future

And even better... I found the reason that the CI was not catching this issue so this kind of thing should be prevented in the future!

So the problem is that I was running the end to end test script from my npm scripts (npm run approve). So it was pulling in those local NPM dependencies.

So what I've done now is:

  1. I call the end to end testing script directly as a bash script, not through npm (./bin/approve)
  2. In the end to end testing script, I'm using npm link to actually build the elm-graphql binary locally and package it up (instead of directly invoking ../bin/elm-graphql, the bundled JS code). That should make the test more realistic.

So this ended up leading to a more robust CI, which I'm very happy about. I can't stand one-off fixes that I have to become superstitious about maybe breaking again in the future.

Thanks again to all of you for helping me identify and understand the issue!!!

I just published NPM version 3.6.1 which fixes this issue 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants