4
0
forked from crowetic/commerce

Run login after creating the customer

This commit is contained in:
Luis Alvarez 2020-10-20 13:18:38 -05:00
parent 7db006f64a
commit ed879f8b2c
3 changed files with 18 additions and 1 deletions

View File

@ -49,6 +49,7 @@ const getProducts: ProductsHandlers['getProducts'] = async ({
// We want the GraphQL version of each product
const graphqlData = await getAllProducts({
variables: { first: LIMIT, entityIds },
config,
})
// Put the products in an object that we can use to get them by id
const productsById = graphqlData.products.reduce<{

View File

@ -1,5 +1,6 @@
import { BigcommerceApiError } from '../../utils/errors'
import { CustomersHandlers } from '..'
import login from '../../operations/login'
import type { CustomersHandlers } from '..'
const createCustomer: CustomersHandlers['createCustomer'] = async ({
res,
@ -54,6 +55,12 @@ const createCustomer: CustomersHandlers['createCustomer'] = async ({
throw error
}
console.log('DATA', result.data)
const loginData = await login({ variables: { email, password }, config })
console.log('LOGIN DATA', loginData)
res.status(200).json({ data: result.data ?? null })
}

View File

@ -1926,3 +1926,12 @@ export type GetSiteInfoQuery = { __typename?: 'Query' } & {
}
}
}
export type LoginMutationVariables = Exact<{
email: Scalars['String']
password: Scalars['String']
}>
export type LoginMutation = { __typename?: 'Mutation' } & {
login: { __typename?: 'LoginResult' } & Pick<LoginResult, 'result'>
}