-
-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: Documentation only changes #1433
base: v4
Are you sure you want to change the base?
Conversation
added Missing docs for sending custom or bearer headers.
// createUploadLink can be used as well | ||
// jaydenseric/apollo-upload-client library for uploading files using apollo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think file upload should be mentioned at all in vue-apollo docs, it's unrelated
let link = createHttpLink({uri: url}) | ||
link = setContext(async (_, {headers}) => { | ||
|
||
// getToken() your defined function for getting the token | ||
const Authorization = getToken() | ||
|
||
const authorizationHeader = Authorization ? {Authorization} : {} | ||
return { | ||
headers: { | ||
...headers, | ||
...authorizationHeader, | ||
}, | ||
} | ||
}).concat(link) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is doing a few things in not-the-most-readable way.
What about having a separate const httpLink = ...
and const authorzationHeaderLink = ...
and then const link = authorzationHeaderLink.concat(httpLink)
?
Authorization
should probably not be uppercased, it's just a string.
And the code style in the docs has spaces inside curly braces.
function getToken() { | ||
const token = JSON.parse(localStorage.getItem('apollo-token')); | ||
return `Bearer ${token}` || null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be not included, getting the token shouldn't be part of the example IMO, wdyt @Akryum?
docs: Documentation only changes