Latest Changes - Logger, Size and Colors

This commit is contained in:
Belen Curcio
2020-10-17 09:07:02 -03:00
parent 5e4686bdd4
commit a42c67a898
11 changed files with 147 additions and 70 deletions

View File

@@ -9,6 +9,24 @@ export const responsiveImageFragment = /* GraphQL */ `
isDefault
}
`
export const multipleChoiceFragment = /* GraphQL */ `
fragment swatchOption on SwatchOptionValue {
isDefault
hexColors
}
fragment multipleChoiceOption on MultipleChoiceOption {
entityId
values {
edges {
node {
label
...swatchOption
}
}
}
}
`
export const productInfoFragment = /* GraphQL */ `
fragment productInfo on Product {
@@ -46,24 +64,17 @@ export const productInfoFragment = /* GraphQL */ `
}
}
}
options {
productOptions {
edges {
node {
entityId
displayName
isRequired
values {
edges {
node {
entityId
label
}
}
}
...multipleChoiceOption
}
}
}
}
${responsiveImageFragment}
${multipleChoiceFragment}
`

View File

@@ -1,10 +1,12 @@
import { CommerceAPIFetchOptions } from 'lib/commerce/api'
import { getConfig } from '..'
import log from '@lib/logger'
export default async function fetchGraphqlApi<Q, V = any>(
query: string,
{ variables, preview }: CommerceAPIFetchOptions<V> = {}
): Promise<Q> {
log.warn(query)
const config = getConfig()
const res = await fetch(config.commerceUrl + (preview ? '/preview' : ''), {
method: 'POST',

5
lib/logger.ts Normal file
View File

@@ -0,0 +1,5 @@
import bunyan from 'bunyan'
const log = bunyan.createLogger({ name: 'Next.js - Commerce' })
export default log