feat: admin auth - save config

This commit is contained in:
NGPixel
2018-06-25 20:55:00 -04:00
parent 0afa65fa58
commit 2500d8b054
6 changed files with 137 additions and 48 deletions

View File

@@ -49,11 +49,33 @@ moment.locale(siteConfig.lang)
const graphQLEndpoint = window.location.protocol + '//' + window.location.host + '/graphql'
const graphQLLink = createPersistedQueryLink().concat(createHttpLink({
includeExtensions: true,
uri: graphQLEndpoint,
credentials: 'include'
}))
const graphQLLink = createPersistedQueryLink().concat(
createHttpLink({
includeExtensions: true,
uri: graphQLEndpoint,
credentials: 'include',
fetch: (uri, options) => {
// Strip __typename fields from variables
let body = JSON.parse(options.body)
// body = body.map(bd => {
// return ({
// ...bd,
// variables: JSON.parse(JSON.stringify(bd.variables), (key, value) => { return key === '__typename' ? undefined : value })
// })
// })
body = {
...body,
variables: JSON.parse(JSON.stringify(body.variables), (key, value) => { return key === '__typename' ? undefined : value })
}
options.body = JSON.stringify(body)
// Inject authentication token
options.headers.Authorization = `Bearer TODO`
return fetch(uri, options)
}
})
)
window.graphQL = new ApolloClient({
link: graphQLLink,