Преглед изворни кода

fix(core): Fix resolution of facet valueList for postgres

Michael Bromley пре 2 година
родитељ
комит
1d8fe47735

+ 4 - 3
packages/admin-ui/src/lib/core/src/public_api.ts

@@ -136,15 +136,16 @@ export * from './shared/components/custom-field-control/custom-field-control.com
 export * from './shared/components/customer-label/customer-label.component';
 export * from './shared/components/data-table/data-table-column.component';
 export * from './shared/components/data-table/data-table.component';
-export * from './shared/components/data-table-filter-presets/add-filter-preset-button.component';
 export * from './shared/components/data-table-2/data-table-column.component';
 export * from './shared/components/data-table-2/data-table-custom-field-column.component';
-export * from './shared/components/data-table-filter-presets/data-table-filter-presets.component';
 export * from './shared/components/data-table-2/data-table-search.component';
 export * from './shared/components/data-table-2/data-table2.component';
-export * from './shared/components/data-table-filter-presets/filter-preset.service';
 export * from './shared/components/data-table-column-picker/data-table-column-picker.component';
 export * from './shared/components/data-table-filter-label/data-table-filter-label.component';
+export * from './shared/components/data-table-filter-presets/add-filter-preset-button.component';
+export * from './shared/components/data-table-filter-presets/data-table-filter-presets.component';
+export * from './shared/components/data-table-filter-presets/filter-preset.service';
+export * from './shared/components/data-table-filter-presets/rename-filter-preset-dialog.component';
 export * from './shared/components/data-table-filters/custom-filter-component.directive';
 export * from './shared/components/data-table-filters/data-table-filters.component';
 export * from './shared/components/datetime-picker/constants';

Разлика између датотеке није приказан због своје велике величине
+ 605 - 626
packages/common/src/generated-types.ts


+ 28 - 0
packages/core/e2e/facet.e2e-spec.ts

@@ -14,6 +14,8 @@ import {
     CurrencyCode,
     DeletionResult,
     FacetWithValuesFragment,
+    GetFacetWithValueListDocument,
+    GetFacetWithValuesDocument,
     LanguageCode,
 } from './graphql/generated-e2e-admin-types';
 import {
@@ -173,6 +175,13 @@ describe('Facet resolver', () => {
         expect(result.facet!.name).toBe('Speaker Category');
     });
 
+    it('facet with valueList', async () => {
+        const result = await adminClient.query(GetFacetWithValueListDocument, {
+            id: speakerTypeFacet.id,
+        });
+        expect(result.facet?.valueList.totalItems).toBe(3);
+    });
+
     it('product.facetValues resolver omits private facets in shop-api', async () => {
         const publicFacetValue = brandFacet.values[0];
         const privateFacetValue = speakerTypeFacet.values[0];
@@ -810,6 +819,25 @@ export const GET_FACET_WITH_VALUES = gql`
     ${FACET_WITH_VALUES_FRAGMENT}
 `;
 
+export const GET_FACET_WITH_VALUE_LIST = gql`
+    query GetFacetWithValueList($id: ID!) {
+        facet(id: $id) {
+            id
+            languageCode
+            isPrivate
+            code
+            name
+            valueList {
+                items {
+                    ...FacetValue
+                }
+                totalItems
+            }
+        }
+    }
+    ${FACET_VALUE_FRAGMENT}
+`;
+
 const DELETE_FACET_VALUES = gql`
     mutation DeleteFacetValues($ids: [ID!]!, $force: Boolean) {
         deleteFacetValues(ids: $ids, force: $force) {

+ 131 - 0
packages/core/e2e/graphql/generated-e2e-admin-types.ts

@@ -7723,6 +7723,31 @@ export type GetFacetWithValuesQuery = {
     } | null;
 };
 
+export type GetFacetWithValueListQueryVariables = Exact<{
+    id: Scalars['ID']['input'];
+}>;
+
+export type GetFacetWithValueListQuery = {
+    facet?: {
+        id: string;
+        languageCode: LanguageCode;
+        isPrivate: boolean;
+        code: string;
+        name: string;
+        valueList: {
+            totalItems: number;
+            items: Array<{
+                id: string;
+                languageCode: LanguageCode;
+                code: string;
+                name: string;
+                translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
+                facet: { id: string; name: string };
+            }>;
+        };
+    } | null;
+};
+
 export type DeleteFacetValuesMutationVariables = Exact<{
     ids: Array<Scalars['ID']['input']> | Scalars['ID']['input'];
     force?: InputMaybe<Scalars['Boolean']['input']>;
@@ -21921,6 +21946,112 @@ export const GetFacetWithValuesDocument = {
         },
     ],
 } as unknown as DocumentNode<GetFacetWithValuesQuery, GetFacetWithValuesQueryVariables>;
+export const GetFacetWithValueListDocument = {
+    kind: 'Document',
+    definitions: [
+        {
+            kind: 'OperationDefinition',
+            operation: 'query',
+            name: { kind: 'Name', value: 'GetFacetWithValueList' },
+            variableDefinitions: [
+                {
+                    kind: 'VariableDefinition',
+                    variable: { kind: 'Variable', name: { kind: 'Name', value: 'id' } },
+                    type: {
+                        kind: 'NonNullType',
+                        type: { kind: 'NamedType', name: { kind: 'Name', value: 'ID' } },
+                    },
+                },
+            ],
+            selectionSet: {
+                kind: 'SelectionSet',
+                selections: [
+                    {
+                        kind: 'Field',
+                        name: { kind: 'Name', value: 'facet' },
+                        arguments: [
+                            {
+                                kind: 'Argument',
+                                name: { kind: 'Name', value: 'id' },
+                                value: { kind: 'Variable', name: { kind: 'Name', value: 'id' } },
+                            },
+                        ],
+                        selectionSet: {
+                            kind: 'SelectionSet',
+                            selections: [
+                                { kind: 'Field', name: { kind: 'Name', value: 'id' } },
+                                { kind: 'Field', name: { kind: 'Name', value: 'languageCode' } },
+                                { kind: 'Field', name: { kind: 'Name', value: 'isPrivate' } },
+                                { kind: 'Field', name: { kind: 'Name', value: 'code' } },
+                                { kind: 'Field', name: { kind: 'Name', value: 'name' } },
+                                {
+                                    kind: 'Field',
+                                    name: { kind: 'Name', value: 'valueList' },
+                                    selectionSet: {
+                                        kind: 'SelectionSet',
+                                        selections: [
+                                            {
+                                                kind: 'Field',
+                                                name: { kind: 'Name', value: 'items' },
+                                                selectionSet: {
+                                                    kind: 'SelectionSet',
+                                                    selections: [
+                                                        {
+                                                            kind: 'FragmentSpread',
+                                                            name: { kind: 'Name', value: 'FacetValue' },
+                                                        },
+                                                    ],
+                                                },
+                                            },
+                                            { kind: 'Field', name: { kind: 'Name', value: 'totalItems' } },
+                                        ],
+                                    },
+                                },
+                            ],
+                        },
+                    },
+                ],
+            },
+        },
+        {
+            kind: 'FragmentDefinition',
+            name: { kind: 'Name', value: 'FacetValue' },
+            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'FacetValue' } },
+            selectionSet: {
+                kind: 'SelectionSet',
+                selections: [
+                    { kind: 'Field', name: { kind: 'Name', value: 'id' } },
+                    { kind: 'Field', name: { kind: 'Name', value: 'languageCode' } },
+                    { kind: 'Field', name: { kind: 'Name', value: 'code' } },
+                    { kind: 'Field', name: { kind: 'Name', value: 'name' } },
+                    {
+                        kind: 'Field',
+                        name: { kind: 'Name', value: 'translations' },
+                        selectionSet: {
+                            kind: 'SelectionSet',
+                            selections: [
+                                { kind: 'Field', name: { kind: 'Name', value: 'id' } },
+                                { kind: 'Field', name: { kind: 'Name', value: 'languageCode' } },
+                                { kind: 'Field', name: { kind: 'Name', value: 'name' } },
+                            ],
+                        },
+                    },
+                    {
+                        kind: 'Field',
+                        name: { kind: 'Name', value: 'facet' },
+                        selectionSet: {
+                            kind: 'SelectionSet',
+                            selections: [
+                                { kind: 'Field', name: { kind: 'Name', value: 'id' } },
+                                { kind: 'Field', name: { kind: 'Name', value: 'name' } },
+                            ],
+                        },
+                    },
+                ],
+            },
+        },
+    ],
+} as unknown as DocumentNode<GetFacetWithValueListQuery, GetFacetWithValueListQueryVariables>;
 export const DeleteFacetValuesDocument = {
     kind: 'Document',
     definitions: [

+ 2 - 1
packages/core/src/service/services/facet-value.service.ts

@@ -152,8 +152,9 @@ export class FacetValueService {
                 ctx,
                 relations: relations ?? ['facet'],
                 channelId: ctx.channelId,
+                entityAlias: 'facetValue',
             })
-            .andWhere('facetId = :id', { id })
+            .andWhere('facetValue.facetId = :id', { id })
             .getManyAndCount()
             .then(([items, totalItems]) => {
                 return {

Неке датотеке нису приказане због велике количине промена