-
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.
- Loading branch information
1 parent
2e9aa5b
commit d917a6b
Showing
15 changed files
with
114 additions
and
13 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Endpoints, OdooIntegrationContext, MutationMetadataParams } from '../../types'; | ||
|
||
export const mutation: Endpoints['mutation'] = async <ApiParams, ApiResponseType>(context: OdooIntegrationContext, metadata: MutationMetadataParams, params?: ApiParams) => { | ||
const mutation = context.config.queries[metadata.mutationName]; | ||
|
||
const response = await context.client.mutate<ApiResponseType, ApiParams>({ | ||
variables: params, | ||
mutation, | ||
fetchPolicy: 'no-cache', | ||
errorPolicy: 'all' | ||
}); | ||
|
||
return response; | ||
}; | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { FetchResult } from '@apollo/client'; | ||
import { MutationMetadataParams } from '@erpgap/odoo-sdk-api-client'; | ||
import { client } from '../../client'; | ||
|
||
/** | ||
* Make the query | ||
* | ||
* @example | ||
*/ | ||
export async function mutation<ApiParams, ApiResponseType>(metadata: MutationMetadataParams, params?: ApiParams): Promise<FetchResult<ApiResponseType>> { | ||
const { data } = await client.post<FetchResult<ApiResponseType>>('mutation', [metadata, params]); | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./fragment-masking"; | ||
export * from "./gql"; |
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,5 +1,11 @@ | ||
import { ProductVariant } from "@erpgap/odoo-sdk-api-client"; | ||
import { Partner, ProductVariant } from "~/graphql"; | ||
|
||
export type ProductVariantQueryResponse { | ||
export type ProductVariantQueryResponse = { | ||
productVariant: ProductVariant | ||
} | ||
|
||
export type LoginMutationResponse = { | ||
login: { | ||
partner: Partner | ||
} | ||
} |
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,15 +1,20 @@ | ||
<script setup lang="ts"> | ||
import { QueryProductVariantArgs, ProductVariantQueryResponse } from '~/graphql' | ||
import { QueryProductVariantArgs, ProductVariantQueryResponse, MutationLoginArgs, LoginMutationResponse } from '~/graphql' | ||
import { sdk } from '~/sdk.config'; | ||
const { data } = await sdk.odoo.query<QueryProductVariantArgs, ProductVariantQueryResponse>({ queryName: 'productVariantQuery' }, { | ||
import { QueryName, MutationName } from '@erp-gap/server/src/types'; | ||
const { data } = await sdk.odoo.query<QueryProductVariantArgs, ProductVariantQueryResponse>({ queryName: QueryName.ProductVariantQuery }, { | ||
productTemplateId: 39, | ||
combinationId: [12, 305] | ||
}); | ||
console.log(data.productVariant.displayName); | ||
// const { data } = await useAsyncData('ttt', async () => await sdk.odoo.getCountries()) | ||
const { data: dataMut } = await sdk.odoo.mutation<MutationLoginArgs, LoginMutationResponse>({ mutationName: MutationName.LoginMutation }, { | ||
email: "[email protected]", | ||
password: "123" | ||
}); | ||
console.log(dataMut?.login.partner.name); | ||
</script> | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { gql } from '@apollo/client'; | ||
export default gql` | ||
mutation($email: String!, $password: String!) { | ||
login(email: $email, password: $password) { | ||
partner{ | ||
id | ||
name | ||
street | ||
street2 | ||
city | ||
state | ||
{ | ||
id | ||
} | ||
country | ||
{ | ||
id | ||
} | ||
phone | ||
} | ||
} | ||
}`; |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { DocumentNode } from '@apollo/client'; | ||
import LoginMutation from './LoginMutation'; | ||
|
||
enum MutationName { | ||
LoginMutation = 'LoginMutation' | ||
} | ||
|
||
const Mutations : Record<MutationName, DocumentNode> = { | ||
LoginMutation | ||
} | ||
|
||
export { | ||
Mutations, | ||
MutationName | ||
} |
File renamed without changes.
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,8 +1,15 @@ | ||
import { DocumentNode } from '@apollo/client'; | ||
import productVariantQuery from './productVariantQuery'; | ||
import ProductVariantQuery from './ProductVariantQuery'; | ||
|
||
const queries : Record<string, DocumentNode> = { | ||
productVariantQuery | ||
enum QueryName { | ||
ProductVariantQuery = 'ProductVariantQuery' | ||
} | ||
|
||
const Queries : Record<QueryName, DocumentNode> = { | ||
ProductVariantQuery | ||
} | ||
|
||
export default queries | ||
export { | ||
Queries, | ||
QueryName | ||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { QueryName } from '../queries' | ||
import { MutationName} from '../mutations' | ||
|
||
export { | ||
QueryName, | ||
MutationName | ||
} | ||
|