-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api): fix header not sent to odoo
- Loading branch information
1 parent
fdd32d6
commit 0a0a26b
Showing
5 changed files
with
37 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,23 +5,25 @@ import { MutationName } from '~/server/mutations'; | |
const { $sdk } = useNuxtApp(); | ||
const { data } = await $sdk().odoo.query<QueryProductVariantArgs, ProductVariantQueryResponse>({ queryName: QueryName.ProductVariantQuery }, { | ||
productTemplateId: 39, | ||
combinationId: [12, 305] | ||
}); | ||
const go = async () => { | ||
const { data } = await $sdk().odoo.mutation<MutationLoginArgs, LoginMutationResponse>({ mutationName: MutationName.LoginMutation }, { | ||
email: "[email protected]", | ||
password: "123" | ||
}); | ||
console.log(data.productVariant.displayName); | ||
console.log(data?.login); | ||
const { data: dataMut } = await $sdk().odoo.mutation<MutationLoginArgs, LoginMutationResponse>({ mutationName: MutationName.LoginMutation }, { | ||
email: "[email protected]", | ||
password: "123" | ||
}); | ||
const { data: asa } = await $sdk().odoo.query<QueryProductVariantArgs, ProductVariantQueryResponse>({ queryName: QueryName.LoadUserQuery }, {}); | ||
console.log(asa.productVariant.displayName); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<button @click="go">Go</button> | ||
<MainBanner /> | ||
|
||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import { Endpoints } from '@erpgap/odoo-sdk-api-client'; | ||
|
||
export default cachedEventHandler(async (event) => { | ||
export default defineEventHandler(async (event) => { | ||
const body = await readBody(event); | ||
|
||
const api: Endpoints = event.context.apolloClient.api; | ||
|
||
return await api.query(body[0], body[1]); | ||
const data = await api.query(body?.[0], body?.[1]); | ||
|
||
if ((data.data as any)?.cookie) { | ||
appendResponseHeader(event, 'Set-cookie', (data.data as any)?.cookie); | ||
} | ||
|
||
return data; | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import { createApiClient } from '@erpgap/odoo-sdk-api-client/server'; | ||
import { createApiClient } from '../../../../packages/sdk-api-client/src/index.server'; | ||
import { MiddlewareConfig } from '../../../../packages/sdk-api-client/src/index'; | ||
import { Queries } from '~/server/queries'; | ||
import { Mutations } from '~/server/mutations'; | ||
|
||
export default defineEventHandler((event) => { | ||
|
||
event.context.apolloClient = createApiClient({ | ||
const config : MiddlewareConfig = { | ||
odooGraphqlUrl: `${process.env.ODOO_BASE_URL}graphql/vsf`, | ||
queries: { ...Queries, ...Mutations } | ||
}); | ||
queries: { ...Queries, ...Mutations }, | ||
realIp: getRequestIP(event), | ||
sessionAuth: parseCookies(event).session_id, | ||
requestHost: getRequestHost(event) | ||
}; | ||
|
||
event.context.apolloClient = createApiClient(config); | ||
}); | ||
|