ardatan / graphql-mesh

🕸️ GraphQL Federation Framework for any API services such as REST, OpenAPI, Swagger, SOAP, gRPC and more...
https://the-guild.dev/graphql/mesh
MIT License
3.29k stars 344 forks source link

'core-js/modules/es6.array.find' cannot be used with the json-schema API #127

Closed daisuke-awaji closed 4 years ago

daisuke-awaji commented 4 years ago

hi. I'm having a bit of trouble, so let me share.

To load the json-schema, I wrote the following in .meshrc.yaml

sources:
  - name: qiita
    handler:
      json-schema:
        source: https://qiita.com/api/v2/schema

package.json is as follows

{
  "dependencies": {
    "@graphql-mesh/cli": "^0.0.16",
    "@graphql-mesh/json-schema": "^0.0.16",
    "@graphql-mesh/openapi": "^0.0.16",
    "@graphql-mesh/runtime": "^0.0.16",
    "graphql": "^14.6.0"
  }
}

And when I try to start the graphql-mesh server, I get an error like the following

$ yarn graphql-mesh serve
yarn run v1.22.4
warning package.json: No license field
$ /Users/daisuke/work/tttt/node_modules/.bin/graphql-mesh serve
error: Unable to serve mesh: Unable to load handler matching json-schema: Cannot find module 'core-js/modules/es6.array.find'
Require stack:
- /Users/daisuke/work/tttt/node_modules/string-interpolation/dist/Interpolator.js
- /Users/daisuke/work/tttt/node_modules/string-interpolation/dist/index.js
- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/json-schema/dist/index.js
- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/runtime/dist/utils.js
- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/runtime/dist/get-mesh.js
- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/runtime/dist/index.js
- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/cli/dist/bin.js {"stack":"Error: Unable to load handler matching json-schema: Cannot find module 'core-js/modules/es6.array.find'\nRequire stack:\n- /Users/daisuke/work/tttt/node_modules/string-interpolation/dist/Interpolator.js\n- /Users/daisuke/work/tttt/node_modules/string-interpolation/dist/index.js\n- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/json-schema/dist/index.js\n- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/runtime/dist/utils.js\n- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/runtime/dist/get-mesh.js\n- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/runtime/dist/index.js\n- /Users/daisuke/work/tttt/node_modules/@graphql-mesh/cli/dist/bin.js\n    at getPackage (/Users/daisuke/work/tttt/node_modules/@graphql-mesh/runtime/dist/utils.js:51:23)"}
✨  Done in 3.05s.

To fix this, I decided to install an older version of core-js.

{
  "dependencies": {
    "@graphql-mesh/cli": "^0.0.16",
    "@graphql-mesh/json-schema": "^0.0.16",
    "@graphql-mesh/openapi": "^0.0.16",
    "@graphql-mesh/runtime": "^0.0.16",
    "core-js": "^2.6.2",           // <------ add it.
    "graphql": "^14.6.0"
  }
}

I think we need to resolve these library dependencies.

ardatan commented 4 years ago

string-interpolation, which is used by json-schema handler, doesn't have core-js dependency. @dotansimha Do you have any idea why this happens?

dotansimha commented 4 years ago

Not sure, @ardatan @daisuke-awaji can you please share a repo that has this issue? I don't think we have any dependency for core-js at all. btw, you need to specify more details for json-schema handler. You can load the YAML validation schema to your IDE to get real-time autocomplete and validation, see Basic Usage in the README

ardatan commented 4 years ago

Available in 0.0.17 🎉

daisuke-awaji commented 4 years ago

Sorry for the late reply. Thanks for solving.