laconic-dot-com/src/lib/cms/index.ts
Manuel Garcia Genta a5e0829ed4
Blog page (#15)
2022-04-11 12:18:52 -03:00

19 lines
440 B
TypeScript

import { GraphQLClient } from 'graphql-request'
import { getSdk } from './generated'
const cms = (preview?: boolean) => {
const endpoint = 'https://graphql.datocms.com/'
const previewEndpoint = 'https://graphql.datocms.com/preview'
return getSdk(
new GraphQLClient(preview ? previewEndpoint : endpoint, {
headers: {
Authorization: `Bearer ${process.env.CMS_ACCESS_TOKEN}`
}
})
)
}
export default cms