Apollo-tooling: Can not use client:codegen

Created on 30 May 2019  ·  7Comments  ·  Source: apollographql/apollo-tooling


I use the same apollo.config.js with [email protected] and [email protected]. [email protected] work, but [email protected] throw the error.

Intended outcome:
This command should work.

Actual outcome:

{ Error: Error in "Loading queries for my-engines-name": Error: [UriError]: Scheme is missing: {scheme: "", authority: "", path: "/path-to-config/apollo.config.js", query: "", fragment: ""}
    at Object.error (/path-to-node_modules/node_modules/@oclif/errors/lib/index.js:22:17)
    at Generate.error (/path-to-node_modules/node_modules/@oclif/command/lib/command.js:48:23)
    at OclifLoadingHandler.showError (/path-to-node_modules/node_modules/apollo/lib/OclifLoadingHandler.js:28:22)
    at OclifLoadingHandler.handle (/path-to-node_modules/node_modules/apollo/lib/OclifLoadingHandler.js:13:18) oclif: { exit: 2 }, code: undefined }
(node:74358) UnhandledPromiseRejectionWarning: Error: Error initializing Apollo GraphQL project "my-engines-name": Error: Error in "Loading queries for my-engines-name": Error: [UriError]: Scheme is missing: {scheme: "", authority: "", path: "path-to-node_modules/apollo.config.js", query: "", fragment: ""}
    at Object.error (/path-to-node_modules/node_modules/@oclif/errors/lib/index.js:22:17)
    at Generate.error (/path-to-node_modules/node_modules/@oclif/command/lib/command.js:48:23)
    at OclifLoadingHandler.showError (/path-to-node_modules/node_modules/apollo/lib/OclifLoadingHandler.js:28:22)
    at GraphQLProject.readyPromise.Promise.all.then.catch.error (/path-to-node_modules/node_modules/apollo-language-server/lib/project/base.js:44:33)
(node:74358) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:74358) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Error: [UriError]: Scheme is missing: {scheme: "", authority: "", path: "/path-to-node_modules/apollo.config.js", query: "", fragment: ""}
    at _validateUri (~/path-to-node_modules/node_modules/vscode-uri/lib/umd/index.js:52:23)
    at _URI.URI (~/path-to-node_modules/node_modules/vscode-uri/lib/umd/index.js:153:17)
    at new _URI (~/path-to-node_modules/node_modules/vscode-uri/lib/umd/index.js:355:51)
    at Function.URI.parse (~/path-to-node_modules/node_modules/vscode-uri/lib/umd/index.js:265:20)
    at exports.normalizeURI (~/path-to-node_modules/node_modules/apollo-language-server/lib/utilities/uri.js:17:39)
    at Array.map (<anonymous>)
    at FileSet.allFiles (~/path-to-node_modules/node_modules/apollo-language-server/lib/fileSet.js:29:14)
    at new GraphQLClientProject (~/path-to-node_modules/node_modules/apollo-language-server/lib/project/client.js:40:21)
    at Generate.createService (~/path-to-node_modules/node_modules/apollo/lib/Command.js:114:28)
    at Generate.init (~/path-to-node_modules/node_modules/apollo/lib/Command.js:37:14)

How to reproduce the issue:
Run apollo client:codegen.

Versions
apollo: v2.12.4

Most helpful comment

If you use yarn, you can use resolutions to lock version before apollo fix this.

  • package.json:
...
  "resolutions": {
    "vscode-uri": "1.0.6"
  },
...

All 7 comments

I found the problem caused by vscode-uri's update.

  • [email protected] rejects the URI that is without scheme
  • apollo passes the config path that has no scheme to vscode-uri

    • such as "apollo.config.js"

I suggest some solutions:

  • add file scheme to local paths
  • use another URI library

Any workaround?

If you use yarn, you can use resolutions to lock version before apollo fix this.

  • package.json:
...
  "resolutions": {
    "vscode-uri": "1.0.6"
  },
...

@HsuTing works perfectly.

Thanks a lot!

Thank you everyone for the info, I'll be looking into this today!

I was seeing the same issue within the vscode version I was trying to release yesterday. After pinning the version, it resolved it on my end.

I tried reproducing via codegen, but could not (from previous or new version). If you were experiencing the issue, could you please report back? Thanks!

[email protected] is the new latest.

It work. Thank you. @trevor-scheer

Was this page helpful?
0 / 5 - 0 ratings