Skip to content

Commit 2d3090e

Browse files
committed
fix: fix list query
1 parent 8e70ca1 commit 2d3090e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

projects/lib/services/resource/resource.service.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { ApolloFactory } from './apollo-factory';
2-
import { ResourceNodeContext } from './resource-node-context';
31
import { Injectable, inject } from '@angular/core';
42
import { TypedDocumentNode } from '@apollo/client/core';
53
import { LuigiCoreService } from '@openmfp/portal-ui-lib';
@@ -15,8 +13,11 @@ import {
1513
} from '@platform-mesh/portal-ui-lib/utils';
1614
import { gql } from 'apollo-angular';
1715
import * as gqlBuilder from 'gql-query-builder';
16+
import VariableOptions from 'gql-query-builder/build/VariableOptions';
1817
import { Observable, of } from 'rxjs';
1918
import { catchError, map } from 'rxjs/operators';
19+
import { ApolloFactory } from './apollo-factory';
20+
import { ResourceNodeContext } from './resource-node-context';
2021

2122
interface ResourceResponseError extends Record<string, any> {
2223
message: string;
@@ -129,7 +130,7 @@ export class ResourceService {
129130
});
130131
} else {
131132
query = {
132-
variables: variables,
133+
variables: this.normalizeGqlBuilderVariables(variables),
133134
query: fieldsOrRawQuery,
134135
};
135136
}
@@ -343,4 +344,12 @@ export class ResourceService {
343344
private isNamespacedResource(nodeContext: ResourceNodeContext) {
344345
return nodeContext?.resourceDefinition?.scope === 'Namespaced';
345346
}
347+
348+
private normalizeGqlBuilderVariables(
349+
variables: VariableOptions,
350+
): Record<string, any> {
351+
return Object.fromEntries(
352+
Object.entries(variables).map(([key, value]) => [key, value.value]),
353+
);
354+
}
346355
}

0 commit comments

Comments
 (0)