Open HAKASHUN opened 5 years ago
Same issue here
Same here
same here
FWIW my solution to this was to pass the header
flag outside of my npm script, which looked like the below:
"gql:schema": "apollo schema:download --endpoint=<endpoint> --header='Authorization: Bearer <token>' schema.json",
So instead of
yarn gql:schema
what worked for me was changing the script to remove --header='Authorization: Bearer <token>'
and passing it through the terminal:
yarn gql:schema --header='Authorization: Bearer <token>'
Somewhat related, trying to push our schema from a remote server to Apollo Engine using the CLI:
In my terminal, I've tried:
apollo service:push --header='Authorization: Bearer <token>'
apollo service:push --header="Authorization: Bearer <token>"
apollo service:push --header=Authorization: Bearer <token>
and every time the response I get is:
Error: Unable to validate user.
Is this API working for anybody out there? Any suggestions on what I may be doing wrong, and how to correct it? Or is this a bug?
FWIW, I'm supplying my service name and endpoint in my apollo.config.js file. Ultimately, I would like to move my validation credentials there also, so in my terminal I can just use:
apollo service:push
But there's no documentation on how to structure the apollo.config.js file for the header. This is what my apollo.config.js file looks like now:
module.exports = {
service: {
name: "<service name>",
endpoint: {
url: "<url>"
},
header: {
Authorization: "Bearer <token>"
}
},
engine: {
apiKey: "<key>",
schemaTag: "dev-test-proxy"
}
};
At this point, ANY method for correctly supplying the header, either via the CLI in my terminal, or via my apollo.config.js would be nice.
same issue here.. I am just trying to download github to schema.json
apollo schema:download --endpoint=https://api.github.com/graphql --header='Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' schema.json
anyone with solution?
@kateile Just put the output filename before the header flag. Oclif (the cli framework we build off of) has an issue with flag parsing when you allow multiple uses of the same flag.
So for example, if you want to provide multiple headers, you can either do
# this
apollo schema:download --endpoint=https://api.github.com/graphql schema.json --header="Authorization: Bearer xxxxxxxxxx" --header="MyHeader: 12345"
# or this
apollo schema:download --endpoint=https://api.github.com/graphql output.json --header="Authorization: Bearer xxxxxxx" "MyHeader: 12345"
the second usage is definitely a bug, but since that bug exists right now, the CLI accidentally mistakes your schema.json
arg as an additional header flag. So putting the header flag last fixes this for now.
last suggestion worked for me :)
Just ran into this today with the latest version of apollo cli
@qswitcher likewise, just ran into this today
Is it expected behavior to fail downloading
scheme.json
depending on the order of the options?