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:
npm install -g apolloapollo schema:download --endpoint="https://xyz.com/graphql" --header=“Authorization: Bearer <TOKEN>”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
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 :
> yarn apollo service:download --endpoint="https://<URL>" --header="Authorization: Bearer <token>"
"schema": "apollo service:download --endpoint=\"https://<URL>\" --header=\"Authorization: Bearer <token>\""
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>"