Skip to content

Commit

Permalink
fix composite query issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lastmjs committed Dec 30, 2024
1 parent f10e2bb commit 2052715
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions src/lib/stable/canister_methods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function decoratorArgumentsHandler<This, Args extends any[], Return>(
methodMetaKey: keyof MethodMeta,
param1?: MethodType<This, Args, Return> | IDL.Type[],
param2?: ClassMethodDecoratorContext | IDL.Type,
param3?: { manual?: boolean }
param3?: { composite?: boolean; manual?: boolean }
): any {
// First overload - decorator without params
if (typeof param1 === 'function') {
Expand Down Expand Up @@ -61,7 +61,7 @@ function decoratorImplementation<This, Args extends any[], Return>(
context: ClassMethodDecoratorContext,
paramIdlTypes?: IDL.Type[],
returnIdlType?: IDL.Type,
options?: { manual?: boolean }
options?: { composite?: boolean; manual?: boolean }
): MethodType<This, Args, Return> {
const name = context.name as string;

Expand All @@ -70,10 +70,18 @@ function decoratorImplementation<This, Args extends any[], Return>(

if (canisterMethodMode !== 'heartbeat') {
if (Array.isArray(globalThis._azleMethodMeta[methodMetaKey])) {
(globalThis._azleMethodMeta[methodMetaKey] as Method[]).push({
name,
index
});
if (canisterMethodMode === 'query') {
(globalThis._azleMethodMeta[methodMetaKey] as Method[]).push({
name,
index,
composite: options?.composite ?? false
});
} else {
(globalThis._azleMethodMeta[methodMetaKey] as Method[]).push({
name,
index
});
}
} else {
(globalThis._azleMethodMeta[methodMetaKey] as Method) = {
name,
Expand Down
1 change: 1 addition & 0 deletions src/lib/stable/canister_methods/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export function query<This, Args extends any[], Return>(
paramIdlTypes?: IDL.Type[],
returnIdlType?: IDL.Type,
options?: {
composite?: boolean;
manual?: boolean;
}
): (
Expand Down

0 comments on commit 2052715

Please sign in to comment.