Apollo-tooling: [apollo-cli] Schema cannot be generated

Created on 6 Jun 2019  ·  4Comments  ·  Source: apollographql/apollo-tooling

Intended outcome:
apollo schema:download is used to generate schema.json

Actual outcome:
Error message shows TypeError: “Authorization is not a legal HTTP header name

How to reproduce the issue:

  1. Install apollo using npm. npm install -g apollo
  2. Generate schema using the following command:
    apollo schema:download --endpoint="https://xyz.com/graphql" --header=“Authorization: Bearer <TOKEN>”
  3. The following error message is showing.
    TypeError: “Authorization is not a legal HTTP header name at validateName (/usr/local/lib/node_modules/apollo/node_modules/node-fetch/lib/index.js:670:9) at Headers.append (/usr/local/lib/node_modules/apollo/node_modules/node-fetch/lib/index.js:828:3) at new Headers (/usr/local/lib/node_modules/apollo/node_modules/node-fetch/lib/index.js:754:11) at new Request (/usr/local/lib/node_modules/apollo/node_modules/node-fetch/lib/index.js:1203:19) at /usr/local/lib/node_modules/apollo/node_modules/node-fetch/lib/index.js:1403:19 at new Promise (<anonymous>) at fetch (/usr/local/lib/node_modules/apollo/node_modules/node-fetch/lib/index.js:1401:9) at /usr/local/lib/node_modules/apollo/node_modules/apollo-link-http/lib/httpLink.js:70:13 at new Subscription (/usr/local/lib/node_modules/apollo/node_modules/zen-observable/lib/Observable.js:183:34) at Observable.subscribe (/usr/local/lib/node_modules/apollo/node_modules/zen-observable/lib/Observable.js:262:14)

Versions
npm - 5.6.0
apollo - apollo/2.12.5 darwin-x64 node-v9.2.1

cli 🚧👷‍♀️👷‍♂️🚧 in triage

Most helpful comment

I ran into a similar issue today. The problem in my case was that the header value was not quoted correctly. It looks like you have the same issue in the command in your description:

apollo schema:download --endpoint="https://xyz.com/graphql" --header=“Authorization: Bearer <TOKEN>”

The quote signs around the Authorization header string are different than the ones around the endpoint string. Try this instead:

apollo schema:download --endpoint="https://xyz.com/graphql" --header="Authorization: Bearer <TOKEN>"

All 4 comments

I ran into a similar issue today. The problem in my case was that the header value was not quoted correctly. It looks like you have the same issue in the command in your description:

apollo schema:download --endpoint="https://xyz.com/graphql" --header=“Authorization: Bearer <TOKEN>”

The quote signs around the Authorization header string are different than the ones around the endpoint string. Try this instead:

apollo schema:download --endpoint="https://xyz.com/graphql" --header="Authorization: Bearer <TOKEN>"

Was this resolved?

@JakeDawkins It's resolved.
@runec Your solution works very well.
The source of the problem is the difference of and " 😅

for future references, and MS Windows users :

cmd

> yarn apollo service:download --endpoint="https://<URL>" --header="Authorization: Bearer <token>"

package.json (do not change the slashes, nor the quotes ❗)

"schema": "apollo service:download --endpoint=\"https://<URL>\" --header=\"Authorization: Bearer <token>\""
Was this page helpful?
0 / 5 - 0 ratings