Skip to content

Commit

Permalink
fix: fix query automatic cache from useFetch
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMunizOdoo committed Dec 29, 2023
1 parent 3959c1d commit 8063ae9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/sdk-api-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@erpgap/odoo-sdk-api-client",
"version": "0.4.9",
"version": "0.5.0",
"private": false,
"sideEffects": false,
"server": "server/index.js",
Expand Down Expand Up @@ -43,4 +43,4 @@
"publishConfig": {
"access": "public"
}
}
}
1 change: 0 additions & 1 deletion packages/sdk-api-client/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import sessionHeaderExtension from './extensions/sessionHeaderExtension ';
import * as apiEndpoints from './api';

const onCreate = (settings: MiddlewareConfig) => {

const client = buildClient(settings);

return {
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@erpgap/odoo-sdk",
"version": "0.4.9",
"version": "0.5.0",
"private": false,
"main": "lib/index.cjs.js",
"module": "lib/index.es.js",
Expand Down Expand Up @@ -41,4 +41,4 @@
"publishConfig": {
"access": "public"
}
}
}
6 changes: 3 additions & 3 deletions packages/sdk/src/connector.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { client } from './client';
import { Options } from './types';
import * as methods from './methods/index';
import { FetchResult } from '@apollo/client';
import { MutationMetadataParams } from '../../sdk-api-client';
import { ApolloQueryResult } from '@apollo/client';
import { QueryMetadataParams } from '../../sdk-api-client';
import hash from 'object-hash';

/**
* Connector methods.
Expand Down Expand Up @@ -32,7 +31,8 @@ export const odooConnector = (options: Options): Methods => {
};

query = async <ApiParams, ApiResponseType>(metadata: QueryMetadataParams, params?: ApiParams): Promise<ApiResponseType> =>{
return await options.ofetch('/api/odoo/query', { method: 'POST', body: [metadata, params], cache: 'no-cache' });
const cacheKey = metadata.cacheKey || hash({ ...metadata, ...params });
return await options.ofetch('/api/odoo/query', { method: 'POST', body: [metadata, params], cache: 'no-cache', key: cacheKey } as any);
};
}

Expand Down

0 comments on commit 8063ae9

Please sign in to comment.